Esempio n. 1
0
    public void Fire(Weapon.WeaponOrder weaponOrder, int weaponAction)
    {
        Weapon weapon = GetWeapons(weaponOrder)[CurrentWeaponIndex[weaponOrder]];

        if (weapon != null)
        {
            if (weaponAction == (int)GameStates.PlayerInput.InputAction.RELOAD)
            {
                ReloadWeapon(weaponOrder);
            }
            else if (weaponAction == (int)GameStates.PlayerInput.InputAction.TRIGGER)
            {
                // knock back effect
                if (weapon.Fire(target) && MaxSpeed != 0)
                {
                    Vector2 dir = (new Vector2(1, 0)).Rotated(GlobalRotation).Normalized();

                    if (weapon.KnockbackForce > 0)
                    {
                        ApplyKnockBackForce(-1.0f * dir * weapon.KnockbackForce);
                    }
                }
            }
        }
    }
Esempio n. 2
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);
        }
    }
Esempio n. 3
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);
    }
Esempio n. 4
0
    private void _serverEquipItem(String info)
    {
        int       inventoryItemIndex = int.Parse(info.Split(";")[0]);
        TeamMapAI teamMapAI          = _gameWorld.GetTeamMapAIs()[int.Parse(info.Split(";")[1])];
        Agent     agent = teamMapAI.GetUnit(info.Split(";")[2]);

        Weapon.WeaponOrder weaponOrder = (Weapon.WeaponOrder) int.Parse(info.Split(";")[3]);
        int weaponIndex = int.Parse(info.Split(";")[4]);

        if (agent != null && IsInstanceValid(agent))
        {
            Inventory inventory = agent.GetInventory();

            // Inventory is not null
            if (inventory != null && IsInstanceValid(inventory) && inventory.GetItem(inventoryItemIndex) != null)
            {
                // It is not in used and is equiptable
                if (!inventory.IsItemIndexInUsed(inventoryItemIndex) && inventory.GetItem(inventoryItemIndex).CurrentItemType == ItemResource.ItemType.EQUIPABLE)
                {
                    // Server local directly process
                    inventory.EquipItem(inventoryItemIndex, weaponOrder, weaponIndex);
                }

                // Sync the client no matter if is passing (if not passing, it may indicate cliet is out of sync with server inventory so need to sync)
                if (GetTree().NetworkPeer != null && GetTree().IsNetworkServer())
                {
                    SyncInventory(-1, agent);
                }
            }
        }
    }
Esempio n. 5
0
    public void UpdateWeaponAmmo(int current, int max, Weapon.WeaponOrder weaponOrder)
    {
        //TextureProgress ammoBar = (TextureProgress)GetNode("controlGame/Margin/Container/AmmoBar");
        //ammoBar.Value = value;
        ((Label)GetNode("controlGame/" + weaponOrder + "WeaponControl/lblWeaponAmmo")).Text = current + "/" + max;


        if (Mathf.Abs((float)current / (float)max) <= 0.1f)
        {
            // Change color during if ammo is under 10%
            ((Label)GetNode("controlGame/" + weaponOrder + "WeaponControl/lblWeaponAmmo")).Set("custom_colors/font_color", new Color("#ffc65b"));
        }
        else
        {
            ((Label)GetNode("controlGame/" + weaponOrder + "WeaponControl/lblWeaponAmmo")).Set("custom_colors/font_color", new Color("#96ff5b"));
        }

        // If not 0 ammo, disable the out ammo message
        if (current == 0)
        {
            ((Label)GetNode("controlGame/" + weaponOrder + "WeaponControl/lblWeaponAmmoMessage")).Visible = true;
            ((Label)GetNode("controlGame/" + weaponOrder + "WeaponControl/lblWeaponAmmoMessage")).Text    = "AMMO OUT";
        }
        else
        {
            ((Label)GetNode("controlGame/" + weaponOrder + "WeaponControl/lblWeaponAmmoMessage")).Visible = false;
        }
    }
Esempio n. 6
0
    public void UpdateWeaponReload(Weapon.WeaponOrder weaponOrder, bool reload)
    {
        ((Label)GetNode("controlGame/" + weaponOrder + "WeaponControl/lblWeaponAmmoMessage")).Visible = reload;

        if (reload)
        {
            ((Label)GetNode("controlGame/" + weaponOrder + "WeaponControl/lblWeaponAmmoMessage")).Text = "RELOADING";
        }
    }
