Example #1
0
    /// <summary>
    ///   Setup the main menu.
    /// </summary>
    private void RunMenuSetup()
    {
        Background      = GetNode <TextureRect>("Background");
        guiAnimations   = GetNode <AnimationPlayer>("GUIAnimations");
        thriveLogo      = GetNode <TextureRect>(ThriveLogoPath);
        newGameButton   = GetNode <Button>(NewGameButtonPath);
        freebuildButton = GetNode <Button>(FreebuildButtonPath);

        MenuArray?.Clear();

        // Get all of menu items
        MenuArray = GetTree().GetNodesInGroup("MenuItem");

        if (MenuArray == null)
        {
            GD.PrintErr("Failed to find all the menu items!");
            return;
        }

        RandomizeBackground();

        options = GetNode <OptionsMenu>("OptionsMenu");
        saves   = GetNode <SaveManagerGUI>("SaveManagerGUI");

        // Load settings
        if (Settings.Instance == null)
        {
            GD.PrintErr("Failed to initialize settings.");
        }

        // Set initial menu
        SwitchMenu();
    }
Example #2
0
    /// <summary>
    ///   Setup the main menu.
    /// </summary>
    private void RunMenuSetup()
    {
        Background = GetNode <TextureRect>("Background");

        if (MenuArray != null)
        {
            MenuArray.Clear();
        }

        // Get all of menu items
        MenuArray = GetTree().GetNodesInGroup("MenuItem");

        if (MenuArray == null)
        {
            GD.PrintErr("Failed to find all the menu items!");
            return;
        }

        RandomizeBackground();

        options = GetNode <OptionsMenu>("OptionsMenu");

        // Load settings
        options.SetSettingsFrom(Settings.Instance);

        // Set initial menu to the current menu index
        SetCurrentMenu(CurrentMenuIndex, false);
    }
Example #3
0
 public void ClearData()
 {
     colors.Clear();
     color1.Modulate = initialColor;
     color2.Modulate = initialColor;
     color3.Modulate = initialColor;
 }
Example #4
0
 public void Stop()
 {
     Players.Clear();
     List.Clear();
     Turn            = 0;
     Action.Disabled = true;
 }
    private void GenerateDominanceMask()
    {
        DominanceMask.Clear();
        RandomNumberGenerator rng = (RandomNumberGenerator) new RandomNumberGenerator();

        for (int i = 0; i < MaternalChromosomeSet.Count; i++)
        {
            rng.Randomize();
            DominanceMask.Add(rng.RandiRange(0, 1));
        }
    }
Example #6
0
 public override void _Process(float delta)
 {
     for (int i = 0; i < MeatArray.Count; i++)
     {
         if (!MeatToRemove.Contains(i))
         {
             temp.Add(MeatArray[i]);
         }
     }
     MeatArray.Clear();
     for (int i = 0; i < temp.Count; i++)
     {
         MeatArray.Add(temp[i]);
     }
     for (int i = 0; i < MeatToAdd.Count; i++)
     {
         MeatArray.Add(MeatToAdd[i]);
     }
     MeatToRemove.Clear();
     MeatToAdd.Clear();
     temp.Clear();
     Multimesh.InstanceCount = MeatArray.Count;
     for (int i = 0; i < MeatArray.Count; i++)
     {
         MeatArray[i].timeOnGround += TimeMultiplier * delta;
         if (MeatArray[i].timeOnGround >= MaxTimeOnGround)
         {
             MeatArray[i].decay = 1;
         }
         if (MeatArray[i].EatersCount > 0 || MeatArray[i].decay > 0)
         {
             Vector3 eatRate = (Vector3) new Vector3(1, 1, 1);
             eatRate *= (MeatArray[i].EatersCount + MeatArray[i].decay) * 0.5f * TimeMultiplier * delta;
             MeatArray[i].meatSpatial.Scale -= eatRate;
             if (MeatArray[i].meatSpatial.Scale.x < 0.05f)
             {
                 MeatArray[i].meatGone = true;
                 MeatArray[i].Collider.QueueFree();
                 AddChild(MeatArray[i].meatSpatial);
                 MeatArray[i].meatSpatial.QueueFree();
                 MeatToRemove.Add(i);
             }
         }
         Multimesh.SetInstanceTransform(i, MeatArray[i].meatSpatial.Transform);
     }
 }
