Exemplo n.º 1
0
    void EndCurrentPuzzle()
    {
        if (CurPuzzle == Puzzles.Length - 1)
        {
            base.PlayFirstBranch();
            Slot_Container sc         = ArticyDatabase.GetObject <Slot_Container>("Start_On_Object");
            ArticyObject   curStartOn = sc.Template.Slot_Feature.Slot_Feature_Slot;
            var            a          = curStartOn as IObjectWithFeatureSlot_Feature;
            if (a != null)
            {
                sc.Template.Slot_Feature.Slot_Feature_Slot = a.GetFeatureSlot_Feature().Slot_Feature_Slot;
            }
            else
            {
                Debug.LogError("no slot feature in EndCurrentPuzzle");
            }

            SceneManager.LoadScene(1);
            // SceneManager.LoadScene(1);
        }
        else
        {
            Puzzles[CurPuzzle].gameObject.SetActive(false);
            CurPuzzle++;
            Puzzles[CurPuzzle].gameObject.SetActive(true);
            SetupLerpFade(1f, 0f, 1.5f);
            GameState = eGameState.FADE_IN;
        }
    }
    // Start is called before the first frame update
    public virtual void Start()
    {
        PlayerCharacter PC = ArticyDatabase.GetObject <PlayerCharacter>("Player_Character_Entity_Tech_Name");

        //Debug.Log("Our player name is: " + PC.Template.Basic_Character_Attributes.NPC_Feature_Name);
        StaticStuff.FlowDebug("Our player name is: " + PC.Template.Basic_Character_Attributes.NPC_Feature_Name);

        FlowPlayer = GetComponent <ArticyFlowPlayer>();
        Slot_Container sc = ArticyDatabase.GetObject <Slot_Container>("Start_On_Object");

        if (sc.Template.Slot_Feature.Slot_Feature_Slot != null)
        {
            //Debug.Log("CaptainsChairSceneRoot.Start() setting StartOn: " + sc.Template.Slot_Feature.Slot_Feature_Slot.name);
            StaticStuff.FlowDebug("CaptainsChairSceneRoot.Start() setting StartOn: " + sc.Template.Slot_Feature.Slot_Feature_Slot.name);
            SetFlowPlayerStartOn(sc.Template.Slot_Feature.Slot_Feature_Slot);
        }
        else
        {
            //Debug.Log("CaptainsChairSceneRoot.Start() no StartOn");
            StaticStuff.FlowDebug("CaptainsChairSceneRoot.Start() no StartOn");
        }

        if (DialogueUI != null)
        {
            DialogueUI.gameObject.SetActive(false);
        }
        //FlowPlayer.StartOn = sc.Template.Slot_Feature.Slot_Feature_Slot;
    }
Exemplo n.º 3
0
    // Use this for initialization
    void Start()
    {
        if (myRef.HasReference)
        {
            var obj = myRef.GetObject();
            //Debug.Log (obj);

            DialogueFragment test = ArticyDatabase.GetObject <DialogueFragment> (obj.TechnicalName);
            //Debug.Log (test);
            //On peut recuperer les proprietes du DialogueFragment avec nomdufragment.propriete
            //Debug.Log(test.Text);
            //Debug.Log (test.Speaker);

            toPrint = test.Text;
            speaker = test.Speaker;
            Debug.Log(speaker);

            //Debug.Log (toPrint);
            //Debug.Log (speaker);

            //Debug.Log (test.Children);
            //Debug.Log (test.OutputPins);
            test.GetInputPins();
            test.GetOutputPins();
            //print (test.InputPins);
            //print (test.OutputPins);
            //print(test.Children);


            /*
             *
             * for (int i = 0; i < test.InputPins.Count; i++) {
             *      print(test.InputPins[i]);
             *      print (test.InputPins [i].Id);
             *      print (test.InputPins [i].Text);
             * }
             *
             * for (int j = 0; j < test.OutputPins.Count; j++) {
             *      print (test.OutputPins [j]);
             *      print (test.OutputPins [j].Id);
             *      print (test.OutputPins [j].Text);
             * }
             *
             * for (int k = 0; k < test.Children.Count; k++) {
             *      print (test.Children [k]);
             * }
             */
        }
    }