Esempio n. 7
0
 protected virtual void ConnectWeapon(Weapon currentWeapon, Weapon.WeaponOrder weaponOrder)
 {
     if (currentWeapon != null)
     {
         // If the current weapon ammo is 0, then notify about out of ammo
         if (currentWeapon.GetAmmo() == 0)
         {
             currentWeapon.EmitSignal(nameof(Weapon.AmmoOutSignal), weaponOrder);
         }
     }
 }
Esempio n. 8
0
 private void _onWeaponReload(Weapon.WeaponOrder weaponOrder, bool isReloading)
 {
     if (weaponOrder == Weapon.WeaponOrder.Left)
     {
         _agent.LeftWeaponAction = (int)GameStates.PlayerInput.InputAction.NOT_TRIGGER;
     }
     else
     {
         _agent.RightWeaponAction = (int)GameStates.PlayerInput.InputAction.NOT_TRIGGER;
     }
 }
Esempio n. 9
0
 private void _onWeaponNeedReload(Weapon.WeaponOrder weaponOrder)
 {
     if (weaponOrder == Weapon.WeaponOrder.Left)
     {
         _agent.LeftWeaponAction = (int)GameStates.PlayerInput.InputAction.RELOAD;
     }
     else
     {
         _agent.RightWeaponAction = (int)GameStates.PlayerInput.InputAction.RELOAD;
     }
 }
Esempio n. 10
0
 public Weapon GetCurrentWeapon(Weapon.WeaponOrder weaponOrder)
 {
     if (weaponOrder == Weapon.WeaponOrder.Right)
     {
         return((Weapon)RightWeapons[CurrentWeaponIndex[weaponOrder]]);
     }
     else
     {
         return((Weapon)LeftWeapons[CurrentWeaponIndex[weaponOrder]]);
     }
 }
Esempio n. 11
0
    // Unequip weapon at given index
    public void UnequipItem(Weapon.WeaponOrder weaponOrder, int weaponIndex)
    {
        int itemIndex = GetEquipItemIndex(weaponOrder, weaponIndex);

        _agent.UnequipWeapon(weaponOrder, weaponIndex);
        _equipmentIndex.Remove((int)weaponOrder + "_" + weaponIndex);
        _usedIndex.Remove(itemIndex);

        EmitSignal(nameof(WeaponChangeSignal), weaponOrder, weaponIndex);
        EmitSignal(nameof(InventoryChangeSignal));
    }
Esempio n. 12
0
 public Godot.Collections.Array <Weapon> GetWeapons(Weapon.WeaponOrder weaponOrder)
 {
     if (weaponOrder == Weapon.WeaponOrder.Right)
     {
         return(RightWeapons);
     }
     else
     {
         return(LeftWeapons);
     }
 }
Esempio n. 13
0
    public int GetEquipItemIndex(Weapon.WeaponOrder weaponOrder, int weaponIndex)
    {
        int index = -1;

        if (_equipmentIndex.ContainsKey((int)weaponOrder + "_" + weaponIndex))
        {
            index = _equipmentIndex[(int)weaponOrder + "_" + weaponIndex];
        }

        return(index);
    }
Esempio n. 14
0
 protected override void DisconnectWeapon(Weapon currentWeapon, Weapon.WeaponOrder weaponOrder)
 {
     if (currentWeapon != null && _agentAI != null && IsInstanceValid(_agentAI))
     {
         // Deregister weapon with ai
         if (currentWeapon.IsConnected(nameof(Weapon.AmmoOutSignal), _agentAI, "_onWeaponNeedReload"))
         {
             currentWeapon.Disconnect(nameof(Weapon.AmmoOutSignal), _agentAI, "_onWeaponNeedReload");
             currentWeapon.Disconnect(nameof(Weapon.ReloadSignal), _agentAI, "_onWeaponReload");
         }
     }
 }
