public override void _Ready()
 {
     SimulationStarted = Global.IsLoaded;
     if (Global.IsLoaded)
     {
         for (int i = 0; i < Global.LoadedGlobalTime.Count; i++)
         {
             GlobalTimeArray.Add((float)Global.LoadedGlobalTime[i]);
         }
         CurrentWaitingTime = Global.LoadedGlobalWaitingTime;
         GD.Print("the array: " + GlobalTimeArray);
         GD.Print(CurrentWaitingTime);
         foreach (Godot.Collections.Dictionary s in Global.LoadedSpecies)
         {
             String speciesName    = (String)s["SpeciesName"];
             Color  color          = new Color((float)s["SpeciesColorR"], (float)s["SpeciesColorG"], (float)s["SpeciesColorB"]);
             int    diet           = (int)((float)s["SpeciesDiet"]);
             int    model          = (int)((float)s["SpeciesModel"]);
             Node   newSpeciesInst = Species.Instance();
             ((Species)newSpeciesInst).InitSpecies(speciesName, color, GlobalTimeArray, diet, true, s, (Species.GraphicModel)model);
             AddChild(newSpeciesInst);
             ((Species)newSpeciesInst).LoadCreatures((Godot.Collections.Array)s["Creatures"]);
             GetParent().GetNode <ItemList2>("DisplayChartsMenu/ItemList2").AddNewSpecies(speciesName);
         }
     }
 }
    public DataCollector(Godot.Collections.Array initArray)
    {
        for (int i = 0; i < initArray.Count; i++)
        {
            PopulationSizeArray.Add(0.0f);
            MaleFitness.Add(0.0f);
            SpeedArray.Add(0.0f);
            PerceptionArray.Add(0.0f);
            MatingCycleArray.Add(0.0f);
            HungerResistanceArray.Add(0.0f);
            ThirstResistanceArray.Add(0.0f);
            GestationArray.Add(0.0f);
            LongevityArray.Add(0.0f);
            LitterSizeArray.Add(0.0f);
            IntelligenceArray.Add(0.0f);
            MemoryArray.Add(0.0f);
            StrengthArray.Add(0.0f);
            HeatResistanceArray.Add(0.0f);
            ColdResistanceArray.Add(0.0f);
            StaminaArray.Add(0.0f);
            SleepCycleArray.Add(0.0f);

            StarvationArray.Add(0.0f);
            DehydrationArray.Add(0.0f);
            OldAgeArray.Add(0.0f);
            BeingHuntedArray.Add(0.0f);
            HeatStrokeArray.Add(0.0f);
            FreezingArray.Add(0.0f);
            SleepDeprivationArray.Add(0.0f);
        }

        CurrentTimeTick     = initArray.Count - 1;
        SpeciesCreationTime = CurrentTimeTick;
    }
Example #3
0
    // Called when the node enters the scene tree for the first time.
    public override void _Ready()
    {
        String[] list    = {};
        String   content = "";
        File     file    = new File();

        if (!file.FileExists(stationsFilePath))
        {
            file.Open("res://lista.json", File.ModeFlags.Read);
            content = file.GetAsText();
            file.Close();
            file.Open(stationsFilePath, File.ModeFlags.Write);
            file.StoreString(content);
            file.Close();
        }
        else
        {
            file.Open(stationsFilePath, File.ModeFlags.Read);
            content = file.GetAsText();
            file.Close();
        }

        file.Open("res://lista.json", File.ModeFlags.Read);
        content = file.GetAsText();
        file.Close();
        list = content.TrimStart('[').TrimEnd(']').Split("::");
        foreach (String element in list)
        {
            stationList.Add(JSON.Parse(element).Result as Godot.Collections.Dictionary);
        }
    }
