Exemplo n.º 1
0
    public override void _Input(InputEvent @event)
    {
        float delta = GetProcessDeltaTime();

        if (Input.IsActionJustPressed("ship_fire_primary"))
        {
            if (WeaponTarget != null)
            {
                FireWeapon(WeaponTarget, Weapon.Railgun);
            }
            else
            {
                FireWeapon(null, Weapon.Railgun);
            }
        }
        else if (Input.IsActionJustPressed("ship_fire_secondary"))
        {
            if (WeaponTarget != null)
            {
                FireWeapon(WeaponTarget, Weapon.Missile);
            }
            else
            {
            }
        }
        if (Input.IsActionJustPressed("ship_target_lock"))
        {
            Godot.Collections.Array lockables = GetTree().GetNodesInGroup("Lockables");
            TryLock(lockables);
        }
        if (Input.IsActionJustReleased("player_up"))
        {
            thrusterFlame.Visible = false;
        }
    }
        public static Array <T> ToGdArray <T>(this IEnumerable <T> elements)
        {
            var o = new Array <T>();

            o.AddRange(elements);
            return(o);
        }
    private void _on_FileDialog_confirmed()
    {
        String path = GetNode <FileDialog>("FileDialog").CurrentPath;

        path += ".save";
        var saveFile = new File();

        saveFile.Open(path, File.ModeFlags.Write);
        Godot.Collections.Array savedTiles      = GetParent().GetNode <BiomeGrid>("BiomeGrid").Save();
        Godot.Collections.Array savedMeat       = GetParent().GetNode <MultiMeshMeat>("MultiMeshMeat").Save();
        Godot.Collections.Array globalTimeArray = GetParent().GetNode <SpeciesHolder>("SpeciesHolder").GetGlobalTimeArray();
        Godot.Collections.Array savedSpecies    = GetParent().GetNode <SpeciesHolder>("SpeciesHolder").Save();
        Godot.Collections.Array plantBiomass    = GetParent().GetNode <BiomeGrid>("BiomeGrid").GetPlantBiomassArray();
        Godot.Collections.Array meatBiomass     = GetParent().GetNode <MultiMeshMeat>("MultiMeshMeat").GetMeatBiomassArray();
        float GlobalCurrentWaitingTime          = GetParent().GetNode <SpeciesHolder>("SpeciesHolder").GetCurrentWaitingTime();
        float BiomesCurrentWaitingTime          = GetParent().GetNode <BiomeGrid>("BiomeGrid").GetCurrentWaitingTime();

        Godot.Collections.Dictionary <String, object> saveData = new Godot.Collections.Dictionary <String, object>()
        {
            { "WorldSize", Global.worldSize },
            { "PlantGrowthRate", Global.biomeGrowthRate },
            { "GloablTimeArray", globalTimeArray },
            { "PlantBiomass", plantBiomass },
            { "MeatBiomass", meatBiomass },
            { "BiomeTiles", savedTiles },
            { "Meat", savedMeat },
            { "Species", savedSpecies },
            { "GlobalWaitingTime", GlobalCurrentWaitingTime },
            { "BiomesWaitingTime", BiomesCurrentWaitingTime }
        };
        saveFile.StoreLine(JSON.Print(saveData));
    }
