Skip to content
Snippets Groups Projects
Commit 3d976250 authored by Leevi Grönlund's avatar Leevi Grönlund
Browse files

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

parents 27db9615 cf8fab8b
No related branches found
No related tags found
No related merge requests found
...@@ -119,7 +119,8 @@ MonoBehaviour: ...@@ -119,7 +119,8 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: dfe928a858872424991e927606dd4bc3, type: 3} m_Script: {fileID: 11500000, guid: dfe928a858872424991e927606dd4bc3, type: 3}
m_Name: m_Name:
m_EditorClassIdentifier: m_EditorClassIdentifier:
worker: {fileID: 0} workerlista: []
worker: {fileID: 548039319383633024, guid: 7dc194a2047a39340a91ca7636a56290, type: 3}
population: 0 population: 0
populationLevel: 0 populationLevel: 0
resourcePoolLevel: 0 resourcePoolLevel: 0
......
...@@ -5,6 +5,9 @@ using UnityEngine; ...@@ -5,6 +5,9 @@ using UnityEngine;
public class City : MonoBehaviour public class City : MonoBehaviour
{ {
[SerializeField]
List<GameObject> workerlista;
[SerializeField] [SerializeField]
GameObject worker; GameObject worker;
...@@ -20,16 +23,18 @@ public class City : MonoBehaviour ...@@ -20,16 +23,18 @@ public class City : MonoBehaviour
[SerializeField] [SerializeField]
public int roadLevel = 0; public int roadLevel = 0;
[SerializeField]
public int collectorLevel = 0;
// Start is called before the first frame update // Start is called before the first frame update
void Start() void Start()
{ {
} }
/**
* Palauttaa kysytyn targetin levelin
*/
public int GetLevel(UpgradeTargets target) public int GetLevel(UpgradeTargets target)
{ {
switch (target) switch (target)
...@@ -41,7 +46,7 @@ public class City : MonoBehaviour ...@@ -41,7 +46,7 @@ public class City : MonoBehaviour
case UpgradeTargets.speed: case UpgradeTargets.speed:
return this.roadLevel; return this.roadLevel;
case UpgradeTargets.collector: case UpgradeTargets.collector:
return this.collectorLevel; return this.workerlista.Count;
default: default:
Debug.Log("Default"); Debug.Log("Default");
return -1; return -1;
...@@ -50,12 +55,19 @@ public class City : MonoBehaviour ...@@ -50,12 +55,19 @@ public class City : MonoBehaviour
return 1; return 1;
} }
/**
* Lisaa uuden collecotrin
*/
public void AddCollector() public void AddCollector()
{ {
GameObject go = Instantiate<GameObject>(worker); GameObject go = Instantiate<GameObject>(worker);
this.workerlista.Add(go);
go.transform.position = new Vector3(); go.transform.position = new Vector3();
this.population++;
} }
......
...@@ -53,7 +53,7 @@ public class Collector : MonoBehaviour ...@@ -53,7 +53,7 @@ public class Collector : MonoBehaviour
MoveTo(hit.collider.gameObject); MoveTo(hit.collider.gameObject);
} }
} }
if (target != null) if (move_to != null)
transform.position = Vector3.MoveTowards(new Vector3(transform.position.x, transform.position.y, -1f), move_to.transform.position, speed * Time.deltaTime); transform.position = Vector3.MoveTowards(new Vector3(transform.position.x, transform.position.y, -1f), move_to.transform.position, speed * Time.deltaTime);
} }
private void OnTriggerEnter2D(Collider2D collision) private void OnTriggerEnter2D(Collider2D collision)
...@@ -67,7 +67,7 @@ public class Collector : MonoBehaviour ...@@ -67,7 +67,7 @@ public class Collector : MonoBehaviour
this.resource = this.target.GetComponent<Resource>(); this.resource = this.target.GetComponent<Resource>();
StartCoroutine("goHome"); StartCoroutine("goHome");
} }
else if (collision.gameObject.name == "City" && this.resource != null) else if (collision.gameObject.tag == "Home" && this.resource != null)
{ {
//resets amount and resource variables //resets amount and resource variables
collision.gameObject.GetComponent<City>().AddResource(this.resource, this.amount); collision.gameObject.GetComponent<City>().AddResource(this.resource, this.amount);
......
...@@ -15,9 +15,12 @@ public static class EventSystem ...@@ -15,9 +15,12 @@ public static class EventSystem
public static void EventHappened(EventType name) public static void EventHappened(EventType name)
{ {
Debug.Log("happened");
if (events.ContainsKey(name)) if (events.ContainsKey(name))
{ {
foreach (IAction e in events.Values){
Debug.Log("contains: "+events.Values.ToString());
foreach (IAction e in events[name]){
e.React(name); e.React(name);
} }
} }
......
...@@ -59,5 +59,9 @@ public class ResourcePool : MonoBehaviour ...@@ -59,5 +59,9 @@ public class ResourcePool : MonoBehaviour
{ {
this.maxCapacity += x; this.maxCapacity += x;
} }
public int GetMaxCapacity()
{
return this.maxCapacity;
}
} }
Assets/Sprites/rock.png

16.2 KiB | W: | H:

Assets/Sprites/rock.png

7.64 KiB | W: | H:

Assets/Sprites/rock.png
Assets/Sprites/rock.png
Assets/Sprites/rock.png
Assets/Sprites/rock.png
  • 2-up
  • Swipe
  • Onion skin
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment