top of page
Search

The Computer - Another Day

  • daibak08
  • May 17, 2021
  • 1 min read

In each day of the game, there is a laptop you use where you check your emails, write your diary and play a mini game. As the programmer, my job was to code this computer and make everything the designers and writers had created into something intractable.


Firstly I created the interact prompt in the days' scene which caused the computer canvas to instantiate as its own Prefabbed GameObject so the day's scene wouldn't be overwritten and technically unloaded. Each canvas for the computer - the desktop, mail, diary and dino minigame - are prefabbed so they can be easily instantiated when the player needs them.


It works like this:





Scripting -


The main script I used to accomplish the goal of moving between different "windows" on the computer, is named buttons.cs and contains different functions I apply to buttons on the onclick() feature.


public void LoadEmail()
    {
        Debug.Log("Loading Emails");
        Instantiate(emailPrefab);
    }

    public void LoadDiary()
    {
        Debug.Log("Loading Diary");
        Instantiate(diaryPrefab);
    }

    public void LoadDino()
    {
        desktop.SetActive(false);
        Instantiate(dinoPrefab);      
    }


    public void ShutDown()
    {
        SCMouseLook = GameObject.Find("MainCamera").GetComponent
        <MouseLook>();
        Debug.Log("Mouse?" + SCMouseLook);
        SCMouseLook.enabled = true;

        Debug.Log("Shutting Down");
        //computer.SetActive(false);
        Cursor.visible = false;
        Cursor.lockState = CursorLockMode.Locked;
        Debug.Log(Time.timeScale);
        Time.timeScale = 1f;                   
        Destroy(GameObject.Find("Computer"));   
    }   

Here you can see I have three load type buttons which instantiate a prefabbed canvas on the players screen and a shutdown function that destroys the desktop/computer and loads back into the overworld.


 
 
 

Comments


bottom of page