Exemplo n.º 4
0
    private void RefreshData(int id)
    {
        Godot.Collections.Dictionary jsonDictionary = this.GetParent().GetParent().Call("ReadData", "Skill") as Godot.Collections.Dictionary;
        Godot.Collections.Dictionary skillData      = jsonDictionary["skill" + id] as Godot.Collections.Dictionary;
        GetNode <LineEdit>("NameLabel/NameText").Text = skillData["name"] as string;
        string icon = skillData["icon"] as string;

        if (icon != "")
        {
            GetNode <Sprite>("IconLabel/IconSprite").Texture = GD.Load(skillData["icon"] as string) as Godot.Texture;
        }
        GetNode <TextEdit>("DescLabel/DescText").Text = skillData["description"] as string;
        GetNode <OptionButton>("SkillTypeLabel/SkillTypeButton").Selected = Convert.ToInt32(skillData["skill_type"]);
        GetNode <SpinBox>("MPCostLabel/MPCostBox").Value            = Convert.ToInt32(skillData["mp_cost"]);
        GetNode <SpinBox>("TPCostLabel/TPCostBox").Value            = Convert.ToInt32(skillData["tp_cost"]);
        GetNode <OptionButton>("TargetLabel/TargetButton").Selected = Convert.ToInt32(skillData["target"]);
        GetNode <OptionButton>("UsableLabel/UsableButton").Selected = Convert.ToInt32(skillData["usable"]);
        GetNode <SpinBox>("HitLabel/HitBox").Value = Convert.ToInt32(skillData["success"]);
        GetNode <OptionButton>("TypeLabel/TypeButton").Selected = Convert.ToInt32(skillData["hit_type"]);
        GetNode <OptionButton>("DamageLabel/DTypeLabel/DTypeButton").Selected     = Convert.ToInt32(skillData["damage_type"]);
        GetNode <OptionButton>("DamageLabel/ElementLabel/ElementButton").Selected = Convert.ToInt32(skillData["element"]);
        GetNode <LineEdit>("DamageLabel/DFormulaLabel/FormulaText").Text          = skillData["formula"] as string;
        if (skillData.Contains("effects") == true)
        {
            this.ClearEffectList();
            Godot.Collections.Array effectList = skillData["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());
            }
        }
    }
Exemplo n.º 5
0
        public bool IsFamily(Guid speaker, Guid listener)
        {
            Guid[] participants = { speaker, listener };
            IEnumerable <IRelationship> relationships = this.Get(participants, new[] { "family" });

            return(relationships.Any());
        }
Exemplo n.º 6
0
    public Packet AddStateVector(Godot.Collections.Array types, Godot.Collections.Array data, bool[] diffVector)
    {
        AddBoolArray(diffVector);

        for (int i = 0; i < types.Count; i++)
        {
            if (!diffVector[i])
            {
                continue;
            }

            switch ((Data.TYPE)types[i])
            {
            case Data.TYPE.U8:
                AddU8((byte)Data.Int(data[i]));
                break;

            case Data.TYPE.U16:
                AddU16((ushort)Data.Int(data[i]));
                break;

            case Data.TYPE.STRING:
                AddString(data[i] as string);
                break;
            }
        }

        return(this);
    }
Exemplo n.º 7
0
    internal void AddItems(List <Item> items)
    {
        foreach (Item item in items)
        {
            var newLabel = new Label();
            newLabel.Text = item.Title;

            newLabel.MouseFilter = MouseFilterEnum.Stop;

            ContextItems.AddChild(newLabel);

            Godot.Collections.Array bindArray = new Godot.Collections.Array {
                Callbacks.Count
            };

            newLabel.Connect(
                "mouse_entered",
                this,
                "OnItemHoverStart",
                bindArray
                );
            newLabel.Connect(
                "mouse_exited",
                this,
                "OnItemHoverEnd",
                bindArray
                );

            Callbacks.Add(item.OnClick);
        }
    }
Exemplo n.º 8
0
    private ArrayMesh draw_hex_tri(Vector3[] base_verts, ref ArrayMesh local_array_mesh)
    {
        Mesh a = new ArrayMesh();

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

        int[] indices = new int[] { 0, 1, 2, 0, 2, 3 };
        mesh_arrays.Resize((int)Mesh.ArrayType.Max);

        for (int i = 0; i < 3; i++)
        {
            List <Vector3> verts = new List <Vector3>();
            for (int i2 = 0; i2 < base_verts.Length; i2++)
            {
                verts.Add(point_rotation(base_verts[i2], base_verts[2], 120f * i));
            }

            //mesh_arrays[Godot.Mesh] = verts;
            mesh_arrays[(int)ArrayMesh.ArrayType.Vertex] = verts.ToArray();
            mesh_arrays[(int)ArrayMesh.ArrayType.Index]  = indices;
        }

        local_array_mesh.AddSurfaceFromArrays(Mesh.PrimitiveType.Triangles, mesh_arrays);
        return(local_array_mesh);
    }
Exemplo n.º 9
0
    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);
    }