Example #4
0
    public override void _Ready()
    {
        int i = 0;

        this.Multimesh.InstanceCount = 0;
        if (Global.IsLoaded)
        {
            this.Multimesh.InstanceCount = Global.LoadedMeat.Count;
            foreach (Godot.Collections.Dictionary m in Global.LoadedMeat)
            {
                Meat newMeat = new Meat();
                newMeat.meatSpatial             = (Spatial) new Spatial();
                newMeat.meatSpatial.Translation = new Vector3((float)m["MeatTranslationX"], (float)m["MeatTranslationY"], (float)m["MeatTranslationZ"]);
                newMeat.meatSpatial.Scale       = new Vector3((float)m["MeatScaleX"], (float)m["MeatScaleY"], (float)m["MeatScaleZ"]);
                newMeat.timeOnGround            = (float)m["TimeOnGround"];
                newMeat.EatersCount             = (int)((float)m["EatersCount"]);
                newMeat.Collider                 = (CreatureCollider) new CreatureCollider();
                newMeat.Collider.Translation     = new Vector3((float)m["ColliderTranslationX"], (float)m["ColliderTranslationY"], (float)m["ColliderTranslationZ"]);
                newMeat.Collider.MyMeat          = newMeat;
                newMeat.Collider.MyCreatureAlive = false;
                AddChild(newMeat.Collider);
                newMeat.decay    = (int)((float)m["Decay"]);
                newMeat.meatGone = (bool)m["MeatGone"];
                MeatArray.Add(newMeat);
                Multimesh.SetInstanceTransform(i, newMeat.meatSpatial.Transform);
                i++;
            }
            MeatBiomassArray = DataCollector.ConvertToFloatArray(Global.LoadedMeatBiomass);
        }
        else
        {
            MeatBiomassArray.Add(0.0f);
        }
    }
Example #5
0
    public void RegisterCategory(string name)
    {
        var newCategory = new Godot.Collections.Dictionary();

        newCategory["name"]  = "Player";
        newCategory["type"]  = Godot.Variant.Type.Nil;
        newCategory["usage"] = Godot.PropertyUsageFlags.Category | Godot.PropertyUsageFlags.ScriptVariable;

        propertyList.Add(newCategory);
    }
Example #6
0
    public void WhenWeWatchASignalFromAnObjectWithNoBoundVariables()
    {
        EmitSignal("Example", 1, 20, 5);
        GDArray args = new GDArray();

        args.Add(1);
        args.Add(20);
        args.Add(5);
        Assert.SignalWasEmittedWithArguments(this, "Example", args,
                                             "Then it captures any arguments that where passed when the signal was emitted");
    }
Example #7
0
    public void UpdatePlantBiomass()
    {
        float currentPlantBiomass = 0.0f;

        foreach (Vector3 key in GroundTiles.Keys)
        {
            if (GroundTiles[key].isPlantGrowing || GroundTiles[key].hasPlant)
            {
                currentPlantBiomass += GroundTiles[key].plantSpatial.Scale.x;
            }
        }
        PlantBiomassArray.Add(currentPlantBiomass);
    }
Example #8
0
    /// <summary>
    /// Display the game list
    /// </summary>
    private void DisplayGameList()
    {
        ClearGrid();
        DisplayHeader();
        gridContainer.Columns = 3;
        Theme theme = ResourceLoader.Load("res://Assets/GUI/BtnUI4.tres") as Theme;

        foreach (CustomLevel cl in customLevelList)
        {
            Label lbl3 = new Label();
            lbl3.AddFontOverride("font", dFont2);
            lbl3.Text = cl.CustomLevelName + "      ";
            lbl3.AddColorOverride("font_color", new Color(0, 0, 0));
            gridContainer.AddChild(lbl3);

            Label lbl2 = new Label();
            lbl2.AddFontOverride("font", dFont2);
            lbl2.Text = cl.Student.StudentName;
            lbl2.AddColorOverride("font_color", new Color(0, 0, 0));
            gridContainer.AddChild(lbl2);

            Button btn = new Button();
            btn.RectMinSize = new Vector2(80, 30);
            btn.Text        = "Play";
            string[] arr = new string[1] {
                btn.Name
            };
            Godot.Collections.Array ar = new Godot.Collections.Array();
            ar.Add(btn);
            btn.Name = cl.CustomLevelId.ToString();
            btn.Connect("pressed", this, "PlayLevel", ar);
            btn.Theme = theme;
            gridContainer.AddChild(btn);
        }
    }
    public void ConvertToFloatArrayNotEmptyArrayTest()
    {
        const int X = 5;
        const int Y = 5;

        bool allFloat = true;

        Godot.Collections.Array inputArray = new Godot.Collections.Array();
        for (int i = 0; i < X; i++)
        {
            inputArray.Add((float)i / 10.0f);
        }
        Godot.Collections.Array parsed        = new Godot.Collections.Array((Godot.Collections.Array)JSON.Parse(JSON.Print(inputArray)).Result);
        Godot.Collections.Array arrayOfFloats = DataCollector.ConvertToFloatArray(parsed);
        for (int i = 0; i < arrayOfFloats.Count; i++)
        {
            if (arrayOfFloats[i].GetType() != typeof(float))
            {
                allFloat = false;
                break;
            }
        }
        Assert.IsEqual(Y, arrayOfFloats.Count, "Then it passes");
        Assert.IsTrue(allFloat, "Then it passes");
    }
