Skip to content
Snippets Groups Projects
Commit 9901ea49 authored by Kimi Heinonen's avatar Kimi Heinonen
Browse files

metodit isolla ja debugattu T erno

parent 3b97d0cf
No related branches found
No related tags found
No related merge requests found
using System.Collections; using System;
using System.Collections;
using System.Collections.Generic; using System.Collections.Generic;
using UnityEngine; using UnityEngine;
...@@ -11,8 +12,18 @@ public class City : MonoBehaviour ...@@ -11,8 +12,18 @@ public class City : MonoBehaviour
{ {
} }
public int GetLevel(UpgradeTargets target)
{
return 1;
}
public void AddCollector()
{
}
/** /**
* 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.
...@@ -32,7 +43,12 @@ public class City : MonoBehaviour ...@@ -32,7 +43,12 @@ public class City : MonoBehaviour
} }
} }
} }
public void AddPopulation(int v)
{
}
/** /**
* Lisaa resurssia r, maaran 'amount' verran (amount >= 0). * Lisaa resurssia r, maaran 'amount' verran (amount >= 0).
......
...@@ -12,7 +12,7 @@ public class CollectorUpgrade : Upgrade ...@@ -12,7 +12,7 @@ public class CollectorUpgrade : Upgrade
UpgradeTargets target = UpgradeTargets.collector; UpgradeTargets target = UpgradeTargets.collector;
City city = gameObject.GetComponent<City>(); City city = gameObject.GetComponent<City>();
float currentLevel = city.GetLevel(target); float currentLevel = city.GetLevel(target);
city.UseResources(getPrices(currentLevel)); city.UseResources(GetPrices(currentLevel));
city.AddCollector(); city.AddCollector();
} }
......
...@@ -20,8 +20,8 @@ public class PopulationUpgrade : Upgrade ...@@ -20,8 +20,8 @@ public class PopulationUpgrade : Upgrade
{ {
UpgradeTargets target = UpgradeTargets.population; UpgradeTargets target = UpgradeTargets.population;
City city = gameObject.GetComponent<City>(); City city = gameObject.GetComponent<City>();
float currentLevel = city.GetLevel(target); int currentLevel = city.GetLevel(target);
city.UseResources(getPrices(currentLevel)); city.UseResources(GetPrices(currentLevel));
city.AddPopulation(currentLevel * 10); city.AddPopulation(currentLevel * 10);
Debug.Log("population upgraded"); Debug.Log("population upgraded");
} }
......
...@@ -20,7 +20,7 @@ public class ResourceCapacityUpgrade : Upgrade ...@@ -20,7 +20,7 @@ public class ResourceCapacityUpgrade : Upgrade
{ {
UpgradeTargets target = UpgradeTargets.capacity; UpgradeTargets target = UpgradeTargets.capacity;
City city = gameObject.GetComponent<City>(); City city = gameObject.GetComponent<City>();
float currentLevel = city.GetLevel(target); int currentLevel = city.GetLevel(target);
city.UseResources(GetPrices(currentLevel)); city.UseResources(GetPrices(currentLevel));
city.IncreaseCapacity(currentLevel * 100); city.IncreaseCapacity(currentLevel * 100);
Debug.Log("Capacity upgraded"); Debug.Log("Capacity upgraded");
......
...@@ -20,7 +20,7 @@ public class ResourceEfficiencyUpgrade : Upgrade ...@@ -20,7 +20,7 @@ public class ResourceEfficiencyUpgrade : Upgrade
{ {
City city = gameObject.GetComponent<City>(); City city = gameObject.GetComponent<City>();
increaseEfficiencyLevel(); increaseEfficiencyLevel();
city.UseResources(getPrices(getEfficiencyLevel() * getEfficiencyLevel())); city.UseResources(GetPrices(getEfficiencyLevel() * getEfficiencyLevel()));
Debug.Log("Efficienfy upgraded to: " + getEfficiencyLevel()); Debug.Log("Efficienfy upgraded to: " + getEfficiencyLevel());
} }
} }
...@@ -59,4 +59,8 @@ public class ResourcePool : MonoBehaviour ...@@ -59,4 +59,8 @@ public class ResourcePool : MonoBehaviour
{ {
this.maxCapacity += x; this.maxCapacity += x;
} }
public void AddCollector()
{
Collector c = gameObject.AddComponent<Collector>();
}
} }
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Road : MonoBehaviour
{
// Start is called before the first frame update
void Start()
{
}
// Update is called once per frame
void Update()
{
}
internal float GetLevel(UpgradeTargets target)
{
throw new NotImplementedException();
}
internal void IncreaseSpeed(float v)
{
throw new NotImplementedException();
}
}
fileFormatVersion: 2
guid: a13d323f8e41b544c95f8ef1a2b4baba
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
...@@ -21,8 +21,8 @@ public class RoadUpgrade : Upgrade ...@@ -21,8 +21,8 @@ public class RoadUpgrade : Upgrade
UpgradeTargets target = UpgradeTargets.speed; UpgradeTargets target = UpgradeTargets.speed;
Road road = gameObject.GetComponent<Road>(); Road road = gameObject.GetComponent<Road>();
City city = gameObject.GetComponent<City>(); City city = gameObject.GetComponent<City>();
float currentLevel = road.getLevel(target); float currentLevel = road.GetLevel(target);
city.UseResources(getPrices(currentLevel)); city.UseResources(GetPrices(currentLevel));
road.IncreaseSpeed(1 / currentLevel); road.IncreaseSpeed(1 / currentLevel);
Debug.Log("Road upgraded"); Debug.Log("Road upgraded");
} }
......
...@@ -58,7 +58,7 @@ public abstract class Upgrade : MonoBehaviour ...@@ -58,7 +58,7 @@ public abstract class Upgrade : MonoBehaviour
} }
public List<float> getPrices(float modifier) public List<float> GetPrices(float modifier)
{ {
List<float> prices = new List<float>(); List<float> prices = new List<float>();
foreach(KeyValuePair<Resources, int> key in resources) foreach(KeyValuePair<Resources, int> key in resources)
......
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