Beispiel #1
0
 void Start()
 {
     spiritQuestionDisplay = GameObject.Find("SpiritUI").GetComponent <SpiritQuestionDisplay>();
     spiritSpawner         = FindObjectOfType <SpiritSpawner>();
     dayCycleController    = GameObject.Find("DayManager").GetComponent <DayCycleController>();
     managePlayerData      = GameObject.Find("PlayerDataManager").GetComponent <ManagePlayerData>();
 }
Beispiel #2
0
    public override void OnStartLocalPlayer()
    {
        base.OnStartLocalPlayer();
        GameObject cameraObj = GameObject.FindGameObjectWithTag("MainCamera");

        cam = cameraObj.GetComponent <Camera>();
        managePlayerData = GameObject.Find("PlayerDataManager").GetComponent <ManagePlayerData>();
    }
Beispiel #3
0
    public void CreateMenu(ManagePlayerData managePlayerData)
    {
        //if menu is already being displayed don't redisplay
        if (displayingMenu)
        {
            return;
        }
        //create Menu
        displayingMenu = true;
        player.GetComponent <FirstPersonAIO>().ControllerPause();
        ///Debug.Log("Creating Menu Now");
        newCanvas = Instantiate(MenuCanvas);
        GameObject  newButton;
        EventSystem eventSystem = EventSystem.current; //get current eventsystem
        //ManagePlayerData managePlayerData = player.GetComponent<ManagePlayerData>();
        //Loop through players Items to check what items they have
        int buttonIndex  = 0;
        int buttonHeight = (int)ingredientButton.GetComponent <RectTransform>().rect.height;

        for (int i = 0; i < numIngredients; i++)
        {
            if (managePlayerData.getIngredientCount(i) > 0) //if the player has at least one of this ingredient make a button for it
            {
                newButton = Instantiate(ingredientButton);
                newButton.transform.SetParent(newCanvas.transform, false);
                //newButton.GetComponent<RectTransform>().position.Set(20, 100 - 30 * buttonIndex, 0);
                newButton.GetComponent <RectTransform>().anchoredPosition = new Vector2(20, 100 - buttonHeight * buttonIndex);
                newButton.GetComponentInChildren <Text>().text            = ((IngredientID)i).ToString();

                //Create new int to store current return value of the button
                int x = new int();
                x = i;
                newButton.GetComponent <Button>().onClick.AddListener(delegate { MenuButtonPressed(x, managePlayerData); });

                if (buttonIndex == 0) //if this is the first button set it as FirstSelected
                {
                    eventSystem.SetSelectedGameObject(newButton);
                }

                buttonIndex++;
            }
        }

        ///Debug.Log("Created Menu");

        // newButton = Instantiate(ingredientButton);
        // newButton.transform.SetParent(newCanvas.transform, false);
        // newButton.GetComponent<RectTransform>().position.Set(20, 100 - 30 * buttonIndex, 0);
        // newButton.GetComponentInChildren<Text>().text = ((IngredientID)0).ToString();

        //GameObject buttonText = newButton.transform.GetChild(0).gameObject;
    }
Beispiel #4
0
    //called on press of menu button
    //removes selected item from the player and adds it to the pot
    void MenuButtonPressed(int index, ManagePlayerData managePlayerData)
    {
        //Debug.Log("Pressed button: " + ((IngredientID)index).ToString());
        managePlayerData.updateIngredients((IngredientID)index, false); //remove item from players inventory
        CookFood cookFood = gameObject.GetComponent <CookFood>();

        cookFood.AddIngredient((IngredientID)index); //add item to pot

        //remove menu and set displaying menu to false
        Destroy(newCanvas);
        displayingMenu = false;
        player.GetComponent <FirstPersonAIO>().ControllerPause();
    }
Beispiel #5
0
    private int numIngredients = 5; //the total number of ingredients in the game

    public void CreateMenu(GameObject player)
    {
        //create Menu
        GameObject       newCanvas = Instantiate(MenuCanvas);
        GameObject       newButton;
        ManagePlayerData managePlayerData = gameObject.GetComponent <ManagePlayerData>();
        //Loop through players Items to check what items they have
        int buttonIndex = 0;

        for (int i = 0; i < numIngredients; i++)
        {
            if (managePlayerData.getIngredientCount(i) > 0) //if the player has at least one of this ingredient make a button for it
            {
                newButton = Instantiate(ingredientButton);
                newButton.transform.SetParent(newCanvas.transform, false);
                newButton.GetComponent <RectTransform>().position.Set(20, 100 - 30 * buttonIndex, 0);
                newButton.GetComponentInChildren <Text>().text = ((IngredientID)i).ToString();
            }
        }
        //GameObject buttonText = newButton.transform.GetChild(0).gameObject;
    }
Beispiel #6
0
    IEnumerator AutoSave()
    {
        yield return(new WaitForSeconds(60));

        //Modify Statistique before autosave.
        TimeSpan dif = -lastStatModif.Subtract(DateTime.UtcNow); //Calculate difference of time between lastautosave and now before modify stat

        lastStatModif = DateTime.UtcNow;

        food    = StatModifier.foodModifier(food, dif);
        clean   = StatModifier.cleanModifier(clean, dif);
        mecanic = StatModifier.mecanicModifier(mecanic, dif);
        mood    = StatModifier.moodModifier(mood, food, mecanic);

        checkAutoSave = false;

        Debug.Log("after : " + food);
        Debug.Log("after : " + mood);
        Debug.Log("after : " + clean);
        Debug.Log("after : " + mecanic);

        ManagePlayerData.AutoSave(mood, food, clean, mecanic);
    }
Beispiel #7
0
 void Start()
 {
     managePlayerData = GameObject.Find("PlayerDataManager").GetComponent <ManagePlayerData>();
 }