Пример #1
0
        private void GainXp(GameObject user)
        {
            Experience experience = user.GetComponent <Experience>();

            if (!experience)
            {
                return;
            }
            experience.GainXp(value);
        }
Пример #2
0
        private void AwardExperience(GameObject instigator)
        {
            Experience experience = instigator.GetComponent <Experience>();

            if (experience == null)
            {
                return;
            }
            experience.GainXp(GetComponent <BaseStats>().GetStat(Stat.ExperienceReward));
        }
Пример #3
0
        public static void IsDead(Player attacker, Player defender, Room room)
        {
            if (defender.HitPoints <= 0)
            {
                HubContext.SendToAllExcept(defender.Name + " dies ", room.fighting, room.players);


                HubContext.SendToClient("You die", defender.HubGuid);

                HubContext.SendToClient(defender.Name + " dies", attacker.HubGuid);

                defender.Target = null;


                //Turn corpse into room item
                var defenderCorpse = new Item
                {
                    name           = "The corpse of " + defender.Name,
                    container      = true,
                    containerItems = new List <Item>(),
                    description    = new Description {
                        look = "The slain corpse of " + defender.Name + " is here.", room = "The slain corpse of " + defender.Name
                    }
                };

                foreach (var invItem in defender.Inventory)
                {
                    invItem.location = Item.ItemLocation.Room;
                    defenderCorpse.containerItems.Add(invItem);
                }



                var oldRoom = room;
                room.items.Add(defenderCorpse);
                room.corpses.Add(defender);

                if (defender.Type == Player.PlayerTypes.Mob || string.IsNullOrEmpty(defender.HubGuid))
                {
                    room.mobs.Remove(defender);
                }
                else
                {
                    //room.players.Remove(defender);
                    //Add slain player to recall
                }

                defender.Target = null;
                attacker.Target = null;

                attacker.Status = PlayerSetup.Player.PlayerStatus.Standing;

                defender.Status = defender.Type == Player.PlayerTypes.Player ? PlayerSetup.Player.PlayerStatus.Ghost : PlayerSetup.Player.PlayerStatus.Dead;

                Cache.updateRoom(room, oldRoom);

                var xp = new Experience();

                int xpGain = xp.GainXp(attacker, defender);
                attacker.Experience      += xpGain;
                attacker.TotalExperience += xpGain;
                HubContext.SendToClient(xpGain + "XP", attacker.HubGuid);

                xp.GainLevel(attacker);
                //calc xp
                //create corpse

                foreach (var player in room.players)
                {
                    var roomdata = LoadRoom.DisplayRoom(room, player.Name);
                    Score.UpdateUiRoom(player, roomdata);
                }
            }
        }
Пример #4
0
        public static void IsDead(Player attacker, Player defender, Room room)
        {
            if (defender.HitPoints <= 0)
            {
                CheckEvent.FindEvent(CheckEvent.EventType.Death, attacker, "death");

                foreach (var player in room.players)
                {
                    if (player != defender)
                    {
                        HubContext.SendToClient(defender.Name + " dies ", player.HubGuid);
                    }
                    else
                    {
                        HubContext.SendToClient("You die", defender.HubGuid);
                    }
                }



                defender.Target         = null;
                defender.ActiveFighting = false;
                defender.Status         = Player.PlayerStatus.Ghost;


                //Turn corpse into room item
                var defenderCorpse = new Item
                {
                    name           = "The corpse of " + defender.Name,
                    container      = true,
                    containerItems = new List <Item>(),
                    description    = new Description {
                        look = "The slain corpse of " + defender.Name + " is here.", room = "The slain corpse of " + defender.Name
                    }
                };

                foreach (var invItem in defender.Inventory)
                {
                    invItem.location = Item.ItemLocation.Room;
                    defenderCorpse.containerItems.Add(invItem);
                }



                var oldRoom = room;
                room.items.Add(defenderCorpse);
                room.corpses.Add(defender);

                if (defender.Type == Player.PlayerTypes.Mob || string.IsNullOrEmpty(defender.HubGuid))
                {
                    room.mobs.Remove(defender);
                }
                else
                {
                    //room.players.Remove(defender);
                    //Add slain player to recall
                }

                defender.Target = null;

                if (attacker.Target.Name == defender.Name)
                {
                    attacker.Target         = null;
                    attacker.Status         = PlayerSetup.Player.PlayerStatus.Standing;
                    attacker.ActiveFighting = false;
                }

                defender.Status = defender.Type == Player.PlayerTypes.Player ? PlayerSetup.Player.PlayerStatus.Ghost : PlayerSetup.Player.PlayerStatus.Dead;

                Cache.updateRoom(room, oldRoom);

                var xp = new Experience();

                int xpGain = xp.GainXp(attacker, defender);
                attacker.Experience      += xpGain;
                attacker.TotalExperience += xpGain;
                HubContext.SendToClient(xpGain + "XP", attacker.HubGuid);

                xp.GainLevel(attacker);
                //calc xp
                //create corpse

                foreach (var player in room.players)
                {
                    var roomdata = LoadRoom.DisplayRoom(room, player.Name);
                    Score.UpdateUiRoom(player, roomdata);
                }

                if (attacker.HubGuid != null)
                {
                    room.fighting.Remove(attacker.HubGuid);
                }

                if (defender.HubGuid != null)
                {
                    room.fighting.Remove(defender.HubGuid);
                }

                //remove followers

                if (defender.Following != null)
                {
                    if (defender.Followers.Count > 0)
                    {
                        foreach (var follower in defender.Followers)
                        {
                            if (follower.HubGuid != null)
                            {
                                HubContext.SendToClient("You stop following " + defender.Name, follower.HubGuid);
                            }
                        }
                    }

                    defender.Followers = null;
                    defender.Following = null;
                }

                // check if defender is following?
                if (attacker.Followers?.FirstOrDefault(x => x.Equals(defender)) != null)
                {
                    attacker.Followers.Remove(defender);

                    if (attacker.HubGuid != null)
                    {
                        HubContext.SendToClient(defender.Name + " stops following you", attacker.HubGuid);
                    }
                }
            }
        }