Example #7
0
    /// <summary>
    ///   Setup the main menu.
    /// </summary>
    private void RunMenuSetup()
    {
        Background           = GetNode <TextureRect>("Background");
        guiAnimations        = GetNode <AnimationPlayer>("GUIAnimations");
        thriveLogo           = GetNode <TextureRect>(ThriveLogoPath);
        newGameButton        = GetNode <Button>(NewGameButtonPath);
        freebuildButton      = GetNode <Button>(FreebuildButtonPath);
        creditsContainer     = GetNode <Control>(CreditsContainerPath);
        credits              = GetNode <CreditsScroll>(CreditsScrollPath);
        licensesDisplay      = GetNode <LicensesDisplay>(LicensesDisplayPath);
        storeLoggedInDisplay = GetNode <Label>(StoreLoggedInDisplayPath);
        modManager           = GetNode <ModManager>(ModManagerPath);

        MenuArray?.Clear();

        // Get all of menu items
        MenuArray = GetTree().GetNodesInGroup("MenuItem");

        if (MenuArray == null)
        {
            GD.PrintErr("Failed to find all the menu items!");
            return;
        }

        RandomizeBackground();

        options         = GetNode <OptionsMenu>("OptionsMenu");
        saves           = GetNode <SaveManagerGUI>("SaveManagerGUI");
        gles2Popup      = GetNode <CustomConfirmationDialog>(GLES2PopupPath);
        modLoadFailures = GetNode <ErrorDialog>(ModLoadFailuresPath);

        // Set initial menu
        SwitchMenu();

        // Easter egg message
        thriveLogo.RegisterToolTipForControl("thriveLogoEasterEgg", "mainMenu");

        if (OS.GetCurrentVideoDriver() == OS.VideoDriver.Gles2 && !IsReturningToMenu)
        {
            gles2Popup.PopupCenteredShrink();
        }

        UpdateStoreNameLabel();
    }
Example #8
0
    /// <summary>
    ///   Setup the main menu.
    /// </summary>
    private void RunMenuSetup()
    {
        Background      = GetNode <TextureRect>("Background");
        guiAnimations   = GetNode <AnimationPlayer>("GUIAnimations");
        thriveLogo      = GetNode <TextureRect>(ThriveLogoPath);
        newGameButton   = GetNode <Button>(NewGameButtonPath);
        freebuildButton = GetNode <Button>(FreebuildButtonPath);

        MenuArray?.Clear();

        // Get all of menu items
        MenuArray = GetTree().GetNodesInGroup("MenuItem");

        if (MenuArray == null)
        {
            GD.PrintErr("Failed to find all the menu items!");
            return;
        }

        RandomizeBackground();

        options    = GetNode <OptionsMenu>("OptionsMenu");
        saves      = GetNode <SaveManagerGUI>("SaveManagerGUI");
        gles2Popup = GetNode <AcceptDialog>(GLES2PopupPath);

        // Load settings
        if (Settings.Instance == null)
        {
            GD.PrintErr("Failed to initialize settings.");
        }

        // Set initial menu
        SwitchMenu();

        // Easter egg message
        ToolTipHelper.RegisterToolTipForControl(
            thriveLogo, toolTipCallbacks, ToolTipManager.Instance.GetToolTip("thriveLogoEasterEgg", "mainMenu"));

        if (OS.GetCurrentVideoDriver() == OS.VideoDriver.Gles2 && !IsReturningToMenu)
        {
            gles2Popup.PopupCenteredMinsize();
        }
    }
