Beispiel #1
0
    // Update is called once per frame
    void Update()
    {
        GameObject      player;
        Timer           t  = new Timer();
        SwitchCharacter sc = new SwitchCharacter();

        if (t.Team() == 0)
        {
            int i = sc.character();
            player = characters[i];
            AttackTeamA(player);
        }
        else if (t.Team() == 1)
        {
            int i = sc.defender();
            player = charactersB[i];
            AttackTeamB(player);
        }
    }
Beispiel #2
0
    // Update is called once per frame
    void Update()
    {
        //ChangePosition();
        SwitchCharacter sc = new SwitchCharacter();
        int             i  = sc.character();

        player = characters[i];
        float Ed = Vector3.Distance(transform.position, player.transform.position);

        //Debug.Log(Ed);
        //SetPosition();

        /*if(agent.enabled == true && agent.remainingDistance < remainingDistance)
         * {
         *  agent.enabled = true;
         *  anim.SetInteger("speed", 0);
         *  anim.SetBool("isWalking", false);
         * // StartCoroutine(RandomMovementtoWayPoint());
         *  //Debug.Log("Arrived ...");
         * }*/

        //Debug.Log(Vector3.Distance(transform.position, player.transform.position));

        /*if(Vector3.Distance(transform.position, player.transform.position) < alertDistance)
         * {
         *  if (Vector3.Distance(transform.position, player.transform.position) <= agent.stoppingDistance)
         *  {
         *      FaceTarget();
         *      anim.SetBool("isProning", true);
         *      anim.SetInteger("speed", 1);
         *  }
         *  //agent.enabled = false;
         * // Dodge();
         * }*/

        if (Vector3.Distance(transform.position, player.transform.position) <= attackingDistance)// && Vector3.Distance(transform.position, player.transform.position) >= alertDistance)
        {
            //Debug.Log("In Red Circle "+ Vector3.Distance(transform.position, player.transform.position));
            agent.enabled = true;
            agent.SetDestination(player.transform.position);
            FaceTarget();
            if (Vector3.Distance(transform.position, player.transform.position) <= 1.7f)//stoppingDistance)
            {
                //Debug.Log("Less Than Rem Dist : "+ Vector3.Distance(transform.position, player.transform.position));
                FaceTarget();
                anim.SetBool("isWalking", false);
                anim.SetBool("GrabLegs", false);
                anim.SetBool("isProning", true);
                anim.SetInteger("speed", 1);
                anim.Play("Prone Idle");
            }
            //Debug.Log("Attacking");
            //agent.enabled = false;
            //Vector3 targetDir = player.transform.position - transform.position;
            //float angle = Vector3.Angle(targetDir, transform.forward);
            //Debug.Log(angle);
            //if (angle < attackAngle)
            //{
            //

            Attack();
            //}
        }
        // Idle
        else if (Vector3.Distance(transform.position, player.transform.position) > attackingDistance)
        {
            //Debug.Log("Outside circle " + Vector3.Distance(transform.position, player.transform.position));
            anim.SetInteger("speed", 0);
            anim.SetBool("isWalking", false);
            anim.SetBool("GrabLegs", false);
            anim.SetBool("isWalkingBack", false);
            anim.SetBool("isAttacking", false);
            anim.SetBool("isDodging", false);
            StartCoroutine(RandomMovementtoWayPoint());
        }

        /*else
         * {
         *  agent.enabled = true;
         *  Move();
         *  if(Vector3.Distance(transform.position, player.transform.position) <= attackingDistance)
         *  {
         *      agent.enabled = false;
         *      anim.SetBool("isWalking", false);
         *      anim.SetInteger("speed", 0);
         *      Attack();
         *      anim.SetBool("isWalking", false);
         *  }
         * }*/

        if (attacked == true)
        {
            agent.enabled = true;
            agent.SetDestination(player.transform.position);
        }
    }