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 UnityEngine;
......@@ -12,6 +13,16 @@ public class City : MonoBehaviour
}
public int GetLevel(UpgradeTargets target)
{
return 1;
}
public void AddCollector()
{
}
/**
* Kayttaa resurssia r, maaran 'amount' verran (amount >= 0).
......@@ -33,6 +44,11 @@ public class City : MonoBehaviour
}
}
public void AddPopulation(int v)
{
}
/**
* Lisaa resurssia r, maaran 'amount' verran (amount >= 0).
......
......@@ -12,7 +12,7 @@ public class CollectorUpgrade : Upgrade
UpgradeTargets target = UpgradeTargets.collector;
City city = gameObject.GetComponent<City>();
float currentLevel = city.GetLevel(target);
city.UseResources(getPrices(currentLevel));
city.UseResources(GetPrices(currentLevel));
city.AddCollector();
}
......
......@@ -20,8 +20,8 @@ public class PopulationUpgrade : Upgrade
{
UpgradeTargets target = UpgradeTargets.population;
City city = gameObject.GetComponent<City>();
float currentLevel = city.GetLevel(target);
city.UseResources(getPrices(currentLevel));
int currentLevel = city.GetLevel(target);
city.UseResources(GetPrices(currentLevel));
city.AddPopulation(currentLevel * 10);
Debug.Log("population upgraded");
}
......
......@@ -20,7 +20,7 @@ public class ResourceCapacityUpgrade : Upgrade
{
UpgradeTargets target = UpgradeTargets.capacity;
City city = gameObject.GetComponent<City>();
float currentLevel = city.GetLevel(target);
int currentLevel = city.GetLevel(target);
city.UseResources(GetPrices(currentLevel));
city.IncreaseCapacity(currentLevel * 100);
Debug.Log("Capacity upgraded");
......
......@@ -20,7 +20,7 @@ public class ResourceEfficiencyUpgrade : Upgrade
{
City city = gameObject.GetComponent<City>();
increaseEfficiencyLevel();
city.UseResources(getPrices(getEfficiencyLevel() * getEfficiencyLevel()));
city.UseResources(GetPrices(getEfficiencyLevel() * getEfficiencyLevel()));
Debug.Log("Efficienfy upgraded to: " + getEfficiencyLevel());
}
}
......@@ -59,4 +59,8 @@ public class ResourcePool : MonoBehaviour
{
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
UpgradeTargets target = UpgradeTargets.speed;
Road road = gameObject.GetComponent<Road>();
City city = gameObject.GetComponent<City>();
float currentLevel = road.getLevel(target);
city.UseResources(getPrices(currentLevel));
float currentLevel = road.GetLevel(target);
city.UseResources(GetPrices(currentLevel));
road.IncreaseSpeed(1 / currentLevel);
Debug.Log("Road upgraded");
}
......
......@@ -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>();
foreach(KeyValuePair<Resources, int> key in resources)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment