public MyMwcObjectBuilder_AssignmentOfAmmo(MyMwcObjectBuilder_FireKeyEnum fireKey, 
     MyMwcObjectBuilder_AmmoGroupEnum group, MyMwcObjectBuilder_SmallShip_Ammo_TypesEnum ammoType)
 {
     FireKey = fireKey;
     Group = group;
     AmmoType = ammoType;
 }
 public MyMwcObjectBuilder_AssignmentOfAmmo(MyMwcObjectBuilder_FireKeyEnum fireKey,
                                            MyMwcObjectBuilder_AmmoGroupEnum group, MyMwcObjectBuilder_SmallShip_Ammo_TypesEnum ammoType)
 {
     FireKey  = fireKey;
     Group    = group;
     AmmoType = ammoType;
 }
        public static MyGuiSmallShipHelperAmmo GetMyGuiSmallShipHelperAmmo(MyMwcObjectBuilder_AmmoGroupEnum ammo)
        {
            MyGuiSmallShipHelperAmmo ret;

            if (m_ammoGroups.TryGetValue((int)ammo, out ret))
            {
                return(ret);
            }
            else
            {
                return(null);
            }
        }
示例#4
0
        /// <summary>
        /// Assign ammo group, ammo type to fire key
        /// </summary>
        /// <param name="fireKey">Fire key</param>
        /// <param name="ammoGroup">Ammo group</param>
        /// <param name="ammoType">Ammmo type</param>
        public void AssignAmmo(MyMwcObjectBuilder_FireKeyEnum fireKey, MyMwcObjectBuilder_AmmoGroupEnum ammoGroup, MyMwcObjectBuilder_SmallShip_Ammo_TypesEnum ammoType)
        {
            MyAmmoAssignment ammoAssignment = GetAmmoAssignment(fireKey);

            if (ammoAssignment != null)
            {
                ammoAssignment.AmmoGroup = ammoGroup;
                ammoAssignment.AmmoType  = ammoType;
            }
            else
            {
                m_ammoAssignmentCollection.Add((int)fireKey, new MyAmmoAssignment(fireKey, ammoGroup, ammoType));
            }
        }
        //  Read this object from message-in
        internal override bool Read(BinaryReader binaryReader, EndPoint senderEndPoint, int gameVersion)
        {
            if (base.Read(binaryReader, senderEndPoint, gameVersion) == false)
            {
                return(NetworkError());
            }

            //  FireKey
            MyMwcObjectBuilder_FireKeyEnum?fireKey = MyMwcMessageIn.ReadObjectBuilderSmallShipAssignmentOfAmmoFireKeyEnumEx(binaryReader, senderEndPoint);

            if (fireKey == null)
            {
                return(NetworkError());
            }
            FireKey = fireKey.Value;
            MyMwcLog.IfNetVerbose_AddToLog("FireKey: " + FireKey);

            //  FireKey
            MyMwcObjectBuilder_AmmoGroupEnum?group = MyMwcMessageIn.ReadObjectBuilderSmallShipAssignmentOfAmmoGroupEnumEx(binaryReader, senderEndPoint);

            if (group == null)
            {
                return(NetworkError());
            }
            Group = group.Value;
            MyMwcLog.IfNetVerbose_AddToLog("Group: " + Group);

            //  Ammo Type
            MyMwcObjectBuilder_SmallShip_Ammo_TypesEnum?ammoType = MyMwcMessageIn.ReadObjectBuilderSmallShipAmmoTypesEnumEx(binaryReader, senderEndPoint);

            if (ammoType == null)
            {
                return(NetworkError());
            }
            AmmoType = ammoType.Value;
            MyMwcLog.IfNetVerbose_AddToLog("AmmoType: " + AmmoType);

            return(true);
        }
        //  Read this object from message-in
        internal override bool Read(BinaryReader binaryReader, EndPoint senderEndPoint, int gameVersion)
        {
            if (base.Read(binaryReader, senderEndPoint, gameVersion) == false) return NetworkError();

            //  FireKey
            MyMwcObjectBuilder_FireKeyEnum? fireKey = MyMwcMessageIn.ReadObjectBuilderSmallShipAssignmentOfAmmoFireKeyEnumEx(binaryReader, senderEndPoint);
            if (fireKey == null) return NetworkError();
            FireKey = fireKey.Value;
            MyMwcLog.IfNetVerbose_AddToLog("FireKey: " + FireKey);

            //  FireKey
            MyMwcObjectBuilder_AmmoGroupEnum? group = MyMwcMessageIn.ReadObjectBuilderSmallShipAssignmentOfAmmoGroupEnumEx(binaryReader, senderEndPoint);
            if (group == null) return NetworkError();
            Group = group.Value;
            MyMwcLog.IfNetVerbose_AddToLog("Group: " + Group);

            //  Ammo Type
            MyMwcObjectBuilder_SmallShip_Ammo_TypesEnum? ammoType = MyMwcMessageIn.ReadObjectBuilderSmallShipAmmoTypesEnumEx(binaryReader, senderEndPoint);
            if (ammoType == null) return NetworkError();
            AmmoType = ammoType.Value;
            MyMwcLog.IfNetVerbose_AddToLog("AmmoType: " + AmmoType);

            return true;
        }
 public static MyGuiSmallShipHelperAmmo GetMyGuiSmallShipHelperAmmo(MyMwcObjectBuilder_AmmoGroupEnum ammo)
 {
     MyGuiSmallShipHelperAmmo ret;
     if (m_ammoGroups.TryGetValue((int)ammo, out ret))
         return ret;
     else
         return null;
 }
 private static void BindAmmo(MyMwcObjectBuilder_SmallShip_Ammo_TypesEnum ammo, MyMwcObjectBuilder_AmmoGroupEnum group, MyMwcObjectBuilder_SmallShip_Weapon_TypesEnum weapon)
 {
     if (!m_ammoBinding.ContainsKey((int)ammo)) 
         m_ammoBinding[(int)ammo] = new Dictionary<int, MyMwcObjectBuilder_SmallShip_Weapon_TypesEnum>();
     m_ammoBinding[(int)ammo][(int)group] = weapon;
 }        
        public static bool IsAmmoInGroup(MyMwcObjectBuilder_SmallShip_Ammo_TypesEnum ammo, MyMwcObjectBuilder_AmmoGroupEnum group)
        {
            return (m_ammoBinding.ContainsKey((int)ammo) && m_ammoBinding[(int)ammo].ContainsKey((int)group));

        }