Esempio n. 15
0
    public void Initialize(ItemResource itemResource, ItemPanelType itemPanelType, int inventoryIndex, Weapon.WeaponOrder weaponOrder, int weaponIndex)
    {
        SelfModulate   = _exitedColor;
        _itemResource  = itemResource;
        _isOnPanel     = false;
        _isUsed        = false;
        _isEquipped    = false;
        _itemPanelType = itemPanelType;

        _inventoryIndex = inventoryIndex;
        _weaponOrder    = weaponOrder;
        _weaponIndex    = weaponIndex;

        ((RichTextLabel)(GetNode("Name"))).Text        = "[" + _inventoryIndex + "] " + _itemResource.ItemID + " " + _itemResource.Name;
        ((Label)(GetNode("Price"))).Text               = "COST: " + _itemResource.Price;
        ((RichTextLabel)(GetNode("Description"))).Text = _itemResource.Description;
        ((TextureRect)(GetNode("Image"))).Texture      = _itemResource.ReferenceTexture;
        ((TextureRect)(GetNode("Image"))).RectScale    = new Vector2(0.5f, 0.5f);

        if (ItemPanelType.PURCHASE == itemPanelType)
        {
            Button btn = ((Button)GetNode("Purchase"));
            btn.Show();
            btn.Connect("pressed", this, nameof(_purchase));
        }
        if (ItemPanelType.WEAPON == itemPanelType)
        {
            Button btn = ((Button)GetNode("Equip"));
            btn.Show();
            btn.Connect("pressed", this, nameof(_equip));

            btn = ((Button)GetNode("Unequip"));
            btn.Connect("pressed", this, nameof(_unequip));
        }
        if (ItemPanelType.INVENTORY == itemPanelType)
        {
            Button btn = ((Button)GetNode("Drop"));
            btn.Show();
            btn.Connect("pressed", this, nameof(_drop));

            btn = ((Button)GetNode("Sell"));
            btn.Show();
            btn.Connect("pressed", this, nameof(_sell));

            if (_itemResource.CurrentItemType == ItemResource.ItemType.USABLE)
            {
                btn = ((Button)GetNode("Use"));
                btn.Show();
                btn.Connect("pressed", this, nameof(_use));
            }
        }
    }
Esempio n. 16
0
 protected override void DisconnectWeapon(Weapon currentWeapon, Weapon.WeaponOrder weaponOrder)
 {
     if (currentWeapon != null && _hud != null)
     {
         // Deregister weapon from UI if connected
         if (currentWeapon.IsConnected(nameof(Weapon.AmmoChangeSignal), _hud, nameof(HUD.UpdateWeaponAmmo)))
         {
             currentWeapon.Disconnect(nameof(Weapon.AmmoChangeSignal), _hud, nameof(HUD.UpdateWeaponAmmo));
             currentWeapon.Disconnect(nameof(Weapon.AmmoOutSignal), _hud, nameof(HUD.UpdateWeaponAmmoOut));
             currentWeapon.Disconnect(nameof(Weapon.ReloadSignal), _hud, nameof(HUD.UpdateWeaponReload));
         }
     }
 }
Esempio n. 17
0
    public String GetInventoryState()
    {
        // Set the current inventory count
        String state = "" + (_items.Count - _availableCapacity) + ";";

        for (int index = 0; index < _items.Count; index++)
        {
            if (_items[index] != null)
            {
                state = state + index + ";" + _items[index].ItemID + ";";
            }
        }

        // sync used item
        state = state + _usedIndex.Count + ";";

        for (int index = 0; index < _usedIndex.Count; index++)
        {
            state = state + _usedIndex[index] + ";";
        }

        // Need to go through all weapons
        String weaponInfo     = "";
        int    equipmentIndex = 0;

        for (int weaponOrderIndex = 0; weaponOrderIndex <= (int)Weapon.WeaponOrder.Left; weaponOrderIndex++)
        {
            Weapon.WeaponOrder currentWeaponOrder = (Weapon.WeaponOrder)weaponOrderIndex;
            int weaponCount = _agent.GetWeapons(currentWeaponOrder).Count;
            for (int weaponIndex = 0; weaponIndex < weaponCount; weaponIndex++)
            {
                String weaponKey       = weaponOrderIndex + "_" + weaponIndex;
                int    weaponItemIndex = -1;
                int    ammo            = -1;

                if (_equipmentIndex.ContainsKey(weaponKey))
                {
                    weaponItemIndex = _equipmentIndex[weaponKey];
                    ammo            = _agent.GetWeapons(currentWeaponOrder)[weaponIndex].GetAmmo();
                }

                weaponInfo = weaponInfo + weaponKey + ";" + weaponItemIndex + ";" + ammo + ";";

                equipmentIndex++;
            }
        }

        state = state + equipmentIndex + ";" + weaponInfo;

        return(state);
    }
