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

Resources

parent 3016c86b
No related branches found
No related tags found
No related merge requests found
...@@ -2,8 +2,14 @@ ...@@ -2,8 +2,14 @@
using System.Collections.Generic; using System.Collections.Generic;
using UnityEngine; using UnityEngine;
public class NewBehaviourScript : MonoBehaviour public class BerryBush : Resource
{ {
public override void checkExistence()
{
}
// Start is called before the first frame update // Start is called before the first frame update
void Start() void Start()
{ {
......
fileFormatVersion: 2 fileFormatVersion: 2
guid: d3674a5cdecf6e14abe5d88e6f0f7618 guid: fa5bb155b8732f34994d234d1a214353
MonoImporter: MonoImporter:
externalObjects: {} externalObjects: {}
serializedVersion: 2 serializedVersion: 2
......
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Forest : Resource
{
private bool isForester;
private float growthspeed;
public void setForester(bool i)
{
isForester = i;
if (isForester == true)
{
growthspeed = 0.5f;
}
else
{
growthspeed = 1;
}
}
public void refreshSprite()
{
if (resources < 125)
{
//yhden puun sprite
}
else if (resources < 250)
{
//2 sprite
}
else if (resources < 375)
{
}
else if (resources < 500)
{
}
else if (resources < 625)
{
}
else if (resources < 750)
{
}
else if (resources < 875)
{
}
else
{
}
}
public override void checkExistence()
{
if (resources < 1)
{
Destroy(gameObject);
}
}
// Start is called before the first frame update
void Start()
{
resources = Random.Range(50, 300);
isForester = false;
growthspeed = 1;
}
// Update is called once per frame
void Update()
{
checkExistence();
StartCoroutine("Grow");
refreshSprite();
}
IEnumerator Grow()
{
yield return new WaitForSeconds(growthspeed);
while (resources < 1000)
{
resources++;
}
}
}
fileFormatVersion: 2 fileFormatVersion: 2
guid: 829c46be4b50d504a8fd053e72cf24e3 guid: cb94cfa918a502245a4097b1749281ad
folderAsset: yes MonoImporter:
DefaultImporter:
externalObjects: {} externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData: userData:
assetBundleName: assetBundleName:
assetBundleVariant: assetBundleVariant:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Outcrop : Resource
{
public override void checkExistence()
{
if (resources < 1)
{
Destroy(gameObject);
}
}
// Start is called before the first frame update
void Start()
{
resources = 0;
}
// Update is called once per frame
void Update()
{
if (resources == 100)
{
// luo Quarry -olio samaan pisteeseen kartalla ja tuhoa Outcrop -olio
}
}
}
fileFormatVersion: 2
guid: 35ded1978221bf847a4ec774ba1dc91c
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Quarry : Resource
{
public override void checkExistence()
{
if (resources < 1)
{
Destroy(gameObject);
}
}
// Start is called before the first frame update
void Start()
{
resources = Random.Range(2000, 4000);
}
// Update is called once per frame
void Update()
{
}
}
fileFormatVersion: 2
guid: 23de19c4f52dce74cb534c58eddea6df
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 Resource : MonoBehaviour
{
protected int resources;
public void setAmount(int i)
{
resources = i;
}
public int getAmount()
{
//r.setAmount(ref.getAmount() - extraction);
return resources;
}
public int extractResource(int amount)
{
if (resources-amount < 0)
{
int r = resources;
resources = 0;
return r;
}
else
{
resources = resources - amount;
return amount;
}
}
public abstract void checkExistence();
}
fileFormatVersion: 2
guid: cd35c40904ffd144cb72afc7c3b5edc1
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.
Please register or to comment