public override void Death()
        {
            List <Player> playerList = (GameWorld.FindAll(p => p is Player).Cast <Player>().ToList());

            foreach (Player p in playerList)
            {
                p.ReceiveExp(0, this);
            }

            //Drop equipment/loot, remove itself from world, etc
            Tile tile = Tile;

            if (tile != null)
            {
                tile.RemoveImmediatly(this);
            }

            LootSack ls = new LootSack(this);

            tile.PutOnTile(ls);

            List <GameObject> changes = new List <GameObject>()
            {
                ls, Inventory, tile.OnTile
            };

            changes.AddRange(Inventory.Objects.Cast <GameObject>().ToList());
            changes.AddRange(Inventory.Items);
            LocalServer.SendToClients(new LevelChangedEvent(changes));

            base.Death();
        }
 public void openingChest()
 {
     if (Closed)
     {
         NonAnimationSoundEvent openedChestSoundEvent = new NonAnimationSoundEvent(openSound);
         LocalServer.SendToClients(openedChestSoundEvent);
         spriteAssetName = openContainerSprite;
     }
 }
        public sealed override bool OnServerReceive(LocalServer server)
        {
            HashSet <GameObject> changed = new HashSet <GameObject>();

            DoAction(server, changed);
            player.ActionPoints -= Cost;

            changed.Add(player);
            LocalServer.SendToClients(new LevelChangedEvent(changed));
            return(true);
        }
        public override bool OnServerReceive(LocalServer server)
        {
            player.AddStatPoint(stat);

            NonAnimationSoundEvent statSoundEvent = new NonAnimationSoundEvent("Sounds/CLICK10A", true, player.Id);

            LocalServer.SendToClients(statSoundEvent);

            LocalServer.SendToClients(new LevelChangedEvent(new List <GameObject> {
                player
            }));
            return(true);
        }
 public override void DoSkill(Living caster, Living livingTarget, Tile TileTarget)
 {
     if (livingTarget != null)
     {
         caster.Mana -= ManaCost;
         NonAnimationSoundEvent MagicBoldSound = new NonAnimationSoundEvent("Sounds/donnerre2");
         LocalServer.SendToClients(MagicBoldSound);
         livingTarget.TakeDamage(skillPower, DamageType.Magic);
     }
     else
     {
         throw new Exception("invalid target");
     }
 }
Beispiel #6
0
        protected override void DoAction(LocalServer server, HashSet <GameObject> changedObjects)
        {
            door.Sprite.SheetIndex = (door.Sprite.SheetIndex + 1) % 2;
            door.Open();

            AddVisibleTiles(server.Level, changedObjects);
            player.ComputeVisibility();
            AddVisibleTiles(server.Level, changedObjects);

            changedObjects.Add(door);
            NonAnimationSoundEvent DoorSoundEvent = new NonAnimationSoundEvent("Sounds/door-1-open");

            LocalServer.SendToClients(DoorSoundEvent);
        }
Beispiel #7
0
        public override bool OnServerReceive(LocalServer server)
        {
            if (player.CurrentSkill != newSelectedSkill)
            {
                player.CurrentSkill = newSelectedSkill;
            }
            else
            {
                player.CurrentSkill = null;
            }

            NonAnimationSoundEvent selectSkillSound = new NonAnimationSoundEvent("Sounds/CLICK14A", true, player.Id);

            LocalServer.SendToClients(selectSkillSound);
            return(true);
        }