示例#10
0
        public override bool HandleInput(MyGuiInput input, bool hasKeyboardActiveControl, bool hasKeyboardActiveControlPrevious, bool receivedFocusInThisUpdate)
        {
            //If this control is not enable, do nothing
            if (!IsEnabled)
            {
                return(false);
            }

            bool isKeyPress = false;
            bool backwardSelectDirection = input.IsKeyPress(Keys.LeftShift) || input.IsKeyPress(Keys.RightShift);
            int  deltaWheelPos           = input.PreviousMouseScrollWheelValue() - input.MouseScrollWheelValue();

            if (deltaWheelPos != 0) // determine just direction
            {
                deltaWheelPos /= Math.Abs(deltaWheelPos);
            }

            if (input.IsNewGameControlPressed(MyGameControlEnums.SELECT_AMMO_BULLET))
            {
                isKeyPress      = true;
                m_selectedGroup = MyMwcObjectBuilder_AmmoGroupEnum.Bullet;
            }

            if (input.IsNewGameControlPressed(MyGameControlEnums.SELECT_AMMO_MISSILE))
            {
                isKeyPress      = true;
                m_selectedGroup = MyMwcObjectBuilder_AmmoGroupEnum.Missile;
            }

            if (input.IsNewGameControlPressed(MyGameControlEnums.SELECT_AMMO_CANNON))
            {
                isKeyPress      = true;
                m_selectedGroup = MyMwcObjectBuilder_AmmoGroupEnum.Cannon;
            }

            if (input.IsNewGameControlPressed(MyGameControlEnums.SELECT_AMMO_UNIVERSAL_LAUNCHER_FRONT))
            {
                isKeyPress      = true;
                m_selectedGroup = MyMwcObjectBuilder_AmmoGroupEnum.UniversalLauncherFront;
            }

            if (input.IsNewGameControlPressed(MyGameControlEnums.SELECT_AMMO_UNIVERSAL_LAUNCHER_BACK))
            {
                isKeyPress      = true;
                m_selectedGroup = MyMwcObjectBuilder_AmmoGroupEnum.UniversalLauncherBack;
            }

            // in case of wheel direction modify flags to run correct code
            if (deltaWheelPos > 0 && Visible && IsEnabled)
            {
                isKeyPress = true;
                backwardSelectDirection = false;
            }
            // in case of wheel direction modify flags to run correct code
            if (deltaWheelPos < 0 && Visible && IsEnabled)
            {
                isKeyPress = true;
                backwardSelectDirection = true;
            }

            if (isKeyPress)
            {
                if (Visible == false)
                {
                    //I am here when the menu opens
                    LoadAmmoFromShip();
                    //If player change fire commands during game play, we need to show actual buttons names.
                    //ReloadControlText();
                    MyGuiSmallShipHelperAmmo.ResetDescription();
                }
                else
                {
                    if (m_selectedGroup == m_selectedGroupLast)
                    {
                        // if (!MyFakes.MW25D)
                        {
                            if (!backwardSelectDirection)
                            {
                                m_selectedIndex++;
                            }
                            else
                            {
                                m_selectedIndex--;
                            }
                        }
                        // else
                        //   m_selectedIndex = 0;
                    }
                    else
                    {
                        //I am here when category is changed
                        LoadAmmoFromShip();
                        MyGuiSmallShipHelperAmmo.ResetDescription();
                    }

                    if (m_selectedIndex >= m_ammoTypesAmounts.Count)
                    {
                        m_selectedIndex = 0;
                    }
                    if (m_selectedIndex < 0)
                    {
                        m_selectedIndex = m_ammoTypesAmounts.Count - 1;
                    }
                }

                Visible             = true;
                m_selectedGroupLast = m_selectedGroup;
                if (m_selectedIndex < m_ammoTypesAmounts.Count && m_selectedIndex >= 0)
                {
                    m_selectedAmmo = m_ammoTypesAmounts[m_selectedIndex].Type;
                }

                MyAudio.AddCue2D(MySoundCuesEnum.SfxHudWeaponScroll);
            }


            //Because I do not want the gun fired before I made the choice, the menu disappears after the release of key (not press)
            if (Visible)
            {
                if (!MySession.Is25DSector)
                {
                    if (input.IsGameControlPressed(MyGameControlEnums.FIRE_PRIMARY) && m_selectedAmmo != 0)
                    {
                        MySession.PlayerShip.Weapons.AmmoAssignments.AssignAmmo(MyMwcObjectBuilder_FireKeyEnum.Primary, m_selectedGroup, m_selectedAmmo);
                        m_isPressLast = true;
                    }
                    if (input.IsGameControlPressed(MyGameControlEnums.FIRE_SECONDARY) && m_selectedAmmo != 0)
                    {
                        MySession.PlayerShip.Weapons.AmmoAssignments.AssignAmmo(MyMwcObjectBuilder_FireKeyEnum.Secondary, m_selectedGroup, m_selectedAmmo);
                        m_isPressLast = true;
                    }
                    if (input.IsGameControlPressed(MyGameControlEnums.FIRE_THIRD) && m_selectedAmmo != 0)
                    {
                        MySession.PlayerShip.Weapons.AmmoAssignments.AssignAmmo(MyMwcObjectBuilder_FireKeyEnum.Third, m_selectedGroup, m_selectedAmmo);
                        m_isPressLast = true;
                    }
                    if (input.IsGameControlPressed(MyGameControlEnums.FIRE_FOURTH) && m_selectedAmmo != 0)
                    {
                        MySession.PlayerShip.Weapons.AmmoAssignments.AssignAmmo(MyMwcObjectBuilder_FireKeyEnum.Fourth, m_selectedGroup, m_selectedAmmo);
                        m_isPressLast = true;
                    }
                    if (input.IsGameControlPressed(MyGameControlEnums.FIRE_FIFTH) && m_selectedAmmo != 0)
                    {
                        MySession.PlayerShip.Weapons.AmmoAssignments.AssignAmmo(MyMwcObjectBuilder_FireKeyEnum.Fifth, m_selectedGroup, m_selectedAmmo);
                        m_isPressLast = true;
                    }

                    if (input.IsNewKeyPress(Keys.Escape))
                    {
                        Visible = false;
                    }
                }
                else
                {  //MyFakes.MW25D
                    if (input.IsGameControlPressed(MyGameControlEnums.FIRE_PRIMARY) && m_selectedAmmo != 0)
                    {
                        MySession.PlayerShip.Weapons.AmmoAssignments.AssignAmmo(MyMwcObjectBuilder_FireKeyEnum.Primary, m_selectedGroup, m_selectedAmmo);
                        m_isPressLast = true;
                    }
                    if (input.IsGameControlPressed(MyGameControlEnums.FIRE_SECONDARY) && m_selectedAmmo != 0)
                    {
                        MySession.PlayerShip.Weapons.AmmoAssignments.AssignAmmo(MyMwcObjectBuilder_FireKeyEnum.Primary, m_selectedGroup, m_selectedAmmo);
                        m_isPressLast = true;
                    }
                    if (input.IsGameControlPressed(MyGameControlEnums.FIRE_THIRD) && m_selectedAmmo != 0)
                    {
                        MySession.PlayerShip.Weapons.AmmoAssignments.AssignAmmo(MyMwcObjectBuilder_FireKeyEnum.Primary, m_selectedGroup, m_selectedAmmo);
                        m_isPressLast = true;
                    }
                    if (input.IsGameControlPressed(MyGameControlEnums.FIRE_FOURTH) && m_selectedAmmo != 0)
                    {
                        MySession.PlayerShip.Weapons.AmmoAssignments.AssignAmmo(MyMwcObjectBuilder_FireKeyEnum.Primary, m_selectedGroup, m_selectedAmmo);
                        m_isPressLast = true;
                    }
                    if (input.IsGameControlPressed(MyGameControlEnums.FIRE_FIFTH) && m_selectedAmmo != 0)
                    {
                        MySession.PlayerShip.Weapons.AmmoAssignments.AssignAmmo(MyMwcObjectBuilder_FireKeyEnum.Primary, m_selectedGroup, m_selectedAmmo);
                        m_isPressLast = true;
                    }

                    if (input.IsNewKeyPress(Keys.Escape))
                    {
                        Visible = false;
                    }
                }

                for (int i = m_ammoTypesAmounts.Count - 1; i >= 0; i--)
                {
                    int itemsPerColumn = 7;

                    int orderX = (int)m_selectedGroup + i / itemsPerColumn;
                    int orderY = i % itemsPerColumn;

                    /*
                     * Vector2 mousePos = MyGuiManager.MouseCursorPosition;
                     * if (MyVideoModeManager.IsTripleHead() == true)
                     *  mousePos += new Vector2(-1, 0);
                     *
                     * if (MyGuiSmallShipHelpers.GetMyGuiSmallShipHelperAmmo(m_ammoTypesAmounts[i].Type).IsPointInMyArea(mousePos))
                     * {
                     * }
                     */
                    //if (MyGuiSmallShipHelpers.GetMyGuiSmallShipHelperAmmo(m_ammoTypesAmounts[i].Type).IsPointInMyArea(MyGuiManager.MouseCursorPosition))
                    MyGuiSmallShipHelperAmmo ammoHelper =
                        MyGuiObjectBuilderHelpers.GetGuiHelper(MyMwcObjectBuilderTypeEnum.SmallShip_Ammo, (int)m_ammoTypesAmounts[i].Type) as MyGuiSmallShipHelperAmmo;
                    if (ammoHelper.IsPointInMyArea(MyGuiManager.MouseCursorPosition))
                    {
                        if (m_selectedIndex != i || m_selectedAmmo != m_ammoTypesAmounts[m_selectedIndex].Type)
                        {
                            MyAudio.AddCue2D(MySoundCuesEnum.SfxHudWeaponScroll);
                        }
                        m_selectedIndex = i;
                        m_selectedAmmo  = m_ammoTypesAmounts[m_selectedIndex].Type;
                    }
                }

                //if (!MyFakes.MW25D)
                {
                    if (m_isPressLast &&
                        !input.IsGameControlPressed(MyGameControlEnums.FIRE_PRIMARY) &&
                        !input.IsGameControlPressed(MyGameControlEnums.FIRE_SECONDARY) &&
                        !input.IsGameControlPressed(MyGameControlEnums.FIRE_THIRD) &&
                        !input.IsGameControlPressed(MyGameControlEnums.FIRE_FOURTH) &&
                        !input.IsGameControlPressed(MyGameControlEnums.FIRE_FIFTH))
                    {
                        //I am here when the menu closes
                        m_isPressLast = false;
                        Visible       = false;
                        MyAudio.AddCue2D(MySoundCuesEnum.SfxHudWeaponSelect);
                    }
                }

                /*  else
                 * {
                 *    if (isKeyPress)
                 *        MyAudio.AddCue2D(MySoundCuesEnum.SfxHudWeaponSelect);
                 * } */
            }

            /*
             * if (MyFakes.MW25D)
             * {
             * return false;
             * }   */

            return(base.HandleInput(input, hasKeyboardActiveControl, hasKeyboardActiveControlPrevious, receivedFocusInThisUpdate));
        }
 private static void BindAmmo(MyMwcObjectBuilder_SmallShip_Ammo_TypesEnum ammo, MyMwcObjectBuilder_AmmoGroupEnum group, MyMwcObjectBuilder_SmallShip_Weapon_TypesEnum weapon)
 {
     if (!m_ammoBinding.ContainsKey((int)ammo))
     {
         m_ammoBinding[(int)ammo] = new Dictionary <int, MyMwcObjectBuilder_SmallShip_Weapon_TypesEnum>();
     }
     m_ammoBinding[(int)ammo][(int)group] = weapon;
 }
 public static bool IsAmmoInGroup(MyMwcObjectBuilder_SmallShip_Ammo_TypesEnum ammo, MyMwcObjectBuilder_AmmoGroupEnum group)
 {
     return(m_ammoBinding.ContainsKey((int)ammo) && m_ammoBinding[(int)ammo].ContainsKey((int)group));
 }
        public static MyMwcObjectBuilder_SmallShip_Weapon_TypesEnum?GetWeaponType(MyMwcObjectBuilder_SmallShip_Ammo_TypesEnum ammo, MyMwcObjectBuilder_AmmoGroupEnum group)
        {
            MyMwcObjectBuilder_SmallShip_Weapon_TypesEnum ret;
            Dictionary <int, MyMwcObjectBuilder_SmallShip_Weapon_TypesEnum> dic;

            if (m_ammoBinding.TryGetValue((int)ammo, out dic))
            {
                if (dic.TryGetValue((int)group, out ret))
                {
                    return(ret);
                }
            }
            return(null);
        }