Exemplo n.º 4
0
    // here we initialize the inventory system
    void Start()
    {
        // This makes use of the fact that every Item entity knows its variable name and every item has a global variable inside the "Inventory" variable set.
        // so we register a listener to the global variables to inform us about any changes of variables inside the Inventory variable set.
        ArticyDatabase.DefaultGlobalVariables.Notifications.AddListener("Inventory.*", OnVarChanged);

        // as mentioned before, every Item knows its variable name, to make easier use in our listener method
        // we create a dictionary linking variable name (eg. "Inventory.crowbar") to the actual Item reference (eg. "Itm_Crowbar")
        // so first we get all items
        var allItems = ArticyDatabase.GetAllOfType <Item>();

        variableItemMap.Clear();

        // then we loop over each item
        foreach (var item in allItems)
        {
            try
            {
                // access its variable binding feature, and take the variable name script in pure text form.
                // and save both in our dictionary
                variableItemMap.Add(item.Template.VariableBinding.VariableName.RawScript, item);
            }
            catch (Exception aEx)
            {
                Debug.LogException(aEx);
            }
        }

        // just making sure that the mouse drag image is disabled
        mouseDragImage.gameObject.SetActive(false);

        // because in editor the user could modify the global variables before starting it, and it would be nice debug feature to "cheat" us items
        // we check if any of those items are already checked.
        // now we check if any items are already aquired
        foreach (var pair in ArticyDatabase.DefaultGlobalVariables.Variables)
        {
            // if the variable is inside the Inventory variable set
            if (pair.Key.Contains("Inventory."))
            {
                // and the variable is actually true
                if ((bool)pair.Value)
                {
                    // we call the same method that is called when the variable would be set at runtime
                    OnVarChanged(pair.Key, true);
                }
            }
        }
    }
Exemplo n.º 5
0
    public void OnBranchesUpdated(IList <Branch> aBranches)
    {
        if (aBranches == null || aBranches.Count == 0)
        {
            Debug.LogWarning("NULL or 0 branches in OnBranchesUpdated()."); return;
        }
        Debug.Log("Num branches: " + aBranches.Count);

        int branchID = Random.Range(0, aBranches.Count);

        branchID = 0; // normally this would be random but for now just go to the Ship
        Branch         branch        = aBranches[branchID];
        ArticyObject   targetObject  = (ArticyObject)branch.Target;
        Slot_Container slotContainer = ArticyDatabase.GetObject <Slot_Container>("Start_On_Object");

        slotContainer.Template.Slot_Feature.Slot_Feature_Slot = targetObject;
    }