Example #9
0
        public void Run(Dictionary test)
        {
            if (Engine.EditorHint)
            {
                Test = (Test)((CSharpScript)test["script"]).New();
            }
            else
            {
                Test = (Test)ResourceLoader.Load <CSharpScript>((string)test["path"]).New();
            }

            //Test = WAT.Test.CreateInstance((CSharpScript) test["script"]);
            TestCase     = (Node)Case.New(Test, test["path"]);
            Test.Assert  = this.Assertions;
            Test.Watcher = this._Watcher;
            Test.Yielder = this._Yielder;
            Methods.Clear();
            if (test.Contains("method"))
            {
                Methods.Add(test["method"]);
            }
            else
            {
                foreach (Dictionary method in Test.GetScriptMethodListWithArgs())
                {
                    Methods.Add(method);
                }
            }

            if (Methods.Count == 0)
            {
                GD.PushWarning("No Tests found in " + test["path"] + "");
                CallDeferred("Complete");
            }

            Test.Connect(nameof(Test.Described), TestCase, "_on_test_method_described");
            Assertions.Connect(nameof(Assertions.Asserted), TestCase, "_on_asserted");
            Assertions.Connect(nameof(Assertions.Asserted), Test, nameof(Test.OnLastAssertion));
            AddChild(Test);
            Start();
        }
    public void ArtificialCombine(Godot.Collections.Array initialValues, float geneticVariation)
    {
        if (initialValues.Count == 15)
        {
            MaternalChromosomeSet.Clear();
            PaternalChromosomeSet.Clear();
        }
        else
        {
            return;
        }
        RandomNumberGenerator rng = (RandomNumberGenerator) new RandomNumberGenerator();

        for (int i = 0; i < initialValues.Count; i++)
        {
            rng.Randomize();
            MaternalChromosomeSet.Add(NormalizeValue((float)initialValues[i] + rng.RandfRange(-geneticVariation, geneticVariation)));
            rng.Randomize();
            PaternalChromosomeSet.Add(NormalizeValue((float)initialValues[i] + rng.RandfRange(-geneticVariation, geneticVariation)));
        }
        CombineSets();
        GenerateDominanceMask();
    }
