Beispiel #1
0
 public override void OnEnter()
 {
     if ((asset1 != null) && (asset2 != null) && (storeResult != null))
     {
         try {
             storeResult.Value = Lua.Run(string.Format("return GetStatus({0}, {1})",
                                                       DialogueLua.SpacesToUnderscores(DialogueLua.DoubleQuotesToSingle(asset1.Value)),
                                                       DialogueLua.SpacesToUnderscores(DialogueLua.DoubleQuotesToSingle(asset2.Value))), DialogueDebug.LogInfo).AsString;
         } catch (System.NullReferenceException) {
         }
     }
     Finish();
 }
Beispiel #2
0
    // Use this for initialization
    void Start()
    {
        int id = DialogueLua.GetVariable("Pet").AsInt;

        transform.GetChild(id).gameObject.SetActive(true);
    }
Beispiel #3
0
        void CheckPregnancy()
        {
            if (Data.Growth != BlossomData.BlossomGrowth.Adult)
            {
                return;
            }
            if (Data.Pregnant == true)
            {
                return;
            }
            if (BlossomManager.Instance.HutAmount >= BlossomManager.Instance.MaxHuts)
            {
                return;
            }
            bool pregnantChance = false;

            int rand = Random.Range(0, 101);

            if (rand <= 15)
            {
                pregnantChance = true;
            }

            if (pregnantChance == true)
            {
                //CHECK COMPATIBLE BLOSSOMS
                List <string> compatibleBlossoms = new List <string>();
                string        match = string.Empty;
                foreach (string blossom in BlossomManager.Instance.OwnedBlossoms)
                {
                    if (Data.ID == blossom)
                    {
                        continue;
                    }
                    if (Data.Parent1 == blossom)
                    {
                        continue;
                    }
                    if (Data.Parent2 == blossom)
                    {
                        continue;
                    }
                    BlossomData.BlossomGrowth growth = (BlossomData.BlossomGrowth)System.Enum.Parse(typeof(BlossomData.BlossomGrowth), DialogueLua.GetVariable(blossom + "Growth").asString);
                    print(growth.ToString());
                    if (growth != BlossomData.BlossomGrowth.Adult)
                    {
                        continue;
                    }
                    if (DialogueLua.GetVariable(blossom + "Pregnant").asBool == true)
                    {
                        continue;
                    }
                    compatibleBlossoms.Add(blossom);
                }
                if (compatibleBlossoms.Count > 0)
                {
                    rand  = Random.Range(0, compatibleBlossoms.Count - 1);
                    match = compatibleBlossoms[rand];
                }
                else
                {
                    print("no compat");
                }
                //IF MATCH FOUND
                if (match != string.Empty)
                {
                    Data.BabyID = BlossomManager.Instance.CreateChildBlossom(Data.ID, match);
                    PixelCrushers.MessageSystem.SendMessage(this, "PregnantBlossom", Data.ID);
                    string babyHut = BlossomManager.Instance.GetEmptyHut();
                    DialogueLua.SetVariable(babyHut + "Blossom", Data.BabyID);
                    DialogueLua.SetVariable(Data.BabyID + "HutX", DialogueLua.GetVariable(babyHut + "X").asFloat);
                    DialogueLua.SetVariable(Data.BabyID + "HutY", DialogueLua.GetVariable(babyHut + "Y").asFloat);
                    DialogueLua.SetVariable(Data.BabyID + "HutName", babyHut);
                    Data.Pregnant     = true;
                    Data.DaysPregnant = 0;
                    GetComponent <BlossomDataSaver>().OnRecordPersistentData();
                }
            }
        }
Beispiel #4
0
 public override void OnEnter()
 {
     if ((actor1Name != null) && (actor2Name != null) && (relationshipType != null) && (incrementAmount != null))
     {
         Lua.Run(string.Format("IncRelationship(Actor[\"{0}\"], Actor[\"{1}\"], {2}, {3})",
                               DialogueLua.StringToTableIndex(actor1Name.Value), DialogueLua.StringToTableIndex(actor2Name.Value),
                               relationshipType.Value, incrementAmount.Value), DialogueDebug.LogInfo);
     }
     Finish();
 }
Beispiel #5
0
 public void ShowResultConversation(int pRank)
 {
     DialogueLua.SetVariable("CompetitionRank", pRank);
     DialogueManager.StartConversation("Competition Result", CompetitionPresenter);
     CompetitionDone = true;
 }
Beispiel #6
0
    // Update is called once per frame
    void Update()
    {
        actualState = DialogueLua.GetVariable("Sequence").AsInt;

        if (LastState != actualState)
        {
            Debug.Log(actualState);

            //stop tout avant de changer
            StopAllCamera();

            LastState = actualState;

            switch (actualState)
            {
            case 1:
                cameras[1].Play();
                DialogueManager.StopConversation();
                DialogueManager.StartConversation("intro");
                break;

            case 2:
                cameras[2].Play();
                femme.SetActive(false);
                break;

            case 3:            //intermede
            case 6:
                cameras[3].Play();
                break;

            case 4:            //supprise
                cameras[4].Play();
                armee.SetActive(true);
                break;

            case 5:            //supprise / rango
                cameras[5].Play();
                break;

            case 7:
            case 9:
            case 11:
                cameras[6].Play();
                rango.SetActive(true);
                break;

            case 8:
            case 10:
            case 12:
                cameras[7].Play();
                break;

            case 13:
                Application.LoadLevel("Spaceship");
                break;

            default:
                break;
            }
        }
    }
 /// <summary>
 /// sets the internal variable that dictates the given audio clip was already played
 /// </summary>
 /// <param name="audioClipName"></param>
 private void markAsPlayedAlready(string audioClipName)
 {
     DialogueLua.SetVariable(this.buildOnceVarName(audioClipName), true);
 }
Beispiel #8
0
        private void ApplyLuaToPosition()
        {
            string s = Lua.Run(string.Format("return Actor[\"{0}\"].Position", DialogueLua.StringToTableIndex(ActorName)), DialogueDebug.LogInfo).AsString;

            ApplyPositionString(s);
        }
        private void EvaluateVariableWatch(Watch watch)
        {
            if (watch == null)
            {
                return;
            }
            var variableName = GetWatchedVariableName(watch.variableIndex);

            watch.variableValue = string.IsNullOrEmpty(variableName) ? Lua.noResult : DialogueLua.GetVariable(variableName);
        }
Beispiel #10
0
        private static void InitializeLuaSubtablesForAsset <T>(string tableName, List <T> assets) where T : Asset
        {
            for (int i = 0; i < assets.Count; i++)
            {
                var asset = assets[i];
                for (int j = 0; j < asset.fields.Count; j++)
                {
                    var field = asset.fields[j];
                    if (field.title.StartsWith(SubtableFieldPrefix))
                    {
                        var subtableTitle = field.title.Substring(SubtableFieldPrefix.Length);
                        var code          = tableName + "[\"" + DialogueLua.StringToTableIndex(asset.Name) + "\"]." + DialogueLua.StringToTableIndex(subtableTitle) + " = { ";
                        if (!string.IsNullOrEmpty(field.value.Trim()))
                        {
                            var articyIds = field.value.Split(';');
                            for (int k = 0; k < articyIds.Length; k++)
                            {
                                var articyId    = articyIds[k];
                                var elementItem = FindAssetByArticyId(articyId);
                                if (elementItem != null)
                                {
                                    code += ((elementItem is Actor) ? "Actor" : "Item") + "[\"" + DialogueLua.StringToTableIndex(elementItem.Name) + "\"]";
                                }
                                else
                                {
                                    code += articyId;
                                }
                                code += ", ";
                            }
                        }
                        code += "}";
                        Lua.Run(code, DialogueDebug.logInfo);

                        // Clear original subtable field to save memory:
                        Lua.Run(tableName + "[\"" + DialogueLua.StringToTableIndex(asset.Name) + "\"]." + DialogueLua.StringToTableIndex(field.title) + " = nil", true);
                    }
                }
            }
        }
Beispiel #11
0
 private void RecordPositionToLua()
 {
     Lua.Run(string.Format("Actor[\"{0}\"].Position = \"{1}\"", DialogueLua.StringToTableIndex(ActorName), GetPositionString()), DialogueDebug.LogInfo);
 }
Beispiel #12
0
 void OnRecordPersistentData()
 {
     DialogueLua.SetVariable(VariableName + "CurrentGrowth", TargetProp.CurrentGrowth);
 }
Beispiel #13
0
 public override void OnEnter()
 {
     if ((actor1Name != null) && (actor2Name != null) && (relationshipType != null) && (relationshipValue != null))
     {
         try {
             Lua.Run(string.Format("SetRelationship(Actor[\"{0}\"], Actor[\"{1}\"], {2}, {3})",
                                   DialogueLua.StringToTableIndex(actor1Name.Value), DialogueLua.StringToTableIndex(actor2Name.Value),
                                   relationshipType.Value, relationshipValue.Value), DialogueDebug.LogInfo);
         } catch (System.NullReferenceException) {
         }
     }
     Finish();
 }
Beispiel #14
0
    void OnApplyPersistentData()
    {
        GetVariableName();
        TargetTree = GetComponent <TreeBase>();


        if (TargetTree.YieldsProduce && DialogueLua.DoesVariableExist(VariableName + "CurrentProduceGrowth"))
        {
            int seasonAmount = DialogueLua.GetVariable(VariableName + "SeasonAmount").asInt;
            TargetTree.ProduceSeasons = new List <TimeManager.MonthNames>();

            for (int i = 0; i < seasonAmount; i++)
            {
                TargetTree.ProduceSeasons.Add((TimeManager.MonthNames)System.Enum.Parse(typeof(TimeManager.MonthNames), DialogueLua.GetVariable(VariableName + "Season" + i).asString));
            }
            //            print(DialogueLua.GetVariable(VariableName + "CurrentProduceGrowth").asInt);
            TargetTree.CurrentProduceGrowth = DialogueLua.GetVariable(VariableName + "CurrentProduceGrowth").asInt;


            TargetTree.ProduceReady = DialogueLua.GetVariable(VariableName + "ProduceReady").asBool;
            TargetTree.SetProduceSprite();
            if (TargetTree.ProduceSeasons.Contains(TimeManager.Instance.CurrentMonth.Name))
            {
                if (TargetTree.FloweringSprite != null)
                {
                    TargetTree.GetComponent <SpriteRenderer>().sprite = TargetTree.FloweringSprite;
                }
            }
        }
        TargetTree.DroppedItems  = DialogueLua.GetVariable(VariableName + "DroppedItems").asInt;
        TargetTree.CurrentGrowth = DialogueLua.GetVariable(VariableName + "CurrentGrowth").asInt;
        TargetTree.NativeTree    = DialogueLua.GetVariable(VariableName + "Native").asBool;
    }
Beispiel #15
0
 private void Sync()
 {
     if (dialogueSystemVariable == null || string.IsNullOrEmpty(dialogueSystemVariable.Value))
     {
         LogWarning(DialogueDebug.Prefix + ": Dialogue System Variable isn't assigned or is blank.");
     }
     else if (playMakerVariable == null)
     {
         LogWarning(DialogueDebug.Prefix + ": PlayMaker Variable isn't assigned or is blank.");
     }
     else
     {
         if (toDialogueSystem != null && toDialogueSystem.Value == true)
         {
             DialogueLua.SetVariable(dialogueSystemVariable.Value, DialogueSystemPlayMakerTools.Vector3ToString(playMakerVariable.Value));
         }
         else
         {
             playMakerVariable.Value = DialogueSystemPlayMakerTools.StringToVector3(DialogueLua.GetVariable(dialogueSystemVariable.Value).AsString);
         }
     }
 }
        private void DrawVariableWatch(Watch watch)
        {
            if (watch == null)
            {
                return;
            }
            CatalogueWatchableVariableNames();
            var needToEvaluate = false;

            EditorGUI.BeginChangeCheck();
            watch.variableIndex = EditorGUILayout.Popup(watch.variableIndex, watchableVariableNames);
            if (EditorGUI.EndChangeCheck())
            {
                watch.variable = FindVariableInDatabase(watch.variableIndex);
                EvaluateVariableWatch(watch);
            }
            var variableName = GetWatchedVariableName(watch.variableIndex);

            if (string.IsNullOrEmpty(variableName))
            {
                EditorGUI.BeginDisabledGroup(true);
                EditorGUILayout.TextField(string.Empty);
                EditorGUI.EndDisabledGroup();
            }
            else if (watch.variable != null && watch.variable.Type == FieldType.Actor)
            {
                EditorGUI.BeginChangeCheck();
                var actorIndex = DrawAssetPopup <Actor>(watch.variableValue.asString, database.actors, GUIContent.none);
                if (EditorGUI.EndChangeCheck())
                {
                    DialogueLua.SetVariable(variableName, Tools.StringToInt(actorIndex));
                    needToEvaluate = true;
                }
            }
            else if (watch.variable != null && watch.variable.Type == FieldType.Location)
            {
                EditorGUI.BeginChangeCheck();
                var locationIndex = DrawAssetPopup <Location>(watch.variableValue.asString, database.locations, GUIContent.none);
                if (EditorGUI.EndChangeCheck())
                {
                    DialogueLua.SetVariable(variableName, Tools.StringToInt(locationIndex));
                    needToEvaluate = true;
                }
            }
            else if (watch.variableValue.isTable)
            {
                EditorGUI.BeginDisabledGroup(true);
                EditorGUILayout.TextField("(table)");
                EditorGUI.EndDisabledGroup();
            }
            else if (watch.variableValue.isBool)
            {
                EditorGUI.BeginChangeCheck();
                var booleanTypeValue = (BooleanType)EditorGUILayout.EnumPopup(watch.variableValue.asBool ? BooleanType.True : BooleanType.False);
                if (EditorGUI.EndChangeCheck())
                {
                    DialogueLua.SetVariable(variableName, booleanTypeValue == BooleanType.True);
                    needToEvaluate = true;
                }
            }
            else if (watch.variableValue.isNumber)
            {
                EditorGUI.BeginChangeCheck();
                var floatValue = EditorGUILayout.FloatField(watch.variableValue.asFloat);
                if (EditorGUI.EndChangeCheck())
                {
                    DialogueLua.SetVariable(variableName, floatValue);
                    needToEvaluate = true;
                }
            }
            else
            {
                EditorGUI.BeginChangeCheck();
                var stringValue = EditorGUILayout.TextField(watch.variableValue.asString);
                if (EditorGUI.EndChangeCheck())
                {
                    DialogueLua.SetVariable(variableName, stringValue);
                    needToEvaluate = true;
                }
            }
            if (needToEvaluate)
            {
                EvaluateVariableWatch(watch);
            }
        }
        public void Open(float pMinAgility, float pMaxAgility, float pMinStrength, float pMaxStrength, float pMinIntellect, float pMaxIntellect, float pMinCharm, float pMaxCharm, CompetitionTierSelectUI prevWindow, List <CompetitioniTier> pTiers, BlossomCompetition pCompetition)
        {
            BlossomDataSaver[] spawnedBlossoms = FindObjectsOfType <BlossomDataSaver>();
            foreach (BlossomDataSaver spawnedBlossom in spawnedBlossoms)
            {
                spawnedBlossom.OnRecordPersistentData();
            }

            BlossomSelectionUI[] children = BlossomContainer.GetComponentsInChildren <BlossomSelectionUI>();
            foreach (BlossomSelectionUI child in children)
            {
                Destroy(child.gameObject);
            }



            foreach (string blossom in BlossomManager.Instance.OwnedBlossoms)
            {
                float agility   = DialogueLua.GetVariable(blossom + "AgilityValue").asFloat;
                float strength  = DialogueLua.GetVariable(blossom + "StrengthValue").asFloat;
                float intellect = DialogueLua.GetVariable(blossom + "IntellectValue").asFloat;
                float charm     = DialogueLua.GetVariable(blossom + "CharmValue").asFloat;

                bool pregnant = DialogueLua.GetVariable(blossom + "Pregnant").asBool;
                bool hungry   = DialogueLua.GetVariable(blossom + "Hungry").asBool;

                float energy   = DialogueLua.GetVariable(blossom + "Energy").asFloat;
                bool  fatigued = energy <= 0 ? true : false;

                string name = DialogueLua.GetVariable(blossom + "Name").asString;

                BlossomData.BlossomGrowth growth = (BlossomData.BlossomGrowth)System.Enum.Parse(typeof(BlossomData.BlossomGrowth), DialogueLua.GetVariable(blossom + "Growth").asString);
                string color = DialogueLua.GetVariable(blossom + "Color").asString;
                Sprite portrait;
                if (growth == BlossomData.BlossomGrowth.Adult)
                {
                    portrait = Resources.Load <BlossomColor>("BlossomColors/" + color).AdultPortrait;
                    print("BlossomColors/" + color);
                }
                else
                {
                    portrait = Resources.Load <BlossomColor>("BlossomColors/" + color).BabyPortrait;
                }

                BlossomSelectionUI ui = Instantiate(BlossomUIPrefab, BlossomContainer);

                ui.SelectBtn.enabled = true;

                ui.BlossomNameText.text   = name;
                ui.BlossomPortrait.sprite = portrait;


                if (pMinAgility == -1 || pMaxAgility == -1)
                {
                    ui.AgilityAmtText.text = agility.ToString("F2") + " / N/A";
                }
                else
                {
                    ui.AgilityAmtText.text = agility.ToString("F2") + " / " + pMinAgility + "-" + pMaxAgility;
                    if (agility < pMinAgility || agility > pMaxAgility)
                    {
                        ui.SelectBtn.enabled    = false;
                        ui.AgilityAmtText.color = Color.red;
                    }
                    else
                    {
                        ui.AgilityAmtText.color = new Color(0, 0.5f, 0);
                    }
                }


                if (pMinStrength == -1 || pMaxStrength == -1)
                {
                    ui.StrengthAmtText.text = strength.ToString("F2") + " / N/A";
                }
                else
                {
                    ui.StrengthAmtText.text = strength.ToString("F2") + " / " + pMinStrength + "-" + pMaxStrength;

                    if (strength < pMinStrength || strength > pMaxStrength)
                    {
                        ui.SelectBtn.enabled     = false;
                        ui.StrengthAmtText.color = Color.red;
                    }
                    else
                    {
                        ui.StrengthAmtText.color = new Color(0, 0.5f, 0);
                    }
                }

                if (pMinIntellect == -1 || pMaxIntellect == -1)
                {
                    ui.IntellectAmtText.text = intellect.ToString("F2") + " / N/A";
                }
                else
                {
                    ui.IntellectAmtText.text = intellect.ToString("F2") + " / " + pMinIntellect + "-" + pMaxIntellect;

                    if (intellect < pMinIntellect || intellect > pMaxIntellect)
                    {
                        ui.SelectBtn.enabled      = false;
                        ui.IntellectAmtText.color = Color.red;
                    }
                    else
                    {
                        ui.IntellectAmtText.color = new Color(0, 0.5f, 0);
                    }
                }


                if (pMinCharm == -1 || pMaxCharm == -1)
                {
                    ui.CharmAmtText.text = charm.ToString("F2") + " / N/A";
                }
                else
                {
                    ui.CharmAmtText.text = charm.ToString("F2") + " / " + pMinCharm + "-" + pMaxCharm;
                    if (charm < pMinCharm || charm > pMaxCharm)
                    {
                        ui.SelectBtn.enabled  = false;
                        ui.CharmAmtText.color = Color.red;
                    }
                    else
                    {
                        ui.CharmAmtText.color = new Color(0, 0.5f, 0);
                    }
                }

                if (pregnant)
                {
                    ui.SelectBtn.enabled = false;

                    ui.PregnantIcon.enabled = true;
                }
                else
                {
                    ui.PregnantIcon.enabled = false;
                }

                if (hungry)
                {
                    ui.HungryIcon.enabled = true;
                }
                else
                {
                    ui.HungryIcon.enabled = false;
                }

                if (fatigued)
                {
                    ui.FatiguedIcon.enabled = true;
                }
                else
                {
                    ui.FatiguedIcon.enabled = false;
                }

                ui.SelectBtn.onClick.AddListener(
                    delegate()
                {
                    BlossomCompetitionManager.Instance.SetBlossom(blossom);
                    ShowConfirmationWindow();
                }
                    );
            }

            BackBtn.onClick.AddListener(
                delegate()
            {
                Close();
                prevWindow.Open(pTiers, pCompetition);
            }
                );

            GetComponent <WindowToggle>().Open();
        }
 public Variable FindVariableInDatabase(int variableIndex)
 {
     return((database == null) ? null : database.variables.Find(x => string.Equals(DialogueLua.StringToTableIndex(x.Name), watchableVariableNames[variableIndex])));
 }
 /// <summary>
 /// checks for an internal lua variable of the given audio clip name to see if it's been played already.
 /// returns true if yes, false if no or not found
 /// </summary>
 /// <param name="audioClipName">audio clip name to test</param>
 /// <returns></returns>
 private bool hasPlayedAlready(string audioClipName)
 {
     return(DialogueLua.GetVariable(this.buildOnceVarName(audioClipName)).asBool);
 }