Exemplo n.º 6
0
    public void LoadArticyState()
    {
        if (ArticyVariables != null)
        {
            ArticyDatabase.DefaultGlobalVariables.Variables = ArticyVariables;

            for (int i = 0; i < EnabledProfiles.Count; ++i)
            {
                template_profile profile = ArticyDatabase.GetObject(EnabledProfiles[i]) as template_profile;
                profile.Template.profile_basic_data.profile_is_enabled = true;
            }

            for (int i = 0; i < DisabledProfiles.Count; ++i)
            {
                template_profile profile = ArticyDatabase.GetObject(DisabledProfiles[i]) as template_profile;
                profile.Template.profile_basic_data.profile_is_enabled = false;
            }
        }
    }
    protected void GoToMiniGame(Branch branch)
    {
        var miniGameFrag = branch.Target as IObjectWithFeatureMini_Game_Name;

        if (miniGameFrag != null)
        {
            //Debug.Log("go to this mini game NOW: " + miniGameFrag.GetFeatureMini_Game__Name().Mini_Game_Name);
            StaticStuff.FlowDebug("go to this mini game NOW: " + miniGameFrag.GetFeatureMini_Game_Name().Mini_Game_Name);
            // FlowPlayer.StartOn = branch.Target as IArticyObject;
            Slot_Container slotContainer = ArticyDatabase.GetObject <Slot_Container>("Start_On_Object");
            slotContainer.Template.Slot_Feature.Slot_Feature_Slot = (ArticyObject)branch.Target;
            SceneManager.LoadScene(miniGameFrag.GetFeatureMini_Game_Name().Mini_Game_Name);
        }
        else
        {
            //Debug.LogError("ERROR: trying to go to a mini game with no name");
            StaticStuff.FlowDebug("ERROR: trying to go to a mini game with no name");
        }
    }
    public void LoadGame()
    {
        SpawnLog();

        InitializeGlobalVariables();

        XDocument xDoc = XDocument.Load(_savePath);

        var anyEndGame = xDoc.Element("save").Element("log").Elements("endGame").Any();

        if (anyEndGame)
        {
            Debug.Log("Game already ended.");
            _controller.GameEnded = true;
            return;
        }

        // set startOn
        var xExecute  = xDoc.Element("save").Element("execute");
        var executeId = xExecute.Attribute(Const.XmlAliases.ExecuteId).Value;

        _player.StartOn = ArticyDatabase.GetObject(executeId);

        // проверить дилей
        var result = CheckForDelay(xExecute);

        if (result.remainingInMinutes > 0)
        {
            var coroutine = new CoroutineObject <DateTime, float>(_controller, _controller.ExecuteWithDelay);
            coroutine.Finished += () =>
            {
                _controller.PlayerStandBy = false;
            };
            coroutine.Start(result.startTime, result.remainingInMinutes);
            _controller.CurrentDelay = coroutine;
        }
        else
        {
            _controller.PlayerStandBy = false;
        }
    }
    public void SpawnLog()
    {
        XDocument xDoc = XDocument.Load(_savePath);

        var log = xDoc.Element("save").Element("log");

        foreach (XElement logEvent in log.Elements())
        {
            switch (logEvent.Name.LocalName)
            {
            case (Const.XmlAliases.Phrase):
                var phrase = ArticyDatabase.GetObject(logEvent.Value) as PhraseDialogueFragment;
                _spawner.SpawnPhrase(phrase.Text);
                break;

            case (Const.XmlAliases.ButtonGroup):
                GameObject bg = _spawner.SpawnButtonGroup();
                bg.GetComponent <ArticyReference>().reference = (ArticyRef)ArticyDatabase.GetObject(logEvent.Attribute("id").Value);
                foreach (XElement xButton in logEvent.Elements())
                {
                    var    blockWithMenuText = ArticyDatabase.GetObject(xButton.Value) as PhraseDialogueFragment;
                    Button b = _spawner.SpawnButtonFromLog(
                        bg,
                        blockWithMenuText.MenuText,
                        bool.Parse(xButton.Attribute(Const.XmlAliases.ButtonPressedAttributte).Value));
                }
                break;

            case (Const.XmlAliases.EndGame):
                if (bool.Parse(logEvent.Attribute(Const.XmlAliases.EndGameWinAttributte).Value))
                {
                    _spawner.SpawnEndGame(true);
                }
                else
                {
                    _spawner.SpawnEndGame(false);
                }
                break;
            }
        }
    }
    public void RewindToState(string stateId)
    {
        Debug.Log($"Rewinding to state {stateId}");

        PlayerStandBy  = false; // если поменять на true - баг (после ревайнда не спавнится выбор, только после перезагрузки игры)
        GameEnded      = false;
        AllowRewinding = false;

        _saveSystem.CleanLog(stateId);
        _spawner.ClearScreen();

        // отрисовать лог (пересмотреть и починить в соответствии с Single Responsibility principle)
        _saveSystem.SpawnLog();

        // инициализировать глобальные переменные
        _saveSystem.InitializeGlobalVariables(stateId);

        // set startOn
        var startOn = ArticyDatabase.GetObject(stateId);

        _player.StartOn = startOn;
    }