Example #11
0
    public void RefreshData(int id)
    {
        Godot.Collections.Dictionary jsonDictionary = this.GetParent().GetParent().Call("ReadData", "Class") as Godot.Collections.Dictionary;
        Godot.Collections.Dictionary classData      = jsonDictionary["class" + id] as Godot.Collections.Dictionary;
        Godot.Collections.Dictionary classSkillList = classData["skill_list"] as Godot.Collections.Dictionary;

        jsonDictionary = this.GetParent().GetParent().Call("ReadData", "System") as Godot.Collections.Dictionary;
        Godot.Collections.Dictionary systemStatsData = jsonDictionary["stats"] as Godot.Collections.Dictionary;

        jsonDictionary = this.GetParent().GetParent().Call("ReadData", "Skill") as Godot.Collections.Dictionary;

        GetNode <LineEdit>("NameLabel/NameText").Text = classData["name"] as string;
        string icon = classData["icon"] as string;

        if (icon != "")
        {
            GetNode <Sprite>("IconLabel/IconSprite").Texture = GD.Load(classData["icon"] as string) as Godot.Texture;
        }
        GetNode <LineEdit>("ExpLabel/ExpText").Text = classData["experience"] as string;

        GetNode <ItemList>("StatsLabel/StatsContainer/DataContainer/StatsListContainer/StatsList").Clear();
        GetNode <ItemList>("StatsLabel/StatsContainer/DataContainer/FormulaListContainer/FormulaList").Clear();
        for (int i = 0; i < systemStatsData.Count; i++)
        {
            string statName = systemStatsData[i.ToString()] as string;
            Godot.Collections.Dictionary classStatFormula = classData["stat_list"] as Godot.Collections.Dictionary;
            string statFormula = "";
            if (classStatFormula.Contains(statName))
            {
                statFormula = classStatFormula[statName].ToString();
            }
            else
            {
                statFormula = "level * 5";
            }
            GetNode <ItemList>("StatsLabel/StatsContainer/DataContainer/StatsListContainer/StatsList").AddItem(statName);
            GetNode <ItemList>("StatsLabel/StatsContainer/DataContainer/FormulaListContainer/FormulaList").AddItem(statFormula);
        }

        GetNode <ItemList>("SkillLabel/SkillContainer/HBoxContainer/SkillListContainer/SkillList").Clear();
        GetNode <ItemList>("SkillLabel/SkillContainer/HBoxContainer/SkillLevelContainer/SkillLevelList").Clear();
        skillListArray.Clear();
        foreach (string element in classSkillList.Keys)
        {
            skillListArray.Add(element);
            Godot.Collections.Dictionary skillData = jsonDictionary["skill" + element] as Godot.Collections.Dictionary;
            string skillName = skillData["name"] as string;
            GetNode <ItemList>("SkillLabel/SkillContainer/HBoxContainer/SkillListContainer/SkillList").AddItem(skillName);
            string level = Convert.ToString(classSkillList[element as string]);
            GetNode <ItemList>("SkillLabel/SkillContainer/HBoxContainer/SkillLevelContainer/SkillLevelList").AddItem(level);
        }

        GetNode <OptionButton>("SkillLabel/AddSkill/SkillLabel/OptionButton").Clear();
        foreach (string element in jsonDictionary.Keys)
        {
            Godot.Collections.Dictionary skillData = jsonDictionary[element] as Godot.Collections.Dictionary;
            string name = Convert.ToString(skillData["name"]);
            GetNode <OptionButton>("SkillLabel/AddSkill/SkillLabel/OptionButton").AddItem(name);
            GetNode <OptionButton>("SkillLabel/AddSkill/SkillLabel/OptionButton").Select(0);
        }
        if (classData.Contains("effects") == true)
        {
            this.ClearEffectList();
            Godot.Collections.Array effectList = classData["effects"] as Godot.Collections.Array;
            foreach (Godot.Collections.Dictionary effect in effectList)
            {
                this.AddEffectList(effect["name"].ToString(), Convert.ToInt32(effect["data_id"]), effect["value1"].ToString(), effect["value2"].ToString());
            }
        }
    }
