Skip to content
Snippets Groups Projects
Commit 3106f2bc authored by Matti Loimaranta's avatar Matti Loimaranta
Browse files

Merge branch 'master' of https://gitlab.utu.fi/eolokk/game_jam19

parents 384d22bb 7e385915
No related branches found
No related tags found
No related merge requests found
fileFormatVersion: 2
guid: 829c46be4b50d504a8fd053e72cf24e3
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
...@@ -1344,8 +1344,10 @@ MonoBehaviour: ...@@ -1344,8 +1344,10 @@ MonoBehaviour:
m_EditorClassIdentifier: m_EditorClassIdentifier:
target: {fileID: 0} target: {fileID: 0}
move_to: {fileID: 0} move_to: {fileID: 0}
max_amount: 10
amount: 0 amount: 0
home: {fileID: 471348698} home: {fileID: 471348698}
resource: {fileID: 0}
speed: 1 speed: 1
--- !u!61 &932290493 --- !u!61 &932290493
BoxCollider2D: BoxCollider2D:
...@@ -1473,126 +1475,6 @@ Transform: ...@@ -1473,126 +1475,6 @@ Transform:
m_Father: {fileID: 0} m_Father: {fileID: 0}
m_RootOrder: 10 m_RootOrder: 10
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!1 &1379725508
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 1379725511}
- component: {fileID: 1379725510}
- component: {fileID: 1379725509}
- component: {fileID: 1379725512}
m_Layer: 0
m_Name: Tree (2)
m_TagString: Resource
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!114 &1379725509
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1379725508}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: bad3649e66714d14d94d87cd3e47c1a1, type: 3}
m_Name:
m_EditorClassIdentifier:
Amount: 20
--- !u!212 &1379725510
SpriteRenderer:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1379725508}
m_Enabled: 1
m_CastShadows: 0
m_ReceiveShadows: 0
m_DynamicOccludee: 1
m_MotionVectors: 1
m_LightProbeUsage: 1
m_ReflectionProbeUsage: 1
m_RenderingLayerMask: 1
m_RendererPriority: 0
m_Materials:
- {fileID: 10754, guid: 0000000000000000f000000000000000, type: 0}
m_StaticBatchInfo:
firstSubMesh: 0
subMeshCount: 0
m_StaticBatchRoot: {fileID: 0}
m_ProbeAnchor: {fileID: 0}
m_LightProbeVolumeOverride: {fileID: 0}
m_ScaleInLightmap: 1
m_PreserveUVs: 0
m_IgnoreNormalsForChartDetection: 0
m_ImportantGI: 0
m_StitchLightmapSeams: 0
m_SelectedEditorRenderState: 0
m_MinimumChartSize: 4
m_AutoUVMaxDistance: 0.5
m_AutoUVMaxAngle: 89
m_LightmapParameters: {fileID: 0}
m_SortingLayerID: 0
m_SortingLayer: 0
m_SortingOrder: 0
m_Sprite: {fileID: 21300000, guid: 473e801b3bc9651409881d3f975c23ef, type: 3}
m_Color: {r: 1, g: 1, b: 1, a: 1}
m_FlipX: 0
m_FlipY: 0
m_DrawMode: 0
m_Size: {x: 1.28, y: 1.28}
m_AdaptiveModeThreshold: 0.5
m_SpriteTileMode: 0
m_WasSpriteAssigned: 1
m_MaskInteraction: 0
m_SpriteSortPoint: 0
--- !u!4 &1379725511
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1379725508}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 2.87, y: -1.7186036, z: -0.1}
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children: []
m_Father: {fileID: 0}
m_RootOrder: 20
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!61 &1379725512
BoxCollider2D:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1379725508}
m_Enabled: 1
m_Density: 1
m_Material: {fileID: 0}
m_IsTrigger: 1
m_UsedByEffector: 0
m_UsedByComposite: 0
m_Offset: {x: 0, y: 0}
m_SpriteTilingProperty:
border: {x: 0, y: 0, z: 0, w: 0}
pivot: {x: 0.5, y: 0.5}
oldSize: {x: 1.28, y: 1.28}
newSize: {x: 1.28, y: 1.28}
adaptiveTilingThreshold: 0.5
drawMode: 0
adaptiveTiling: 0
m_AutoTiling: 0
serializedVersion: 2
m_Size: {x: 1.28, y: 1.28}
m_EdgeRadius: 0
--- !u!1 &1667231311 --- !u!1 &1667231311
GameObject: GameObject:
m_ObjectHideFlags: 0 m_ObjectHideFlags: 0
...@@ -1682,8 +1564,8 @@ GameObject: ...@@ -1682,8 +1564,8 @@ GameObject:
m_Component: m_Component:
- component: {fileID: 1699889077} - component: {fileID: 1699889077}
- component: {fileID: 1699889076} - component: {fileID: 1699889076}
- component: {fileID: 1699889075}
- component: {fileID: 1699889078} - component: {fileID: 1699889078}
- component: {fileID: 1699889075}
m_Layer: 0 m_Layer: 0
m_Name: Tree (1) m_Name: Tree (1)
m_TagString: Resource m_TagString: Resource
...@@ -1700,10 +1582,9 @@ MonoBehaviour: ...@@ -1700,10 +1582,9 @@ MonoBehaviour:
m_GameObject: {fileID: 1699889074} m_GameObject: {fileID: 1699889074}
m_Enabled: 1 m_Enabled: 1
m_EditorHideFlags: 0 m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: bad3649e66714d14d94d87cd3e47c1a1, type: 3} m_Script: {fileID: 11500000, guid: cb94cfa918a502245a4097b1749281ad, type: 3}
m_Name: m_Name:
m_EditorClassIdentifier: m_EditorClassIdentifier:
Amount: 0
--- !u!212 &1699889076 --- !u!212 &1699889076
SpriteRenderer: SpriteRenderer:
m_ObjectHideFlags: 0 m_ObjectHideFlags: 0
......
...@@ -17,7 +17,7 @@ public class City : MonoBehaviour ...@@ -17,7 +17,7 @@ public class City : MonoBehaviour
* Kayttaa resurssia r, maaran 'amount' verran (amount >= 0). * Kayttaa resurssia r, maaran 'amount' verran (amount >= 0).
* Voidaan kayttaa maximissaan sen verran resursseja mita niita on kaytossa. * Voidaan kayttaa maximissaan sen verran resursseja mita niita on kaytossa.
*/ */
public void useResource(Resource r, int amount) public void UseResource(Resource r, int amount)
{ {
if (amount<0) if (amount<0)
{ {
...@@ -26,20 +26,21 @@ public class City : MonoBehaviour ...@@ -26,20 +26,21 @@ public class City : MonoBehaviour
ResourcePool[] lista = gameObject.GetComponents<ResourcePool>(); ResourcePool[] lista = gameObject.GetComponents<ResourcePool>();
for (int i = 0; i < lista.Length; i++) for (int i = 0; i < lista.Length; i++)
{ {
if (lista[i].getResource().GetType().Equals(r.GetType())) if (lista[i].GetResource().GetType().Equals(r.GetType()))
{ {
lista[i].useResource(amount); lista[i].UseResource(amount);
} }
} }
} }
/** /**
* Lisaa resurssia r, maaran 'amount' verran (amount >= 0). * Lisaa resurssia r, maaran 'amount' verran (amount >= 0).
* Voidaan lisata maximissaan resurssin maximikapasiteettiin asti, * Voidaan lisata maximissaan resurssin maximikapasiteettiin asti,
* ts. jos nykyinen resurssimaara + lisatty maara >= maximikapasiteetti * ts. jos nykyinen resurssimaara + lisatty maara >= maximikapasiteetti
* niin uusi resurssimaara = maximikapasiteetti * niin uusi resurssimaara = maximikapasiteetti
*/ */
public void addResource(Resource r, int amount) public void AddResource(Resource r, int amount)
{ {
if (amount<0) if (amount<0)
{ {
...@@ -49,14 +50,26 @@ public class City : MonoBehaviour ...@@ -49,14 +50,26 @@ public class City : MonoBehaviour
for (int i = 0; i < lista.Length; i++) for (int i = 0; i < lista.Length; i++)
{ {
if (lista[i].getResource().GetType().Equals(r.GetType())) if (lista[i].GetResource().GetType().Equals(r.GetType()))
{ {
lista[i].addResource(amount); lista[i].AddResource(amount);
return; return;
} }
} }
ResourcePool respool = gameObject.AddComponent<ResourcePool>(); ResourcePool respool = gameObject.AddComponent<ResourcePool>();
respool.setResource(r); respool.SetResource(r);
respool.addResource(amount); respool.AddResource(amount);
}
/**
* Lisaa kaikkien resurssipoolien maxKapasiteettia x:n verran
*/
public void IncreaseCapacity(int x)
{
ResourcePool[] lista = gameObject.GetComponents<ResourcePool>();
for (int i = 0; i < lista.Length; i++)
{
lista[i].SetCapacity(x);
}
} }
} }
...@@ -16,6 +16,8 @@ public class Collector : MonoBehaviour ...@@ -16,6 +16,8 @@ public class Collector : MonoBehaviour
[SerializeField] [SerializeField]
private GameObject move_to; private GameObject move_to;
[SerializeField]
private int max_amount = 10;
[SerializeField] [SerializeField]
private int amount; private int amount;
...@@ -23,6 +25,8 @@ public class Collector : MonoBehaviour ...@@ -23,6 +25,8 @@ public class Collector : MonoBehaviour
[SerializeField] [SerializeField]
private GameObject home; private GameObject home;
[SerializeField]
private Resource resource;
public float speed = 1; public float speed = 1;
...@@ -57,15 +61,27 @@ public class Collector : MonoBehaviour ...@@ -57,15 +61,27 @@ public class Collector : MonoBehaviour
} }
private void OnTriggerEnter2D(Collider2D collision) private void OnTriggerEnter2D(Collider2D collision)
{ {
Debug.Log(collision.gameObject.name);
if (collision.gameObject.tag == "Resource") if (collision.gameObject.tag == "Resource")
{
//Amount of resources worker is carrying right now
this.amount = collision.gameObject.GetComponent<Resource>().extractResource(this.max_amount);
//Gives target resource to resource variable
this.resource = this.target.GetComponent<Resource>();
StartCoroutine("goHome"); StartCoroutine("goHome");
}
else if (collision.gameObject.name == "City") else if (collision.gameObject.name == "City")
{
//resets amount and resource variables
this.amount = 0;
this.resource = null;
MoveTo(this.target); MoveTo(this.target);
} }
}
IEnumerator goHome() IEnumerator goHome()
{ {
yield return new WaitForSeconds(4); yield return new WaitForSeconds(4);
MoveTo(home); MoveTo(home);
} }
} }
...@@ -18,19 +18,19 @@ public class ResourcePool : MonoBehaviour ...@@ -18,19 +18,19 @@ public class ResourcePool : MonoBehaviour
void Start() void Start()
{ {
} }
public void setResource(Resource r) public void SetResource(Resource r)
{ {
this.r = r; this.r = r;
} }
public Resource getResource() public Resource GetResource()
{ {
return r; return r;
} }
/** /**
* Kayttaa resurssia maaran X verran * Kayttaa resurssia maaran X verran
*/ */
public void useResource(int x) public void UseResource(int x)
{ {
if (this.amount - x <= 0) if (this.amount - x <= 0)
{ {
...@@ -44,7 +44,7 @@ public class ResourcePool : MonoBehaviour ...@@ -44,7 +44,7 @@ public class ResourcePool : MonoBehaviour
/** /**
* Lisaa resurssia maaran X verran * Lisaa resurssia maaran X verran
*/ */
public void addResource(int x) public void AddResource(int x)
{ {
if (this.amount + x >= this.maxCapacity) if (this.amount + x >= this.maxCapacity)
{ {
...@@ -55,4 +55,8 @@ public class ResourcePool : MonoBehaviour ...@@ -55,4 +55,8 @@ public class ResourcePool : MonoBehaviour
this.amount += x; this.amount += x;
} }
} }
public void SetCapacity(int x)
{
this.maxCapacity += x;
}
} }
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment