예제 #1
0
파일: Pawn.cs 프로젝트: travisSVK/GGJ2020
    public bool Attack(Pawn other)
    {
        bool pawnDied = false;

        if (m_swordHp > 0.0f)
        {
            AttackOutcome outcome = other.TakeDmg(m_dmg);
            m_swordHp -= m_dmg;
            if (m_swordHp <= 0.0f)
            {
                if (armyId == GameBoard.PLAYER_ARMY_ID)
                {
                    FindObjectOfType <AdvancementManager>().NewBrokenSword(transform.position);
                }

                m_swordHp    = 0.0f;
                m_isInCombat = false;
                m_tileRemoveCallback(this);
                if ((outcome == AttackOutcome.None) || ((outcome == AttackOutcome.Repair) && other.m_isInCombat))
                {
                    m_assignToTileCallback(other, m_tilePositionX, m_tilePositionY, m_subTilePositionX, m_subTilePositionY);
                    other.m_isMovingToFreePlace = true;
                }
                else if (outcome == AttackOutcome.Death)
                {
                    m_killCallback?.Invoke(other.gameObject);
                }

                if (!(armyId == GameBoard.PLAYER_ARMY_ID && m_armyManager.AskForRepair(this)))
                {
                    m_killCallback?.Invoke(gameObject, false);
                }
                return(true);
            }

            if ((outcome == AttackOutcome.Death) || ((outcome == AttackOutcome.Repair) && !other.m_isInCombat))
            {
                m_isMovingToFreePlace = true;
                m_assignToTileCallback(this, other.m_tilePositionX, other.m_tilePositionY, other.m_subTilePositionX, other.m_subTilePositionY);
                if (outcome == AttackOutcome.Death)
                {
                    m_killCallback?.Invoke(other.gameObject, false);
                }
                m_isInCombat = false;
                pawnDied     = true;
            }
        }
        return(pawnDied);
    }