Beispiel #20
0
        public void OnApplyPersistentData()
        {
            TargetData = GetComponent <NPCData>();

            VariableName                   = "NPC" + TargetData.NPCID;
            TargetData.Met                 = DialogueLua.GetVariable(VariableName + "Met").asBool;
            TargetData.GreetedToday        = DialogueLua.GetVariable(VariableName + "GreetedToday").asBool;
            TargetData.CurrentAffection    = DialogueLua.GetVariable(VariableName + "CurrentAffection").asFloat;
            TargetData.CurrentAcquaintance = DialogueLua.GetVariable(VariableName + "CurrentAcquaintance").asFloat;
            if (DialogueLua.DoesVariableExist(VariableName + "CurrentLevel"))
            {
                TargetData.CurrentLevel = DialogueLua.GetVariable(VariableName + "CurrentLevel").asString;
            }
            if (DialogueLua.DoesVariableExist(VariableName + "CurrentX"))
            {
                TargetData.transform.position = new Vector2(DialogueLua.GetVariable(VariableName + "CurrentX").asFloat, DialogueLua.GetVariable(VariableName + "CurrentY").asFloat);
            }
        }
Beispiel #21
0
 public override void OnEnter()
 {
     if ((actor1Name != null) && (actor2Name != null) && (relationshipType != null) && (storeResult != null))
     {
         try {
             storeResult.Value = Lua.Run(string.Format("return GetRelationship(Actor[\"{0}\"], Actor[\"{1}\"], \"{2}\")",
                                                       DialogueLua.StringToTableIndex(actor1Name.Value), DialogueLua.StringToTableIndex(actor2Name.Value),
                                                       relationshipType.Value), DialogueDebug.LogInfo).AsFloat;
         } catch (System.NullReferenceException) {
         }
     }
     Finish();
 }
 //Set player gender to choose correct audio files for player dialogue
 public void setPlayerGender(bool gender)
 {
     DialogueLua.SetVariable("QuestVariables.IsPlayerMale", gender);
 }