Esempio n. 18
0
    protected override void ConnectWeapon(Weapon currentWeapon, Weapon.WeaponOrder weaponOrder)
    {
        if (currentWeapon != null && _hud != null)
        {
            // Register new weapon with UI if not connect (as cannot connect again)
            if (!currentWeapon.IsConnected(nameof(Weapon.AmmoChangeSignal), _hud, nameof(HUD.UpdateWeaponAmmo)))
            {
                currentWeapon.Connect(nameof(Weapon.AmmoChangeSignal), _hud, nameof(HUD.UpdateWeaponAmmo));
                currentWeapon.Connect(nameof(Weapon.AmmoOutSignal), _hud, nameof(HUD.UpdateWeaponAmmoOut));
                currentWeapon.Connect(nameof(Weapon.ReloadSignal), _hud, nameof(HUD.UpdateWeaponReload));
            }

            base.ConnectWeapon(currentWeapon, weaponOrder);
        }
    }
Esempio n. 19
0
    public void SetHUD(HUD hud, InventoryManager _inventoryManager)
    {
        isCurrentPlayer = true;

        _hud = hud;

        Connect(nameof(Agent.WeaponChangeSignal), _hud, nameof(HUD.UpdateWeapon));
        Connect(nameof(Agent.HealthChangedSignal), _hud, nameof(HUD.UpdateHealth));
        Connect(nameof(Agent.DefeatedAgentChangedSignal), _hud, nameof(HUD.UpdateDefeatedAgent));

        setHealth(MaxHealth);
        setEnergy(MaxEnergy);

        for (int index = 0; index <= (int)Weapon.WeaponOrder.Left; index++)
        {
            Weapon.WeaponOrder weaponOrder = (Weapon.WeaponOrder)index;
            Weapon             weapon      = GetWeapons(weaponOrder)[GetCurrentWeaponIndex(weaponOrder)];
            if (weapon != null)
            {
                ConnectWeapon(weapon, weaponOrder);

                EmitSignal(nameof(WeaponChangeSignal), CurrentInventory.GetItems()[CurrentInventory.GetEquipItemIndex(weaponOrder, GetCurrentWeaponIndex(weaponOrder))], weaponOrder);
                // Emit signal to update info
                weapon.EmitSignal(nameof(Weapon.AmmoChangeSignal), weapon.GetAmmo(), weapon.GetMaxAmmo(), weaponOrder);
            }
            else
            {
                EmitSignal(nameof(WeaponChangeSignal), null, weaponOrder);
            }
        }

        // Set up the player indicator screen
        ScreenIndicator screenIndicator = (ScreenIndicator)((PackedScene)GD.Load("res://ui/ScreenIndicator.tscn")).Instance();

        AddChild(screenIndicator);
        screenIndicator.Initialize(this);

        // Setup Inventory UI
        _inventoryUI = (InventoryUI)_hud.GetNode("controlGame/InventoryUI");
        _inventoryUI.Initialize(_inventoryManager, CurrentInventory);

        if (!_teamMapAI.IsConnected(nameof(TeamMapAI.TeamUnitUsageAmountChangeSignal), _hud, nameof(HUD.UpdateTeamUnitUsageAmount)))
        {
            _teamMapAI.Connect(nameof(TeamMapAI.TeamUnitUsageAmountChangeSignal), _hud, nameof(HUD.UpdateTeamUnitUsageAmount));
            // Notify the HUD to change
            _teamMapAI.ChargeAmount(0);
        }
    }
Esempio n. 20
0
    public void UnequipItem(Inventory inventory, Weapon.WeaponOrder weaponOrder, int weaponIndex)
    {
        if (inventory != null && IsInstanceValid(inventory))
        {
            String info = (int)inventory.GetAgent().GetCurrentTeam() + ";" + inventory.GetAgent().GetUnitName() + ";" + (int)weaponOrder + ";" + weaponIndex;

            if (GetTree().NetworkPeer == null || GetTree().IsNetworkServer())
            {
                _serverUnequipItem(info);
            }
            else
            {
                RpcId(1, nameof(_serverUnequipItem), info);
            }
        }
    }
Esempio n. 21
0
 private void _shieldStatusChange(int ammo, int maxAmmo, Weapon.WeaponOrder weaponOrder)
 {
     if (ammo == 0)
     {
         if (!_collisionShape2D.Disabled)
         {
             _toggleShield(false);
         }
     }
     else
     {
         if (_collisionShape2D.Disabled)
         {
             _toggleShield(true);
         }
     }
 }