Example #10
0
 public Godot.Collections.Array Save()
 {
     Godot.Collections.Array savedMeat = new Godot.Collections.Array();
     for (int i = 0; i < MeatArray.Count; i++)
     {
         if (!MeatToRemove.Contains(i))
         {
             savedMeat.Add(MeatToDictionary(i, MeatArray));
         }
     }
     for (int i = 0; i < MeatToAdd.Count; i++)
     {
         savedMeat.Add(MeatToDictionary(i, MeatToAdd));
     }
     return(savedMeat);
 }
Example #11
0
 public static Godot.Collections.Array CreateSingleBind(
     this Godot.Object gdobj, object bind)
 {
     Godot.Collections.Array binds = new Godot.Collections.Array();
     binds.Add(bind);
     return(binds);
 }
Example #12
0
 public override void _Ready()
 {
     //The Length of the trail
     if (length <= 0)
     {
         length = 2;
     }
     //How many sides the trail will have
     if (densityAround < 3)
     {
         densityAround = 3;
     }
     //How many segments the trail will have
     if (densityLengthwise < 2)
     {
         densityLengthwise = 2;
     }
     //We get the segment length by deviding the lentghth of the trail by the amount of desired segments
     segmentLength = length / densityLengthwise;
     //We add the Transforms origin vector3 into the array for the amount of segements we want in the trail
     //Loop through the amount of desired segements
     for (int i = 0; i < densityLengthwise; i++)
     {
         //Add the global transforms origin vector3 as the value
         points.Add(GlobalTransform.origin);
     }
 }
Example #13
0
    public void onPong(float signature)
    {
        //  Bail if not the server
        if (!GetTree().IsNetworkServer())
        {
            return;
        }

        // Obtain the unique ID of the caller
        int peerId = GetTree().GetRpcSenderId();

        // Check if the answer matches the expected one
        if (pingEntries[peerId] != null && pingEntries[peerId].signature == signature)
        {
            // It does. Calculate the elapsed time, in milliseconds
            pingEntries[peerId].lastPing = (PINGTIMEOUT - pingEntries[peerId].timer.TimeLeft) * 1000;
            // If here, the ping timeout timer is running but must be configured now for the ping interval
            pingEntries[peerId].timer.Stop();
            pingEntries[peerId].timer.Disconnect("timeout", this, nameof(onPingTimeout));
            Godot.Collections.Array array = new Godot.Collections.Array();
            array.Add(peerId);
            pingEntries[peerId].timer.Connect("timeout", this, nameof(onPingInterval), array, (uint)ConnectFlags.Oneshot);
            pingEntries[peerId].timer.Start(PINGINTERVAL);
            // Broadcast the new value to everyone
            RpcUnreliable(nameof(pingValueChagned), peerId + ";" + pingEntries[peerId].lastPing);
            // And allow the server to do something with this value
            EmitSignal(nameof(PingUpdatedSignal), peerId, pingEntries[peerId].lastPing);
        }
    }
