Exemplo n.º 1
0
 public void BuyAmmo(int ammoAmount)
 {
     Ammo.Add(Math.Abs(ammoAmount));
     if (Ammo.IsMax)
     {
         Console.WriteLine("Закуплено патронов до максимума.");
     }
     else
     {
         Console.WriteLine($"Закуплено {ammoAmount} патронов.");
     }
 }
Exemplo n.º 2
0
        public void BuyAmmo(int ammoAmount)
        {
            //Подсчёт
            int boughtAmmo = ammoAmount;

            if (ammoAmount + Ammo > Ammo.Max)
            {
                boughtAmmo = Ammo.Max - Ammo;
            }

            Ammo.Add(ammoAmount);
            Console.WriteLine($"Было закуплено {boughtAmmo} патронов.");
        }
Exemplo n.º 3
0
        /// <summary>
        /// Initializes a new instance of the <see cref="ChangingRoleEventArgs"/> class.
        /// </summary>
        /// <param name="player"><inheritdoc cref="Player"/></param>
        /// <param name="newRole"><inheritdoc cref="NewRole"/></param>
        /// <param name="shouldPreservePosition"><inheritdoc cref="Lite"/></param>
        /// <param name="reason"><inheritdoc cref="Reason"/></param>
        public ChangingRoleEventArgs(Player player, RoleType newRole, bool shouldPreservePosition, CharacterClassManager.SpawnReason reason)
        {
            Player  = player;
            NewRole = newRole;
            if (InventorySystem.Configs.StartingInventories.DefinedInventories.ContainsKey(newRole))
            {
                foreach (ItemType itemType in InventorySystem.Configs.StartingInventories.DefinedInventories[newRole].Items)
                {
                    Items.Add(itemType);
                }
                foreach (KeyValuePair <ItemType, ushort> ammoPair in InventorySystem.Configs.StartingInventories.DefinedInventories[newRole].Ammo)
                {
                    Ammo.Add(ammoPair.Key, ammoPair.Value);
                }
            }

            Lite   = shouldPreservePosition;
            Reason = (SpawnReason)reason;
        }