Ejemplo n.º 1
0
    public void Update()
    {
        //Inputmanager
        timeCalculations.TimeCalculationsUpdate();
        t += Time.deltaTime;
        RayCastAndTouchWithSpawnLogic();
        uiController.uiView.lifeTime.text = "Days: " + timeCalculations.lifeTimeDays.ToString() + " Hours: " + timeCalculations.lifeTimeHours.ToString() + " Minutes: " + timeCalculations.lifeTimeMinutes.ToString();

        if (inputManager.objectSpawnHandler.foodList.Count > 0)
        {
            inputManager.objectSpawnHandler.UpdateDestroyFood();
            if (inputManager.objectSpawnHandler.t == 0)
            {
                uiController.uiMath.HungerGains(20);
                player.PlayerGainHungerPoints(20);
                save.SaveGameState(player.GetHungerPoints(), player.GetHappienessPoints(), timeCalculations.GetNowTime());
            }
        }
        if (inputManager.objectSpawnHandler.toyList.Count > 0)
        {
            inputManager.objectSpawnHandler.UpdateDestroyToy();
            if (inputManager.objectSpawnHandler.t == 0)
            {
                uiController.uiMath.HappienessGains(20);
                player.PlayerGainHappienessPoints(20);
                save.SaveGameState(player.GetHungerPoints(), player.GetHappienessPoints(), timeCalculations.GetNowTime());
            }
        }

        //Player stateMachine
        stateMachineManager.StateMachineManagerUpdate(inputManager.objectSpawnHandler.spawnedFood, inputManager.objectSpawnHandler.spawnedToy, inputManager.anchorHandler.visualAnchorClone, t);

        //UI Controller

        //Player And UI Update
        if (timeCalculations.GetNowTime() > timeCalculations.GetTimeRules())
        {
            player.PlayerLossHappienessPoints(1);
            player.PlayerLossHungerPoints(1);
            uiController.uiMath.HappinessLoss(1);
            uiController.uiMath.HungerLoss(1);
            save.SaveGameState(player.GetHungerPoints(), player.GetHappienessPoints(), timeCalculations.GetNowTime());
            timeCalculations.AddTimeToTimeRules();
        }

        uiController.UIControllerUpdate();

        if (player.spawnedPlayer != null && player.spawnedPlayer.transform.position.y < -5)
        {
            player.PlayerLossHappienessPoints(100);
            player.PlayerLossHungerPoints(100);
            uiController.uiMath.HappinessLoss(100);
            uiController.uiMath.HungerLoss(100);
        }
    }