public void EquipItem()
    {
        ClearWaitingForInputOnButtons();
        switch (hackerOrRunner)
        {
        case Item.HackerRunner.Runner:
            Loadout runnerLoadout = FindObjectOfType <PlayerData>().GetCurrentRunner().GetLoadout();

            if (selectedItem.GetItemType() == Item.ItemTypes.Arm || selectedItem.GetItemType() == Item.ItemTypes.Leg)
            {
                // Do we have an arm or leg slot selected? If so, equip to that one
                foreach (LoadoutSlotBtn loadoutSlot in runnerLoadoutSlotBtns)
                {
                    if (loadoutSlot.GetItemType() == selectedItem.GetItemType() && loadoutSlot.GetIsActive())
                    {
                        hubWorldSFX.PlayHubSoundEffect(HubWorldSFX.HubSoundeffect.EquipItem);
                        runnerLoadout.EquipItem(selectedItem as RunnerMod, loadoutSlot.GetLeftOrRight());
                        recentlyEquippedItem = true;
                    }
                }
                if (recentlyEquippedItem == false)
                {
                    // get and activate the appropriate buttons
                    foreach (LoadoutSlotBtn loadoutSlot in runnerLoadoutSlotBtns)
                    {
                        if (loadoutSlot.GetItemType() == selectedItem.GetItemType())
                        {
                            loadoutSlot.SetButtonToAskForInput();
                        }
                    }
                    waitingToEquip = true;
                    DisableAllOtherInputs();
                    // TODO: DISABLE OTHER INPUTS SOMEHOW
                }
            }
            else
            {
                hubWorldSFX.PlayHubSoundEffect(HubWorldSFX.HubSoundeffect.EquipItem);
                runnerLoadout.EquipItem(selectedItem as RunnerMod);
                recentlyEquippedItem = true;
            }
            break;

        case Item.HackerRunner.Hacker:
            HackerLoadout hackerLoadout = FindObjectOfType <PlayerData>().GetCurrentHacker().GetHackerLoadout();

            if (selectedItem.IsHackerMod())
            {
                hubWorldSFX.PlayHubSoundEffect(HubWorldSFX.HubSoundeffect.EquipItem);
                hackerLoadout.EquipItem(selectedItem as HackerMod);
                recentlyEquippedItem = true;
                SetupActiveHackerSlots();
            }
            else if (selectedItem.IsHackerChipset())
            {
                foreach (LoadoutSlotBtn loadoutSlot in activeHackerSlotBtns)
                {
                    if (loadoutSlot.GetItemType() == selectedItem.GetItemType() && loadoutSlot.GetIsActive())
                    {
                        hubWorldSFX.PlayHubSoundEffect(HubWorldSFX.HubSoundeffect.EquipItem);
                        hackerLoadout.EquipItem(selectedItem as HackerModChip, loadoutSlot.GetSlotNumber() - 1);
                        recentlyEquippedItem = true;
                    }
                }
                if (recentlyEquippedItem == false)
                {
                    // get and activate the appropriate buttons
                    foreach (LoadoutSlotBtn loadoutSlot in activeHackerSlotBtns)
                    {
                        if (loadoutSlot.GetItemType() == selectedItem.GetItemType())
                        {
                            loadoutSlot.SetButtonToAskForInput();
                        }
                    }
                    waitingToEquip = true;
                    DisableAllOtherInputs();
                    // TODO: DISABLE OTHER INPUTS SOMEHOW
                }
            }
            break;
        }
        SetupInventoryList();
    }