Example #12
0
    public void RefreshData(int id)
    {
        Godot.Collections.Dictionary jsonDictionary = this.GetParent().GetParent().Call("ReadData", "Enemy") as Godot.Collections.Dictionary;
        Godot.Collections.Dictionary enemyData      = jsonDictionary["enemy" + id] as Godot.Collections.Dictionary;

        jsonDictionary = this.GetParent().GetParent().Call("ReadData", "System") as Godot.Collections.Dictionary;
        Godot.Collections.Dictionary systemStatsData = jsonDictionary["stats"] as Godot.Collections.Dictionary;
        Godot.Collections.Dictionary itemList        = this.GetParent().GetParent().Call("ReadData", "Item") as Godot.Collections.Dictionary;
        Godot.Collections.Dictionary weaponList      = this.GetParent().GetParent().Call("ReadData", "Weapon") as Godot.Collections.Dictionary;
        Godot.Collections.Dictionary armorList       = this.GetParent().GetParent().Call("ReadData", "Armor") as Godot.Collections.Dictionary;

        GetNode <LineEdit>("NameLabel/NameLine").Text = enemyData["name"] as string;
        string graphic = enemyData["graphicImage"] as string;

        if (graphic != "")
        {
            graphicsPath = enemyData["graphicImage"] as string;
            GetNode <Sprite>("GraphicLabel/Graphic").Texture = GD.Load(enemyData["graphicImage"] as string) as Godot.Texture;
        }

        GetNode <ItemList>("StatsLabel/StatsContainer/DataContainer/StatList").Clear();
        GetNode <ItemList>("StatsLabel/StatsContainer/DataContainer/FormulaList").Clear();
        for (int i = 0; i < systemStatsData.Count; i++)
        {
            string statName = systemStatsData[i.ToString()] as string;
            Godot.Collections.Dictionary enemyStatFormula = enemyData["stat_list"] as Godot.Collections.Dictionary;
            string statFormula = "";
            if (enemyStatFormula.Contains(statName))
            {
                statFormula = enemyStatFormula[statName].ToString();
            }
            else
            {
                statFormula = "level * 5";
            }
            GetNode <ItemList>("StatsLabel/StatsContainer/DataContainer/StatList").AddItem(statName);
            GetNode <ItemList>("StatsLabel/StatsContainer/DataContainer/FormulaList").AddItem(statFormula);
        }

        Godot.Collections.Dictionary dropList = enemyData["drop_list"] as Godot.Collections.Dictionary;

        GetNode <ItemList>("DropsLabel/DropsContainer/VBoxContainer/HBoxContainer/DropsList").Clear();
        GetNode <ItemList>("DropsLabel/DropsContainer/VBoxContainer/HBoxContainer/ChanceList").Clear();
        dropIdArray.Clear();
        foreach (string drop in dropList.Keys)
        {
            string kind    = drop[0].ToString();
            string kind_id = drop.Remove(0, 1);
            switch (kind)
            {
            case "i":
                dropIdArray.Add(drop);
                Godot.Collections.Dictionary itemData = itemList["item" + kind_id] as Godot.Collections.Dictionary;
                GetNode <ItemList>("DropsLabel/DropsContainer/VBoxContainer/HBoxContainer/DropsList").AddItem(itemData["name"].ToString());
                break;

            case "w":
                dropIdArray.Add(drop);
                Godot.Collections.Dictionary weaponData = weaponList["weapon" + kind_id] as Godot.Collections.Dictionary;
                GetNode <ItemList>("DropsLabel/DropsContainer/VBoxContainer/HBoxContainer/DropsList").AddItem(weaponData["name"].ToString());
                break;

            case "a":
                dropIdArray.Add(drop);
                Godot.Collections.Dictionary armorData = armorList["armor" + kind_id] as Godot.Collections.Dictionary;
                GetNode <ItemList>("DropsLabel/DropsContainer/VBoxContainer/HBoxContainer/DropsList").AddItem(armorData["name"].ToString());
                break;
            }
            GetNode <ItemList>("DropsLabel/DropsContainer/VBoxContainer/HBoxContainer/ChanceList").AddItem(dropList[drop].ToString());
        }
        GetNode <SpinBox>("ExpLabel/ExpSpin").Value   = Convert.ToInt32(enemyData["experience"]);
        GetNode <SpinBox>("GoldLabel/GoldSpin").Value = Convert.ToInt32(enemyData["money"]);

        if (enemyData.Contains("effects") == true)
        {
            this.ClearEffectList();
            Godot.Collections.Array effectList = enemyData["effects"] as Godot.Collections.Array;
            foreach (Godot.Collections.Dictionary effect in effectList)
            {
                this.AddEffectList(effect["name"].ToString(), Convert.ToInt32(effect["data_id"]), effect["value1"].ToString(), effect["value2"].ToString());
            }
        }
    }
Example #13
0
 private void _on_CancelInitialEquipButton_pressed()
 {
     initialEquipEdit = -1;
     equipEditArray.Clear();
     GetNode <WindowDialog>("InitialEquipLabel/InitialEquipChange").Hide();
 }