Esempio n. 22
0
    public void UpdateWeapon(ItemResource itemResource, Weapon.WeaponOrder weaponOrder)
    {
        TextureRect symbol = (TextureRect)GetNode("controlGame/" + weaponOrder + "WeaponControl/textureWeaponSymbol");

        if (itemResource == null)
        {
            ((Label)GetNode("controlGame/" + weaponOrder + "WeaponControl/lblWeaponName")).Text = "NO WEAPON";
            symbol.RectScale = Vector2.Zero;
            ((Label)GetNode("controlGame/" + weaponOrder + "WeaponControl/lblWeaponAmmo")).Text = "0/0";
        }
        else
        {
            ((Label)GetNode("controlGame/" + weaponOrder + "WeaponControl/lblWeaponName")).Text = itemResource.ItemID + " " + itemResource.Name;
            symbol.Texture   = itemResource.ReferenceTexture;
            symbol.RectScale = new Vector2(0.5f, 0.5f);
        }
    }
Esempio n. 23
0
    /**
     * Unequip weapon at given weapon order's given index
     **/
    public void UnequipWeapon(Weapon.WeaponOrder weaponOrder, int index)
    {
        Godot.Collections.Array <Weapon> weapons = GetWeapons(weaponOrder);

        Weapon weapon = (Weapon)weapons[index];

        if (weapon != null)
        {
            Node2D weaponHolder = GetWeaponsHolder(weaponOrder);
            weaponHolder.RemoveChild(weapon);
            // Null the weapon
            weapons[index] = null;
            DisconnectWeapon(weapon, Weapon.WeaponOrder.Left);
            // Empty out weapon
            weapon.Deinitialize();
        }
    }
Esempio n. 24
0
    // Equip weapon at given index
    public void EquipItem(int itemIndex, Weapon.WeaponOrder weaponOrder, int weaponIndex)
    {
        if (IsItemIndexInUsed(itemIndex))
        {
            return;
        }

        // Unequip weapon first
        UnequipItem(weaponOrder, weaponIndex);
        String wepaonKey = (int)weaponOrder + "_" + weaponIndex;

        _equipmentIndex.Add(wepaonKey, itemIndex);
        _usedIndex.Add(itemIndex);
        _agent.EquipWeapon(_items[itemIndex].ReferencePackedScene, weaponOrder, weaponIndex);

        EmitSignal(nameof(WeaponChangeSignal), weaponOrder, weaponIndex);
        EmitSignal(nameof(InventoryChangeSignal));
    }
Esempio n. 25
0
    private void _populateWeaponSlots()
    {
        for (int weaponOrderIndex = 0; weaponOrderIndex <= (int)Weapon.WeaponOrder.Left; weaponOrderIndex++)
        {
            Weapon.WeaponOrder weaponOrder = (Weapon.WeaponOrder)weaponOrderIndex;

            Agent agent = _inventory.GetAgent();
            if (agent != null && IsInstanceValid(agent))
            {
                Godot.Collections.Array <Weapon> weapons = agent.GetWeapons(weaponOrder);
                for (int weaponIndex = 0; weaponIndex < weapons.Count; weaponIndex++)
                {
                    String name = "WeaponSlotPanel_" + weaponOrder + "_" + weaponIndex;

                    WeaponSlotPanel currentWeaponSlotPanel = null;

                    // If panel does not exist, created it
                    if (!_gridContainerWeaponSlots.HasNode(name))
                    {
                        currentWeaponSlotPanel      = (WeaponSlotPanel)GetNode("WeaponSlotPanel").Duplicate();
                        currentWeaponSlotPanel.Name = name;
                        _gridContainerWeaponSlots.AddChild(currentWeaponSlotPanel);

                        currentWeaponSlotPanel.Connect(nameof(WeaponSlotPanel.WeaponSlotPanelClickSignal), this, nameof(_populateWeaponChoices));
                    }
                    else
                    {
                        currentWeaponSlotPanel = (WeaponSlotPanel)_gridContainerWeaponSlots.GetNode(name);
                    }

                    ItemResource itemResource = null;

                    if (weapons[weaponIndex] != null)
                    {
                        itemResource = _inventoryManager.GetPurchasableItemByID(weapons[weaponIndex].ItemResourceID);
                    }

                    // Initialize with current weapon
                    currentWeaponSlotPanel.Initialize(itemResource, weaponOrder, weaponIndex);
                    currentWeaponSlotPanel.Show();
                }
            }
        }
    }
