Пример #1
0
    public void Shooted(Vector3 velocity)
    {
        GetComponent <Rigidbody>().isKinematic = false;
        GetComponent <Rigidbody>().velocity    = velocity;
        ePlayerInputMode = EPlayerInputMode.FREEMOVE;

        OnHideUIButton();
    }
Пример #2
0
    private void Start()
    {
        lastPosition = this.transform.position;


        m_rb             = GetComponent <Rigidbody>();
        collidedCannon   = false;
        ePlayerInputMode = EPlayerInputMode.FREEMOVE;
        anim             = GetComponent <Animator>();
    }
Пример #3
0
    private void OnTriggerEnter(Collider other)
    {
        if (other.CompareTag("Axe"))
        {
            OnPlaySound(4, 1);
            Restart();
        }

        else if (other.CompareTag("Hinge") && currentHinge == null)
        {
            currentHinge     = other.gameObject;
            ePlayerInputMode = EPlayerInputMode.INHINGE;
            anim.SetBool("Running", false);
            anim.SetBool("Attacking", false);
            anim.SetInteger("Condition", 0);
            gameObject.AddComponent <HingeJoint>();

            //GetComponent<Rigidbody>().useGravity = false;
            GetComponent <HingeJoint>().connectedBody = other.GetComponent <Rigidbody>();
        }
    }
Пример #4
0
    void GetInput()
    {
        if (ePlayerInputMode == EPlayerInputMode.FREEMOVE)
        {
            if (Input.GetMouseButtonDown(0))
            {
                if (anim.GetBool("Running"))
                {
                    anim.SetBool("Running", false);
                    anim.SetInteger("Condition", 0);
                }

                if (!anim.GetBool("Running"))
                {
                    Attacking();
                }
            }
        }

        if (ePlayerInputMode == EPlayerInputMode.INHINGE)
        {
            if (Input.GetKey(KeyCode.W))
            {
                GetComponent <Rigidbody>().velocity += transform.forward * .5f;
            }

            if (Input.GetKey(KeyCode.S))
            {
                GetComponent <Rigidbody>().velocity += transform.forward * -.5f;
            }

            if (Input.GetKey(KeyCode.E))
            {
                currentHinge = null;
                Destroy(GetComponent <HingeJoint>());
                ePlayerInputMode = EPlayerInputMode.FREEMOVE;
                //GetComponent<Rigidbody>().AddForce(GetComponent<Rigidbody>().velocity * .02f, ForceMode.Impulse);
            }
        }
    }
Пример #5
0
 public void Restart()
 {
     this.transform.position = lastPosition;
     ePlayerInputMode        = EPlayerInputMode.FREEMOVE;
     OnHideUIButton();
 }
Пример #6
0
    private void OnTriggerStay(Collider other)
    {
        if (other.CompareTag("Cannon"))
        {
            if (ePlayerInputMode == EPlayerInputMode.CANNON)
            {
                if (OnShowUIButton != null)
                {
                    OnShowUIButton(EUIButton.Q);
                }
            }

            else if (ePlayerInputMode == EPlayerInputMode.FREEMOVE)
            {
                if (OnShowUIButton != null)
                {
                    OnShowUIButton(EUIButton.E);
                }
            }

            if (Input.GetKeyDown(KeyCode.E) && collidedCannon)
            {
                anim.SetBool("Running", false);
                anim.SetBool("Attacking", false);
                anim.SetInteger("Condition", 0);

                ePlayerInputMode = EPlayerInputMode.CANNON;
                other.GetComponent <CCannonBehaviour>().enabled = true;
                cannonNormalCamera.SetActive(true);
                playerNormalCamera.SetActive(false);
            }

            else if (Input.GetKeyDown(KeyCode.Q) && collidedCannon)
            {
                playerNormalCamera.SetActive(true);
                cannonNormalCamera.SetActive(false);
                other.GetComponent <CCannonBehaviour>().enabled = false;
                ePlayerInputMode = EPlayerInputMode.FREEMOVE;
            }
        }

        else if (other.CompareTag("ImpulseCannon"))
        {
            if (ePlayerInputMode == EPlayerInputMode.INCANNON)
            {
                if (OnShowUIButton != null)
                {
                    OnShowUIButton(EUIButton.Q);
                }
            }

            else if (ePlayerInputMode == EPlayerInputMode.FREEMOVE)
            {
                if (OnShowUIButton != null)
                {
                    OnShowUIButton(EUIButton.E);
                }
            }

            if (Input.GetKeyDown(KeyCode.E) && collidedCannon)
            {
                transform.position = other.gameObject.transform.GetChild(0).transform.position;
                GetComponent <Rigidbody>().isKinematic = true;

                anim.SetBool("Running", false);
                anim.SetBool("Attacking", false);
                anim.SetInteger("Condition", 0);

                ePlayerInputMode = EPlayerInputMode.INCANNON;
                other.GetComponent <CCannonImpulseBehaviour>().enabled = true;
                impulseCannonCamera.SetActive(true);
                playerNormalCamera.SetActive(false);
            }

            else if (Input.GetKeyDown(KeyCode.Q) && collidedCannon)
            {
                playerNormalCamera.SetActive(true);
                impulseCannonCamera.SetActive(false);
                other.GetComponent <CCannonImpulseBehaviour>().enabled = false;
                ePlayerInputMode = EPlayerInputMode.FREEMOVE;
            }
        }

        else if (other.CompareTag("Treasure") && Input.GetKeyDown(KeyCode.E))
        {
            other.GetComponent <CTreasureBehaviour>().Open();
        }
    }