Exemplo n.º 11
0
    /// <summary>
    /// update the moral ui
    /// </summary>
    private void UpdateMoraleUI()
    {
        // the moral is found in the template of the Manfred entity, the of the Player_Character class
        var moralValue = ArticyDatabase.GetObject <Player_Character>("Chr_Manfred").Template.Morale.MoraleValue;

        // assign the moral value
        moralTextLabel.text = moralValue.ToString();

        // and to make it a little nicer, we change the color according to the moral value
        if (moralValue == 0)
        {
            moralTextLabel.color = Color.yellow;
        }
        if (moralValue < 0)
        {
            moralTextLabel.color = Color.red;
        }
        if (moralValue > 0)
        {
            moralTextLabel.color = Color.green;
        }
    }
Exemplo n.º 12
0
    private void ApplyState(GlobalVariableState state)
    {
        if (state != null)
        {
            if (ArticyDatabase.IsObjectAvailable(state.NodeTechnicalName))
            {
                Debug.Log($"#StateRestore#Applying {state.NodeTechnicalName}");
                player.StartOn = ArticyDatabase.GetObject(state.NodeTechnicalName);
            }
#if UNITY_EDITOR
            else
            {
                Debug.LogError($"Technical name:{state.NodeTechnicalName} for state {state.Id} is not available in the database. Maybe it doesn't exist.");
                UnityEditor.EditorApplication.isPaused = true;
            }
#endif
            transition.newSceneName             = state.SceneId;
            transition.transitionDestinationTag = state.SceneTag;
            ArticyGlobalVariables.Default.Session.TargetLocation = state.targetLocation;
            GetCurrentMissionAndObjective(state.Id, out int mission, out int objective);
            manager.LastMission   = mission;
            manager.LastObjective = objective;
        }
    }
Exemplo n.º 13
0
    /// <summary>
    /// this is a script method the designer created in the articy project, and the plugin generated a c# method for us.
    /// The intent of this method is to just completely restart the game, and is used on the final screen of the game.
    /// </summary>
    public void restart()
    {
        // its important to only call the logic outside of any forecastings
        if (!IsCalledInForecast)
        {
            // because we want to restart the game, we reset the variables
            ArticyDatabase.DefaultGlobalVariables.ResetVariables();

            // we have to reset the moral value
            ArticyDatabase.GetObject <Player_Character>("Chr_Manfred").Template.Morale.MoraleValue = 0;

            // then we check every location we have in the database to find the one that is flagged as the start location
            var locations = ArticyDatabase.GetAllOfType <LocationSettings>();
            foreach (var loc in locations)
            {
                if (loc.Template.LocationSettings.IsStartLocation)
                {
                    // once found, we just continue with that.
                    ContinueFlow(loc);
                    break;
                }
            }
        }
    }