Esempio n. 26
0
    private void _updateWeaponChange(Weapon.WeaponOrder weaponOrder, int weaponIndex)
    {
        String          name = "WeaponSlotPanel_" + weaponOrder + "_" + weaponIndex;
        WeaponSlotPanel currentWeaponSlotPanel = (WeaponSlotPanel)_gridContainerWeaponSlots.GetNode(name);

        Agent  agent  = _inventory.GetAgent();
        Weapon weapon = agent.GetWeapons(weaponOrder)[weaponIndex];

        ItemResource itemResource = null;

        if (weapon != null)
        {
            itemResource = _inventoryManager.GetPurchasableItemByID(weapon.ItemResourceID);
        }

        currentWeaponSlotPanel.Initialize(itemResource, weaponOrder, weaponIndex);

        _populateWeaponChoices(weaponOrder, weaponIndex);
    }
Esempio n. 27
0
    private void _populateWeaponChoices(Weapon.WeaponOrder weaponOrder, int weaponIndex)
    {
        _cleanGridContainer(_gridContainerWeaponChoices);

        int inventoryItemIndex = 0;

        foreach (ItemResource itemResource in _inventory.GetItems())
        {
            if (itemResource != null && itemResource.CurrentItemType == ItemResource.ItemType.EQUIPABLE)
            {
                ItemPanel panel = (ItemPanel)_itemPanel.Duplicate();

                _gridContainerWeaponChoices.AddChild(panel);

                populateWeaponChoicePanel(panel, itemResource, inventoryItemIndex, weaponOrder, weaponIndex);
            }

            inventoryItemIndex++;
        }
    }
Esempio n. 28
0
    public void Initialize(ItemResource itemResource, Weapon.WeaponOrder weaponOrder, int weaponIndex)
    {
        SelfModulate  = _exitedColor;
        _itemResource = itemResource;
        _isOnPanel    = false;
        _weaponOrder  = weaponOrder;
        _weaponIndex  = weaponIndex;

        ((Label)(GetNode("Name"))).Text = _weaponOrder + " " + _weaponIndex;

        if (itemResource != null)
        {
            ((TextureRect)(GetNode("Image"))).Texture   = _itemResource.ReferenceTexture;
            ((TextureRect)(GetNode("Image"))).RectScale = new Vector2(0.5f, 0.5f);
        }
        else
        {
            // No image
            ((TextureRect)(GetNode("Image"))).RectScale = Vector2.Zero;
        }
    }
Esempio n. 29
0
    private void _serverUnequipItem(String info)
    {
        String[] splitInfo = info.Split(";");
        int      infoIndex = 0;

        TeamMapAI teamMapAI = _gameWorld.GetTeamMapAIs()[int.Parse(splitInfo[infoIndex])];

        infoIndex++;

        Agent agent = teamMapAI.GetUnit(splitInfo[infoIndex]);

        infoIndex++;

        Weapon.WeaponOrder weaponOrder = (Weapon.WeaponOrder) int.Parse(splitInfo[infoIndex]);
        infoIndex++;

        int weaponIndex = int.Parse(splitInfo[infoIndex]);

        infoIndex++;

        if (agent != null && IsInstanceValid(agent))
        {
            Inventory inventory = agent.GetInventory();
            if (inventory != null && IsInstanceValid(inventory))
            {
                if (agent.GetWeapons(weaponOrder)[weaponIndex] != null)
                {
                    inventory.UnequipItem(weaponOrder, weaponIndex);
                }
                // Sync the client no matter if is passing (if not passing, it may indicate cliet is out of sync with server inventory so need to sync)
                if (GetTree().NetworkPeer != null && GetTree().IsNetworkServer())
                {
                    SyncInventory(-1, agent);
                }
            }
        }
    }
Esempio n. 30
0
 public void UpdateWeaponAmmoOut(Weapon.WeaponOrder weaponOrder)
 {
     ((Label)GetNode("controlGame/" + weaponOrder + "WeaponControl/lblWeaponAmmoMessage")).Visible = true;
     ((Label)GetNode("controlGame/" + weaponOrder + "WeaponControl/lblWeaponAmmoMessage")).Text    = "AMMO OUT";
 }