Example #1
0
    // Update is called once per frame
    void Update()
    {
        if (combatEnd)
        {
            return;
        }
        elapsedTime += Time.deltaTime;
        if (elapsedTime > updateTime && combatData.gameState.Equals("combat"))
        {
            elapsedTime = 0.0f;
            clearUnits();
            foreach (CombatDataUnit unit in combatData.dataUnits)
            {
                GetCellAt(unit.locX, unit.locY).dataUnit = unit;
            }
        }

        if (combatData.gameState.Equals("won"))
        {
            // todo: display won dialog and loot window
            LootData lootData = CombatService.getCombatResults(playerId, gameId, encounterId);
            gameController.combatWindow.SetActive(false);
            lootWindow.SetActive(true);
            earnedXp.text = lootData.xpEarned.ToString();
            earnedGp.text = lootData.gpEarned.ToString();
            earnedAp.text = lootData.apEarned.ToString();

            combatEnd = true;
            // remove encounter from game
            enemyManager.encounterObjects.TryGetValue(encounterId, out GameObject encGameObjectToDelete);
            if (encGameObjectToDelete != null)
            {
                Destroy(encGameObjectToDelete);
            }
        }
        else if (combatData.gameState.Equals("lost"))
        {
            // todo: display lost dialog and remove player from game
            combatEnd = true;
        }
    }