Exemplo n.º 14
0
    public override void InitManager()
    {
        base.InitManager();
        instance          = this;
        AllRandoTemplates = ArticyDatabase.GetAllOfType <template_random_profile>();



        if (RandoProfilesReference.HasReference)
        {
            UserFolder randoFolder = RandoProfilesReference.GetObject <UserFolder>();

            for (int i = 0; i < randoFolder.Children.Count; ++i)
            {
                UserFolder childRandoFolder = randoFolder.Children[i] as UserFolder;
                if (childRandoFolder != null)
                {
                    for (int j = 0; j < childRandoFolder.Children.Count; ++j)
                    {
                        template_profile randoProfile = childRandoFolder.Children[j] as template_profile;

                        //if (randoProfile.PreviewImage != null && randoProfile.PreviewImage.Asset != null)
                        //{
                        //    ImagePhoto.sprite = AssignedProfile.PreviewImage.Asset.LoadAssetAsSprite();
                        //}

                        if (randoProfile != null && randoProfile.PreviewImage != null && randoProfile.PreviewImage.Asset != null)
                        {
                            RandoProfileList.Add(randoProfile);
                        }
                    }
                }
            }
        }

        //Debug.Log("Found " + RandoProfileList.Count + " rando profiles");

        if (LastHumanProfilesReference.HasReference)
        {
            UserFolder randoFolderLastHumans = LastHumanProfilesReference.GetObject <UserFolder>();
            for (int i = 0; i < randoFolderLastHumans.Children.Count; ++i)
            {
                template_profile randoProfile = randoFolderLastHumans.Children[i] as template_profile;

                if (randoProfile != null && randoProfile.PreviewImage != null && randoProfile.PreviewImage.Asset != null)
                {
                    LastHumanProfileList.Add(randoProfile);
                }
            }
        }
        //Debug.Log("Found " + LastHumanProfileList.Count + " last human rando profiles");

        if (DeveloperProfilesReference.HasReference)
        {
            UserFolder devFolder = DeveloperProfilesReference.GetObject <UserFolder>();

            for (int j = 0; j < devFolder.Children.Count; ++j)
            {
                template_profile devProfile = devFolder.Children[j] as template_profile;
                DeveloperProfileList.Add(devProfile);
            }
        }

        //Debug.Log("Found " + DeveloperProfileList.Count + " dev profiles");

        if (PlantProfilesReference.HasReference)
        {
            UserFolder randoFolderPlants = PlantProfilesReference.GetObject <UserFolder>();
            for (int i = 0; i < randoFolderPlants.Children.Count; ++i)
            {
                template_profile randoProfile = randoFolderPlants.Children[i] as template_profile;

                if (randoProfile != null && randoProfile.PreviewImage != null && randoProfile.PreviewImage.Asset != null)
                {
                    PlantProfileList.Add(randoProfile);
                }
            }
        }

        if (AnyRandomTemplateReference.HasReference)
        {
            AnyRandomTemplate = AnyRandomTemplateReference.GetObject <template_random_profile>();
        }
        //Debug.Log("Found " + PlantProfileList.Count + " plant rando profiles");

        for (int i = 0; i < SubplotProfileReferences.Count; ++i)
        {
            if (SubplotProfileReferences[i].HasReference)
            {
                template_profile subplotProfile = SubplotProfileReferences[i].GetObject <template_profile>();

                if (subplotProfile != null)
                {
                    SubplotProfiles.Add(subplotProfile);
                }
            }
        }
        //Debug.Log("Found " + SubplotProfiles.Count + " subplot profiles");

        string trolo = "";

        for (int i = 0; i < AllRandoTemplates.Count; ++i)
        {
            trolo += "Found " + GetRandoCandidatesByTemplate(AllRandoTemplates[i]) + " : " + AllRandoTemplates[i].DisplayName + "'s\n";
        }
        //Debug.Log(trolo);

        List <template_profile> profiles = RandoProfileList; //ArticyDatabase.GetAllOfType<template_profile>();

        int ecoPlusSpare        = 0;
        int healthPlusSpare     = 0;
        int peacePlusSpare      = 0;
        int prosperityPlusSpare = 0;

        int ecoPlusDeath        = 0;
        int healthPlusDeath     = 0;
        int peacePlusDeath      = 0;
        int prosperityPlusDeath = 0;

        int ecoMinusDeath        = 0;
        int healthMinusDeath     = 0;
        int peaceMinusDeath      = 0;
        int prosperityMinusDeath = 0;

        int ecoMinusSpare        = 0;
        int healthMinusSpare     = 0;
        int peaceMinusSpare      = 0;
        int prosperityMinusSpare = 0;

        for (int i = 0; i < profiles.Count; ++i)
        {
            if (profiles[i].Template.profile_death_data.profile_death_ecology_value > 0)
            {
                ecoPlusDeath += Mathf.RoundToInt(profiles[i].Template.profile_death_data.profile_death_ecology_value);
            }
            else
            {
                ecoMinusDeath += Mathf.RoundToInt(profiles[i].Template.profile_death_data.profile_death_ecology_value);
            }
            if (profiles[i].Template.profile_death_data.profile_death_peace_value > 0)
            {
                peacePlusDeath += Mathf.RoundToInt(profiles[i].Template.profile_death_data.profile_death_peace_value);
            }
            else
            {
                peaceMinusDeath += Mathf.RoundToInt(profiles[i].Template.profile_death_data.profile_death_peace_value);
            }
            if (profiles[i].Template.profile_death_data.profile_death_healthcare_value > 0)
            {
                healthPlusDeath += Mathf.RoundToInt(profiles[i].Template.profile_death_data.profile_death_healthcare_value);
            }
            else
            {
                healthMinusDeath += Mathf.RoundToInt(profiles[i].Template.profile_death_data.profile_death_healthcare_value);
            }
            if (profiles[i].Template.profile_death_data.profile_death_prosperity_value > 0)
            {
                prosperityPlusDeath += Mathf.RoundToInt(profiles[i].Template.profile_death_data.profile_death_prosperity_value);
            }
            else
            {
                prosperityMinusDeath += Mathf.RoundToInt(profiles[i].Template.profile_death_data.profile_death_prosperity_value);
            }


            if (profiles[i].Template.profile_spare_data.profile_spare_ecology_value > 0)
            {
                ecoPlusSpare += Mathf.RoundToInt(profiles[i].Template.profile_spare_data.profile_spare_ecology_value);
            }
            else
            {
                ecoMinusSpare += Mathf.RoundToInt(profiles[i].Template.profile_spare_data.profile_spare_ecology_value);
            }
            if (profiles[i].Template.profile_spare_data.profile_spare_peace_value > 0)
            {
                peacePlusSpare += Mathf.RoundToInt(profiles[i].Template.profile_spare_data.profile_spare_peace_value);
            }
            else
            {
                peaceMinusSpare += Mathf.RoundToInt(profiles[i].Template.profile_spare_data.profile_spare_peace_value);
            }
            if (profiles[i].Template.profile_spare_data.profile_spare_healthcare_value > 0)
            {
                healthPlusSpare += Mathf.RoundToInt(profiles[i].Template.profile_spare_data.profile_spare_healthcare_value);
            }
            else
            {
                healthMinusSpare += Mathf.RoundToInt(profiles[i].Template.profile_spare_data.profile_spare_healthcare_value);
            }
            if (profiles[i].Template.profile_spare_data.profile_spare_prosperity_value > 0)
            {
                prosperityPlusSpare += Mathf.RoundToInt(profiles[i].Template.profile_spare_data.profile_spare_prosperity_value);
            }
            else
            {
                prosperityMinusSpare += Mathf.RoundToInt(profiles[i].Template.profile_spare_data.profile_spare_prosperity_value);
            }
        }
        //Debug.Log("MEGASTATS\n" +
        //    "Eco Plus Spare: " + ecoPlusSpare + "\n" +
        //    "Health Plus Spare: " + healthPlusSpare + "\n" +
        //    "Peace Plus Spare: " + peacePlusSpare + "\n" +
        //    "Prosperity Plus Spare: " + prosperityPlusSpare + "\n" +

        //    "Eco Minus Spare: " + ecoMinusSpare + "\n" +
        //    "Health Minus Spare: " + healthMinusSpare + "\n" +
        //    "Peace Minus Spare: " + peaceMinusSpare + "\n" +
        //    "Prosperity Minus Spare: " + prosperityMinusSpare + "\n" +

        //    "Eco Plus Death: " + ecoPlusDeath + "\n" +
        //    "Health Plus Death: " + healthPlusDeath + "\n" +
        //    "Peace Plus Death: " + peacePlusDeath + "\n" +
        //    "Prosperity Plus Death: " + prosperityPlusDeath + "\n" +

        //    "Eco Minus Death: " + ecoMinusDeath + "\n" +
        //    "Health Minus Death: " + healthMinusDeath + "\n" +
        //    "Peace Minus Death: " + peaceMinusDeath + "\n" +
        //    "Prosperity Minus Death: " + prosperityMinusDeath + "\n"

        //    );
    }
