Esempio n. 1
0
    private void Update()
    {
        Vector3 originpos = transform.position + Vector3.up * 0.2f;

        Debug.DrawRay(originpos, Vector3.forward * 3, Color.red);
        if (Physics.Raycast(originpos, transform.forward, out hit, 3))
        {
            if (hit.collider.tag == "Interactable")
            {
                if (Input.GetKeyDown(KeyCode.E))
                {
                    print("interact");
                    TriggerEventScript tEvent = hit.collider.GetComponent <TriggerEventScript>();
                    tEvent.CallEvent();
                }
            }
        }

        //gain Stam
        if (gainStam == true && curStam <= maxStam)
        {
            curStam = curStam += regenStam * Time.deltaTime;

            if (curStam > maxStam)
            {
                curStam = maxStam;
            }
        }

        //drain Stam
        if (curStam >= 0 && Input.GetKey(KeyCode.LeftShift))
        {
            curStam = curStam -= drainStam * Time.deltaTime;
        }
    }
Esempio n. 2
0
/*
    private void OnDrawGizmos()
    {
        if (Physics.Raycast(transform.position * 1.0f, transform.TransformDirection(Vector3.forward), out hit, 3))
        {
            Gizmos.color = Color.green;
            Gizmos.DrawLine(transform.position * 1.0f, transform.TransformDirection(Vector3.forward));
            //it works but wrong
        }
    }
*/
    private void Update()
    {
       
        //Testing preparation for sit animation
        if (Input.GetKeyDown(KeyCode.T))
        {
            //BeginToSit();
            sitting = true;
        }
        

       /* else if (this.InMyState)
        {
            this.InMyState = false;
            // You have just leaved your state!
        }*/
        if (Physics.Raycast(transform.position * 1.0f, transform.TransformDirection(Vector3.forward), out hit, 3))
        {
            if (hit.collider.tag == "Interactable")
            { 
                if (anim.GetBool("moving") == false)
                { 
                    if (Input.GetKeyDown(KeyCode.E) || Input.GetKeyDown("joystick button 2"))//"X" Button
                    {
                        if (hit.collider == sitCollider)
                        {
                            LightMatchScript match = GameObject.Find("Player").GetComponent<LightMatchScript>();

                            if (match.isLit == true)
                            {
                                match.isLit = false;
                                StartCoroutine(DelayCheck());
                            }
                            GameObject GameManager = GameObject.Find("GameManager");
                            GameObject PuzzleChurch = GameManager.transform.Find("Puzzle Church").gameObject;
                            GameObject ChurchLight = PuzzleChurch.transform.Find("ChurchLight").gameObject;

                            if (ChurchLight.activeSelf)
                            {
                                transform.Rotate(0, rotation, 0);
                                anim.Play("Sit");
                            }
                        }
                            if (!this.anim.GetCurrentAnimatorStateInfo(0).IsName("Sit"))
                            {
                                TriggerEventScript tEvent = hit.collider.GetComponent<TriggerEventScript>();
                                tEvent.CallEvent();

                                anim.Play("Idle");
                            }
                    }
                }
            }
        }

        if (Input.GetKey("left shift") && SpntPan.GetComponent<CanvasGroup>().alpha == 1
            || Input.GetKey("joystick button 0") && SpntPan.GetComponent<CanvasGroup>().alpha == 1)//***Tianna!!*** "A" Button
        {
            //Sprint TUT
            SpntPan.GetComponent<CanvasGroup>().alpha = 0;//***Tianna!!***
        }
    }