//written by Jak
    public void Hide()
    {
        moveModeActive = false;

        //Disable camera rotation
        Camera.main.GetComponent <CamLock>().enabled = false; //This is renabled when the object has stopped moving in update

        playerPossession possessedItem = target.GetComponent <playerPossession>();

        possessedItem.enabled = true; //Enable the item playerPossesion script

        //Disable movement
        possessedItem.GetComponent <playerController>().enabled = false;

        //switch off gravity for the target
        possessedItem.GetComponent <Rigidbody>().constraints    = RigidbodyConstraints.None;
        possessedItem.GetComponent <Rigidbody>().drag           = 0; //set drag to 0 so item falls like a sack of potatoes without affecting gravity
        possessedItem.GetComponent <Rigidbody>().angularDrag    = 0;
        possessedItem.GetComponent <Rigidbody>().useGravity     = true;
        possessedItem.GetComponent <Rigidbody>().freezeRotation = true; //Freeze item rotation while possesed, caused the camera to glitch - Jak - 13/11/17

        possessedItem.GetComponentInChildren <Renderer>().material.SetFloat("_AuraOnOff", 1);
        possessedItem.GetComponentInChildren <Renderer>().material.SetColor("_ASEOutlineColor", Color.black);

        //Camera Pivot setup
        //Create pivot object for camera orbiting - check when rigidbody is grounded, then add - might need to move this to update function
        pivot = new GameObject("Pivot");
        pivot.transform.position = possessedItem.transform.position;
        pivot.transform.rotation = possessedItem.transform.rotation;
        pivot.transform.SetParent(possessedItem.transform);

        //Child camera to pivot point
        Camera.main.transform.SetParent(pivot.transform);

        //Spawn lureSphere
        if (possessedItem.GetComponent <ItemController>().isScaryObject() && !lureSphereCreated)
        {
            Instantiate(lureSphere, possessedItem.transform);
            lureSphereCreated = true;
        }

        //Renable rotation while falling
        Camera.main.GetComponent <CamLock>().enabled = true;
        //End Camera Orbit

        //Change UI
        GameManager.Instance.EnableHideScaryLure(false);
        GameManager.Instance.EnableMoveMode(false);

        if (possessedItem.GetComponent <ItemController>().isScaryObject())
        {
            GameManager.Instance.EnableHideScary(true);
        }
        else
        {
            GameManager.Instance.EnableHideNonScary(true);
        }
        //End UI

        hidden      = true; //set that we are now hidden in an object
        CamPivotSet = true;
    }
Пример #2
0
    // Update is called once per frame
    void Update()
    {
        if (!isPaused)
        {
            Cursor.lockState = CursorLockMode.Locked;
            Cursor.visible   = false;
        }

        if (Input.GetKeyDown(KeyCode.Escape))
        {
            if (!isStoryboardActive)
            {
                Pause();
            }
            else
            {
                menuSkip();
            }
        }
        if (menuSkipBool)
        {
            if (screenDimension != new Vector3(Screen.width / 2, Screen.height / 2))
            {
                screenDimension = new Vector3(Screen.width / 2, Screen.height / 2);
                cursor.GetComponent <RectTransform>().position = new Vector3(screenDimension.x, screenDimension.y, cursor.GetComponent <RectTransform>().position.z);
                if (screenDimension.x > 900)
                {
                    cursor.GetComponent <Text>().fontSize = 25;
                }

                else
                {
                    cursor.GetComponent <Text>().fontSize = 50;
                }
            }
        }

        //timeLeft = timer;
        txt_npcCount.text = NPCcount.ToString();
        //txt_playerHealth.text = player.health.ToString() + "%";

        //Pause the game - kinda
        //if (Input.GetKey(KeyCode.Escape) && !win)
        //{
        //    Time.timeScale = 0; //slow the game to a hault
        //    canvasPause.gameObject.SetActive(true);
        //    Camera.main.GetComponent<CamLock>().enabled = false;
        //    player.gameObject.GetComponent<playerCannonBall>().enabled = false;
        //    player.gameObject.GetComponent<playerPossession>().enabled = false;
        //    player.gameObject.GetComponent<AudioSource>().enabled = false;
        //    player.gameObject.GetComponent<PlayerController>().enabled = false;

        //    AgentController[] agents = GameObject.FindObjectsOfType<AgentController>();

        //    foreach (AgentController agent in agents)
        //        agent.gameObject.GetComponent<script_ProtonBeam_v5>().enabled = false;


        //    paused = true;
        //}

        //Winscreen
        if (NPCcount <= 0)
        {
            NPCcount = 0;
            //    win = true;
            StoryboardOutro.gameObject.SetActive(true);
            Time.timeScale   = 0;
            isPaused         = true;
            Cursor.lockState = CursorLockMode.None;
            Cursor.visible   = true;
            //    player.gameObject.GetComponent<playerCannonBall>().enabled = false;
            //    player.gameObject.GetComponent<playerPossession>().enabled = false;
            //    player.gameObject.GetComponent<AudioSource>().enabled = false;
            gameObject.GetComponentInParent <CharacterController>().enabled = false;
            gameObject.GetComponentInParent <playerController>().enabled    = false;

            //    AgentController[] agents = GameObject.FindObjectsOfType<AgentController>();

            //    foreach (AgentController agent in agents)
            //        agent.gameObject.GetComponent<script_ProtonBeam_v5>().enabled = false;
        }
        //else
        //{
        //    timeLeft = timer - Time.time; //Countdown the timer
        //}

        //Gameover State
        if (!player.IsHidden()) //Might cause core loop issues unsure yet, need this to prevent unreferenced error because i move the camera
        {
            if (player.GetComponent <playerController>().GetEctoplasm <= 0)
            {
                Time.timeScale = 1;

                if (player.IsPossessed())
                {
                    player.PossessedItem.GetComponent <playerPossession>().UnpossessItem();
                }

                GameObject.FindGameObjectWithTag("Player").GetComponent <playerController>().GetEctoplasm = 100;
                GameObject.FindGameObjectWithTag("Player").transform.position = GameObject.Find("respawnPosition").transform.position;
            }
        }
    } //End update