Пример #1
0
        public CampaignData SaveNewCampaign()
        {
            var newData = new CampaignData(CurrentCampaignSequence.campaignName, CurrentCampaignIndex, FarthestCampaignIndex, CurrentCampaignIsCompleted, CampaignPlayerData);

            CampaignDataSlots.Add(newData);

            CampaignDataFileHandler.SaveCampaignData(newData);

            return(newData);
        }
Пример #2
0
        public static string DataToString(CampaignData data)
        {
            var sequence   = instance.NamesToCampaignSequences[data.CampaignName];
            var dataString = $"{sequence.campaignName}: Chapter {data.FarthestCampaignIndex + 1} - {sequence.chapterNames[data.FarthestCampaignIndex]} - {data.Difficulty.ToString()} - {data.TimeStamp}";

            if (data.IsCompleted)
            {
                dataString += " - COMPLETE";
            }

            return(dataString);
        }
Пример #3
0
        void Start()
        {
            singlePlayerButton.onClick.AddListener(SceneLoader.instance.GoToSingleplayerMenu);
            mainMenuButton.onClick.AddListener(SceneLoader.instance.GoToMainMenu);

            saveSlots = new List <GameObject>();

            campaignActionButton.interactable = false;

            var allSlots = CampaignManager.instance.CampaignDataSlots
                           .OrderByDescending(slot => slot.TimeStamp);

            if (allSlots.Count() == 0)
            {
                var button = CreateButton("Start New Story...");
                button.onClick.AddListener(() => {
                    selectedGameObject = button.gameObject;
                    var buttonImage    = selectedGameObject.GetComponent <Image>();
                    buttonImage.color  = SELECTED_COLOR;
                    campaignActionButton.interactable = true;
                });
                var actionLabel = campaignActionButton.gameObject.GetComponentInChildren <TextMeshProUGUI>();
                actionLabel.text = "Start";
                campaignActionButton.onClick.AddListener(() => {
                    SceneLoader.instance.GoToCampaignNewStoryMenu();
                });
            }
            else
            {
                foreach (var slot in allSlots)
                {
                    var button = CreateButton(CampaignManager.DataToString(slot));
                    button.onClick.AddListener(() => {
                        if (selectedGameObject != null)
                        {
                            var selectedButton   = selectedGameObject.GetComponent <Image>();
                            selectedButton.color = UNSELECTED_COLOR;
                        }
                        selectedSaveSlot   = slot;
                        selectedGameObject = button.gameObject;
                        var buttonImage    = selectedGameObject.GetComponent <Image>();
                        buttonImage.color  = SELECTED_COLOR;
                        campaignActionButton.interactable = true;
                    });
                }

                campaignActionButton.onClick.AddListener(LoadButton);
            }
            campaignCancelButton.onClick.AddListener(() => {
                SceneLoader.instance.GoToLastMenu();
            });
        }
Пример #4
0
        void Start()
        {
            saveSlots = new List <GameObject>();

            saveSlots.Add(campaignCreateNewDataButton.gameObject);

            campaignSaveButton.interactable = false;

            campaignCreateNewDataButton.onClick.AddListener(() => {
                if (selectedGameObject != null)
                {
                    var selectedButton   = selectedGameObject.GetComponent <Image>();
                    selectedButton.color = UNSELECTED_COLOR;
                }
                selectedSaveSlot   = null;
                selectedGameObject = campaignCreateNewDataButton.gameObject;
                var buttonImage    = selectedGameObject.GetComponent <Image>();
                buttonImage.color  = SELECTED_COLOR;
                campaignSaveButton.interactable = true;
            });

            var allSlots = CampaignManager.instance.CampaignDataSlots
                           .OrderByDescending(slot => slot.TimeStamp);

            foreach (var slot in allSlots)
            {
                var button = CreateButton(CampaignManager.DataToString(slot));
                button.onClick.AddListener(() => {
                    if (selectedGameObject != null)
                    {
                        var selectedButton   = selectedGameObject.GetComponent <Image>();
                        selectedButton.color = UNSELECTED_COLOR;
                    }
                    selectedSaveSlot   = slot;
                    selectedGameObject = button.gameObject;
                    var buttonImage    = selectedGameObject.GetComponent <Image>();
                    buttonImage.color  = SELECTED_COLOR;
                    campaignSaveButton.interactable = true;
                });
            }

            campaignSaveButton.onClick.AddListener(SaveButton);
            campaignContinueButton.onClick.AddListener(ContinueButton);
        }