Example #14
0
    public void ArtificialCombineHighestValueZeroVariationTest()
    {
        const float V = 100;
        const int   W = 0;
        const int   X = 15;
        const int   Y = 15;
        bool        Z = true;

        Godot.Collections.Array initialValues = new Godot.Collections.Array();
        Genome gen = new Genome();

        for (int i = 0; i < X; i++)
        {
            initialValues.Add(V);
        }
        gen.ArtificialCombine(initialValues, W);
        if (CheckChromosome(gen.getMaternal()) && CheckChromosome(gen.getPaternal()))
        {
            Z = true;
        }
        else
        {
            Z = false;
        }
        Assert.IsEqual(X, gen.getMaternal().Count, "Then it Passes");
        Assert.IsEqual(Y, gen.getPaternal().Count, "Then it Passes");
        Assert.IsTrue(Z, "Then it Passes");
    }
Example #15
0
 // Called when the node enters the scene tree for the first time.
 public override void _Ready()
 {
     //
     globale = (Global)GetNode("/root/Global");
     //
     if (globale.is_mobile())
     {
         label      = (Label)GetNode("Label");
         label.Text = "You can jump with the jump button.";
     }
     else
     {
         string txt_inps = "";
         Godot.Collections.Array iept = InputMap.GetActionList("jump");
         Godot.Collections.Array ie   = new Godot.Collections.Array();
         foreach (InputEvent inpe in iept)
         {
             if (inpe is InputEventKey)
             {
                 ie.Add(inpe);
             }
         }
         for (int i = 0; i < ie.Count; i++)
         {
             txt_inps += ((InputEvent)ie[i]).AsText();
             if (i < ie.Count - 1)
             {
                 txt_inps += " - ";
             }
         }
         label      = (Label)GetNode("Label");
         label.Text = "You can jump with " + txt_inps + "";
     }
 }
Example #16
0
    // public void SortCard()
    // {
    //     hand1.Clear();
    //     for (int i = 0; i < 13; i++) { hand1.Add(new Card(hand1coppy[i], true)); }
    // }
    public void fillHand()
    {
        var deck = new int[] { 11, 12, 13, 14, 15, 16, 17, 18, 19, 21, 22, 23, 24, 25, 26, 27, 28, 29, 31, 32, 33, 34, 35, 36, 37, 38, 39, 41, 42, 43, 44, 45, 46, 47, 48, 49, 110, 111, 112, 113, 210, 211, 212, 213, 310, 311, 312, 313, 410, 411, 412, 413 };
        int n    = deck.Length;

        Shuffle(deck, n);
        //for (int i = 0; i < n; i++){GD.Print(deck[i]);}
        //Add 13 lá bài vào array
        for (int i = 0; i < 13; i++)
        {
            hand1.Add(new Card(deck[i], true)); hand1coppy.Add(hand1[i].cardID);
        }
        GD.Print(hand1coppy);
        SortArr(hand1coppy, 13);
        GD.Print(hand1coppy);
        //_on_Sort_pressed();
        for (int i = 13; i < 26; i++)
        {
            hand2.Add(new Card(deck[i], false));
        }
        for (int i = 26; i < 39; i++)
        {
            hand3.Add(new Card(deck[i], false));
        }
        for (int i = 39; i < 52; i++)
        {
            hand4.Add(new Card(deck[i], false));
        }
    }
Example #17
0
/*
 *      var LODNodesList = []
 *      var lodDistanceMax = max(100.0, LOD_DistanceMax)
 *      var playerCam = get_tree().get_viewport().get_camera() #get_tree().get_root().get_node("Main/Player")
 *      var playerLoc = playerCam.get_global_transform().origin
 #TODO Hex level LOD manager by areas and areas with LODs
 *      var children_of_bindings = get_node("parent").get_children()
 *      for child in children_of_bindings:
 *              if child.get_class() == "MeshInstaceLOD":
 #child.set_Distance(clamp(child.global_transform.origin.distance_to( playerLoc ),0.0,lodDistanceMax))
 *                      LODNodesList.insert(LODNodesList.size(),child)
 *
 *      while(!isThreadTerminated()):
 *              playerLoc = playerCam.get_global_transform().origin
 *              for child in LODNodesList:
 *                      pass
 #child.set_Distance(clamp(child.global_transform.origin.distance_to( playerLoc ),0.0,lodDistanceMax))
 #print("I'm a thread! Userdata is: ")
 */

    private void ThreadLoop()
    {
        float   lodDistanceCap = Mathf.Max(100.0f, LOD_DistanceMax);
        var     playerCam      = GetTree().Root.GetViewport().GetCamera();//GetViewport().GetCamera();
        Vector3 playerDist;

        Godot.Collections.Array           childrens = GetNode("parent").GetChildren();
        Godot.Collections.Array <MeshLOD> LODArray  = new Godot.Collections.Array <MeshLOD>();
        foreach (var child in childrens)
        {
            if (child is MeshLOD)
            {
                LODArray.Add((MeshLOD)child);
            }
        }
        while (true)
        {
            if (threadTerminated)
            {
                break;
            }
            playerDist = playerCam.GlobalTransform.origin;
            foreach (MeshLOD lod in LODArray)
            {
                lod.set_Distance(Mathf.Min(lod.GlobalTransform.origin.DistanceTo(playerDist), lodDistanceCap));
            }
        }
    }
