示例#1
0
    // Update is called once per frame
    void Update()
    {
        m_Lifetime -= Time.deltaTime;
        if (m_Lifetime <= 0f)
        {
            ReviveSpawns revival = GetComponent <ReviveSpawns>();
            if (revival && GameController.sReviveSpawns.ContainsKey(revival.mObjectId))
            {
                GameController.sReviveSpawns.Remove(revival.mObjectId);
            }

            Destroy(gameObject);
        }
    }
    public void OnAnimationEnd()
    {
        if (mOurState == ReviveMonsterState.eMonsterStateReviving)
        {
            float        distanceTo = 0f;
            ReviveSpawns closest    = GameController.GetClosestReviveSpawn(transform.position, ref distanceTo);
            if (!closest)
            {
                return;
            }
            closest.SpawnRevive();

            m_BrainActive = true;
        }
    }
    public void UpdateRevive()
    {
        float        distanceTo = 0f;
        ReviveSpawns closest    = GameController.GetClosestReviveSpawn(transform.position, ref distanceTo);

        if (!closest)
        {
            mOurState = ReviveMonsterState.eMonsterStateAttacking;
            return;
        }

        if (distanceTo <= m_ReviveMonsterDistance)
        {
            OnReviveStart();
        }
    }
    public override void UpdateDesiredMovePoint()
    {
        float        distanceTo = 0f;
        ReviveSpawns closest    = GameController.GetClosestReviveSpawn(transform.position, ref distanceTo);

        if (closest)
        {
            Vector3 dir        = Vector3.Normalize(transform.position - closest.transform.position);
            Vector3 desiredPos = (closest.transform.position) + (m_MonsterAttackDistance * dir);
            m_DesiredMovePosition = desiredPos;
            mOurState             = ReviveMonsterState.eMonsterStateReviving;
            return;
        }

        mOurState = ReviveMonsterState.eMonsterStateAttacking;

        base.UpdateDesiredMovePoint();
    }