Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found

Target

Select target project
  • eolokk/game_jam19
  • lejugr/game_jam19
  • tmpoht/game_jam19
  • kjahei/game_jam19
  • makalo/game_jam19
5 results
Show changes
Showing
with 634 additions and 0 deletions
fileFormatVersion: 2
guid: d3674a5cdecf6e14abe5d88e6f0f7618
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
fileFormatVersion: 2
guid: f212001d582b5ec48b714aaad705947b
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class GroundGenerator : MonoBehaviour
{
int[,] ground = new int[15, 15];
[SerializeField]
private GameObject[] tiles = null;
[SerializeField]
private GameObject[] resourceGOs = null;
[SerializeField]
private GameObject homeGO = null;
private int food = 2;
private int stone = 3;
private int wood = 4;
private int home = 5;
private int groundDepth = 1;
private int resourceDepth = 0;
private int houseDepth = -2;
private int workerDepth = -1;
private int[] houseCoords;
/*
0,1,2
3,4,5
6,7,8
*/
// Start is called before the first frame update
void Start()
{
houseCoords = new int[]{ ground.GetLength(0) / 2, ground.GetLength(1) / 2 };
for (int i = 1; i < ground.GetLength(0) - 1; i++)
{
for (int j = 1; j < ground.GetLength(1) - 1; j++)
{
ground[i, j] = 1;
if (isEdge(i,j))
continue;
generateResource(i,j);
}
}
createGround();
createHome();
createResources();
Destroy(gameObject);
}
bool isEdge(int x, int y) {
return x == 1 || x == ground.GetLength(0) - 2 || y == 1 || y == ground.GetLength(1) - 2;
}
void generateResource(int x, int y) {
if (Random.value < 0.10f)
{
ground[x, y] = wood;
}
if (Random.value < 0.10f)
{
ground[x, y] = stone;
}
if (Random.value < 0.10f)
{
ground[x, y] = food;
}
}
void createGround()
{
for (int i = 1; i < ground.GetLength(0) - 1; i++)
{
for (int j = 1; j < ground.GetLength(1) - 1; j++)
{
if (ground[i, j] == 0)
continue;
if (ground[i - 1, j] == 0 && ground[i, j - 1] == 0)
{
spawn(tiles[6], i, j, groundDepth);
}
else if (ground[i + 1, j] == 0 && ground[i, j - 1] == 0)
{
spawn(tiles[8], i, j, groundDepth);
}
else if (ground[i + 1, j] == 0 && ground[i, j + 1] == 0)
{
spawn(tiles[2], i, j, groundDepth);
}
else if (ground[i - 1, j] == 0 && ground[i, j + 1] == 0)
{
spawn(tiles[0], i, j, groundDepth);
}
else if (ground[i + 1, j] == 0)
{
spawn(tiles[5], i, j, groundDepth);
}
else if (ground[i - 1, j] == 0)
{
spawn(tiles[3], i, j, groundDepth);
}
else if (ground[i, j + 1] == 0)
{
spawn(tiles[1], i, j, groundDepth);
}
else if (ground[i, j - 1] == 0)
{
spawn(tiles[7], i, j, groundDepth);
}
else
{
spawn(tiles[4], i, j, groundDepth);
}
}
}
}
void createResources()
{
for (int i = 1; i < ground.GetLength(0) - 1; i++)
{
for (int j = 1; j < ground.GetLength(1) - 1; j++)
{
if ((i >= houseCoords[0] - 1 && i <= houseCoords[0] + 1) && (j >= houseCoords[1] - 1 && j <= houseCoords[1] + 1))
continue;
if (ground[i, j] == wood)
{
spawn(resourceGOs[0], i, j, resourceDepth);
}
if (ground[i, j] == stone)
{
spawn(resourceGOs[1], i, j, resourceDepth);
}
if (ground[i, j] == food)
{
spawn(resourceGOs[2], i, j, resourceDepth);
}
}
}
}
private void createHome() {
ground[ground.GetLength(0) / 2, ground.GetLength(1) / 2] = home;
GameObject go = spawn(homeGO, houseCoords[0], houseCoords[1], houseDepth);
go.GetComponent<City>().AddCollector();
}
private GameObject spawn(GameObject go, int x, int y, int z) {
return Instantiate<GameObject>(go, new Vector3(x, y, z), Quaternion.identity);
}
}
\ No newline at end of file
fileFormatVersion: 2
guid: 14c4e830c0ab41b43857c747422e6d5d
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class MenuSript : MonoBehaviour
{
[SerializeField]
private GameObject playButton;
[SerializeField]
private GameObject exitButton;
private void OnMouseDown() {
if (gameObject == exitButton) {
Application.Quit();
}
if (gameObject == playButton) {
UnityEngine.SceneManagement.SceneManager.LoadScene(1);
}
}
}
fileFormatVersion: 2
guid: 6b987107b9a225144a51d7e298dbf2aa
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
fileFormatVersion: 2
guid: f89945eadb9a561409691a6395ace8d0
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class BerryBush : Resource
{
public bool coroutineRunning =false;
public override void checkExistence()
{
if (!coroutineRunning)
{
StartCoroutine("timer");
coroutineRunning = true;
}
}
private IEnumerator timer()
{
yield return new WaitForSeconds(600);
setAmount(50);
coroutineRunning = false;
}
public override void setAmount(int i)
{
base.setAmount(i);
}
public override void refreshSprite()
{
if (sprites == null) return;
if (getAmount() < 1)
{
gameObject.GetComponent<SpriteRenderer>().sprite = sprites[5];
}
else if (getAmount() <= 10)
{
gameObject.GetComponent<SpriteRenderer>().sprite = sprites[4];
}
else if (getAmount() <= 20)
{
gameObject.GetComponent<SpriteRenderer>().sprite = sprites[3];
}
else if (getAmount() <= 30)
{
gameObject.GetComponent<SpriteRenderer>().sprite = sprites[2];
}
else if (getAmount() <= 40)
{
gameObject.GetComponent<SpriteRenderer>().sprite = sprites[1];
}
else
{
gameObject.GetComponent<SpriteRenderer>().sprite = sprites[0];
}
}
// Start is called before the first frame update
void Start()
{
setEventType(EventType.Berrypicked);
setAmount(50);
}
// Update is called once per frame
void Update()
{
}
}
......@@ -12,78 +12,74 @@ public class Forest : Resource
isForester = i;
if (isForester == true)
{
growthspeed = 0.5f;
growthspeed = 3f;
}
else
{
growthspeed = 1;
growthspeed = 5f;
}
}
public override void refreshSprite()
{
if (resources < 125)
if (sprites == null) return;
if (getAmount() < 25)
{
//yhden puun sprite
gameObject.GetComponent<SpriteRenderer>().sprite = sprites[7];
}
else if (resources < 250)
else if (getAmount() < 50)
{
//2 sprite
gameObject.GetComponent<SpriteRenderer>().sprite = sprites[6];
}
else if (resources < 375)
else if (getAmount() < 75)
{
gameObject.GetComponent<SpriteRenderer>().sprite = sprites[5];
}
else if (resources < 500)
else if (getAmount() < 100)
{
gameObject.GetComponent<SpriteRenderer>().sprite = sprites[4];
}
else if (resources < 625)
else if (getAmount() < 125)
{
gameObject.GetComponent<SpriteRenderer>().sprite = sprites[3];
}
else if (resources < 750)
else if (getAmount() < 150)
{
gameObject.GetComponent<SpriteRenderer>().sprite = sprites[2];
}
else if (resources < 875)
else if (getAmount() < 175)
{
gameObject.GetComponent<SpriteRenderer>().sprite = sprites[1];
}
else
{
gameObject.GetComponent<SpriteRenderer>().sprite = sprites[0];
}
}
public override void checkExistence()
{
if (resources < 1)
if (getAmount() < 1)
{
Destroy(gameObject);
gameObject.SetActive(false);
}
}
// Start is called before the first frame update
void Start()
{
resources = Random.Range(50, 300);
setEventType(EventType.WoodChopped);
setAmount(Random.Range(50, 70));
isForester = false;
growthspeed = 1;
growthspeed = 3f;
StartCoroutine("Grow");
}
// Update is called once per frame
void Update()
{
}
IEnumerator Grow()
{
while (resources < 1000)
while (getAmount() < 200)
{
resources++;
setAmount(getAmount() + 1);
yield return new WaitForSeconds(growthspeed);
}
}
......
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
// Luokka, joka vaatii collectoreilta 100 puuta ennen kuin Quarry voidaan luoda samaan pisteeseen kartalla
public class Outcrop : MonoBehaviour
{
[SerializeField]
private int wood;
private readonly int woodNeeded = 100;
[SerializeField]
private GameObject quarry =null;
[SerializeField]
private Resource neededResource =null;
public Resource getNeededResource()
{
return neededResource;
}
public int getAmount()
{
return wood;
}
public void setAmount(int amount)
{
wood = amount;
}
public void checkExistence()
{
if (getAmount() >= woodNeeded)
{
GameObject go = Instantiate<GameObject>(quarry);
go.transform.position = this.transform.position;
gameObject.SetActive(false);
}
}
public void addResource(int amount)
{
setAmount(getAmount() + amount);
checkExistence();
}
public int stillNeeded()
{
return woodNeeded-wood;
}
// Start is called before the first frame update
void Start()
{
setAmount(0);
GameObject go = new GameObject();
neededResource = go.AddComponent<Forest>();
neededResource.enabled = false;
}
// Update is called once per frame
void Update()
{
if (getAmount() == 100)
{
// luo Quarry -olio samaan pisteeseen kartalla ja tuhoa Outcrop -olio
}
}
}
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Quarry : Resource
{
public override void checkExistence()
{
if (getAmount() < 1)
{
gameObject.SetActive(false);
}
}
public override void refreshSprite()
{
if (sprites == null) return;
if (getAmount() < 50)
{
gameObject.GetComponent<SpriteRenderer>().sprite = sprites[5];
}
else if (getAmount() < 166)
{
gameObject.GetComponent<SpriteRenderer>().sprite = sprites[4];
}
else if (getAmount() < 333)
{
gameObject.GetComponent<SpriteRenderer>().sprite = sprites[3];
}
else if (getAmount() < 500)
{
gameObject.GetComponent<SpriteRenderer>().sprite = sprites[2];
}
else if (getAmount() < 633)
{
gameObject.GetComponent<SpriteRenderer>().sprite = sprites[1];
}
else
{
gameObject.GetComponent<SpriteRenderer>().sprite = sprites[0];
}
}
// Start is called before the first frame update
void Start()
{
setEventType(EventType.StoneCut);
setAmount(Random.Range(500, 800));
}
// Update is called once per frame
void Update()
{
}
}
......@@ -4,44 +4,65 @@ using UnityEngine;
public abstract class Resource : MonoBehaviour
{
protected int resources;
[SerializeField]
private int resources;
public void setAmount(int i)
[SerializeField]
private Sprite resourceImg;
[SerializeField]
protected Sprite[] sprites;
private EventType type;
public void setEventType(EventType e)
{
type = e;
}
public EventType getEventType()
{
return type;
}
public Sprite getResourceImg()
{
return resourceImg;
}
public virtual void setAmount(int i)
{
resources = i;
refreshSprite();
checkExistence();
}
public int getAmount()
{
//r.setAmount(ref.getAmount() - extraction);
return resources;
}
// Soittaa resurssin keruuseen liittyvän äänen sekä vähentää resurssista annetun määrän yksiköitä tai asettaa määrän nollaan,
// mikäli vähennettävä arvo on suurempi kuin resurssiyksiköiden senhetkinen määrä. Palauttaa resurssin vähennetyn määrän.
public int extractResource(int amount)
{
EventSystem.EventHappened(getEventType());
if (resources-amount < 0)
{
int r = resources;
resources = 0;
refreshSprite();
checkExistence();
setAmount(0);
return r;
}
else
{
resources = resources - amount;
refreshSprite();
checkExistence();
setAmount(resources - amount);
return amount;
}
}
// Metodi spriten päivitystä varten.
public abstract void refreshSprite();
// Metodi jolla tarkistetaan resurssien olemassaolon ehdot ja suoritetaan tarvittavat toimenpiteet.
public abstract void checkExistence();
}
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:
fileFormatVersion: 2
guid: 6c8bd6d1b4693cf40af60b640e73f52b
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant: