void OnTriggerEnter(Collider other) { CharacterBehaviour cb = other.GetComponent <CharacterBehaviour> (); if (cb != null) { switch (buildingType) { case "hut": if (cb.CarriedResourceType().Equals("wood")) { tribe.StoreWood(cb.CarriedResourceAmount()); } else if (cb.CarriedResourceType().Equals("rock")) { tribe.StoreRock(cb.CarriedResourceAmount()); } else if (!cb.CarriedResourceType().Equals("")) { Debug.Log(other.name + " was carrying " + cb.CarriedResourceType() + ", which is unknown. (Is it not lowercase?)"); } cb.ResetCarrying(); break; case "barracks": if (!cb.GetJob().Equals("kill")) { string message = ""; if (tribe.GetResourceAmount("wood") < 5) { message += "Not enough wood! (" + tribe.GetResourceAmount("wood") + " / 5)"; } if (tribe.GetResourceAmount("rock") < 2) { message += "\nNot enough rocks! (" + tribe.GetResourceAmount("rock") + " / 2)"; } if (message.Equals("")) { SoundHandler.PlaySound("equip"); cb.SetJob("kill"); tribe.StoreWood(-5); tribe.StoreRock(-2); } else { HUDController.PostMessage(message, false); } } else { SoundHandler.PlaySound("dequip"); cb.SetJob(""); tribe.StoreWood(5); tribe.StoreRock(2); } break; } } }
void Update() { woodValueText.text = "Wood: " + playerTribe.GetResourceAmount("wood"); rockValueText.text = "Rocks: " + playerTribe.GetResourceAmount("rock"); workerValueText.text = "Workers: " + playerTribe.GetCharacterCount(); foreach (CharacterBehaviour cb in playerTribe.GetCharacters()) { string text = cb.GetName(); if (cb.CarriedResourceType() != "") { text += "\nGathered " + cb.CarriedResourceType() + ": " + cb.CarriedResourceAmount(); } cb.nameTextMesh.text = text; } messagesText.text = ""; for (int i = messages.Length - 1; i > lastMsgRows - 1; i--) { messagesText.text += messages[i] + (i > lastMsgRows ? "\n" : ""); } latestMessageText.text = ""; for (int i = lastMsgRows - 1; i > 0; i--) { latestMessageText.text += messages[i] + (i > 0 ? "\n" : ""); } latestMessageText.text += messages [0]; if (lastPostTime + messageCooldown < Time.fixedTime && messageCooldown > 0 && !freeze) { PostMessage("", false); } if (!started) { started = true; PostMessage("Press the button on the right (and slightly above) to continue.", true); } }