Exemplo n.º 15
0
 //load the character infos from articy
 void LoadCharacters()
 {
     m_Char       = ArticyDatabase.GetObject <Entity>(m_CharName);
     m_CharLoaded = true;
 }
Exemplo n.º 16
0
 public template_day GetCurrentDaySaved()
 {
     return(ArticyDatabase.GetObject(CurrentDay) as template_day);
 }
Exemplo n.º 17
0
    public void RollDay(bool restoreFromSave)
    {
        List <template_profile> profiles = new List <template_profile>();
        int currentDayIndex = SaveManager.instance.GetCurrentPlayerState().GetCurrentDayIndex();

        if (restoreFromSave)
        {
            List <ProfileState> profileStates = SaveManager.instance.GetCurrentPlayerState().GetCurrentDayProfiles();
            for (int i = 0; i < profileStates.Count; ++i)
            {
                template_profile profile = ArticyDatabase.GetObject(profileStates[i].ProfileID) as template_profile;
                if (profile != null)
                {
                    profiles.Add(profile);
                }
                else
                {
                    Debug.LogError("Invalid Profile ID: " + profileStates[i].ProfileID.ToString() + " saved for day: " + (currentDayIndex + 1));
                }
            }
        }
        else
        {
            template_day day = GameManager.instance.GetCurrentDay();

            if (day == null)
            {
                Debug.LogError("DAY NOT FOUND; PROBABLY GOING TO EXPLODE");
            }
            template_day_task dayTask = day.Template.day.day_task_slot as template_day_task;

            if (dayTask == null)
            {
                Debug.LogError("DAY TASK NOT FOUND; PROBABLY GOING TO EXPLODE");
            }
            dayTask.Template.task.task_profile_count.CallScript();


            Debug.Log("Getting " + ArticyGlobalVariables.Default.day.profile_count + " profiles for day " + (currentDayIndex + 1) + "; Day Name: " + day.DisplayName);

            List <ArticyObject> dailyProfileTemplates = new List <ArticyObject>(dayTask.Template.task.task_daily_profiles);
            for (int j = 0; j < ArticyGlobalVariables.Default.day.profile_count; ++j)
            {
                int index = j;
                if (dayTask.Template.task.task_profile_shuffler)
                {
                    index = UnityEngine.Random.Range(0, dailyProfileTemplates.Count);
                }
                else
                {
                }
                template_profile        dailyProfile       = dailyProfileTemplates[index] as template_profile;
                template_random_profile dailyRandomProfile = dailyProfileTemplates[index] as template_random_profile;

                if (dayTask.Template.task.task_profile_shuffler)
                {
                    dailyProfileTemplates.RemoveAt(index);
                }
                if (dailyRandomProfile != null)
                {
                    dailyProfile = ProfileManager.instance.RollProfileByRandoDefinition(dailyRandomProfile);
                }
                if (dailyProfile == null)
                {
                    Debug.LogError("Rolled null profile for day " + (currentDayIndex + 1) + "!");
                    continue;
                }
                else if (!dailyProfile.Template.profile_basic_data.profile_is_enabled)
                {
                    Debug.Log("Skipping un-enabled profile: " + dailyProfile.Template.profile_basic_data.profile_name + " for day: " + (currentDayIndex + 1) + "!");
                }
                else
                {
                    profiles.Add(dailyProfile);
                    AllProfiles.Add(dailyProfile);
                }
            }
            int profileDelta = ArticyGlobalVariables.Default.day.profile_count - profiles.Count;
            for (int i = 0; i < profileDelta; ++i)
            {
                template_profile dailyProfile = null;
                dailyProfile = ProfileManager.instance.RollProfileByRandoDefinition(ProfileManager.instance.AnyRandomTemplate);
                if (dailyProfile == null)
                {
                    Debug.LogError("Rolled null profile for day " + (currentDayIndex + 1) + "!");
                    continue;
                }
                else
                {
                    profiles.Add(dailyProfile);
                    AllProfiles.Add(dailyProfile);
                }
            }

            SaveManager.instance.GetCurrentPlayerState().SetCurrentDayProfiles(profiles);
            // grab only its general properties
        }

        List <ulong> profileIDs = new List <ulong>();

        for (int i = 0; i < profiles.Count; ++i)
        {
            profileIDs.Add(profiles[i].Id);

            if (!restoreFromSave)
            {
                Phone.instance.AddNewsText(profiles[i].Template.profile_basic_data.profile_appearance_news_first);
                Phone.instance.AddNewsText(profiles[i].Template.profile_basic_data.profile_appearance_news_second);
            }
        }
        Debug.Log("Found " + profiles.Count + " profiles for day " + (currentDayIndex + 1));

        if (!restoreFromSave)
        {
            SaveManager.instance.GetCurrentPlayerState().AddDailyProfiles(currentDayIndex + 1, profileIDs);
        }
        DailyProfiles.Add(currentDayIndex + 1, profiles);
    }
