Inheritance: Codebreak.Service.World.Network.MessageDispatcher
Esempio n. 1
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="subArea"></param>
        /// <param name="id"></param>
        /// <param name="x"></param>
        /// <param name="y"></param>
        /// <param name="width"></param>
        /// <param name="height"></param>
        /// <param name="data"></param>
        /// <param name="dataKey"></param>
        /// <param name="createTime"></param>
        public MapInstance(int subAreaId, int id, int x, int y, int width, int height, string data, string dataKey, string createTime, List <int> f0teamCells, List <int> f1teamCells, bool subInstance = false)
        {
            Id              = id;
            SubAreaId       = subAreaId;
            X               = x;
            Y               = y;
            Width           = width;
            Height          = height;
            Data            = data;
            DataKey         = dataKey;
            CreateTime      = createTime;
            FightTeam0Cells = f0teamCells;
            FightTeam1Cells = f1teamCells;

            m_subInstance        = subInstance;
            m_cells              = new List <MapCell>();
            m_interactiveObjects = new List <InteractiveObject>();
            m_cellById           = new Dictionary <int, MapCell>();
            m_entityById         = new Dictionary <long, AbstractEntity>();
            m_entityByName       = new Dictionary <string, AbstractEntity>();
            m_initialized        = false;

            m_paddock = PaddockManager.Instance.GetByMapId(Id);

            FightManager = new FightManager(this);
            SubArea.AddUpdatable(this);
            SubArea.SafeAddHandler(base.Dispatch);
            SpawnManager.Instance.RegisterMap(this);
            Initialize();
        }
Esempio n. 2
0
        /// <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;
        }
Esempio n. 3
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="character"></param>
 /// <param name="grades"></param>
 public bool StartMonsterFight(CharacterEntity character, IEnumerable <MonsterGradeDAO> grades)
 {
     return(FightManager.StartMonsterFight(character, new MonsterGroupEntity(NextMonsterId, Id, RandomFreeCell, grades)));
 }
Esempio n. 4
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="subArea"></param>
        /// <param name="id"></param>
        /// <param name="x"></param>
        /// <param name="y"></param>
        /// <param name="width"></param>
        /// <param name="height"></param>
        /// <param name="data"></param>
        /// <param name="dataKey"></param>
        /// <param name="createTime"></param>
        public MapInstance(int subAreaId, int id, int x, int y, int width, int height, string data, string dataKey, string createTime, List<int> f0teamCells, List<int> f1teamCells, bool subInstance = false)
        {
            Id = id;
            SubAreaId = subAreaId;
            X = x;
            Y = y;
            Width = width;
            Height = height;
            Data = data;
            DataKey = dataKey;
            CreateTime = createTime;
            FightTeam0Cells = f0teamCells;
            FightTeam1Cells = f1teamCells;

            m_subInstance = subInstance;
            m_cells = new List<MapCell>();
            m_interactiveObjects = new List<InteractiveObject>();
            m_cellById = new Dictionary<int, MapCell>();
            m_entityById = new Dictionary<long, AbstractEntity>();
            m_entityByName = new Dictionary<string, AbstractEntity>();
            m_initialized = false;

            m_paddock = PaddockManager.Instance.GetByMapId(Id);

            FightManager = new FightManager(this);
            SubArea.AddUpdatable(this);
            SubArea.SafeAddHandler(base.Dispatch);
            SpawnManager.Instance.RegisterMap(this);
            Initialize();
        }