Beispiel #1
0
    // Update is called once per frame
    public void Update()
    {
        if (AZ == null && distance == 0.0f)
        {
            clone.transform.position = player.transform.position;
            transform.position       = player.transform.position;
            return;
        }


        RaycastHit hit;
        Ray        ray = Camera.main.ScreenPointToRay(Input.mousePosition);

        if (Physics.Raycast(ray, out hit, Mathf.Infinity) && AZ)
        {
            AZ.transform.position = hit.point + new Vector3(0.0f, 6.0f, 0.0f);
        }

        if ((distance == 0.0f || rayon == 0.0f) && AZ)
        {
            if (rayon == 0.0f)
            {
                clone = Instantiate(PS, player.transform.position + new Vector3(0, 1, 0), Quaternion.LookRotation(-hit.point - new Vector3(0, 1, 0) + player.transform.position));
                transform.position = player.transform.position + new Vector3(0, 1, 0);
            }
            else
            {
                clone = Instantiate(PS, player.transform.position, new Quaternion(0, 0, 0, 0));
            }
            audio.clip = sound[Random.Range(0, sound.Length)];
            audio.Play();
            player.GetComponent <MayaSorts>().LastSending[positionInTab] = Time.realtimeSinceStartup;
            StartCoroutine(Execute());
            Destroy(AZ.gameObject);
            return;
        }

        if (Input.GetKeyDown(KeyCode.Escape))
        {
            Destroy(gameObject);
        }
        if (Input.GetMouseButton(0) && AZ)
        {
            clone = Instantiate(PS, hit.point, new Quaternion(0, 0, 0, 0));
            player.GetComponent <MayaSorts>().LastSending[positionInTab] = Time.realtimeSinceStartup;
            transform.position = hit.point;
            audio.clip         = sound[Random.Range(0, sound.Length)];
            audio.Play();
            StartCoroutine(Execute());
            Destroy(AZ.gameObject);
        }
    }
Beispiel #2
0
    void updateAnimator()
    {
        if (attack && !move)
        {
            if (counter != 0)
            {
                counter = System.Math.Max(counter - Time.deltaTime, 0);
            }
            else if (counter == 0)
            {
                Stats mayaStat = maya.GetComponent <Stats>();
                int   damage   = stats.getDamage(mayaStat);
                // Debug.Log(damage);
                GetComponent <AudioSource>().Play();
                mayaStat.hp -= damage;
                if (mayaStat.hp <= 0)
                {
                    attack = false;
                    dead   = true;
                }
                counter = hitRate;
            }
        }
        else
        {
            counter = 0.6f;
        }


        anim.SetInteger("health", health);
        anim.SetBool("isMoving", move);
        anim.SetBool("attack", attack);
        if (attack)
        {
            anim.SetFloat("attackRange", distToMaya);
        }
        else
        {
            anim.SetFloat("attackRange", 1000);
        }
    }