Beispiel #1
0
        protected override void Enter(TrueDummyEnemy.DummyEnemyInputs input)
        {
            base.Enter(input);

            if (input != TrueDummyEnemy.DummyEnemyInputs.PETRIFIED)
            {
                anim.SetBool("Attack", true);
                combatDirector.RemoveToAttack(enemy, enemy.CurrentTarget());
            }
        }
        protected override void Update()
        {
            base.Update();

            if (enemy.CurrentTarget() != null)
            {
                Vector3 myForward       = (enemy.CurrentTarget().transform.position - root.position).normalized;
                Vector3 forwardRotation = new Vector3(myForward.x, 0, myForward.z);

                root.forward = Vector3.Lerp(root.forward, forwardRotation, rotationSpeed * Time.deltaTime);

                if (IsAttack())
                {
                    sm.SendInput(TrueDummyEnemy.DummyEnemyInputs.BEGIN_ATTACK);
                }
                else
                {
                    if (enemy.IsInPos())
                    {
                        Vector3 pos1 = new Vector3(root.position.x, 0, root.position.z);
                        Vector3 pos2 = new Vector3(enemy.CurrentTarget().transform.position.x, 0, enemy.CurrentTarget().transform.position.z);
                        Vector3 pos3 = new Vector3(enemy.CurrentTargetPos().position.x, 0, enemy.CurrentTargetPos().position.z);

                        if (Vector3.Distance(pos1, pos2) >= distanceMin && Vector3.Distance(pos1, pos3) >= 1)
                        {
                            combatDirector.GetNewNearPos(enemy);
                            sm.SendInput(TrueDummyEnemy.DummyEnemyInputs.GO_TO_POS);
                        }
                    }
                    else
                    {
                        Vector3 pos1 = new Vector3(root.position.x, 0, root.position.z);
                        Vector3 pos2 = new Vector3(enemy.CurrentTarget().transform.position.x, 0, enemy.CurrentTarget().transform.position.z);

                        if (Vector3.Distance(pos1, pos2) >= distanceMax)
                        {
                            sm.SendInput(TrueDummyEnemy.DummyEnemyInputs.GO_TO_POS);
                        }
                    }
                }
            }
        }
        protected override void Update()
        {
            base.Update();

            timer += Time.deltaTime;

            if (timer >= cd)
            {
                sm.SendInput(TrueDummyEnemy.DummyEnemyInputs.IDLE);
                combatDirector.AddToAttack(enemy, enemy.CurrentTarget());
            }
        }
Beispiel #4
0
        protected override void Exit(TrueDummyEnemy.DummyEnemyInputs input)
        {
            base.Exit(input);

            if (input != TrueDummyEnemy.DummyEnemyInputs.PETRIFIED)
            {
                timer = 0;
                anim.SetBool("Attack", false);
                var myEnemy = (EnemyBase)enemy;
                myEnemy.attacking = false;
                combatDirector.AddToAttack(enemy, enemy.CurrentTarget());
            }
        }