Beispiel #1
0
 /// <summary>
 /// 
 /// </summary>
 /// <param name="entity"></param>
 public void SendInformations(AbstractEntity entity)
 {
     var guildName = string.Empty;
     var guildEmblem = string.Empty;
     if(Guild != null)
     {
         guildName = Guild.Name;
         guildEmblem = Guild.Emblem;
     }
     // Map -2 to 0
     var guildId = GuildId == -2 ? 0 : GuildId;
     entity.Dispatch(WorldMessage.PADDOCK_INFORMATIONS(guildId, Price, MountPlace, ItemPlace, guildName, guildEmblem));
 }
        /// <summary>
        /// 
        /// </summary>
        /// <param name="actor"></param>
        /// <param name="guid"></param>
        /// <param name="quantity"></param>
        public override void SellItem(AbstractEntity entity, long guid, int quantity, long price = -1)
        {
            if (quantity < 1)
            {
                Logger.Debug("ShopExchange unable to sell, quantity < 1 : " + entity.Name);
                entity.Dispatch(WorldMessage.EXCHANGE_SELL_ERROR());
                return;
            }

            var item = entity.Inventory.Items.Find(entry => entry.Id == guid);

            if (item == null)
            {
                Logger.Debug("ShopExchange unable to sell null item : " + entity.Name);
                entity.Dispatch(WorldMessage.EXCHANGE_SELL_ERROR());
                return;
            }

            if (quantity > item.Quantity)
                quantity = item.Quantity;

            var sellPrice = (item.Template.Price / 10) * quantity;

            entity.Inventory.RemoveItem(guid, quantity);
            entity.Inventory.AddKamas(sellPrice);
        }
 /// <summary>
 /// 
 /// </summary>
 public void SendMapFightInfos(AbstractEntity entity)
 {
     if (State == FightStateEnum.STATE_PLACEMENT)
     {
         entity.Dispatch(WorldMessage.FIGHT_FLAG_DISPLAY(this));
         Team0.SendMapFightInfos(entity);
         Team1.SendMapFightInfos(entity);
     }
 }
 /// <summary>
 /// 
 /// </summary>
 /// <param name="entity"></param>
 public void SendMapFightInfos(AbstractEntity entity)
 {
     entity.Dispatch(WorldMessage.FIGHT_FLAG_UPDATE(OperatorEnum.OPERATOR_ADD, LeaderId, Fighters.ToArray()));
     foreach (var option in m_blockedOption)
         entity.Dispatch(WorldMessage.FIGHT_OPTION(option.Key, option.Value, LeaderId));
 }
        /// <summary>
        /// 
        /// </summary>
        /// <param name="entity"></param>
        /// <param name="path"></param>
        /// <param name="cellId"></param>
        public void MovementFinish(AbstractEntity entity, MovementPath path, int cellId)
        {
            if (entity.Type == EntityTypeEnum.TYPE_CHARACTER)
            {
                var character = (CharacterEntity)entity;
                if (character.CanGameAction(GameActionTypeEnum.FIGHT))
                {
                    foreach (var monsterGroup in m_entityById.Values.OfType<MonsterGroupEntity>())
                    {
                        if (CanBeAggro(character, cellId, monsterGroup))
                        {
                            entity.CellId = cellId;
                            if (monsterGroup.AlignmentId == -1)
                            {
                                if (FightManager.StartMonsterFight(character, monsterGroup))
                                    return;
                            }
                            else
                            {
                                if (FightManager.StartAggression(monsterGroup, character))
                                    return;
                            }
                        }         
                    }
                }
            }

            if (entity.CellId == cellId)
                return;

            entity.Orientation = path.GetDirection(path.LastStep);

            if (entity.Type == EntityTypeEnum.TYPE_CHARACTER)
            {
                var character = (CharacterEntity)entity;
                var cell = GetCell(cellId);
                if (cell != null)
                {
                    if (cell.Trigger != null)
                    {
                        if(!cell.SatisfyConditions(character))
                        {
                            entity.Dispatch(WorldMessage.IM_ERROR_MESSAGE(InformationEnum.ERROR_CONDITIONS_UNSATISFIED));
                            return;
                        }

                        entity.CellId = cellId;
                        cell.ApplyActions(character);
                        return;
                    }                    
                }     
            }

            entity.CellId = cellId;
        }
 /// <summary>
 /// 
 /// </summary>
 /// <param name="entity"></param>
 public void SendInteractiveData(AbstractEntity entity) 
     => entity.Dispatch(WorldMessage.INTERACTIVE_DATA_FRAME(m_interactiveObjects));
 /// <summary>
 /// 
 /// </summary>
 /// <param name="entity"></param>
 public void SendMapInformations(AbstractEntity entity) 
     => entity.Dispatch(WorldMessage.GAME_MAP_INFORMATIONS(OperatorEnum.OPERATOR_ADD, Entities.ToArray()));
 /// <summary>
 /// 
 /// </summary>
 /// <param name="entity"></param>
 public void SendFightCount(AbstractEntity entity) 
     => entity.Dispatch(WorldMessage.FIGHT_COUNT(FightManager.FightCount));
        /// <summary>
        /// 
        /// </summary>
        /// <param name="entity"></param>
        public void SendAllInformations(AbstractEntity entity)
        {
            entity.CachedBuffer = true;

            // Before showing up we span all required base entities
            SendMapInformations(entity);
            SendInteractiveData(entity);
            SendPaddockInformations(entity);
            entity.Dispatch(WorldMessage.GAME_DATA_SUCCESS());

            // Sub data that arent necessary to be instantly shown
            SendFightCount(entity);
            SendFightsInformations(entity);

            entity.CachedBuffer = false;
        }