Example #14
0
    public void RefreshData(int id)
    {
        Godot.Collections.Dictionary jsonDictionary = this.GetParent().GetParent().Call("ReadData", "Character") as Godot.Collections.Dictionary;
        Godot.Collections.Dictionary charaData      = jsonDictionary["chara" + id] as Godot.Collections.Dictionary;
        GetNode <OptionButton>("CharacterButton").SetItemText(id, charaData["name"].ToString());
        GetNode <LineEdit>("NameLabel/NameText").Text = charaData["name"].ToString();
        string face = charaData["faceImage"].ToString();

        if (face != "")
        {
            facePath = charaData["faceImage"].ToString();
            GetNode <Sprite>("FaceLabel/FaceSprite").Texture = GD.Load(charaData["faceImage"].ToString()) as Godot.Texture;
        }
        if (charaData.Contains("description"))
        {
            GetNode <TextEdit>("DescLabel/DescText").Text = charaData["description"].ToString();
        }
        else
        {
            GetNode <TextEdit>("DescLabel/DescText").Text = "";
        }
        GetNode <SpinBox>("InitLevelLabel/InitLevelText").Value = Convert.ToInt32(charaData["initialLevel"]);
        GetNode <SpinBox>("MaxLevelLabel/MaxLevelText").Value   = Convert.ToInt32(charaData["maxLevel"]);

        jsonDictionary = this.GetParent().GetParent().Call("ReadData", "System") as Godot.Collections.Dictionary;
        Godot.Collections.Dictionary wtypeDictionary      = jsonDictionary["weapons"] as Godot.Collections.Dictionary;
        Godot.Collections.Dictionary atypeDictionary      = jsonDictionary["armors"] as Godot.Collections.Dictionary;
        Godot.Collections.Dictionary equipSlotsDictionary = jsonDictionary["slots"] as Godot.Collections.Dictionary;

        Godot.Collections.Dictionary etypeDictionary = charaData["equip_types"] as Godot.Collections.Dictionary;
        GetNode <ItemList>("EquipLabel/EquipContainer/EquipContainer/EquipList").Clear();
        equipIdArray.Clear();
        string equip_name;

        foreach (string equip in etypeDictionary.Keys)
        {
            string kind    = equip[0].ToString();
            string type_id = etypeDictionary[equip].ToString();
            equipIdArray.Add(Convert.ToInt32(etypeDictionary[equip]));
            switch (kind)
            {
            case "w":
                string w_id = equip.Remove(0, 1);
                equip_name = "W: " + wtypeDictionary[type_id].ToString();
                GetNode <ItemList>("EquipLabel/EquipContainer/EquipContainer/EquipList").AddItem(equip_name);
                break;

            case "a":
                string a_id = equip.Remove(0, 1);
                equip_name = "A: " + atypeDictionary[type_id].ToString();
                GetNode <ItemList>("EquipLabel/EquipContainer/EquipContainer/EquipList").AddItem(equip_name);
                break;
            }
        }

        Godot.Collections.Dictionary weaponList = this.GetParent().GetParent().Call("ReadData", "Weapon") as Godot.Collections.Dictionary;
        Godot.Collections.Dictionary armorList  = this.GetParent().GetParent().Call("ReadData", "Armor") as Godot.Collections.Dictionary;

        GetNode <ItemList>("InitialEquipLabel/PanelContainer/TypeContainer/TypeList").Clear();
        GetNode <ItemList>("InitialEquipLabel/PanelContainer/TypeContainer/EquipList").Clear();
        Godot.Collections.Dictionary initialEquipData = charaData["initial_equip"] as Godot.Collections.Dictionary;
        initialEquipIdArray.Clear();
        foreach (string equip in equipSlotsDictionary.Keys)
        {
            GetNode <ItemList>("InitialEquipLabel/PanelContainer/TypeContainer/TypeList").AddItem(equipSlotsDictionary[equip].ToString());
            string kind    = equip[0].ToString();
            int    kind_id = Convert.ToInt32(equip.Remove(0, 1));

            switch (kind)
            {
            case "w":
                int w_id = -1;
                if (kind_id < initialEquipData.Keys.Count)
                {
                    w_id = Convert.ToInt32(initialEquipData[kind_id.ToString()]);
                }

                initialEquipIdArray.Add(w_id);
                if (w_id >= 0)
                {
                    Godot.Collections.Dictionary weaponData = weaponList["weapon" + w_id] as Godot.Collections.Dictionary;
                    GetNode <ItemList>("InitialEquipLabel/PanelContainer/TypeContainer/EquipList").AddItem(weaponData["name"].ToString());
                }
                else
                {
                    GetNode <ItemList>("InitialEquipLabel/PanelContainer/TypeContainer/EquipList").AddItem("None");
                }
                break;

            case "a":
                int a_id = -1;
                if (kind_id < initialEquipData.Keys.Count)
                {
                    a_id = Convert.ToInt32(initialEquipData[kind_id.ToString()]);
                }

                initialEquipIdArray.Add(a_id);
                if (a_id >= 0)
                {
                    Godot.Collections.Dictionary armorData = armorList["armor" + a_id] as Godot.Collections.Dictionary;
                    GetNode <ItemList>("InitialEquipLabel/PanelContainer/TypeContainer/EquipList").AddItem(armorData["name"].ToString());
                }
                else
                {
                    GetNode <ItemList>("InitialEquipLabel/PanelContainer/TypeContainer/EquipList").AddItem("None");
                }
                break;
            }
        }

        jsonDictionary = this.GetParent().GetParent().Call("ReadData", "Class") as Godot.Collections.Dictionary;
        for (int i = 0; i < jsonDictionary.Count; i++)
        {
            Godot.Collections.Dictionary classData = jsonDictionary["class" + i] as Godot.Collections.Dictionary;
            if (i > GetNode <OptionButton>("ClassLabel/ClassText").GetItemCount())
            {
                GetNode <OptionButton>("ClassLabel/ClassText").AddItem(classData["name"].ToString());
            }
            else
            {
                GetNode <OptionButton>("ClassLabel/ClassText").SetItemText(i, classData["name"].ToString());
            }
        }

        if (charaData.Contains("effects") == true)
        {
            this.ClearEffectList();
            Godot.Collections.Array effectList = charaData["effects"] as Godot.Collections.Array;
            foreach (Godot.Collections.Dictionary effect in effectList)
            {
                this.AddEffectList(effect["name"].ToString(), Convert.ToInt32(effect["data_id"]), effect["value1"].ToString(), effect["value2"].ToString());
            }
        }
    }