Beispiel #23
0
        public bool IsBlossomValid(string pID)
        {
            if (CurrentCompetition == null)
            {
                Debug.LogError("No competition selected");
                return(false);
            }
            if (CurrentTier.Tier == -1)
            {
                Debug.LogError("No valid tier selected");
                return(false);
            }


            if (CurrentCompetition.Stat1 != Stat.StatName.Null)
            {
                float minValue = -1;
                float maxValue = -1;

                switch (CurrentCompetition.Stat1)
                {
                case Stat.StatName.Strength:
                    minValue = CurrentTier.MinStrength;
                    maxValue = CurrentTier.MaxStrength;
                    break;

                case Stat.StatName.Agility:
                    minValue = CurrentTier.MinAgility;
                    maxValue = CurrentTier.MaxAgility;
                    break;

                case Stat.StatName.Intellect:
                    minValue = CurrentTier.MinIntellect;
                    maxValue = CurrentTier.MaxIntellect;
                    break;

                case Stat.StatName.Charm:
                    minValue = CurrentTier.MinCharm;
                    maxValue = CurrentTier.MaxCharm;
                    break;

                default:
                    break;
                }
                if (minValue == -1 || maxValue == -1)
                {
                    Debug.LogError("Competition stats not set properly");
                    return(false);
                }
                float blossomValue = DialogueLua.GetVariable(pID + CurrentCompetition.Stat1.ToString() + "Value").asFloat;
                if (blossomValue < minValue || blossomValue > maxValue)
                {
                    return(false);
                }
            }

            if (CurrentCompetition.Stat2 != Stat.StatName.Null)
            {
                float minValue = -1;
                float maxValue = -1;

                switch (CurrentCompetition.Stat2)
                {
                case Stat.StatName.Strength:
                    minValue = CurrentTier.MinStrength;
                    maxValue = CurrentTier.MaxStrength;
                    break;

                case Stat.StatName.Agility:
                    minValue = CurrentTier.MinAgility;
                    maxValue = CurrentTier.MaxAgility;
                    break;

                case Stat.StatName.Intellect:
                    minValue = CurrentTier.MinIntellect;
                    maxValue = CurrentTier.MaxIntellect;
                    break;

                case Stat.StatName.Charm:
                    minValue = CurrentTier.MinCharm;
                    maxValue = CurrentTier.MaxCharm;
                    break;

                default:
                    break;
                }
                if (minValue == -1 || maxValue == -1)
                {
                    Debug.LogError("Competition stats not set properly");
                    return(false);
                }
                float blossomValue = DialogueLua.GetVariable(pID + CurrentCompetition.Stat2.ToString() + "Value").asFloat;
                if (blossomValue < minValue || blossomValue > maxValue)
                {
                    return(false);
                }
            }

            if (CurrentCompetition.Stat3 != Stat.StatName.Null)
            {
                float minValue = -1;
                float maxValue = -1;

                switch (CurrentCompetition.Stat3)
                {
                case Stat.StatName.Strength:
                    minValue = CurrentTier.MinStrength;
                    maxValue = CurrentTier.MaxStrength;
                    break;

                case Stat.StatName.Agility:
                    minValue = CurrentTier.MinAgility;
                    maxValue = CurrentTier.MaxAgility;
                    break;

                case Stat.StatName.Intellect:
                    minValue = CurrentTier.MinIntellect;
                    maxValue = CurrentTier.MaxIntellect;
                    break;

                case Stat.StatName.Charm:
                    minValue = CurrentTier.MinCharm;
                    maxValue = CurrentTier.MaxCharm;
                    break;

                default:
                    break;
                }
                if (minValue == -1 || maxValue == -1)
                {
                    Debug.LogError("Competition stats not set properly");
                    return(false);
                }
                float blossomValue = DialogueLua.GetVariable(pID + CurrentCompetition.Stat3.ToString() + "Value").asFloat;
                if (blossomValue < minValue || blossomValue > maxValue)
                {
                    return(false);
                }
            }

            if (CurrentCompetition.Stat4 != Stat.StatName.Null)
            {
                float minValue = -1;
                float maxValue = -1;

                switch (CurrentCompetition.Stat4)
                {
                case Stat.StatName.Strength:
                    minValue = CurrentTier.MinStrength;
                    maxValue = CurrentTier.MaxStrength;
                    break;

                case Stat.StatName.Agility:
                    minValue = CurrentTier.MinAgility;
                    maxValue = CurrentTier.MaxAgility;
                    break;

                case Stat.StatName.Intellect:
                    minValue = CurrentTier.MinIntellect;
                    maxValue = CurrentTier.MaxIntellect;
                    break;

                case Stat.StatName.Charm:
                    minValue = CurrentTier.MinCharm;
                    maxValue = CurrentTier.MaxCharm;
                    break;

                default:
                    break;
                }
                if (minValue == -1 || maxValue == -1)
                {
                    Debug.LogError("Competition stats not set properly");
                    return(false);
                }
                float blossomValue = DialogueLua.GetVariable(pID + CurrentCompetition.Stat4.ToString() + "Value").asFloat;
                if (blossomValue < minValue || blossomValue > maxValue)
                {
                    return(false);
                }
            }
            return(true);
        }
