Ejemplo n.º 1
0
    // Update is called once per frame
    void Update()
    {
        if (characterProperty.isDead)
        {
            anim.CrossFade(die.name);
            if (anim [die.name].time > anim [die.name].length * 0.95)
            {
                anim.enabled = false;
            }
        }

        if (opponent != null)
        {
            if (Input.GetMouseButton(1) && opponent.tag == "Enemy" && InRange(characterProperty.attackRange) && clickToMove.lockTo.tag == "Enemy")
            {
                //Attacking
                clickToMove.state = "attacking";
                anim.CrossFade(attack.name);
                transform.LookAt(opponent.transform);
                if (anim [attack.name].time <= 0.2f)
                {
                    impacted = false;
                }
                if ((anim [attack.name].time > anim [attack.name].length * impactTime) && (impacted == false))
                {
                    //opponent.GetComponent<CharacterProperty> ().damaged (gameObject.GetComponent<CharacterProperty>().attackDmg);
                    characterProperty.Attack(opponent);
                    impacted = true;
                }
            }
        }
    }