Example #15
0
    public void SyncInventoryState(String state, InventoryDatabase inventoryDatabase)
    {
        String[] stateInfo  = state.Split(";");
        int      stateIndex = 0;

        // Set the current inventory count
        int inventoryCount = int.Parse(stateInfo[stateIndex]);

        _availableCapacity = _items.Count - inventoryCount;

        stateIndex++;

        // Clean up the inventory
        for (int index = 0; index < _items.Count; index++)
        {
            _items[index] = null;
        }

        for (int index = 0; index < inventoryCount; index++)
        {
            int inventoryInex = int.Parse(stateInfo[stateIndex]);
            stateIndex++;
            _items[inventoryInex] = inventoryDatabase.GetItemByID(stateInfo[stateIndex]);
            stateIndex++;
        }

        // sync used item
        int usedIndex = int.Parse(stateInfo[stateIndex]);

        stateIndex++;

        // Clean up the used index
        _usedIndex.Clear();

        for (int index = 0; index < usedIndex; index++)
        {
            _usedIndex.Add(int.Parse(stateInfo[stateIndex]));
            stateIndex++;
        }

        int equipCount = int.Parse(stateInfo[stateIndex]);

        stateIndex++;

        _equipmentIndex.Clear();

        for (int index = 0; index < equipCount; index++)
        {
            String weaponKey = stateInfo[stateIndex];
            stateIndex++;

            int itemIndex = int.Parse(stateInfo[stateIndex]);
            stateIndex++;

            int ammo = int.Parse(stateInfo[stateIndex]);
            stateIndex++;

            Weapon.WeaponOrder weaponOrder = (Weapon.WeaponOrder) int.Parse(weaponKey.Split("_")[0]);
            int weaponIndex = int.Parse(weaponKey.Split("_")[1]);

            if (itemIndex != -1)
            {
                _equipmentIndex.Add(weaponKey, itemIndex);

                if (_agent.GetWeapons(weaponOrder)[weaponIndex] == null || _agent.GetWeapons(weaponOrder)[weaponIndex].ItemResourceID != _items[itemIndex].ItemID)
                {
                    // Client is not equip same as server, try to enforced it
                    _agent.UnequipWeapon(weaponOrder, weaponIndex);
                    _agent.EquipWeapon(_items[itemIndex].ReferencePackedScene, weaponOrder, weaponIndex);
                    _agent.GetWeapons(weaponOrder)[weaponIndex].SetAmmo(ammo);
                    EmitSignal(nameof(WeaponChangeSignal), weaponOrder, weaponIndex);
                }
            }
            else
            {
                if (_agent.GetWeapons(weaponOrder)[weaponIndex] != null)
                {
                    // Client is equip while server does not, try to enforced it
                    _agent.UnequipWeapon(weaponOrder, weaponIndex);
                    EmitSignal(nameof(WeaponChangeSignal), weaponOrder, weaponIndex);
                }
            }
        }

        EmitSignal(nameof(InventoryChangeSignal));
    }