示例#14
0
        private bool TryAssignAmmo(MyMwcObjectBuilder_SmallShip_Weapon_TypesEnum weaponType, MyMwcObjectBuilder_AmmoGroupEnum ammoGroup, MyMwcObjectBuilder_FireKeyEnum fireKey, MyMwcObjectBuilder_SmallShip_Ammo_TypesEnum[] ammoPriorities)
        {
            for (int i = 0; i < ammoPriorities.Length; i++)
            {
                if (Weapons.AmmoInventoryItems.GetAmmoInventoryItems(ammoPriorities[i]).Count > 0)
                {
                    Weapons.AmmoAssignments.AssignAmmo(fireKey, ammoGroup, ammoPriorities[i]);

                    MyBotParams botParamsOneSlot = SettingsForWeaponType(weaponType, ammoPriorities[i]);
                    botParamsOneSlot.FireKey = fireKey;
                    botParamsOneSlot.HasAmmo = true;
                    m_botWeaponParamsAllSlots[(int)fireKey - 1] = botParamsOneSlot;
                    return true;
                }
            }
            return false;
        }
 public static MyMwcObjectBuilder_SmallShip_Weapon_TypesEnum? GetWeaponType(MyMwcObjectBuilder_SmallShip_Ammo_TypesEnum ammo, MyMwcObjectBuilder_AmmoGroupEnum group)
 {
     MyMwcObjectBuilder_SmallShip_Weapon_TypesEnum ret;
     Dictionary<int, MyMwcObjectBuilder_SmallShip_Weapon_TypesEnum> dic;
     if (m_ammoBinding.TryGetValue((int)ammo, out dic))
     {
         if (dic.TryGetValue((int)group, out ret))
         {
             return ret;
         }
     }
     return null;
 }
示例#16
0
 /// <summary>
 /// Assign ammo group, ammo type to fire key
 /// </summary>
 /// <param name="fireKey">Fire key</param>
 /// <param name="ammoGroup">Ammo group</param>
 /// <param name="ammoType">Ammmo type</param>
 public void AssignAmmo(MyMwcObjectBuilder_FireKeyEnum fireKey, MyMwcObjectBuilder_AmmoGroupEnum ammoGroup, MyMwcObjectBuilder_SmallShip_Ammo_TypesEnum ammoType)
 {
     MyAmmoAssignment ammoAssignment = GetAmmoAssignment(fireKey);
     if (ammoAssignment != null)
     {
         ammoAssignment.AmmoGroup = ammoGroup;
         ammoAssignment.AmmoType = ammoType;
     }
     else
     {
         m_ammoAssignmentCollection.Add((int)fireKey, new MyAmmoAssignment(fireKey, ammoGroup, ammoType));
     }
 }
示例#17
0
 public static void WriteObjectBuilderSmallShipAssignmentOfAmmoGroupEnum(MyMwcObjectBuilder_AmmoGroupEnum val, BinaryWriter binaryWriter)
 {
     binaryWriter.Write((byte)val);
 }