コード例 #1
0
        public void Update()
        {
            if (target != null)
            {
                float dist = (transform.position - target.transform.position).sqrMagnitude;
                if (dist < meleeDistance)
                {
                    CanMove = false;
                    anim.SetFloat("Speed", 0);
                }
                else
                {
                    CanMove = true;
                }
                switch (currentState)
                {
                case TurrateState.Follow:
                    break;

                case TurrateState.Attack:
                    if (CanMove)
                    {
                        skills.AttackDown();
                    }
                    else
                    {
                        skills.AltAttackDown();
                    }
                    break;
                }
            }
            // stop moving when in melee distance
        }
コード例 #2
0
        public void Update()
        {
            if (playerController != null)
            {
                if (playerController.AttackButtonDown)
                {
                    skills.AttackDown();
                }
                if (playerController.AttackButtonUp)
                {
                    skills.AttackUp();
                }
                if (playerController.AltAttackButtonDown)
                {
                    skills.AltAttackDown();
                }
                if (playerController.AltAttackButtonUp)
                {
                    skills.AltAttackUp();
                }
                if (playerController.SkillOneButtonDown)
                {
                    skills.SkillOneDown();
                }
                if (playerController.SkillOneButtonUp)
                {
                    skills.SkillOneUp();
                }
                if (playerController.SkillTwoButtonDown)
                {
                    skills.SkillTwoDown();
                }
                if (playerController.SkillTwoButtonUp)
                {
                    skills.SkillTwoUp();
                }
                if (playerController.SkillThreeButtonDown)
                {
                    skills.SkillThreeDown();
                }
                if (playerController.SkillThreeButtonUp)
                {
                    skills.SkillThreeUp();
                }
                if (playerController.SkillFourButtonDown)
                {
                    skills.SkillFourDown();
                }
                if (playerController.SkillFourButtonUp)
                {
                    skills.SkillFourUp();
                }
            }

            Vector3 viewPos = Camera.main.WorldToViewportPoint(transform.position);

            viewPos.x = Mathf.Clamp01(viewPos.x);
            viewPos.y = Mathf.Clamp(viewPos.y, 0, .9f);
            Vector3 pos = Camera.main.ViewportToWorldPoint(viewPos);

            pos.y = 0;
            transform.position = pos;
        }