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

added upgrade system

parent 2b40d9b2
No related branches found
No related tags found
No related merge requests found
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class CollectorUpgrade : Upgrade
{
// Start is called before the first frame update
void Start()
{
UpgradeTargets target = UpgradeTargets.collector;
City city = gameObject.GetComponent<City>();
float currentLevel = city.getLevel(target);
city.useResources(getPrices(currentLevel));
city.addCollector();
}
// Update is called once per frame
void Update()
{
}
}
fileFormatVersion: 2
guid: f39036a325f1d1f4da3df98a7fb16119
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class PopulationUpgrade : Upgrade
{
// Start is called before the first frame update
public void Start()
{
}
// Update is called once per frame
public void Update()
{
}
public void upgrade()
{
UpgradeTargets target = UpgradeTargets.population;
City city = gameObject.GetComponent<City>();
float currentLevel = city.getLevel(target);
city.useResources(getPrices(currentLevel));
city.addPopulation(currentLevel * 10);
Debug.Log("population upgraded");
}
}
fileFormatVersion: 2
guid: fcd69bbed7a9ef3409a62541648ecefa
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class ResourceCapacityUpgrade : Upgrade
{
// Start is called before the first frame update
void Start()
{
}
// Update is called once per frame
void Update()
{
}
public void upgrade()
{
UpgradeTargets target = UpgradeTargets.capacity;
City city = gameObject.GetComponent<City>();
float currentLevel = city.getLevel(target);
city.useResources(getPrices(currentLevel));
city.increaseCapacity(currentLevel * 100);
Debug.Log("Capacity upgraded");
}
}
fileFormatVersion: 2
guid: 2670538e329f5494c9ccb621f90f3d23
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class ResourceEfficiencyUpgrade : Upgrade
{
// Start is called before the first frame update
void Start()
{
}
// Update is called once per frame
void Update()
{
}
public void upgrade()
{
City city = gameObject.GetComponent<City>();
increaseEfficiencyLevel();
city.useResources(getPrices(getEfficiencyLevel() * getEfficiencyLevel()));
Debug.Log("Efficienfy upgraded to: " + getEfficiencyLevel());
}
}
fileFormatVersion: 2
guid: 80c1408915a79524aa4536502432e25d
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class RoadUpgrade : Upgrade
{
// Start is called before the first frame update
void Start()
{
}
// Update is called once per frame
void Update()
{
}
public void upgrade()
{
UpgradeTargets target = UpgradeTargets.speed;
Road road = gameObject.GetComponent<Road>();
City city = gameObject.GetComponent<City>();
float currentLevel = road.getLevel(target);
city.useResources(getPrices(currentLevel));
road.increaseSpeed(1 / currentLevel);
Debug.Log("Road upgraded");
}
}
fileFormatVersion: 2
guid: 9aec1805133c8c746afa3368a29d0e34
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public abstract class Upgrade : MonoBehaviour
{
/*
private float baseWoodCost = 10;
private float baseStoneCost = 10;
private float baseFoodCost = 10;
*/
private float efficiencyLevel = 1;
private Dictionary<Resources, int> resources = new Dictionary<Resources, int>();
// Start is called before the first frame update
void Start()
{
}
// Update is called once per frame
void Update()
{
}
public float getEfficiencyLevel()
{
return efficiencyLevel;
}
public void increaseEfficiencyLevel()
{
efficiencyLevel++;
}
public float getEfficiency()
{
switch (efficiencyLevel)
{
case 1:
Debug.Log("effLevel 1");
return 1;
case 2:
Debug.Log("effLevel 2");
return 0.9f;
case 3:
return 0.8f;
case 4:
return 0.7f;
case 5:
return 0.6f;
default:
Debug.Log("Default");
return 1;
}
}
public List<float> getPrices(float modifier)
{
List<float> prices = new List<float>();
foreach(KeyValuePair<Resources, int> key in resources)
{
prices.Add(key.Value * modifier * 50 * getEfficiency());
}
return prices;
}
}
fileFormatVersion: 2
guid: 06620cacd9f76874d8f0e478ddea0be2
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
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