StartAggression() public method

public StartAggression ( MonsterGroupEntity monsters, CharacterEntity victim ) : bool
monsters Codebreak.Service.World.Game.Entity.MonsterGroupEntity
victim Codebreak.Service.World.Game.Entity.CharacterEntity
return bool
Esempio n. 1
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;
        }