Example #18
0
        internal static bool TrySerializeDelegate(Delegate @delegate, Collections.Array serializedData)
        {
            if (@delegate is MulticastDelegate multicastDelegate)
            {
                bool someDelegatesSerialized = false;

                Delegate[] invocationList = multicastDelegate.GetInvocationList();

                if (invocationList.Length > 1)
                {
                    var multiCastData = new Collections.Array();

                    foreach (Delegate oneDelegate in invocationList)
                    {
                        someDelegatesSerialized |= TrySerializeDelegate(oneDelegate, multiCastData);
                    }

                    if (!someDelegatesSerialized)
                    {
                        return(false);
                    }

                    serializedData.Add(multiCastData);
                    return(true);
                }
            }

            if (TrySerializeSingleDelegate(@delegate, out byte[] buffer))
Example #19
0
    private void OnTriviaRequestComplete(Result result, int response_code, string[] headers, byte[] body)
    {
        GD.Print("[GdOpenTdb] Loading Questions success!");
        var             jsonStr = System.Text.Encoding.UTF8.GetString(body);
        JSONParseResult dict    = JSON.Parse(jsonStr);

        if (dict.Error != 0)
        {
            GD.Print("Error: " + dict.Error + "/", dict.ErrorLine);
        }
        else
        {
            Dictionary parsed = dict.Result as Dictionary;
            Godot.Collections.Array results = parsed["results"] as Godot.Collections.Array;

            Array <Question> ParsedQuestions = new Array <Question>();

            foreach (Dictionary r in results)
            {
                ParsedQuestions.Add(CreateFromJsonResult(r));
            }

            EmitSignal(nameof(QuestionsLoaded), ParsedQuestions);
        }
    }
Example #20
0
 public Godot.Collections.Array Save()
 {
     Godot.Collections.Array savedTiles = (Godot.Collections.Array) new Godot.Collections.Array();
     foreach (Vector3 key in GroundTiles.Keys)
     {
         Godot.Collections.Dictionary <String, object> TileDictionary = new Godot.Collections.Dictionary <String, object>()
         {
             { "BiomeType", (int)(GroundTiles[key].type) },
             { "PlantTranslationX", GroundTiles[key].plantSpatial.Translation.x },
             { "PlantTranslationY", GroundTiles[key].plantSpatial.Translation.y },
             { "PlantTranslationZ", GroundTiles[key].plantSpatial.Translation.z },
             { "PlantScaleX", GroundTiles[key].plantSpatial.Scale.x },
             { "PlantScaleY", GroundTiles[key].plantSpatial.Scale.y },
             { "PlantScaleZ", GroundTiles[key].plantSpatial.Scale.z },
             { "PlantGrowthTime", GroundTiles[key].plantGrowthTime },
             { "EatersCount", GroundTiles[key].EatersCount },
             { "IsPlantGrowing", GroundTiles[key].isPlantGrowing },
             { "HasPlant", GroundTiles[key].hasPlant },
             { "GridIndexX", GroundTiles[key].gridIndex.x },
             { "GridIndexY", GroundTiles[key].gridIndex.y },
             { "GridIndexZ", GroundTiles[key].gridIndex.z },
         };
         savedTiles.Add(TileDictionary);
     }
     return(savedTiles);
 }
Example #21
0
    public override void _Ready()
    {
        _team = (Team)GetNode("Team");
        _team.CurrentTeamCode = _defaultTeamCode;

        _captureTeamCode  = _team.CurrentTeamCode;
        _unitDisplayLabel = ((Label)(GetNode("UnitDisplay/Name")));
        _unitDisplay      = (UnitDisplay)GetNode("UnitDisplay");

        _collisionShape = (CollisionShape2D)GetNode("CollisionShape2D");

        _rng = new RandomNumberGenerator();
        _rng.Randomize();

        _base    = (Sprite)GetNode("Base");
        _boundry = (Sprite)GetNode("Boundry");

        _timer = (Timer)GetNode("CaptureTimer");

        agentsEntered = new Godot.Collections.Array();

        for (int index = 0; index < Enum.GetNames(typeof(Team.TeamCode)).Length; index++)
        {
            agentsEntered.Add(0);
        }

        // Update unit display
        SetCaptureBaseTeam(_team.CurrentTeamCode);
    }
Example #22
0
    public Godot.Collections.Array GetPath(Vector2 source, Vector2 target)
    {
        Vector2 cellSource = _tileMap.WorldToMap(source);
        Vector2 cellTarget = _tileMap.WorldToMap(target);

        int sourceId = getPointID((int)cellSource.x, (int)cellSource.y);
        int targetId = getPointID((int)cellTarget.x, (int)cellTarget.y);

        Godot.Collections.Array worldPath = new Godot.Collections.Array();

        if (!_aStar.HasPoint(sourceId) || !_aStar.HasPoint(targetId))
        {
            return(worldPath);
        }

        Vector2[] cellPath = _aStar.GetPointPath(sourceId, targetId);

        if (cellPath == null || cellPath.Length == 0)
        {
            return(worldPath);
        }


        // Reverse adding the points
        for (int index = 0; index < cellPath.Length; index++)
        {
            int id = getPointID((int)cellPath[index].x, (int)cellPath[index].y);
            worldPath.Add(_tilestoWorld[id]);
        }

        return(worldPath);
    }
 public static void AddRange <T>(this Array <T> array, IEnumerable <T> elements)
 {
     foreach (var element in elements)
     {
         array.Add(element);
     }
 }
Example #24
0
    private void SaveSkillData()
    {
        Godot.Collections.Dictionary jsonDictionary = this.GetParent().GetParent().Call("ReadData", "Skill") as Godot.Collections.Dictionary;
        Godot.Collections.Dictionary skillData      = jsonDictionary["skill" + skillSelected] as Godot.Collections.Dictionary;
        Godot.Collections.Array      effectList     = new Godot.Collections.Array();

        skillData["name"] = GetNode <LineEdit>("NameLabel/NameText").Text;
        GetNode <OptionButton>("SkillButton").SetItemText(skillSelected, GetNode <LineEdit>("NameLabel/NameText").Text);
        skillData["icon"]        = iconPath;
        skillData["description"] = GetNode <TextEdit>("DescLabel/DescText").Text;
        skillData["skill_type"]  = GetNode <OptionButton>("SkillTypeLabel/SkillTypeButton").Selected;
        skillData["mp_cost"]     = GetNode <SpinBox>("MPCostLabel/MPCostBox").Value;
        skillData["tp_cost"]     = GetNode <SpinBox>("TPCostLabel/TPCostBox").Value;
        skillData["target"]      = GetNode <OptionButton>("TargetLabel/TargetButton").Selected;
        skillData["usable"]      = GetNode <OptionButton>("UsableLabel/UsableButton").Selected;
        skillData["success"]     = GetNode <SpinBox>("HitLabel/HitBox").Value;
        skillData["hit_type"]    = GetNode <OptionButton>("TypeLabel/TypeButton").Selected;
        skillData["damage_type"] = GetNode <OptionButton>("DamageLabel/DTypeLabel/DTypeButton").Selected;
        skillData["element"]     = GetNode <OptionButton>("DamageLabel/ElementLabel/ElementButton").Selected;
        skillData["formula"]     = GetNode <LineEdit>("DamageLabel/DFormulaLabel/FormulaText").Text;
        int effectSize = GetNode <ItemList>("EffectLabel/PanelContainer/VBoxContainer/HBoxContainer/EffectNames").GetItemCount();

        for (int i = 0; i < effectSize; i++)
        {
            Godot.Collections.Dictionary effectData = new Godot.Collections.Dictionary();
            effectData["name"]    = GetNode <ItemList>("EffectLabel/PanelContainer/VBoxContainer/HBoxContainer/EffectNames").GetItemText(i);
            effectData["data_id"] = GetNode <ItemList>("EffectLabel/PanelContainer/VBoxContainer/HBoxContainer/DataType").GetItemText(i);
            effectData["value1"]  = GetNode <ItemList>("EffectLabel/PanelContainer/VBoxContainer/HBoxContainer/EffectValue1").GetItemText(i);
            effectData["value2"]  = GetNode <ItemList>("EffectLabel/PanelContainer/VBoxContainer/HBoxContainer/EffectValue2").GetItemText(i);
            effectList.Add(effectData);
        }
        skillData["effects"] = effectList;
        this.GetParent().GetParent().Call("StoreData", "Skill", jsonDictionary);
    }
    bool WheelRaycast(float maxDistance, ref RaycastHit hit)
    {
        var space = GetWorld().DirectSpaceState;
        var to    = castOrigin + (castDirection.Normalized() * maxDistance);

        var exclusion = new Godot.Collections.Array();

        exclusion.Add(rigidbody.GetRid());

        var result = space.IntersectRay(castOrigin, to, exclusion);

        GetViewport().GetNode <Node>("DebugDraw").Call("draw_line_3d", castOrigin, to, Colors.Red);
        hit = new RaycastHit();

        if (result.Keys.Count > 0)
        {
            hit.isColliding = true;
            hit.normal      = (Vector3)result["normal"];
            hit.point       = (Vector3)result["position"];
            hit.distance    = hit.point.DistanceTo(castOrigin);
            return(true);
        }
        else
        {
            return(false);
        }
    }
Example #26
0
    protected void InitializeTeamMapAI()
    {
        Godot.Collections.Array <TeamMapAISetting> teamMapAISettings = GameStates.GetTeamMapAISettings();

        TeamMapAIs = new Godot.Collections.Array <TeamMapAI>();

        // Start with neutral and above
        for (int index = 0; index < (int)(Team.TeamCode.NEUTRAL); index++)
        {
            TeamMapAI ai = (TeamMapAI)((PackedScene)GD.Load("res://ai/TeamMapAI.tscn")).Instance();
            ai.Name = nameof(TeamMapAI) + "_" + (Team.TeamCode)index;
            AddChild(ai);

            ai.Initialize(this, _inventoryManager, CapaturableBaseManager.GetBases(), (Team.TeamCode)index, _pathFinding);

            if (teamMapAISettings != null)
            {
                ai.SetMaxUnitUsageAmount(teamMapAISettings[index].Budget);
                ai.SetAutoSpawnMember(teamMapAISettings[index].AutoSpawnMember);
            }

            TeamMapAIs.Add(ai);

            foreach (CapturableBase capturable in CapaturableBaseManager.GetBases())
            {
                capturable.Connect(nameof(CapturableBase.BaseTeamChangeSignal), ai, nameof(TeamMapAI.HandleCapturableBaseCaptured));
            }
        }
    }
Example #27
0
 private void _initializeWeapon(Godot.Collections.Array <Weapon> weapons)
 {
     for (int index = 0; index < MaxWeaponCount; index++)
     {
         weapons.Add(null);
     }
 }
    public Godot.Collections.Array getTscnInDir(string pathName)
    {
        var files = new Godot.Collections.Array();
        var dir   = new Directory();

        dir.Open(pathName);

        dir.ListDirBegin();

        while (true)
        {
            string file = dir.GetNext();
            if (file == "")
            {
                break;
            }
            else if (!(file.BeginsWith(".")) && (file.EndsWith(".tscn")))
            {
                files.Add(file);
                GD.Print(file);
            }
        }

        return(files);
    }
Example #29
0
    public CardData GetRandomCard()
    {
        var selectedIndex = (int)(_random.Randi() % _cards.Count);
        var cardDataJson  = (Godot.Collections.Dictionary)_cards[selectedIndex];

        var cardType = cardDataJson["type"].ToString();

        var cardData = new CardData
        {
            Id          = cardDataJson["id"].ToString(),
            Name        = cardDataJson["name"].ToString(),
            Description = cardDataJson["description"].ToString(),
            Type        = cardDataJson["type"].ToString(),
            Image       = cardDataJson["image"].ToString(),
        };

        if (cardType == nameof(CardType.Weapon))
        {
            cardData = new WeaponCardData
            {
                Id          = cardDataJson["id"].ToString(),
                Name        = cardDataJson["name"].ToString(),
                Description = cardDataJson["description"].ToString(),
                Type        = cardDataJson["type"].ToString(),
                Image       = cardDataJson["image"].ToString(),
                Range       = int.Parse(cardDataJson["range"].ToString()),
                Wide        = int.Parse(cardDataJson["wide"].ToString()),
            };
        }

        _graveyard.Add(cardDataJson);
        _cards.RemoveAt(selectedIndex);

        return(cardData);
    }
Example #30
0
    public void updateMapData(int sizeMap, int[] terrain, int[] playerUnits)
    {
        GD.Print("GUI: updata map data");

        maxPlayerOnMap = 0;
        players        = new Player[8];

        //panel LOBBY
        for (int i = 0; i < 8; i++)
        {
            Label  lblChild = vbcPlayerUnitsCounts.GetChild(i) as Label;
            Button buP      = vbcPlayerTypeChange.GetChild(i) as Button;

            if (playerUnits[i] > 0)
            {
                //data
                players[i]            = new Player(i);
                players[i].playerType = (i == 0)? Player.TYPEPLAYER.LOCAL : Player.TYPEPLAYER.IA; //primero player local el resto IA
                players[i].playerteam = i;                                                        //free for all
                players[i].unitsCount = playerUnits[i];

                //view
                lblChild.Text    = (String.Format("P{0}.{1} Units:{2}", i, players[i].playerType, players[i].unitsCount));
                lblChild.Visible = (true);
                buP.Visible      = (true);

                //connect onclick
                if (!buP.IsConnected("pressed", this, "onClickChangeTypePlayer"))
                {
                    Godot.Collections.Array gdArray = new Godot.Collections.Array(); gdArray.Add(i);
                    buP.Connect("pressed", this, "onClickChangeTypePlayer", gdArray);
                }

                //multi
                maxPlayerOnMap++;
            }
            else
            {
                lblChild.Visible = (false);
                buP.Visible      = (false);
            }
        }

        //datas terrain show view
        lblTerrainDataSize.Text = ("Map: " + sizeMap + " x " + sizeMap);

        vbcTerrainDatas.GetChild <Label>(0).Text = ("Deep Water: " + terrain[0]);
        vbcTerrainDatas.GetChild <Label>(1).Text = ("Water: " + terrain[1]);
        vbcTerrainDatas.GetChild <Label>(2).Text = ("Ground: " + terrain[2]);
        vbcTerrainDatas.GetChild <Label>(3).Text = ("Glass: " + terrain[3]);
        vbcTerrainDatas.GetChild <Label>(4).Text = ("Forest: " + terrain[4]);
        vbcTerrainDatas.GetChild <Label>(5).Text = ("Hill: " + terrain[5]);
        vbcTerrainDatas.GetChild <Label>(6).Text = ("Mountain: " + terrain[6]);
        vbcTerrainDatas.GetChild <Label>(7).Text = ("Top: " + terrain[7]);

        vbcTerrainDatas.GetChild <Label>(8).Text  = ("River: " + terrain[8]);
        vbcTerrainDatas.GetChild <Label>(9).Text  = ("Road: " + terrain[9]);
        vbcTerrainDatas.GetChild <Label>(10).Text = ("Building: " + terrain[10]);
    }