Example #16
0
 public void ClearData()
 {
     colors.Clear();
 }
Example #17
0
    void _on_Timer_timeout()
    {
        if (mode == "Easy")
        {
            waveCount++;
            if (waveCount < 4)
            {
                AddSpawnColorsData();
            }
            else if (waveCount == 4)
            {
                ResetWaveTimer();
                setCount++;

                GetTree().CallGroup("ColorData", "ClearData");
                GetTree().CallGroup("Path", "ClearData");
                GetTree().CallGroup("Ball", "Fade");

                if (colorsData.Count != 0)
                {
                    colorsData.Clear();
                }
                AddData(colorsData);

                if (unusedColorsData.Count != 0)
                {
                    unusedColorsData.Clear();
                }
                AddData(unusedColorsData);

                spawnColorsData.Clear();
                AddSpawnColorsData();


                waveTimer.Start();
            }
        }

        if (mode == "Hard")
        {
            waveCount++;

            if (waveCount == 2 && firstLeft)
            {
                firstLeft = !firstLeft;
                GetTree().CallGroup("LeftTimer", "stop");
                GetTree().CallGroup("RightTimer", "start");
                AddSpawnColorsData("Right");
            }
            else if (waveCount == 2 && !firstLeft)
            {
                firstLeft = !firstLeft;
                GetTree().CallGroup("RightTimer", "stop");
                GetTree().CallGroup("LeftTimer", "start");
                AddSpawnColorsData("Left");
            }
            else if (waveCount == 3 && firstLeft)
            {
                GetTree().CallGroup("RightTimer", "start");
                GetTree().CallGroup("LeftTimer", "start");
                AddSpawnColorsData("Right");
            }
            else if (waveCount == 3 && !firstLeft)
            {
                GetTree().CallGroup("RightTimer", "start");
                GetTree().CallGroup("LeftTimer", "start");
                AddSpawnColorsData("Left");
            }
            else if (waveCount == 4)
            {
                if (colorsData.Count > 0)
                {
                    if (spawnColorsData_Left.Count < 3)
                    {
                        spawnColorsData_Left.Add(colorsData[0]);
                        colorsData.Clear();
                    }
                    else if (spawnColorsData_Right.Count < 3)
                    {
                        spawnColorsData_Right.Add(colorsData[0]);
                        colorsData.Clear();
                    }
                }
            }
            else if (waveCount == 5)
            {
                ResetWaveTimer();
                setCount++;

                GetTree().CallGroup("ColorData", "ClearData");
                GetTree().CallGroup("Path", "ClearData");
                GetTree().CallGroup("Ball", "Fade");

                if (colorsData.Count != 0)
                {
                    colorsData.Clear();
                }
                AddData(colorsData);

                if (unusedColorsData.Count != 0)
                {
                    unusedColorsData.Clear();
                }
                AddData(unusedColorsData);

                midColors.Clear();
                spawnColorsData_Left.Clear();
                spawnColorsData_Right.Clear();

                AddSpawnColorsData("Left");
                AddSpawnColorsData("Right");

                if (firstLeft)
                {
                    GetTree().CallGroup("RightTimer", "stop");
                }
                else
                {
                    GetTree().CallGroup("LeftTimer", "stop");
                }


                waveTimer.Start();
            }
        }
    }