Example #1
0
        private void LifeLoss(int Damage)
        {
            /*
             *  Odečtení armoru, nebo hp, když nestačí armor, odečte se zbytek z hp
             */
            PlayerCombat.BaseArmor = this.Defender.Armor;
            PlayerCombat.BaseHeal  = this.Defender.Health;

            int DamageOverLimit = 0;

            if (this.Defender.Armor > 0)
            {
                this.Defender.Armor -= Damage;
                if (this.Defender.Armor < 0)
                {
                    DamageOverLimit     = (-this.Defender.Armor);
                    this.Defender.Armor = 0;
                }
            }
            else
            {
                this.Defender.Health -= Damage;
            }

            this.Defender.Health -= DamageOverLimit;
            PlayerTable.Update(this.Defender);

            PlayerCombat.CurrArmor = this.Defender.Armor;
            PlayerCombat.CurrHeal  = this.Defender.Health;
        }
Example #2
0
        public void CmdRefill(int id)
        {
            Player player = PlayerTable.Select(id);

            System.Random rnd  = new System.Random();
            int           rnum = rnd.Next(0, 100);

            if (rnum >= 0 && rnum <= 33) //healthpack
            {
                Character ch = CharacterTable.Select(player.CharacterID);
                player.Health = ch.BHealth + Constants.player_basehealth;
                PlayerTable.Update(player);
                this.message = "Health";
            }
            else if (rnum > 33 && rnum <= 66)//ammo
            {
                Inventory i = InventoryTable.Select(player.InventoryID);
                i.Actual = WeaponTable.Select(i.Weapon_ID).Ammo;
                InventoryTable.Update(i);
                this.message = "Ammo";
            }
            else //Weapon
            {
                Collection <Weapon>    weapons     = WeaponTable.Select();
                Collection <Inventory> inventories = InventoryTable.Select();
                Collection <Weapon>    notowned    = new Collection <Weapon>();
                foreach (Weapon w in weapons)
                {
                    bool add = true;
                    foreach (Inventory inv in inventories)
                    {
                        if (w.ID == inv.Weapon_ID && inv.Player_ID == player.ID) //pokud hráč již vlastní zbraň
                        {
                            add = false;
                            break;
                        }
                    }
                    if (add)
                    {
                        notowned.Add(w);
                    }
                }
                if (notowned.Count == 0) //pokud uz vlastnim vše
                {
                    Character ch = CharacterTable.Select(player.CharacterID);
                    player.Armor += 100;
                    PlayerTable.Update(player);
                    this.message = "Armor";
                }
                else
                {
                    int       WeaponID = rnd.Next(0, notowned.Count - 1);
                    Inventory i        = new Inventory();
                    i.Player_ID = player.ID;
                    i.Weapon_ID = notowned[WeaponID].ID;
                    i.Actual    = notowned[WeaponID].Ammo;
                    i.Slot      = InventoryTable.Select_Count() + 1;
                    InventoryTable.Insert(i);
                    this.message = notowned[WeaponID].Name;
                }
            }
            PlayerRefill.ObtainedItem = this.message;
        }