Exemplo n.º 18
0
    public void PopulateShop(bool restoreFromSave)
    {
        List <template_item> unOwnedItems = new List <template_item>();
        PlayerState          player       = SaveManager.instance.GetCurrentPlayerState();

        if (restoreFromSave)
        {
            bool toySlotUsed = false;
            for (int i = 0; i < player.GetCurrentDayItems().Count; ++i)
            {
                template_item item = ArticyDatabase.GetObject(player.GetCurrentDayItems()[i]) as template_item;

                if (toySlotUsed && item.Template.item_data.item_slot_number == 2)
                {
                    GameObject marker = Shop.instance.GetShopItemSpawnMarkerForPosition(1);
                    SpawnItem(item, marker.transform.position);
                }
                else
                {
                    GameObject marker = Shop.instance.GetShopItemSpawnMarkerForPosition(item.Template.item_data.item_slot_number);
                    SpawnItem(item, marker.transform.position);
                    if (item.Template.item_data.item_slot_number == 2)
                    {
                        toySlotUsed = true;
                    }
                }

                //if (i >= shopItemSpawnMarkers.Count)
                //{
                //    Debug.LogError("Invalid number of items in savegame! Contact Ott!");
                //}
                //else
                //{

                //}
            }
        }
        else
        {
            bool          isInfoToolSlotEmpty = true;
            template_item substituteItem      = null;
            for (int j = 0; j < 3; ++j)
            {
                unOwnedItems.Clear();
                for (int i = 0; i < ItemDictionary[j].Count; ++i)
                {
                    //if (!SaveManager.instance.GetCurrentCarryoverPlayerState().IsItemOwnedByID(ItemDictionary[j][i].Id))
                    //{
                    //    unOwnedItems.Add(ItemDictionary[j][i]);
                    //}

                    if (!ItemDictionary[j][i].Template.item_data.item_variable.CallScript() && substituteItem != ItemDictionary[j][i])
                    {
                        if (j == 1)
                        {
                            isInfoToolSlotEmpty = false;
                        }
                        if (ItemDictionary[j][i] != GetStarterBody() && ItemDictionary[j][i] != GetStarterHead())
                        {
                            unOwnedItems.Add(ItemDictionary[j][i]);
                        }
                    }
                }

                if (isInfoToolSlotEmpty && j == 1)
                {
                    for (int i = 0; i < ItemDictionary[2].Count; ++i)
                    {
                        if (!ItemDictionary[2][i].Template.item_data.item_variable.CallScript())
                        {
                            if (ItemDictionary[2][i] != GetStarterBody() && ItemDictionary[2][i] != GetStarterHead())
                            {
                                unOwnedItems.Add(ItemDictionary[2][i]);
                            }
                        }
                    }
                }

                if (unOwnedItems.Count > 0)
                {
                    if (isInfoToolSlotEmpty && j == 1)
                    {
                        GameObject marker = Shop.instance.GetShopItemSpawnMarkerForPosition(1);

                        template_item rolledItem = unOwnedItems[Random.Range(0, unOwnedItems.Count)];
                        substituteItem = rolledItem;
                        unOwnedItems.Remove(rolledItem);
                        SpawnItem(rolledItem, marker.transform.position);
                        player.AddCurrentDayItem(rolledItem.Id);
                    }
                    else
                    {
                        GameObject marker = Shop.instance.GetShopItemSpawnMarkerForPosition(j);

                        template_item rolledItem = unOwnedItems[Random.Range(0, unOwnedItems.Count)];
                        unOwnedItems.Remove(rolledItem);
                        SpawnItem(rolledItem, marker.transform.position);
                        player.AddCurrentDayItem(rolledItem.Id);
                    }
                }
            }
        }
    }
 public void LoadState(string id)
 {
     XDocument xDoc = XDocument.Load(_savePath);
     var       df   = ArticyDatabase.GetObject(id) as PhraseDialogueFragment;
 }