Beispiel #24
0
    }    //End of Start

    // Update is called once per frame
    void Update()
    {
        //Toggles DebugPanel onscreen
        if (Input.GetKeyDown(KeyCode.F11))
        {
            debugActive = !debugActive;
            debugScreen.GetComponent <Image>().enabled = !this.GetComponent <Image>().enabled;
            konduktööri1DebugText.enabled       = !konduktööri1DebugText.enabled;
            myyjä1DebugText.enabled             = !myyjä1DebugText.enabled;
            myyjä2DebugText.enabled             = !myyjä2DebugText.enabled;
            mummo1DebugText.enabled             = !mummo1DebugText.enabled;
            nuoriNainen1DebugText.enabled       = !nuoriNainen1DebugText.enabled;
            conversationActiveDebugText.enabled = !conversationActiveDebugText.enabled;
        }

        //Sets quest status to innitial.
        if (Input.GetKeyDown(KeyCode.F5) && debugActive)
        {
            DialogueLua.SetVariable("QuestVariables.LipunTarkastus1Done", true);
            DialogueLua.SetVariable("QuestVariables.Tarjoilija1Done", false);
            DialogueLua.SetVariable("QuestVariables.Tarjoilija2Done", false);
            DialogueLua.SetVariable("QuestVariables.Mummo1Done", false);
            DialogueLua.SetVariable("QuestVariables.NuoriNainen1Done", false);
        }

        //Sets quest status to after first talk with myyjä
        if (Input.GetKeyDown(KeyCode.F6) && debugActive)
        {
            DialogueLua.SetVariable("QuestVariables.LipunTarkastus1Done", true);
            DialogueLua.SetVariable("QuestVariables.Tarjoilija1Done", true);
            DialogueLua.SetVariable("QuestVariables.Tarjoilija2Done", false);
            DialogueLua.SetVariable("QuestVariables.Mummo1Done", false);
            DialogueLua.SetVariable("QuestVariables.NuoriNainen1Done", false);
        }

        //Sets quest status to after second talk with myyjä
        if (Input.GetKeyDown(KeyCode.F7) && debugActive)
        {
            DialogueLua.SetVariable("QuestVariables.LipunTarkastus1Done", true);
            DialogueLua.SetVariable("QuestVariables.Tarjoilija1Done", true);
            DialogueLua.SetVariable("QuestVariables.Tarjoilija2Done", true);
            DialogueLua.SetVariable("QuestVariables.Mummo1Done", false);
            DialogueLua.SetVariable("QuestVariables.NuoriNainen1Done", false);
        }

        //Sets quest status adter mummo keskustelu
        if (Input.GetKeyDown(KeyCode.F8) && debugActive)
        {
            DialogueLua.SetVariable("QuestVariables.LipunTarkastus1Done", true);
            DialogueLua.SetVariable("QuestVariables.Tarjoilija1Done", true);
            DialogueLua.SetVariable("QuestVariables.Tarjoilija2Done", true);
            DialogueLua.SetVariable("QuestVariables.Mummo1Done", true);
            DialogueLua.SetVariable("QuestVariables.NuoriNainen1Done", false);
        }

        //Updates debug text fields
        konduktööri1DebugText.text       = "LipunTarkastus1Done: " + DialogueLua.GetVariable("QuestVariables.LipunTarkastus1Done").AsBool;
        myyjä1DebugText.text             = "Myyjä1Done: " + DialogueLua.GetVariable("QuestVariables.Tarjoilija1Done").AsBool;
        myyjä2DebugText.text             = "Myyjä2Done: " + DialogueLua.GetVariable("QuestVariables.Tarjoilija2Done").AsBool;
        mummo1DebugText.text             = "Mummo1Done: " + DialogueLua.GetVariable("QuestVariables.Mummo1Done").AsBool;
        nuoriNainen1DebugText.text       = "NuoriNainen1Done: " + DialogueLua.GetVariable("QuestVariables.NuoriNainen1Done").AsBool;
        conversationActiveDebugText.text = "ConversationActive: " + DialogueLua.GetVariable("QuestVariables.ConversationActive").AsBool;
    }    //End of update
Beispiel #25
0
        float GetBlossomResult(string pID)
        {
            float score = 0;
            //float luck = Random.Range();
            List <Stat.StatName> stats = new List <Stat.StatName>();

            if (CurrentCompetition.Stat1 != Stat.StatName.Null)
            {
                stats.Add(CurrentCompetition.Stat1);
            }
            if (CurrentCompetition.Stat2 != Stat.StatName.Null)
            {
                stats.Add(CurrentCompetition.Stat2);
            }
            if (CurrentCompetition.Stat3 != Stat.StatName.Null)
            {
                stats.Add(CurrentCompetition.Stat3);
            }
            if (CurrentCompetition.Stat4 != Stat.StatName.Null)
            {
                stats.Add(CurrentCompetition.Stat4);
            }

            foreach (Stat.StatName stat in stats)
            {
                float blossomValue     = DialogueLua.GetVariable(pID + stat.ToString() + "Value").asFloat;
                float blossomAffection = DialogueLua.GetVariable(pID + "Affection").asFloat;

                float affectionMultiplier = (blossomAffection / 1000);
                affectionMultiplier = Mathf.Clamp(affectionMultiplier, 0f, maxAffectionLuckMultiplier);

                float genericLuckMultiplier   = Random.Range(0, maxGenericLuckMultiplier);
                float affectionLuckMultiplier = Random.Range(0, affectionMultiplier);

                float affectionLuck  = 0;
                float genericLuck    = 0;
                float totalLuckScore = 0;

                switch (stat)
                {
                case Stat.StatName.Null:
                    break;

                case Stat.StatName.Strength:
                    affectionLuck  = CurrentTier.MaxStrength * affectionLuckMultiplier;
                    genericLuck    = CurrentTier.MaxStrength * genericLuckMultiplier;
                    totalLuckScore = affectionLuck + genericLuck;
                    break;

                case Stat.StatName.Agility:
                    affectionLuck  = CurrentTier.MaxAgility * affectionLuckMultiplier;
                    genericLuck    = CurrentTier.MaxAgility * genericLuckMultiplier;
                    totalLuckScore = affectionLuck + genericLuck;
                    break;

                case Stat.StatName.Intellect:
                    affectionLuck  = CurrentTier.MaxIntellect * affectionLuckMultiplier;
                    genericLuck    = CurrentTier.MaxIntellect * genericLuckMultiplier;
                    totalLuckScore = affectionLuck + genericLuck;
                    break;

                case Stat.StatName.Charm:
                    affectionLuck  = CurrentTier.MaxCharm * affectionLuckMultiplier;
                    genericLuck    = CurrentTier.MaxCharm * genericLuckMultiplier;
                    totalLuckScore = affectionLuck + genericLuck;
                    break;

                default:
                    break;
                }
                totalLuckScore += blossomValue;

                float statScore = Random.Range(blossomValue, totalLuckScore);
                score += statScore;
            }
            return(score);
        }
        public void Open(List <string> pResults, List <string> pBlossoms, int pRank, string pTitle = "", string pPrompt = "")
        {
            BlossomCompetition currentCompetition = BlossomCompetitionManager.Instance.CurrentCompetition;
            CompetitioniTier   currentTier        = BlossomCompetitionManager.Instance.CurrentTier;

            // BlossomColor[] allColors = Resources.LoadAll<BlossomColor>("BlossomColors");


            WinnerText.text = pResults[0];

            BlossomData.BlossomGrowth growth = (BlossomData.BlossomGrowth)System.Enum.Parse(typeof(BlossomData.BlossomGrowth), DialogueLua.GetVariable(pBlossoms[0] + "Growth").asString);
            string color = DialogueLua.GetVariable(pBlossoms[0] + "Color").asString;
            Sprite portrait;

            if (growth == BlossomData.BlossomGrowth.Adult)
            {
                portrait = Resources.Load <BlossomColor>("BlossomColors/" + color).AdultPortrait;
            }
            else
            {
                portrait = Resources.Load <BlossomColor>("BlossomColors/" + color).BabyPortrait;
            }

            WinnerImage.sprite = portrait;



            SecondText.text = pResults[1];

            growth = (BlossomData.BlossomGrowth)System.Enum.Parse(typeof(BlossomData.BlossomGrowth), DialogueLua.GetVariable(pBlossoms[1] + "Growth").asString);
            color  = DialogueLua.GetVariable(pBlossoms[2] + "Color").asString;

            if (growth == BlossomData.BlossomGrowth.Adult)
            {
                portrait = Resources.Load <BlossomColor>("BlossomColors/" + color).AdultPortrait;
            }
            else
            {
                portrait = Resources.Load <BlossomColor>("BlossomColors/" + color).BabyPortrait;
            }


            ThirdText.text = pResults[2];

            growth = (BlossomData.BlossomGrowth)System.Enum.Parse(typeof(BlossomData.BlossomGrowth), DialogueLua.GetVariable(pBlossoms[2] + "Growth").asString);
            color  = DialogueLua.GetVariable(pBlossoms[2] + "Color").asString;

            if (growth == BlossomData.BlossomGrowth.Adult)
            {
                portrait = Resources.Load <BlossomColor>("BlossomColors/" + color).AdultPortrait;
            }
            else
            {
                portrait = Resources.Load <BlossomColor>("BlossomColors/" + color).BabyPortrait;
            }


            for (int i = 3; i < pResults.Count; i++)
            {
                GameObject result = Instantiate(ResultsPrefab, Content);

                growth = (BlossomData.BlossomGrowth)System.Enum.Parse(typeof(BlossomData.BlossomGrowth), DialogueLua.GetVariable(pBlossoms[i] + "Growth").asString);
                color  = DialogueLua.GetVariable(pBlossoms[i] + "Color").asString;

                if (growth == BlossomData.BlossomGrowth.Adult)
                {
                    portrait = Resources.Load <BlossomColor>("BlossomColors/" + color).AdultPortrait;
                }
                else
                {
                    portrait = Resources.Load <BlossomColor>("BlossomColors/" + color).BabyPortrait;
                }

                result.GetComponentInChildren <TextMeshProUGUI>().text = (i + 1) + ": " + pResults[i];
            }

            base.Open(pTitle, pPrompt);
            CloseButton.onClick.AddListener(
                delegate()
            {
                Continue(pRank);
            }
                );
        }
