public void Open() { renderer.sprite = open; if (!isOpen) { GoblinLootCoordinator.IncreaseLoot(1); EventCoordinator.TriggerEvent(EventName.System.Economy.ChestWasOpened(), GameMessage.Write().WithChest(this)); EventCoordinator.TriggerEvent(EventName.System.Economy.AmountLootedChanged(), GameMessage.Write().WithIntMessage(GoblinLootCoordinator.GetLootAmount())); } isOpen = true; }
void AmountLootedChanged(GameMessage msg) { text.text = "X" + GoblinLootCoordinator.GetLootAmount(); }
void OnLootThrow(GameMessage msg) { if (GoblinLootCoordinator.HasLoot()) { GameObject newThrown = Instantiate(lootPrefab); newThrown.transform.position = msg.coordinates; newThrown.GetComponent <LootFly>().ThrowAt(msg.targetCoordinates); GoblinLootCoordinator.DecreaseLoot(1); //Debug.Log("target coords: " + msg.targetCoordinates); newThrown.GetComponentInChildren <SpriteRenderer>().sprite = itemSprites[Random.Range(0, itemSprites.Count)]; newThrown.transform.parent = GoblinLootCoordinator.Instance.transform; EventCoordinator.TriggerEvent(EventName.System.Economy.AmountLootedChanged(), GameMessage.Write().WithIntMessage(GoblinLootCoordinator.GetLootAmount())); } }