Ejemplo n.º 1
0
	// BIG TODO: change the hierarchy to a messaging system
	void Start() {
		// TODO: make this read from a file instead of hardcoded ofc lol
		foodWeb = new RungeEcosystem();
		foodWeb.AddSpecies("grass",       -0.03f,  1.0f,  0f);
		foodWeb.AddSpecies("oak tree",    -0.03f,  0.8f, 10f);
		foodWeb.AddSpecies("berries",     -0.03f,  0.6f, 10f);
		foodWeb.AddSpecies("rabbit",      -0.01f, -0.1f,  0f);
		foodWeb.AddSpecies("caterpillar", -0.01f, -0.2f, 10f);
		foodWeb.AddSpecies("squirrel",    -0.01f, -0.2f, 10f);
		foodWeb.AddSpecies("fox",         -0.01f, -0.2f,  0f);
		
		foodWeb.AddInteraction("rabbit",      "grass",       0.05f, 0.8f);
		foodWeb.AddInteraction("rabbit",      "berries",     0.02f, 0.8f);
		foodWeb.AddInteraction("squirrel",    "berries",     0.02f, 0.8f);
		foodWeb.AddInteraction("squirrel",    "oak tree",    0.04f, 0.8f);
		foodWeb.AddInteraction("caterpillar", "oak tree",    0.04f, 0.8f);
		foodWeb.AddInteraction("fox",         "berries",     0.02f, 0.5f);
		foodWeb.AddInteraction("fox",         "squirrel",    0.02f, 0.6f);
		foodWeb.AddInteraction("fox",         "rabbit",      0.05f, 0.6f);
		foodWeb.AddInteraction("fox",         "caterpillar", 0.01f, 0.5f);
		// TODO: add humans hunting as the interesting bit of this ecosystem

		Transform iconTransform = new GameObject("Icon Manager").transform; // for organisation
		iconTransform.SetParent(transform);
		iconWeb = new IconManager(iconTransform, transferPrefab, interactionPrefab);
		iconWeb.AddSpecies("grass",       'p',    0f,  0f,  100f, 1f, iconPrefab, pictures[0], Color.green);
		iconWeb.AddSpecies("oak tree",    'p',    0f, 10f,  100f, 1f, iconPrefab, pictures[1], Color.black);
		iconWeb.AddSpecies("berries",     'p',    0f, 10f,  100f, 1f, iconPrefab, pictures[2], Color.magenta);
		iconWeb.AddSpecies("rabbit",      'h',    1f,  0f,  100f, 1f, iconPrefab, pictures[3], Color.grey);
		iconWeb.AddSpecies("caterpillar", 'h', 0.03f, 10f,  100f, 1f, iconPrefab, pictures[4], Color.yellow);
		iconWeb.AddSpecies("squirrel",    'h',  0.5f, 10f,  100f, 1f, iconPrefab, pictures[5], Color.white);
		iconWeb.AddSpecies("fox",         'o',    5f,  0f,  100f, 1f, iconPrefab, pictures[6], Color.red);

		speciesNames = new List<string>();
		speciesNames.Add("grass");
		speciesNames.Add("oak tree");
		speciesNames.Add("berries");
		speciesNames.Add("rabbit");
		speciesNames.Add("caterpillar");
		speciesNames.Add("squirrel");
		speciesNames.Add("fox");
		foreach (string species in speciesNames) SetIconInteractionSprings(species);
		
		CreateGraph();
		InvokeRepeating("UpdateIconPopulations", 0.7f, 2f);

		screenWidth = 2f * Camera.main.orthographicSize * Screen.width / Screen.height;
		screenHeight = screenWidth / Screen.width * Screen.height;

		gui = transform.Find("GUI").GetComponent<GUI>();
		gui.Init(screenWidth, screenHeight);
	}