Ejemplo n.º 1
0
 void OnTriggerEnter(Collider col)
 {
     if (col.tag == "Door")
     {
         Debug.Log("Enemy Open Door");
         DoorBehaviour doorScript = col.GetComponent <DoorBehaviour>();
         doorScript.interactDoor();
     }
 }
Ejemplo n.º 2
0
    //Set Animation Flags
    void AnimationControl()
    {
        //TESTE------------------------------------------------------------
        if (Input.GetKeyDown(KeyCode.H))
        {
            Alarm alarm_script = GameObject.Find("Alarm").GetComponent <Alarm>();
            if (!alarm_script.alarmOn)
            {
                alarm_script.StartAlarm();
            }
            else
            {
                alarm_script.StopAlarm();
            }
        }
        //------------------------------------------------------------
        //Open Door
        if (onDoor && Input.GetKeyDown(KeyCode.F))
        {
            if (targetDoor.tag == "Door")
            {
                DoorBehaviour doorScript = targetDoor.GetComponent <DoorBehaviour>();
                doorScript.interactDoor();
                onDoor = false;
            }

            if (targetDoor.tag == "DoorTimer")
            {
                DoorBehaviour script;
                GameObject    parent;
                parent = targetDoorButton.transform.parent.gameObject;
                script = parent.transform.Find("Door").GetComponent <DoorBehaviour>();
                script.openDoor();
            }
        }
        if (onButton && Input.GetKeyDown(KeyCode.F))
        {
            DoorBehaviour script;
            GameObject    parent;
            // Debug.Log(targetDoorButton.name);
            parent = targetDoorButton.transform.parent.gameObject;
            Debug.Log(parent.name);

            script = parent.transform.Find("Door").GetComponent <DoorBehaviour>();

            script.pressButton();
        }
        //Get Watch
        if (onWatch && Input.GetKeyDown(KeyCode.F))
        {
            GameObject watch = GameObject.FindGameObjectWithTag("Watch");
            Destroy(watch);
            onWatch = false;
            GameObject cont   = GameObject.Find("GameController");
            Controller script = cont.GetComponent <Controller>();
            script.pickSatellite();
            hasSatellite = true;
        }

        //Running Jump
        //if (controller.isGrounded)
        //{
        //    if (Input.GetKey(KeyCode.W) && Input.GetKey(KeyCode.LeftShift) && Input.GetKeyDown(KeyCode.Space))
        //    {
        //        anim.SetTrigger("isRunningJump");
        //        translation.y = 1000;
        //        //Debug.Log("Jumped");
        //    }
        //}
        //else if (!controller.isGrounded)
        //{
        //    //Debug.Log("Not on Ground");
        //}

        //Crouch
        if (Input.GetKeyDown(KeyCode.LeftControl))
        {
            // controller.height = 7;
            //controller.center = crouchCapsuleCenter;
            anim.SetBool("isCrouching", true);
            anim.SetBool("isCrouch", true);
        }
        else if (Input.GetKeyUp(KeyCode.LeftControl))
        {
            controller.height = 12.5f;
            //controller.center = capsuleCenter;
            anim.SetBool("isCrouchWalking", false);
            anim.SetBool("isCrouching", false);
            anim.SetBool("isCrouch", false);
        }

        //Crouch Walking
        if (Input.GetKey(KeyCode.W) && Input.GetKey(KeyCode.LeftControl))
        {
            anim.SetBool("isCrouchWalking", true);
        }
        else if (Input.GetKey(KeyCode.W) && Input.GetKeyUp(KeyCode.LeftControl))
        {
            anim.SetBool("isCrouchWalking", false);
            anim.SetBool("isCrouching", false);
            anim.SetBool("isCrouch", false);
        }
        else if (Input.GetKeyUp(KeyCode.W) && Input.GetKey(KeyCode.LeftControl))
        {
            anim.SetBool("isCrouchWalking", false);
            anim.SetBool("isCrouching", false);
            anim.SetBool("isCrouch", true);
        }

        //Walk
        if (translation.z != 0 && Input.GetKey(KeyCode.W))
        {
            if (footsteps1_pressed)
            {
                footsteps1.Play();
                footsteps1_pressed = false;
            }

            anim.SetBool("isWalking", true);
            speed = speedWalk;
        }
        else
        {
            footsteps1.Stop();
            footsteps1_pressed = true;


            anim.SetBool("isWalking", false);
        }

        //Run
        if (translation.z != 0 && Input.GetKey(KeyCode.W) && Input.GetKey(KeyCode.LeftShift))
        {
            if (footsteps_run1_pressed)
            {
                // footsteps1.clip = footsteps_run1_clip;
                footsteps1.Pause();
                footsteps_run1.Play();
                footsteps_run1_pressed = false;
            }
            anim.SetBool("isRunning", true);
            speed = speedRun;
        }
        else
        {
            footsteps_run1.Stop();
            footsteps1.UnPause();
            footsteps_run1_pressed = true;
            anim.SetBool("isRunning", false);
        }
    }