Пример #1
0
        /// <summary>
        /// Create a Fighter instance corresponding to the network given type
        /// </summary>
        /// <param name="fighter"></param>
        /// <returns></returns>
        public Fighter CreateFighter(GameFightFighterInformations fighter)
        {
            if (fighter == null)
            {
                throw new ArgumentNullException("fighter");
            }
            if (fighter is GameFightCharacterInformations)
            {
                return(new CharacterFighter(fighter as GameFightCharacterInformations, this));
            }
            if (fighter is GameFightMonsterInformations)
            {
                return(new MonsterFighter(fighter as GameFightMonsterInformations, this));
            }

            throw new Exception(string.Format("Fighter of type {0} not handled", fighter.GetType()));
        }
Пример #2
0
        public override void Update(GameFightFighterInformations informations)
        {
            if (informations == null)
            {
                throw new ArgumentNullException("informations");
            }

            if (informations is GameFightMonsterInformations)
            {
                Update(informations as GameFightMonsterInformations);
            }
            else
            {
                logger.Error("Cannot update a {0} with a {1} instance", GetType(), informations.GetType());
                base.Update(informations);
            }
        }
Пример #3
0
 protected void AddFighter(GameFightFighterInformations infos)
 {
     lock (CheckLock)
     {
         if (infos is GameFightMonsterInformations monsterInfo)
         {
             Monsters.Add(new Monster(monsterInfo.ContextualId, monsterInfo.Disposition.CellId, monsterInfo.Stats,
                                      (uint)monsterInfo.TeamId, monsterInfo.Alive, monsterInfo.CreatureGenericId, (byte)monsterInfo.CreatureGrade));
         }
         //else if (infos is GameFightCompanion companionInfo)
         //    Companions.Add(new Companion(companionInfo.ContextualId, companionInfo.Disposition.CellId,
         //        companionInfo.Stats, companionInfo.TeamId, companionInfo.Alive, companionInfo.CompanionGenericId,
         //        companionInfo.Level, companionInfo.MasterId));
         else if (infos is GameFightCharacterInformations)
         {
             Fighters.Add(new Fighter(infos.ContextualId, infos.Disposition.CellId, infos.Stats, (uint)infos.TeamId,
                                      infos.Alive));
         }
         else
         {
             throw new Exception($"Typeof({infos.TypeID}) [{infos.GetType()}] type is missing on AddFighter()");
         }
     }
 }