Exemplo n.º 10
0
    private void LoadValues()
    {
        _mSensitivity.Text = Settings.Sensitivity.ToString();
        UpdateHistory("msensitivity", Settings.Sensitivity.ToString());
        _mInvert.Pressed = Settings.InvertedMouse;
        UpdateHistory("minvertmouse", Settings.InvertedMouse.ToString());

        foreach (LineEdit le in _playerControls)
        {
            Godot.Collections.Array actionList = InputMap.GetActionList(le.Name);
            foreach (InputEvent ie in actionList)
            {
                if (ie is InputEventKey iek)
                {
                    // FIXME - this only does 1 key per command
                    string key = OS.GetScancodeString(iek.Scancode).ToLower();
                    le.Text = key;
                    break;
                }
                else if (ie is InputEventMouseButton iem)
                {
                    // FIXME - append mouse to index number, interpret it for save too
                    le.Text = iem.ButtonIndex.ToString();
                }
            }
        }
    }
Exemplo n.º 11
0
    virtual public void Explode(Player ignore, float damage)
    {
        if (_areaOfEffect)
        {
            Godot.Collections.Array result = _game.World.FindRadius(this, _areaOfEffectRadius);
            foreach (Godot.Collections.Dictionary r in result)
            {
                if (r["collider"] is Player pl)
                {
                    if (pl != ignore || ignore == null)
                    {
                        // find how far from explosion as a percentage, apply to damage
                        float dist = this.Transform.origin.DistanceTo(pl.Transform.origin);
                        dist = dist > _areaOfEffectRadius ? (_areaOfEffectRadius * .99f) : dist;
                        float pc = ((_areaOfEffectRadius - dist) / _areaOfEffectRadius);
                        float d  = damage * pc;

                        // inflict damage
                        pl.TakeDamage(_playerOwner, this.GlobalTransform.origin, d);
                        _explodedPlayers.Add(pl, pc);
                    }
                }
            }
        }

        // FIXME - all particles should now be under particles manager
        Particles p = (Particles)_particleScene.Instance();

        p.Transform = this.Transform;
        _game.World.ProjectileManager.AddChild(p);
        p.Emitting = true;

        // remove projectile
        Exploded = true;
    }
Exemplo n.º 12
0
    private void RemoveVariableObserver(String name, Boolean clear)
    {
        if (this.story != null)
        {
            if (this.observedVariables.Contains(name))
            {
                String signalName = this.ObservedVariableSignalName(name);
                if (this.HasUserSignal(signalName))
                {
                    Godot.Collections.Array connections = this.GetSignalConnectionList(signalName);
                    foreach (Godot.Collections.Dictionary connection in connections)
                    {
                        this.Disconnect(signalName, connection["target"] as Godot.Object, connection["method"] as String);
                    }
                    // Seems like there's no way to undo `AddUserSignal` so we're just going to unbind everything :/
                }

                this.story.RemoveVariableObserver(null, name);

                if (clear)
                {
                    this.observedVariables.Remove(name);
                }
            }
        }
    }
Exemplo n.º 13
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))
Exemplo n.º 14
0
    public void TryLock(Godot.Collections.Array lockables)
    {
        Vector2     distance   = Vector2.Inf;
        Destroyable tempTarget = null;

        foreach (Destroyable lockable in lockables)
        {
            Vector2 lockableDistance = lockable.GlobalPosition - GetGlobalMousePosition();
            lockableDistance.x = Mathf.Abs(lockableDistance.x);
            lockableDistance.y = Mathf.Abs(lockableDistance.y);

            if (lockableDistance < distance)
            {
                distance   = lockable.GlobalPosition - GetGlobalMousePosition();
                tempTarget = lockable;
            }
        }
        if (Mathf.Abs(distance.x) > targetLockRadius * activeCamera.Zoom.x || Mathf.Abs(distance.y) > targetLockRadius * activeCamera.Zoom.y)
        {
            if (WeaponTarget != null)
            {
                WeaponTarget.Destroyed -= OnTargetDestroyed;
            }
            WeaponTarget = null;
        }
        else
        {
            WeaponTarget            = tempTarget;
            WeaponTarget.Destroyed += OnTargetDestroyed;
        }
    }