Пример #2
0
    public void LoadPlayer(int saveSlotToLoad)
    {
        SaveObject saveObject = SaveSystem.LoadPlayerData(saveSlotToLoad);

        // Recreate Owned Items
        ownedItems = new List <Item>();
        List <SaveItem> deserializedSaveItems = JsonConvert.DeserializeObject <List <SaveItem> >(saveObject.items);

        foreach (SaveItem saveItem in deserializedSaveItems)
        {
            if (saveItem.hackerOrRunner == (int)Item.HackerRunner.Hacker)
            {
                // Hacker Items
                if (saveItem.itemType == (int)Item.ItemTypes.Rig || saveItem.itemType == (int)Item.ItemTypes.NeuralImplant || saveItem.itemType == (int)Item.ItemTypes.Uplink)
                {
                    HackerMod newHackerMod = ScriptableObject.CreateInstance <HackerMod>();
                    newHackerMod.RecreateSavedHackerMod(saveItem);
                    ownedItems.Add(newHackerMod);
                }
                else
                {
                    HackerModChip newHackerModChip = ScriptableObject.CreateInstance <HackerModChip>();
                    newHackerModChip.RecreateSavedHackerModChip(saveItem);
                    ownedItems.Add(newHackerModChip);
                }
            }
            else if (saveItem.hackerOrRunner == (int)Item.HackerRunner.Runner)
            {
                // Create Runner Items
                RunnerMod newRunnerMod = ScriptableObject.CreateInstance <RunnerMod>();
                newRunnerMod.RecreateSavedRunnerMod(saveItem);
                ownedItems.Add(newRunnerMod);
            }
        }

        // Create Runners
        List <SaveRunner> saveRunners = JsonConvert.DeserializeObject <List <SaveRunner> >(saveObject.runners);

        ownedRunners = new List <CharacterData>();
        foreach (SaveRunner saveRunner in saveRunners)
        {
            CharacterData newRunner = ScriptableObject.CreateInstance <CharacterData>();
            newRunner.RecreateRunnerFromSaveData(saveRunner);

            Loadout runnerLoadout = newRunner.GetLoadout();
            runnerLoadout.EquipItem((RunnerMod)GetLoadedItemById(saveRunner.headItemId));
            runnerLoadout.EquipItem((RunnerMod)GetLoadedItemById(saveRunner.torsoModId));
            runnerLoadout.EquipItem((RunnerMod)GetLoadedItemById(saveRunner.exoskeletonModId));
            runnerLoadout.EquipItem((RunnerMod)GetLoadedItemById(saveRunner.leftArmModId), Loadout.LeftOrRight.Left);
            runnerLoadout.EquipItem((RunnerMod)GetLoadedItemById(saveRunner.rightArmModId), Loadout.LeftOrRight.Right);
            runnerLoadout.EquipItem((RunnerMod)GetLoadedItemById(saveRunner.leftLegModId), Loadout.LeftOrRight.Left);
            runnerLoadout.EquipItem((RunnerMod)GetLoadedItemById(saveRunner.rightLegModId), Loadout.LeftOrRight.Right);
            runnerLoadout.EquipItem((RunnerMod)GetLoadedItemById(saveRunner.weaponModId));

            ownedRunners.Add(newRunner);
            if (newRunner.GetRunnerId() == saveObject.currentRunner)
            {
                currentRunner = newRunner;
            }
        }

        List <SaveHacker> saveHackers = JsonConvert.DeserializeObject <List <SaveHacker> >(saveObject.hackers);

        ownedHackers = new List <HackerData>();
        foreach (SaveHacker saveHacker in saveHackers)
        {
            HackerData newHacker = ScriptableObject.CreateInstance <HackerData>();
            newHacker.RecreateHackerFromSave(saveHacker);

            if (!newHacker.GetIsLocked())
            {
                HackerMod newRigMod = (HackerMod)GetLoadedItemById(saveHacker.rigModId);
                if (saveHacker.rigSoftwareId1 != -1)
                {
                    newRigMod.InstallChip((HackerModChip)GetLoadedItemById(saveHacker.rigSoftwareId1), 0);
                }
                if (saveHacker.rigSoftwareId2 != -1)
                {
                    newRigMod.InstallChip((HackerModChip)GetLoadedItemById(saveHacker.rigSoftwareId2), 1);
                }
                if (saveHacker.rigSoftwareId3 != -1)
                {
                    newRigMod.InstallChip((HackerModChip)GetLoadedItemById(saveHacker.rigSoftwareId3), 2);
                }
                newHacker.GetHackerLoadout().EquipRecreatedItem(newRigMod);

                HackerMod newNeuralImplantMod = (HackerMod)GetLoadedItemById(saveHacker.neuralImplantId);
                if (saveHacker.neuralWetwareId1 != -1)
                {
                    newNeuralImplantMod.InstallChip((HackerModChip)GetLoadedItemById(saveHacker.neuralWetwareId1), 0);
                }
                if (saveHacker.neuralWetwareId2 != -1)
                {
                    newNeuralImplantMod.InstallChip((HackerModChip)GetLoadedItemById(saveHacker.neuralWetwareId2), 1);
                }
                if (saveHacker.neuralWetwareId3 != -1)
                {
                    newNeuralImplantMod.InstallChip((HackerModChip)GetLoadedItemById(saveHacker.neuralWetwareId3), 2);
                }
                newHacker.GetHackerLoadout().EquipRecreatedItem(newNeuralImplantMod);

                HackerMod newUplinkMod = (HackerMod)GetLoadedItemById(saveHacker.uplinkId);
                if (saveHacker.uplinkChipsetId1 != -1)
                {
                    newUplinkMod.InstallChip((HackerModChip)GetLoadedItemById(saveHacker.uplinkChipsetId1), 0);
                }
                if (saveHacker.uplinkChipsetId2 != -1)
                {
                    newUplinkMod.InstallChip((HackerModChip)GetLoadedItemById(saveHacker.uplinkChipsetId2), 1);
                }
                if (saveHacker.uplinkChipsetId3 != -1)
                {
                    newUplinkMod.InstallChip((HackerModChip)GetLoadedItemById(saveHacker.uplinkChipsetId3), 2);
                }
                newHacker.GetHackerLoadout().EquipRecreatedItem(newUplinkMod);
            }

            ownedHackers.Add(newHacker);
            if (newHacker.GetHackerId() == saveObject.currentHacker)
            {
                currentHacker = newHacker;
            }
        }

        List <SaveJob> saveJobs = JsonConvert.DeserializeObject <List <SaveJob> >(saveObject.jobOptions);

        currentJobOptions = new List <Job>();
        foreach (SaveJob saveJob in saveJobs)
        {
            Job newJob = ScriptableObject.CreateInstance <Job>();
            newJob.LoadJobFromSave(saveJob);

            currentJobOptions.Add(newJob);
        }

        // General Player Data
        currentCredits  = saveObject.playerCredits;
        generatedItemId = saveObject.currentItemId;
        saveSlot        = saveObject.saveSlot;

        // Shop Stuff
        currentShopType   = (ShopMenu.ShopForSaleType)saveObject.currentShopType;
        previousShopTypes = new List <ShopMenu.ShopForSaleType>();
        List <int> shopTypeIds = JsonConvert.DeserializeObject <List <int> >(saveObject.previousShopTypes);

        foreach (int shopTypeId in shopTypeIds)
        {
            previousShopTypes.Add((ShopMenu.ShopForSaleType)shopTypeId);
        }

        List <SaveItem> savedShopItems = JsonConvert.DeserializeObject <List <SaveItem> >(saveObject.itemsForSale);

        itemsForSale = new List <Item>();
        foreach (SaveItem saveItem in savedShopItems)
        {
            if (saveItem.hackerOrRunner == (int)Item.HackerRunner.Hacker)
            {
                // Hacker Items
                if (saveItem.itemType == (int)Item.ItemTypes.Rig || saveItem.itemType == (int)Item.ItemTypes.NeuralImplant || saveItem.itemType == (int)Item.ItemTypes.Uplink)
                {
                    HackerMod newHackerMod = ScriptableObject.CreateInstance <HackerMod>();
                    newHackerMod.RecreateSavedHackerMod(saveItem);
                    itemsForSale.Add(newHackerMod);
                }
                else
                {
                    HackerModChip newHackerModChip = ScriptableObject.CreateInstance <HackerModChip>();
                    newHackerModChip.RecreateSavedHackerModChip(saveItem);
                    itemsForSale.Add(newHackerModChip);
                }
            }
            else if (saveItem.hackerOrRunner == (int)Item.HackerRunner.Runner)
            {
                // Create Runner Items
                RunnerMod newRunnerMod = ScriptableObject.CreateInstance <RunnerMod>();
                newRunnerMod.RecreateSavedRunnerMod(saveItem);
                itemsForSale.Add(newRunnerMod);
            }
        }

        isPlayerLoaded = true;
    }