Beispiel #27
0
        void Start()
        {
            Data = GetComponent <BlossomData>();
            if (DialogueLua.DoesVariableExist(Data.ID + "HutX"))
            {
                Data.HutPosition = new Vector2(DialogueLua.GetVariable(Data.ID + "HutX").asFloat, DialogueLua.GetVariable(Data.ID + "HutY").asFloat);
                Data.HutName     = DialogueLua.GetVariable(Data.ID + "HutName").asString;
                Data.Hut         = BlossomManager.Instance.GetHutObject(Data.HutName);
            }


            GetComponent <BlossomAppearance>().SetAppearance(Data.Growth, Data.Color);
        }
Beispiel #28
0
 // Update is called once per frame
 void Update()
 {
     //IF statement for enabling interaction for Tarjoilija for inbetween Konduktööri and Mummo
     if (DialogueLua.GetVariable("QuestVariables.LipunTarkastus1Done").AsBool&& DialogueLua.GetVariable("QuestVariables.KuulutusDone").AsBool&& DialogueLua.GetVariable("QuestVariables.Tarjoilija2Done").AsBool == false)
     {
         gameObject.GetComponent <Usable>().enabled = true;
         gameObject.GetComponentInChildren <BoxCollider>().enabled = true;
     }
     else
     {
         gameObject.GetComponentInChildren <Usable>().enabled      = false;
         gameObject.GetComponentInChildren <BoxCollider>().enabled = false;
     }
 }
        public string CreateChildBlossom(string pParent1, string pParent2)
        {
            //CREATE BLOSSOM

            BlossomData newBlossom = Instantiate(BlossomPrefab, transform);

            newBlossom.ID = "Blossom" + CurrentBlossomID.ToString();
            string ID = newBlossom.ID;

            CurrentBlossomID += 1;
            newBlossom.Age    = 0;
            newBlossom.Name   = GetRandomBlossomName();



            newBlossom.Parent1 = pParent1;
            newBlossom.Parent2 = pParent2;

            newBlossom.Energy = 2;

            //STATS
            //Agility
            newBlossom.Agility.Value         = 0;
            newBlossom.Agility.Potential     = SetChildStat(pParent1, pParent2, "AgilityPotential");
            newBlossom.Agility.LearningSpeed = SetChildStat(pParent1, pParent2, "AgilityLearningSpeed");
            //Strength
            newBlossom.Strength.Value         = 0;
            newBlossom.Strength.Potential     = SetChildStat(pParent1, pParent2, "StrengthPotential");
            newBlossom.Strength.LearningSpeed = SetChildStat(pParent1, pParent2, "StrengthLearningSpeed");
            //Intellect
            newBlossom.Intellect.Value         = 0;
            newBlossom.Intellect.Potential     = SetChildStat(pParent1, pParent2, "IntellectPotential");
            newBlossom.Intellect.LearningSpeed = SetChildStat(pParent1, pParent2, "IntellectLearningSpeed");
            //Charm
            newBlossom.Charm.Value         = 0;
            newBlossom.Charm.Potential     = SetChildStat(pParent1, pParent2, "CharmPotential");
            newBlossom.Charm.LearningSpeed = SetChildStat(pParent1, pParent2, "CharmLearningSpeed");


            //TRAITS
            string dominantParent;
            int    rand = Random.Range(0, 100);

            if (rand <= 50)
            {
                dominantParent = pParent2;
            }
            else
            {
                dominantParent = pParent1;
            }
            Dictionary <Trait, int> parentTraits = new Dictionary <Trait, int>();

            List <Trait> parent1Traits      = new List <Trait>();
            int          parent1TraitAmount = DialogueLua.GetVariable(pParent1 + "TraitAmount").asInt;

            for (int i = 0; i < parent1TraitAmount; i++)
            {
                string traitName = DialogueLua.GetVariable(pParent1 + "Trait" + i).asString;
                parent1Traits.Add(Resources.Load <Trait>("BlossomTraits/" + traitName));
            }

            List <Trait> parent2Traits      = new List <Trait>();
            int          parent2TraitAmount = DialogueLua.GetVariable(pParent2 + "TraitAmount").asInt;

            for (int i = 0; i < parent1TraitAmount; i++)
            {
                string traitName = DialogueLua.GetVariable(pParent2 + "Trait" + i).asString;
                parent1Traits.Add(Resources.Load <Trait>("BlossomTraits/" + traitName));
            }

            List <Trait> dominantTraits    = new List <Trait>();
            List <Trait> nonDominantTraits = new List <Trait>();

            if (dominantParent == pParent1)
            {
                dominantTraits    = parent1Traits;
                nonDominantTraits = parent2Traits;
            }
            else
            {
                dominantTraits    = parent2Traits;
                nonDominantTraits = parent1Traits;
            }

            foreach (Trait trait in dominantTraits)
            {
                if (!parentTraits.ContainsKey(trait))
                {
                    parentTraits.Add(trait, trait.Probabilty * 2);
                }
            }

            foreach (Trait trait in nonDominantTraits)
            {
                if (!parentTraits.ContainsKey(trait))
                {
                    parentTraits.Add(trait, trait.Probabilty);
                }
                else
                {
                    parentTraits[trait] += trait.Probabilty;
                }
            }

            rand = Random.Range(1, 2);
            for (int i = 0; i < rand; i++)
            {
                Trait trait = WeightedRandomizer.From(parentTraits).TakeOne();
                if (!newBlossom.Traits.Contains(trait))
                {
                    newBlossom.Traits.Add(trait);
                }
            }



            //STAT POTENTIAL BONUS DISTRIBUTION
            for (int potentialBonus = 10; potentialBonus > 0; potentialBonus--)
            {
                List <string> availableStats = new List <string>();
                availableStats.Add("AgilityPotential");
                availableStats.Add("StrengthPotential");
                availableStats.Add("IntellectPotential");
                availableStats.Add("CharmPotential");

                if (availableStats.Count > 0)
                {
                    rand = Random.Range(0, availableStats.Count);
                    float currentVal = DialogueLua.GetVariable(newBlossom + availableStats[rand]).asFloat;
                    DialogueLua.SetVariable(newBlossom + availableStats[rand], currentVal + 1);
                }
                else
                {
                    break;
                }
            }

            //STAT LEARNING SPEED BONUS DISTRIBUTION
            for (int learningSpeedBonus = 2; learningSpeedBonus > 0; learningSpeedBonus--)
            {
                List <string> availableStats = new List <string>();

                availableStats.Add("AgilityLearningSpeed");
                availableStats.Add("StrengthLearningSpeed");
                availableStats.Add("IntellectLearningSpeed");
                availableStats.Add("CharmLearningSpeed");

                if (availableStats.Count > 0)
                {
                    rand = Random.Range(0, availableStats.Count);
                    float currentVal = DialogueLua.GetVariable(newBlossom + availableStats[rand]).asFloat;
                    DialogueLua.SetVariable(newBlossom + availableStats[rand], currentVal + 0.1f);
                }
                else
                {
                    break;
                }
            }


            string parent1Color = DialogueLua.GetVariable(pParent1 + "Color").asString;
            string parent2Color = DialogueLua.GetVariable(pParent2 + "Color").asString;

            BlossomColorMix[] allMixes    = Resources.LoadAll <BlossomColorMix>("BlossomColorMixes");
            BlossomColorMix   matchingMix = null;

            foreach (BlossomColorMix mix in allMixes)
            {
                if ((mix.Input1.Name == parent1Color && mix.Input2.Name == parent2Color) || (mix.Input1.Name == parent2Color && mix.Input2.Name == parent1Color))
                {
                    matchingMix = mix;
                }
            }
            if (matchingMix != null)
            {
                Dictionary <string, int> outputs = new Dictionary <string, int>();
                foreach (ColorOutput output in matchingMix.Outputs)
                {
                    outputs.Add(output.Output.Name, output.Output.Probability);
                }
                string color = WeightedRandomizer.From(outputs).TakeOne();
                newBlossom.Color = color;
            }
            else
            {
                Dictionary <string, int> parentColors = new Dictionary <string, int>();
                BlossomColor             color1       = Resources.Load <BlossomColor>("BlossomColors/" + parent1Color);
                BlossomColor             color2       = Resources.Load <BlossomColor>("BlossomColors/" + parent2Color);

                parentColors.Add(color1.Name, color1.Probability);
                if (!parentColors.ContainsKey(color2.Name))
                {
                    parentColors.Add(color2.Name, color2.Probability);
                }
                string color = WeightedRandomizer.From(parentColors).TakeOne();
                newBlossom.Color = color;
            }


            //DESTROY OBJECT
            Destroy(newBlossom.gameObject);
            return(ID);
        }
Beispiel #30
0
 private void Sync()
 {
     if (dialogueSystemVariable == null || string.IsNullOrEmpty(dialogueSystemVariable.Value))
     {
         LogWarning(DialogueDebug.Prefix + ": Dialogue System Variable isn't assigned or is blank.");
     }
     else if (playMakerVariable == null)
     {
         LogWarning(DialogueDebug.Prefix + ": PlayMaker Variable isn't assigned or is blank.");
     }
     else
     {
         if (toDialogueSystem != null && toDialogueSystem.Value == true)
         {
             DialogueLua.SetVariable(dialogueSystemVariable.Value, DialogueSystemPlayMakerTools.ArrayToString(playMakerVariable.Values));
         }
         else
         {
             playMakerVariable.Values = DialogueSystemPlayMakerTools.StringToArray(DialogueLua.GetVariable(dialogueSystemVariable.Value).AsString, VariableType.GameObject, searchSceneObjects.Value, searchPrefabs.Value);
         }
     }
 }