Ejemplo n.º 1
0
        public void AddPriorityCommand()
        {
            for (var x = 0; x < Game.MapWidth; x++)
            {
                for (var y = 0; y < Game.MapHeight; y++)
                {
                    if (!(Game.Map[x, y] is Player))
                    {
                        continue;
                    }

                    VIPLocation = new Point(x, y);
                    var command   = Game.Map[x, y].Act(x, y);
                    var animation = new EntityAnimation
                    {
                        Command     = command,
                        Entity      = Game.Map[x, y],
                        Location    = new Point(x * ElementSize, y * ElementSize),
                        Destenation = new Point(x + command.DeltaX, y + command.DeltaY)
                    };
                    Animations.Add(animation);
                }
            }
            return;
        }
Ejemplo n.º 2
0
        public void BeginAct()
        {
            Animations.Clear();
            AddPriorityCommand();

            for (var x = 0; x < Game.MapWidth; x++)
            {
                for (var y = 0; y < Game.MapHeight; y++)
                {
                    var entity = Game.Map[x, y];
                    if (entity == null || (VIPLocation.X == x && VIPLocation.Y == y))
                    {
                        continue;
                    }

                    var command = entity.Act(x, y);

                    if (!Game.IsPointInBorders(x + command.DeltaX, y + command.DeltaY))
                    {
                        throw new Exception($"{entity.GetType()} falls out of the game field");
                    }

                    var animation = new EntityAnimation
                    {
                        Command     = command,
                        Entity      = entity,
                        Location    = new Point(x * ElementSize, y * ElementSize),
                        Destenation = new Point(x + command.DeltaX, y + command.DeltaY)
                    };
                    Animations.Add(animation);
                }
            }

            Animations = Animations.OrderByDescending(z => z.Entity.DrawingPriority).ToList();
        }