Exemplo n.º 15
0
    /**
     * AddWeapon
     * Assign weapon to target weaponOrder and index
     **/
    public bool EquipWeapon(PackedScene weaponScene, Weapon.WeaponOrder weaponOrder, int index)
    {
        Godot.Collections.Array <Weapon> weapons = GetWeapons(weaponOrder);

        if (weapons[index] != null)
        {
            return(false);
        }

        Node2D weaponHolder = GetWeaponsHolder(weaponOrder);
        Weapon weapon       = (Weapon)(weaponScene.Instance());

        weaponHolder.AddChild(weapon);
        weapon.Initialize(_gameWorld, this, weaponOrder);
        weapons[index] = weapon;
        weapon.Hide();

        // If it is current weapon, then perform weapon change
        if (index == CurrentWeaponIndex[weaponOrder])
        {
            changeWeapon(index, weaponOrder);
        }

        return(true);
    }
Exemplo n.º 16
0
    override public void Explode(float val)
    {
        // any players nearby
        Godot.Collections.Array result = this.FindPlayersInRadius();

        foreach (Dictionary <object, object> r in result)
        {
            if (r["collider"] is Player pl)
            {
                // calc damage per ammunition
                float damage = pl.CurrentShells * .75f + pl.CurrentRockets * 1.5f + pl.CurrentCells * .75f;

                // remove 90% of ammunition for players affected
                pl.CurrentShells  = (int)Math.Floor(pl.CurrentShells * .9);
                pl.CurrentRockets = (int)Math.Floor(pl.CurrentRockets * .9);
                pl.CurrentCells   = (int)Math.Floor(pl.CurrentCells * .9);

                // inflict damage
                pl.TakeDamage(this.Transform, this.GetType().ToString().ToLower(), 0, this._playerOwner, damage);
            }

            // ammunition boxes, backpacks, pipebombs, buildings
        }

        this.FinishExplode();
    }
Exemplo n.º 17
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));
            }
        }
    }
Exemplo n.º 18
0
        public void FindGUIs()
        {
            Array guiData = this.RootUI.GetAllChildren();

            foreach (var child in guiData)
            {
                if (child is GUIData data)
                {
                    this.Add(data);
                }
            }

            if (this.Cursor is null)
            {
                this.Cursor = this.PersistentRoot.GetNode <ManagedCursor>("Cursor");
            }

            if (this.Tooltip is null)
            {
                this.Tooltip = this.PersistentRoot.GetNode <Tooltip>("Tooltip");
                this.SetupManagedComponents(this.Tooltip);
            }

            this.Add(this.Tooltip);

            if (this.ContextMenu is null)
            {
                this.ContextMenu = this.PersistentRoot.GetNode <ContextMenu>("Context Menu");
                this.SetupManagedComponents(this.ContextMenu);
            }

            this.Add(this.ContextMenu);
        }
Exemplo n.º 19
0
    public static void UnBind(string KeyName)
    {
        KeyName = KeyName.ToLower();
        Godot.Collections.Array actions = InputMap.GetActions();

        foreach (string a in actions)
        {
            if (!a.Contains("ui_"))
            {
                Godot.Collections.Array actionList = InputMap.GetActionList(a);
                foreach (InputEvent ie in actionList)
                {
                    if (ie is InputEventKey iek)
                    {
                        string key = OS.GetScancodeString(iek.Scancode);
                        if (key.ToLower() == KeyName)
                        {
                            InputMap.ActionEraseEvent(a, iek);

                            RemoveBind(BindingsWithArg, a);
                            RemoveBind(BindingsWithArgDistinct, a);
                            RemoveBind(BindingsWithoutArg, a);
                            RemoveBind(BindingsWithoutArgDistinct, a);
                        }
                    }
                }
            }
        }
    }
