예제 #1
0
 public void Execute()
 {
     if (Vector3.Distance(player.position, transform.position) <= m_minDist)
     {
         if (!Jumping)
         {
             Jump();
         }
     }
     else
     {
         movement.Move();
     }
 }
예제 #2
0
    void Update()
    {
        if (playerMov.GhostWalkActivated())
        {
            anim.Play("Idle");
            return;
        }

        if (Vector3.Distance(player.position, transform.position) <= m_distance)
        {
            anim.Play("Attack");
            attack.Execute();
        }
        else
        {
            anim.Play("Run");
            attack.ResetAttack();
            movement.Move();
        }
    }
예제 #3
0
    void FixedUpdate()
    {
        if (playerMov.GhostWalkActivated())
        {
            anim.Play("Idle");
            return;
        }

        m_playerDir = player.transform.position - transform.position;

        if (m_playerDir.magnitude <= m_distance)
        {
            atkStrat.Execute();
        }
        else
        {
            anim.Play("Walk");
            movement.Move();
        }
    }
예제 #4
0
    // Update is called once per frame
    void FixedUpdate()
    {
        if (m_fireBreathParticle.activeSelf)
        {
            m_fireEffTimer += Time.deltaTime;
            if (m_fireEffTimer >= maxEffectTime)
            {
                m_fireBreathParticle.SetActive(false);
                m_fireEffTimer -= maxEffectTime;
            }
        }
        if (!m_CanAttack)
        {
            m_Timer += Time.deltaTime;
            if (m_Timer >= m_IddleTimer)
            {
                m_CanAttack = true;
                m_Timer    -= m_IddleTimer;
            }
            else
            {
                return;
            }
        }

        if (playerMov.GhostWalkActivated())
        {
            anim.Play("idle");
            return;
        }

        float distPlayer = Vector3.Distance(m_player.position, transform.position);

        if (m_CanAttack && distPlayer > m_minDist)
        {
            m_Strategy       = m_FireBallStrategy;
            m_FireBallTimer += Time.deltaTime;
            if (m_FireBallTimer > m_secondsPerFireBall)
            {
                anim.Play("attack");
                m_fireBreathParticle.SetActive(true);
                m_FireBallTimer -= m_secondsPerFireBall;
                m_Strategy.Execute();
                m_CanAttack = false;
            }
            else
            {
                anim.Play("run");
                m_Movement.Move();
                return;
            }
        }
        else if (m_CanAttack && distPlayer <= m_minDist)
        {
            anim.Play("attack");
            m_Strategy = m_MeleeStrategy;
            gameObject.transform.LookAt(m_player);
            m_Strategy.Execute();
            m_CanAttack = false;
        }

        /*OLD STRATEGY
         *
         * float distPlayer = Vector3.Distance(m_player.position, transform.position);
         *
         * if (m_CanAttack && distPlayer > m_minDist)
         * {
         * m_Movement.Move();
         * return;
         * }
         *
         * else if (m_CanAttack && distPlayer <= m_minDist)
         * {
         *
         * int rand = Random.Range(0, 5);
         *      if (rand == 0)
         * {
         *              m_fireBreathParticle.SetActive (false);
         *              m_Strategy = m_FireBallStrategy;
         *      }
         * else
         * {
         *              m_fireBreathParticle.SetActive (true);
         *              m_Strategy = m_MeleeStrategy;
         *      }
         *
         * m_Strategy.Execute();
         * m_CanAttack = false;
         * }
         */
    }