예제 #1
0
    // Actually start the combat
    public void CombatStart(GameObject player, GameObject opponent)
    {
        print(player.name + " wants to fight " + opponent.name);
        combatPlayer = player;
        combatOpponent = opponent;
        InCombat = true;

        _winPanel.SetActive(false);
        _fightCanvasAnimator.enabled = true;
        _fightPanel.SetActive(true);
        _startCombatButton.gameObject.SetActive(false);
        _fightTextObject.GetComponent<ScrollingText>().SetText(_fightText,
            delegate
            {
                SetupBattleOptions(true);
            });

        _diceAnimator.gameObject.SetActive(false);

        _diceAnimator.enabled = true;
        _diceAnimator.gameObject.GetComponent<Image>().enabled = true;

        enemyLives = 10;
        playerLives = 10;
        StartCoroutine(CombatUpdate());
        if (OnCombatStarted != null)
        {
            OnCombatStarted.Invoke();
        }
    }
예제 #2
0
    public void TickEntities()
    {
        bool hasStartedCombat = false;

        for (int i = 0; i < entities.Count; i++)
        {
            var entity = entities[i];
            if (entity == player)
            {
                continue;
            }

            entity.Tick(this);

            // TODO WT: Support multiple attackers.
            if (!hasStartedCombat && Vector2Int.Distance(player.position, entity.position) == 1.0f)
            {
                OnCombatStarted?.Invoke(entity);
                hasStartedCombat = true;
            }
        }
    }