Exemplo n.º 20
0
    /// <summary>
    /// Update a PlayerData from an array of serialized data
    /// </summary>
    /// <param name="p"></param>
    /// <param name="data"></param>
    /// <returns></returns>
    public static PlayerData FromArray(this PlayerData p, Godot.Collections.Array data)
    {
        int i = 0;

        p.NetworkId                       = (int)data[i++];
        p.Num                             = (int)data[i++];
        p.Name                            = (string)data[i++];
        p.Ready                           = (Boolean)data[i++];
        p.AIControlled                    = (Boolean)data[i++];
        p.Color                           = (Color)data[i++];
        p.Score                           = (int)data[i++];
        p.TechBeingResearched             = (ResearchType)data[i++];
        p.TechResearchProgress            = (int)data[i++];
        p.Resources.Raw                   = (int)data[i++];
        p.Resources.Power                 = (int)data[i++];
        p.Resources.Science               = (int)data[i++];
        p.TechLevel[ResearchType.Mine]    = (int)data[i++];
        p.TechLevel[ResearchType.Power]   = (int)data[i++];
        p.TechLevel[ResearchType.Science] = (int)data[i++];
        p.TechLevel[ResearchType.Missile] = (int)data[i++];
        p.TechLevel[ResearchType.Laser]   = (int)data[i++];
        p.TechLevel[ResearchType.Shield]  = (int)data[i++];

        return(p);
    }
Exemplo n.º 21
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);
    }
Exemplo n.º 22
0
    /// <summary>
    ///   Setup the main menu.
    /// </summary>
    private void RunMenuSetup()
    {
        Background = GetNode <TextureRect>("Background");
        thriveLogo = GetNode <TextureRect>(ThriveLogoPath);

        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);
    }
Exemplo n.º 23
0
        public IRelationship GetBestRelationship(
            Guid speaker,
            Guid listener,
            IEnumerable <string> tags = null)
        {
            Guid[] participants = { speaker, listener };
            IEnumerable <IRelationship> relationships = this.Get(participants, tags, false);

            int           highestValue = int.MinValue;
            IRelationship bestMatch    = null;

            foreach (IRelationship relationship in relationships)
            {
                int value = relationship.GetRelationshipValue(speaker, listener);
                if (value > highestValue)
                {
                    highestValue = value;
                    bestMatch    = relationship;
                }
            }

            if (bestMatch is null)
            {
                throw new InvalidOperationException("No relationship between " + speaker + " and " + listener + ".");
            }

            return(bestMatch);
        }
Exemplo n.º 24
0
        public void BringToFront(string name)
        {
            if (!this.ActiveGUIs.Any(gui => gui.Name.Equals(name, StringComparison.OrdinalIgnoreCase)))
            {
                return;
            }

            GUIData toFront = this.ActiveGUIs.First(g => g.Name.Equals(name, StringComparison.OrdinalIgnoreCase));

            foreach (GUIData gui in this.ActiveGUIs)
            {
                if (toFront.Equals(gui) || gui.m_AlwaysOnTop)
                {
                    continue;
                }

                //gui.ZIndex = gui.DefaultSortingOrder;
            }

            GUIData[] found = this.ActiveGUIs
                              .Where(data => data.m_AlwaysOpen == false)
                              .ToArray();
            if (found.Any())
            {
                //toFront.ZIndex = found.Max(data => data.DefaultSortingOrder) + 1;
            }
        }
 public static void Fill <T>(this T[] arr, T item)
 {
     for (var index = 0; index < arr.Length; index++)
     {
         arr[index] = item;
     }
 }
Exemplo n.º 26
0
 private void _initializeWeapon(Godot.Collections.Array <Weapon> weapons)
 {
     for (int index = 0; index < MaxWeaponCount; index++)
     {
         weapons.Add(null);
     }
 }
 public static void AddRange <T>(this Array <T> array, IEnumerable <T> elements)
 {
     foreach (var element in elements)
     {
         array.Add(element);
     }
 }
