Пример #1
0
    public void ChangeState(CharacterState characterState)
    {
        state = characterState;
        movement.AnimateMove(Vector3.zero, state);

        // Do Some Behaviuor
        StartCoroutine(InvicibleTouch());
    }
Пример #2
0
    private void Update()
    {
        if (state == CharacterState.death)
        {
            agent.Stop();
            movement.AnimateDeath();
            return;
        }

        if (state == CharacterState.bomb)
        {
            FindShortestTarget();
            agent.SetDestination(target.position);
        }
        else if (currBomber)
        {
            RaycastHit2D[] hits;

            Vector3 dir = Vector3.zero;
            // Vector3 dest = this.transform.position + dir.normalized;
            Vector3 dest      = this.transform.position;
            float   randValue = Random.value;
            if (randValue < 0.6f)
            {
                dir = (this.transform.position - currBomber.transform.position);
            }
            else
            {
                dir.x += -currBomber.transform.position.x;
                dir.y += -currBomber.transform.position.y;
            }

            foreach (string tag in targetTags)
            {
                foreach (GameObject obj in GameObject.FindGameObjectsWithTag(tag))
                {
                    if (obj.transform.position != currBomber.transform.position)
                    {
                        float dist       = Vector3.Distance(this.transform.position, obj.transform.position);
                        float distToBomb = Vector3.Distance(currBomber.transform.position, obj.transform.position);
                        if (dist < 5 && dist < distToBomb)
                        {
                            dir += (transform.position - obj.transform.position);
                        }
                    }
                }
            }

            dest = dir;
            Debug.DrawLine(transform.position, dest, Color.blue, 2.5f);
            Debug.DrawLine(transform.position, currBomber.transform.position, Color.red, 2.5f);

            agent.SetDestination(dest);
        }

        movement.AnimateMove(agent.velocity, state);
        bombBehavior.Run(-Time.deltaTime, ref state);
    }
Пример #3
0
 void Update()
 {
     if (target && agent)
     {
         // Update Target Position and Animate Move
         agent.SetDestination(target.position);
         movement.AnimateMove(agent.velocity);
     }
 }