コード例 #1
0
    // Author: Kyle Weekley, Ben Stern
    /// <summary>
    /// Called before Start to handle singleton setup
    /// </summary>
    private void Awake()
    {
        if (_instance != null && _instance != this)
        {
            Destroy(gameObject);
            return;
        }
        _instance = this;
        DontDestroyOnLoad(gameObject);
        //because cafeteria manager is not destroyed when new scenes are loaded we need to reget certain elements when entering a new scene
        SceneManager.sceneLoaded += OnSceneLoaded;

        OnSceneLoaded(SceneManager.GetActiveScene(), LoadSceneMode.Single);
    }
コード例 #2
0
 /// <summary>
 /// Author: John Vance
 /// Purpose: Changes where the selected object code runs
 /// </summary>
 /// <param name="scene"></param>
 /// <param name="mode"></param>
 void OnSceneLoaded(Scene scene, LoadSceneMode mode)
 {
     if (scene.name == "Kitchen" || scene.name == "130_Kitchen")
     {
         kitchenManager = GameObject.Find("Game Manager").GetComponent <KitchenManager>();
     }
     if (scene.name == "Cafeteria" || scene.name == "130_Cafeteria")
     {
         cafeteriaManager = GameObject.Find("CafeteriaManager").GetComponent <CafeteriaManager>();
     }
     if (GameObject.Find("Selection Sprite"))
     {
         selectionIcon = GameObject.Find("Selection Sprite").GetComponent <Image>();
     }
 }
コード例 #3
0
    // Author: Trenton Plager, Kyle Weekley
    /// <summary>
    /// Purpose: Updates the cookbook display to the current recipe index (which should be 0)
    /// Obtains reference to CafeteriaManager to inform the specials and orders lists
    /// Restrictions: None
    /// </summary>
    void Start()
    {
        // The cookbook needs to find the CafeteriaManager, which may not exist based on scenes entered
        GameObject CafeteriaManagerObject = GameObject.Find("CafeteriaManager");

        // If the CafeteriaManager does exist, grab the script from it
        // Then set up the specials and orders info
        if (CafeteriaManagerObject)
        {
            cafeteriaManager = CafeteriaManagerObject.GetComponent <CafeteriaManager>();
            specials         = new List <string>(cafeteriaManager.Specials.Keys);
            orders           = cafeteriaManager.Orders;
        }

        UpdateCookbookDisplay();
    }
コード例 #4
0
    // Start is called before the first frame update
    void Start()
    {
        // Initialized the dialogueLines list
        dialogueLines = new List <string>();
        // Populated the list with some possible lines
        dialogueLines.Add("Man, it smells so good in here compared to outside.");
        dialogueLines.Add("Ooh, this is gonna be good!");
        dialogueLines.Add("Can't really find much good food out there.");

        // Get reference to GameManager (Kyle: Added single .find here since guests are now being instantiated at runtime)
        gameManager = GameObject.Find("CafeteriaManager");

        // Quick reference to the cafeteria manager script
        cafeteriaManager = gameManager.GetComponent <CafeteriaManager>();

        // If an order hasn't already been specified, pick a random order from the available specials when they are initally created
        if (orderKeyRequested == null)
        {
            PickOrder();
        }

        // Give the guest a unique dialogue line when they are initally created
        uniqueGreetingLine = GetRandomDialogueLine();
    }