Exemplo n.º 28
0
    public virtual void changeWeapon(int weaponIndex, Weapon.WeaponOrder weaponOrder)
    {
        weaponIndex = Mathf.Abs(weaponIndex);
        Godot.Collections.Array <Weapon> weapons = GetWeapons(weaponOrder);

        // Caculate actual index base on availble weapon
        weaponIndex = weaponIndex % weapons.Count;

        Weapon currentWeapon = ((Weapon)weapons[CurrentWeaponIndex[weaponOrder]]);

        if (currentWeapon != null)
        {
            DisconnectWeapon(currentWeapon, weaponOrder);

            currentWeapon.Hide();
        }

        CurrentWeaponIndex[weaponOrder] = weaponIndex % weapons.Count;
        currentWeapon = ((Weapon)weapons[CurrentWeaponIndex[weaponOrder]]);


        if (currentWeapon != null)
        {
            currentWeapon.Show();

            ConnectWeapon(currentWeapon, weaponOrder);

            EmitSignal(nameof(WeaponChangeSignal), CurrentInventory.GetItems()[CurrentInventory.GetEquipItemIndex(weaponOrder, weaponIndex)], weaponOrder);

            // Emit signal to update info
            currentWeapon.EmitSignal(nameof(Weapon.AmmoChangeSignal), currentWeapon.GetAmmo(), currentWeapon.GetMaxAmmo(), weaponOrder);
        }
    }
Exemplo n.º 29
0
        public static Dictionary WasEmittedWithArgs(Object emitter, string signal, Array arguments, string context)
        {
            var passed     = $"Signal {signal} was emitted from {emitter} with arguments {arguments}";
            var failed     = $"Signal {signal} was not emitted from {emitter} with arguments {arguments}";
            var altFailure = $"Signal {signal} was not emitted from {emitter}";

            var success = false;
            var result  = "";
            var watcher = (Reference)emitter.GetMeta("watcher");
            var data    = (IDictionary)watcher.Call("get_data", signal);

            if ((int)data["emit_count"] <= 0)
            {
                success = false;
                result  = altFailure;
            }
            else if (FoundMatchingCall(arguments, (IEnumerable)data["calls"]))
            {
                success = true;
                result  = passed;
            }
            else
            {
                success = false;
                result  = failed;
            }

            return(Result(success, passed, result, context));
        }
Exemplo n.º 30
0
    public override void _Ready()
    {
        compoundBars = GetTree().GetNodesInGroup("CompoundBar");

        mouseHoverPanel              = GetNode <PanelContainer>(MouseHoverPanelPath);
        pauseButton                  = GetNode <TextureButton>(PauseButtonPath);
        resumeButton                 = GetNode <TextureButton>(ResumeButtonPath);
        leftPanels                   = GetNode <VBoxContainer>(LeftPanelsPath);
        agentsPanel                  = GetNode <Control>(AgentsPanelPath);
        environmentPanel             = GetNode <NinePatchRect>(EnvironmentPanelPath);
        environmentPanelBarContainer = GetNode <GridContainer>(EnvironmentPanelBarContainerPath);
        glucoseBar                   = GetNode <ProgressBar>(GlucoseBarPath);
        ammoniaBar                   = GetNode <ProgressBar>(AmmoniaBarPath);
        phosphateBar                 = GetNode <ProgressBar>(PhosphateBarPath);
        hydrogenSulfideBar           = GetNode <ProgressBar>(HydrogenSulfideBarPath);
        ironBar                    = GetNode <ProgressBar>(IronBarPath);
        compoundsPanel             = GetNode <NinePatchRect>(CompoundsPanelPath);
        CompoundsPanelBarContainer = GetNode <GridContainer>(CompoundsPanelBarContainerPath);
        oxytoxyBar                 = GetNode <ProgressBar>(OxytoxyBarPath);
        atpBar    = GetNode <TextureProgress>(AtpBarPath);
        healthBar = GetNode <TextureProgress>(HealthBarPath);
        ammoniaReproductionBar   = GetNode <TextureProgress>(AmmoniaReproductionBarPath);
        phosphateReproductionBar = GetNode <TextureProgress>(PhosphateReproductionBarPath);
        atpLabel        = GetNode <Label>(AtpLabelPath);
        hpLabel         = GetNode <Label>(HpLabelPath);
        menu            = GetNode <Control>(MenuPath);
        animationPlayer = GetNode <AnimationPlayer>(AnimationPlayerPath);
        hoveredItems    = GetNode <VBoxContainer>(HoveredItemsContainerPath);
        populationLabel = GetNode <Label>(PopulationLabelPath);
        patchLabel      = GetNode <Label>(PatchLabelPath);
        editorButton    = GetNode <TextureButton>(EditorButtonPath);
        helpScreen      = GetNode <Control>(HelpScreenPath);

        OnEnterStageTransition();
    }