Пример #1
0
        public CreatureAnimation Add(CreatureAnimation other)
        {
            var newCommands = new List <CreatureCommand>(commands);

            newCommands.AddRange(other.commands);
            return(new CreatureAnimation(newCommands));
        }
Пример #2
0
        public override CreatureAnimation MakeCurrentAnim()
        {
            CreatureAnimation result;

            if (isGoingUp)
            {
                var distToUpperBorder = Location.Y - originalCoords.Y + webSize.Height;
                if (distToUpperBorder > 8)
                {
                    result = new CreatureAnimation().Add(new CreatureCommand {
                        dy = -1
                    }).Repeat(8);
                }
                else
                {
                    result = new CreatureAnimation().Add(new CreatureCommand {
                        dy = -1
                    }).Repeat(distToUpperBorder)
                             .Add(new CreatureAnimation().Add(new CreatureCommand {
                        dy = 1
                    }).Repeat(8 - distToUpperBorder));
                    isGoingUp = false;
                }
            }
            else
            {
                var distToLowerBorder = (originalCoords.Y + webSize.Height + 64) - Location.Y; //remove magic constants (sprite size)
                if (distToLowerBorder > 8)
                {
                    result = new CreatureAnimation().Add(new CreatureCommand {
                        dy = 1
                    }).Repeat(8);
                }
                else
                {
                    result = new CreatureAnimation()
                             .Add(new CreatureCommand {
                        dy = 1
                    }).Repeat(distToLowerBorder)
                             .Add(new CreatureAnimation().Add(new CreatureCommand {
                        dy = -1
                    }).Repeat(8 - distToLowerBorder));
                    isGoingUp = true;
                }
            }
            return(result);
        }
Пример #3
0
        public void MakeRealAnim(List <Terrain> mapObjs, string pressedKey)
        {
            bool isOnGround = false;

            foreach (var o in mapObjs)
            {
                if (o.Hitbox.Contains(new Point(Location.X - o.Location.X, Location.Y - o.Location.Y + 64 + 1)))
                {
                    isOnGround = true;
                    break;
                }
            }
            if (isOnGround)
            {
                if (pressedKey == "A")
                {
                    currentAnim = new CreatureAnimation().Add(new CreatureCommand {
                        dx = -1
                    }).Repeat(8);
                }
                else if (pressedKey == "D")
                {
                    currentAnim = new CreatureAnimation().Add(new CreatureCommand {
                        dx = 1
                    }).Repeat(8);
                }
                else
                {
                    currentAnim = new CreatureAnimation().Add(new CreatureCommand()).Repeat(8);
                }
            }
            else
            {
                currentAnim = new CreatureAnimation().Add(new CreatureCommand {
                    dy = 1
                }).Repeat(8);
            }
        }
Пример #4
0
        public override CreatureAnimation MakeCurrentAnim()
        {
            CreatureAnimation result;

            if (!isGoingUp)
            {
                if (Location.Y > bottomY)
                {
                    isGoingUp = true;
                }
                result = new CreatureAnimation()
                         .Add(new CreatureCommand {
                    dy = 1
                })
                         .Add(new CreatureCommand {
                    dx = 1, dy = 1
                })
                         .Repeat(4);
            }
            else
            {
                if (Location.Y < originalY)
                {
                    //disappear and remove from game.creatures
                }
                result = new CreatureAnimation()
                         .Add(new CreatureCommand {
                    dy = -1
                })
                         .Add(new CreatureCommand {
                    dx = 1, dy = -1
                })
                         .Repeat(4);
            }
            return(result);
        }