Пример #1
0
    public void PopResult(Scavenging scavenging)
    {
        clearInventorySlot();

        //Force to reload itemfound and log
        nbrItemFound = 0;
        nbrLog       = 0;

        //=============    REMOVE EXEMPLE TEXTE    ===================
        for (int i = 0; i < scavengingLogContent.transform.childCount; i++)
        {
            Destroy(scavengingLogContent.transform.GetChild(i).gameObject);
        }



        //=============    ANIMATION    ================
        healthBar.SetValue(scavenging.oldStatusBar.health);
        hungerBar.SetValue(scavenging.oldStatusBar.hunger);
        thirstBar.SetValue(scavenging.oldStatusBar.thirst);
        energyBar.SetValue(scavenging.oldStatusBar.energy);
    }
Пример #2
0
 public void StartPupUpResult(Scavenging scavenging)
 {
     menuController.OpenMenu(popUpResult.gameObject);
     popUpResult.PopResult(scavenging);
 }
Пример #3
0
    private void LoadGame()
    {
        GameData data = SaveSystem.Load();

        if (data != null)
        {
            PlayerController.IS_FIRST_GAME = data.is_firstGame;
            loaded = data;
            PlayerController.Player.currentStats[(int)StatType.Health] = data.health;
            PlayerController.Player.currentStats[(int)StatType.Hunger] = data.hunger;
            PlayerController.Player.currentStats[(int)StatType.Thirst] = data.thirst;
            PlayerController.Player.currentStats[(int)StatType.Energy] = data.energy;

            UpdateGameClock(data.gameClock);

            foreach (string s in data.consumables)
            {
                Consumable c = Instantiate(Resources.Load("Items/Consumables/" + s) as Consumable);
                if (c != null)
                {
                    InventoryManager.Inventory.AddItem(c);
                }
            }

            for (int i = 0; i < data.equipment.Count; i++)
            {
                Gear g = Instantiate(Resources.Load("Items/Gear/" + data.equipment[i]) as Gear);
                g.liveGear = data.equipementLife[i];
                if (g != null)
                {
                    InventoryManager.Inventory.AddItem(g);
                }
            }

            foreach (string s in data.junks)
            {
                Junk j = Instantiate(Resources.Load("Items/Junks/" + s) as Junk);
                if (j != null)
                {
                    InventoryManager.Inventory.AddItem(j);
                }
            }
            foreach (string s in data.resources)
            {
                Resource r = Instantiate(Resources.Load("Items/Resources/" + s) as Resource);
                if (r != null)
                {
                    InventoryManager.Inventory.AddItem(r);
                }
            }

            for (int i = 0; i < data.equippedGear.Count; i++)
            {
                Gear equipped = Resources.Load("Items/Gear/" + data.equippedGear[i]) as Gear;
                if (equipped != null)
                {
                    Debug.Log(equipped + " is equipped");
                    foreach (Gear g in InventoryManager.Inventory.GetItems(typeof(Gear)))
                    {
                        if (g.IsSameAs(equipped) && g.liveGear == data.equippedGearLife[i])
                        {
                            Debug.Log(g + " is equivalent to " + equipped);
                            PlayerController.Player.EquipGear(g);
                        }
                    }
                }
            }

            Debug.Log("Save loaded!");
            NewGame = false;

            if (data.isSleeping)
            {
                BackgroundTasks.Tasks.IsSleeping    = true;
                BackgroundTasks.Tasks.StartSleeping = GameData.ConvertStringToDateTime(data.sleepingStartTime);
                BackgroundTasks.Tasks.EndSleeping   = GameData.ConvertStringToDateTime(data.sleepingEndTime);
            }

            /*=====    SCAVENGING    =======*/
            if (data.isScavenging)
            {
                BackgroundTasks.Tasks.actualScavengingStep = data.scavengingActualStep;
                BackgroundTasks.Tasks.totalScavengingSteps = data.scavengingTotalSteps;

                Scavenging scavenging = new Scavenging();
                //load itemsfound
                List <(Item item, Item.ItemClass itemClass)> itemsFound = new List <(Item item, Item.ItemClass itemClass)>();
                for (int i = 0; i < data.scavengingItemsFound_itemName.Count; i++)
                {
                    Item.ItemClass itemC = Item.ConvertStringToItemCLass(data.scavengingItemsFound_itemClass[i]);
                    itemsFound.Add((Item.LoadItem(data.scavengingItemsFound_itemName[i], itemC), itemC));
                }

                scavenging.itemsFound   = itemsFound;
                scavenging.scavengeLog  = data.ScavengeLog;
                scavenging.oldStatusBar = (data.scavengingOldStatusBar[0], data.scavengingOldStatusBar[1],
                                           data.scavengingOldStatusBar[2], data.scavengingOldStatusBar[3]);

                BackgroundTasks.Tasks.lastScavenging = scavenging;

                List <DateTime> scavengepalier = new List <DateTime>();
                foreach (var palier in data.scavengingPalier)
                {
                    scavengepalier.Add(GameData.ConvertStringToDateTime(palier));
                }


                if (data.scavengingStartTime != null && data.scavengingEndTime != null)
                {
                    BackgroundTasks.Tasks.StartScavenging = GameData.ConvertStringToDateTime(data.scavengingStartTime);
                    BackgroundTasks.Tasks.EndScavenging   = GameData.ConvertStringToDateTime(data.scavengingEndTime);
                    Debug.Log("After loading : " + BackgroundTasks.Tasks.StartScavenging + " - " + BackgroundTasks.Tasks.EndScavenging);
                }


                BackgroundTasks.Tasks.scavengingPalier = scavengepalier;
                BackgroundTasks.Tasks.IsScavenging     = true;
            }
            else
            {
                BackgroundTasks.Tasks.IsScavenging = false;
            }
            Debug.Log("New State Of IsScavenging because loaddata" + BackgroundTasks.Tasks.IsScavenging);

            /*========    END SCAVENGING    ========*/
        }
        else
        {
            NewGame = true;
        }
    }