Beispiel #8
0
        /// <summary>
        /// Adds exp to the players current exp. Can be a flat value or calculated based on the killed enemy his "power"
        /// </summary>
        /// <param name="expGained"></param>
        /// <param name="killedEnemy"></param>
        public void ReceiveExp(int expGained, Enemy killedEnemy = null)
        {
            if (killedEnemy != null)
            {
                int   expmod        = 50;
                float diffulcityMod = killedEnemy.statAverige / statAverige;
                expGained = (int)(diffulcityMod * expmod);
            }

            exp += expGained;

            while (exp >= RequiredExperience())
            {
                LevelUp();
                NonAnimationSoundEvent LevelUpSound = new NonAnimationSoundEvent("Sounds/Taiko_Drum_1", true, Id);
                LocalServer.SendToClients(LevelUpSound);
            }
        }
        /// <summary>
        /// Puts the Living object on a given tile (if possible)
        /// </summary>
        /// <param name="t">Destination tile</param>
        public virtual void MoveTo(Tile t)
        {
            Tile oldTile = Tile;

            if (oldTile != null)
            {
                oldTile.RemoveImmediatly(this);
            }

            if (!t.PutOnTile(this))
            {
                if (!oldTile.PutOnTile(this))
                {
                    throw new Exception();
                }
            }
            else if (Visible)
            { //Movement animation
                LocalServer.SendToClients(new LivingMoveAnimationEvent(this, t, "Sounds/Footsteps 2 steps"));
            }
        }
        protected override void DoAction(LocalServer server, HashSet <GameObject> changedObjects)
        {
            potion.stackCount--;
            switch (potion.GetPotionType)
            {
            case PotionType.Health:
                player.Health += potion.PotionValue;
                NonAnimationSoundEvent PotionSoundEvent = new NonAnimationSoundEvent("Sounds/Potion Sound smaller");
                LocalServer.SendToClients(PotionSoundEvent);

                break;

            case PotionType.Mana:
                player.Mana += potion.PotionValue;
                NonAnimationSoundEvent PotionSoundEvent2 = new NonAnimationSoundEvent("Sounds/Potion Sound smaller");
                LocalServer.SendToClients(PotionSoundEvent2);
                break;

            default:
                throw new Exception("invalid potionType");
            }
            changedObjects.Add(potion);
        }
        public override bool OnServerReceive(LocalServer server)
        {
            List <GameObject> changed = new List <GameObject>();

            if (item != null)
            {
                changed.Add(item);
            }
            if (player.MouseSlot.Item != null)
            {
                changed.Add(player.MouseSlot.Item);
            }

            changed.Add(target);
            changed.Add(player.MouseSlot);
            changed.Add(player);//needed for skill slots
            player.MouseSlot.AddTo(item, target);

            NonAnimationSoundEvent pickupSound = new NonAnimationSoundEvent("Sounds/CLICK10B", true, player.Id);

            LocalServer.SendToClients(new LevelChangedEvent(changed));
            return(true);
        }
        /// <summary>
        /// Handles attacking an opponent. First checks if attacker hits opponent, if succesfull sends attackvalue to defending side, if unsuccesfull displays miss feedback
        /// </summary>
        /// <param name="target"></param>
        public void Attack(Living target)
        {
            string     hitSound    = "Sounds/muted_metallic_crash_impact";
            int        damageDealt = 0;
            DamageType damageType  = DamageType.Physical;

            if (Weapon.SlotItem != null)
            {
                WeaponEquipment weaponItem = Weapon.SlotItem as WeaponEquipment;
                damageType = weaponItem.GetDamageType;
                hitSound   = weaponItem.HitSound;
            }

            //double hitNumber = GameEnvironment.Random.NextDouble();
            //if (hitNumber < HitChance())
            if (TryHit(target))
            {
                double attackValue = AttackValue();
                NonAnimationSoundEvent hitSoundEvent = new NonAnimationSoundEvent(hitSound);
                //no annimation for attacks (hit or miss) yet. when inplementing that, include sound effect there and remove this.
                LocalServer.SendToClients(hitSoundEvent);
                damageDealt = target.TakeDamage(attackValue, damageType);
            }
            else
            {
                //TODO: Display attack missed (visual feedback on fail)

                NonAnimationSoundEvent missSoundEvent = new NonAnimationSoundEvent("Sounds/Dodge");
                //no annimation for attacks (hit or miss) yet. when inplementing that, include sound effect there and remove this.
                LocalServer.SendToClients(missSoundEvent);
            }

            if (damageDealt > 0)
            {
                ProcessReflection(damageDealt, target);
            }
        }
Beispiel #13
0
        public override bool OnServerReceive(LocalServer server)
        {
            NonAnimationSoundEvent nextLevelSound = new NonAnimationSoundEvent("Sounds/wooden-stairs-1");

            LocalServer.SendToClients(nextLevelSound);
            Level             level      = new Level(server.LevelIndex + 1);
            List <GameObject> playerlist = server.Level.FindAll(obj => obj is Player);

            for (int p = 1; p <= playerlist.Count; p++)
            {
                Player player = playerlist[p - 1] as Player;
                (level.Find("StartTile" + p) as Tile).PutOnTile(player);
                player.ActionPoints = Player.MaxActionPoints;
            }
            foreach (Player p in playerlist)
            {
                p.ComputeVisibility();
            }

            server.Level = level;

            LocalServer.SendToClients(new LevelUpdatedEvent(level));
            return(true);
        }