Пример #1
0
    private void OnCollisionStay(Collision collision)
    {
        // Get companion from collision event.
        GameObject collidedComp = collision.gameObject;

        if (collidedComp.transform.childCount > 0 &&
            controller.isCompanion(collidedComp.transform.GetChild(0).gameObject) &&
            collidedComp.transform.GetChild(0).FindChild("Player") == null)
        {
            GameObject child = collidedComp.transform.GetChild(0).gameObject;
            anim = GameObject.Find("Player").GetComponentInParent <Animation>();
            anim.Play(Animations.ATTACK_1);
            AnimationState attack = anim[Animations.ATTACK_1];
            attack.wrapMode = WrapMode.Once;
            // Idle 1
            // anim.CrossFadeQueued(Animations.IDLE_1);
            //Debug.Log(attack.time == attack.length);
            //Debug.Log(attack.time);
            //Debug.Log(attack.length);
            //if (attack.time == attack.length)
            //{

            if (Time.time > (startAttackTime + attack.length))
            {
                model.setCanvas(child.tag);
                int collidedData = model.getCompanion().health;
                model.setHealth(collidedData - 2);
                view.updateHealthBar(collidedComp);
                startAttackTime = Time.time;
            }
        }
    }
Пример #2
0
    public void Attack()
    {
        if (this.isCompanion(selectComp))
        {
            Rigidbody rbSelected = selectComp.transform.parent.GetComponent <Rigidbody>();
            Rigidbody rbPlayer   = GameObject.Find("Player").transform.parent.parent.GetComponent <Rigidbody>();
            rbSelected.isKinematic = false;
            rbPlayer.isKinematic   = false;
            anim.Play(Animations.WALK);
            anim[Animations.WALK].wrapMode = WrapMode.Loop;
            Debug.Log(GameObject.Find("Player").transform.parent.gameObject.tag);
            model.setCanvas(GameObject.Find("Player").transform.parent.gameObject.tag);
            model.setWalk(true);

            // Idle 1
            //anim.CrossFadeQueued(Animations.IDLE_1);
        }
    }