Codebreak.Service.World.Game.Entity.AbstractEntity.StopAction C# (CSharp) Метод

StopAction() публичный Метод

public StopAction ( GameActionTypeEnum actionType ) : void
actionType GameActionTypeEnum
Результат void
        public virtual void StopAction(GameActionTypeEnum actionType, params object[] args)
        {
            if (CurrentAction != null && CurrentAction.Type == actionType)
            {
                if (!CurrentAction.IsFinished)
                    CurrentAction.Stop(args);
                if(CurrentAction != null && CurrentAction.Type == actionType)
                    CurrentAction = null;
            }

            switch(actionType)
            {
                case GameActionTypeEnum.MAP:
                    Map?.DestroyEntity(this);
                    break;
            }
        }

Usage Example

Пример #1
0
        /// <summary>
        /// 
        /// </summary>
        public void MoveEntity(AbstractEntity entity)
        {
            if (entity.MovementInterval == 0)
                entity.MovementInterval = Util.Next(10000, 25000);

            if(entity.NextMovementTime == 0)            
                entity.NextMovementTime = UpdateTime + entity.MovementInterval;
            
            if (entity.NextMovementTime > UpdateTime)
                return;

            entity.NextMovementTime = UpdateTime + entity.MovementInterval;

            // Move only if there is a player on the map, else it is useless
            if (m_playerCount == 0)
                return;

            var cellId = entity.LastCellId;
            if (cellId < 1)
                cellId = GetNearestMovementCell(entity.CellId);

            if (entity.LastCellId == 0)
                entity.LastCellId = entity.CellId;
            else
                entity.LastCellId = 0;

            if (cellId < 1)
                return;

            Move(entity, entity.CellId, Pathmaker.FindPathAsString(entity.CellId, cellId, false));

            entity.StopAction(GameActionTypeEnum.MAP_MOVEMENT);
        }