Пример #5
0
        public CampaignData SaveCampaign(CampaignData data)
        {
            // Overwrite existing data
            CampaignDataFileHandler.DeleteCampaignData(data);

            data.CampaignName          = CurrentCampaignSequence.campaignName;
            data.CurrentCampaignIndex  = CurrentCampaignIndex;
            data.FarthestCampaignIndex = FarthestCampaignIndex;
            data.IsCompleted           = CurrentCampaignIsCompleted;
            data.PlayerData            = CampaignPlayerData;
            data.Difficulty            = CurrentCampaignDifficulty;
            data.UnitWrapperData       = CampaignPlayerData.CampaignUnits.Select(unit => new UnitWrapper(unit)).ToList();
            data.WeaponWrapperData     = CampaignPlayerData.Weapons.Select(weapon => new WeaponWrapper(weapon)).ToList();
            data.ItemWrapperData       = CampaignPlayerData.Items.Select(item => new ItemWrapper(item)).ToList();

            CampaignDataFileHandler.SaveCampaignData(data);

            CurrentCampaignSaved = true;
            return(data);
        }
Пример #6
0
        private void SaveButton()
        {
            CampaignData newData = null;

            if (selectedSaveSlot == null)
            {
                newData = CampaignManager.instance.SaveNewCampaign();
            }
            else
            {
                newData = CampaignManager.instance.SaveCampaign(selectedSaveSlot);
            }

            if (newData != null)
            {
                var newLabel = selectedGameObject.GetComponentInChildren <TextMeshProUGUI>();
                newLabel.text = CampaignManager.DataToString(newData);
                dataSaved     = true;
            }
        }
Пример #7
0
        public void LoadCampaign(CampaignData data)
        {
            CurrentCampaignSequence    = NamesToCampaignSequences[data.CampaignName];
            CurrentCampaignIndex       = data.CurrentCampaignIndex;
            FarthestCampaignIndex      = data.FarthestCampaignIndex;
            CurrentCampaignIsCompleted = data.IsCompleted;
            CampaignPlayerData         = data.PlayerData.Clone();
            CurrentCampaignDifficulty  = data.Difficulty;

            // Regenerate Units with Skills
            CampaignPlayerData.CampaignUnits = new List <Unit>();
            foreach (var unitWrapper in data.UnitWrapperData)
            {
                var unit = UnitFactory.instance.GenerateUnit(unitWrapper);
                CampaignPlayerData.AddCampaignUnit(unit);
            }

            CampaignPlayerUnitData = CampaignPlayerData.CampaignUnits.Select(unit => new UnitWrapper(unit)).ToList();

            CampaignPlayerData.Weapons = new List <Weapon>();
            foreach (var weaponWrapper in data.WeaponWrapperData)
            {
                var weapon = WeaponFactory.instance.GenerateWeapon(weaponWrapper.WeaponName);
                CampaignPlayerData.Weapons.Add(weapon);
            }

            // TODO: Sebastian
            // Now you need to regenerate Items using the wrapper data of items that was saved in
            // Campaign Data. See above for reference!
            CampaignPlayerData.Items = new List <Item>();
            foreach (var itemWrapper in data.ItemWrapperData)
            {
                var item = ItemFactory.instance.GenerateItem(itemWrapper.ItemName);
                CampaignPlayerData.Items.Add(item);
            }

            LoadCampaignChapterMenu();
        }