Skip to content

Instantly share code, notes, and snippets.

@stipebosnjak
Created November 2, 2018 01:40
Show Gist options
  • Save stipebosnjak/0a47ab30c005c254ed8009aa36726ebb to your computer and use it in GitHub Desktop.
Save stipebosnjak/0a47ab30c005c254ed8009aa36726ebb to your computer and use it in GitHub Desktop.
StellarObject - Stash
using System.Collections.Generic;
using UnityEngine;
namespace Assets._Scripts
{
public class StellarObject : MonoBehaviour
{
public const float TICK_TIME = 5f;
private List<Factory> Factories;
private float tempTick;
public int Population;
public float Water;
public float Food;
public float Materials;
public float Defense;
public float WaterFactor;
public float FoodFactor;
public float MaterialFactor;
public float DefenseFactor = 1;
private Factory _materialFactory;
private Factory _defenseFactory;
private Factory _waterFactory;
private Factory _foodFactory;
public bool Paused { get; set; }
public void Awake()
{
_waterFactory = new Factory(7, 1);
_foodFactory = new Factory(3, 2);
_materialFactory = new Factory(2, 3);
_defenseFactory = new Factory(1, 4);
}
// making defense from materials
// population consume priority :
// Food and Water for making more Food and Water
// if they have more food and water than needed than larger percent of population works on building the defense
// if
public void Update()
{
if (Paused)
return;
//10
//2
// food production
// 1 human unit can produce 4 food units
// 1 human unit will consume 1 food unit
// 1 human unit will produce 5 - 15 water units units depending on the planet surface
// 1 human unit will consume 1 water unit
// 1 human unit will produce 1 defense unit with 1 material unit
// 1 human unit will produce 2 - 8 material units depending on the planet surface
// if tick occurs then update all
var labor = Population;
Water += _waterFactory.Produce(ref labor, WaterFactor);
Food += _foodFactory.Produce(ref labor, FoodFactor);
Materials += _materialFactory.Produce(ref labor, MaterialFactor);
Defense += _defenseFactory.Produce(ref labor, DefenseFactor);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment