예제 #1
0
 public Bullet(Point point, Hero.Direction dir, Color color)
 {
     this.point = point;
     Direction  = dir;
     Alive      = true;
     Color      = color;
 }
예제 #2
0
 public Boss(int y)
 {
     Health    = 100;
     Velocity  = 5;
     Image     = Properties.Resources.bright2;
     Direction = Hero.Direction.Right;
     Position  = new Point(30, y);
 }
예제 #3
0
 public Zombie(Point pos)
 {
     Position  = pos;
     Image     = Properties.Resources.zdown;
     Alive     = true;
     Velocity  = 4;
     Direction = Hero.Direction.Down;
 }
예제 #4
0
 public Projectile(int x, int y,Image image,Hero.Direction dir)
 {
     this.x = x;
     this.y = y;
     mask = new Rectangle(x, y, 32, 32);
     this.img = image;
     this.dir=dir;
 }
예제 #5
0
 public Bullet(Point point, Hero.Direction dir, Color color, int x, int y)
 {
     this.point = point;
     Direction  = dir;
     Alive      = true;
     Color      = color;
     this.x     = x;
     this.y     = y;
 }
예제 #6
0
        public virtual void Move(Point HeroLocation)
        {
            int hor = Math.Abs(HeroLocation.X - Position.X);
            int ver = Math.Abs(HeroLocation.Y - Position.Y);

            if (Position.X > HeroLocation.X)
            {
                if (hor > ver)
                {
                    Image     = Properties.Resources.bleft1;
                    Direction = Hero.Direction.Left;
                }
                Position = new Point(Position.X - Velocity, Position.Y);
            }

            if (Position.X < HeroLocation.X)
            {
                if (hor > ver)
                {
                    Image     = Properties.Resources.bright2;
                    Direction = Hero.Direction.Right;
                }
                Position = new Point(Position.X + Velocity, Position.Y);
            }

            if (Position.Y > HeroLocation.Y)
            {
                if (hor < ver)
                {
                    Image     = Properties.Resources.bright2;
                    Direction = Hero.Direction.Up;
                }
                Position = new Point(Position.X, Position.Y - Velocity);
            }

            if (Position.Y < HeroLocation.Y)
            {
                if (hor < ver)
                {
                    Image     = Properties.Resources.bright2;
                    Direction = Hero.Direction.Down;
                }
                Position = new Point(Position.X, Position.Y + Velocity);
            }
        }
예제 #7
0
파일: Map.cs 프로젝트: Betzer09/ClashBattle
 public bool MoveCharacter(Hero.Direction CurrentSpot)
 {
     if (CurrentSpot == Hero.Direction.Up)
     {
         if (_Adventurer.PositionX > 0)
         {
             _Adventurer.Move(Actor.Direction.Up);
         }
     }
     if (CurrentSpot == Hero.Direction.Right)
     {
         if (_Adventurer.PositionY < _Cells.GetLength(0) - 1)
         {
             _Adventurer.Move(Actor.Direction.Right);
         }
     }
     if (CurrentSpot == Hero.Direction.Left)
     {
         if (_Adventurer.PositionY > 0)
         {
             _Adventurer.Move(Actor.Direction.Left);
         }
     }
     if (CurrentSpot == Hero.Direction.Down)
     {
         if (_Adventurer.PositionX < _Cells.GetLength(1) - 1)
         {
             _Adventurer.Move(Actor.Direction.Down);
         }
     }
     if (LocationOfAdventurer.HasItem == true || LocationOfAdventurer.HasMonster == true)
     {
         //Hero needs to act
         return(true);
     }
     else
     {
         return(false);
     }
 }
예제 #8
0
 public Bullet(Point point, Hero.Direction dir)
 {
     this.point = point;
     Direction  = dir;
     Alive      = true;
 }
예제 #9
0
 public void moveWater()
 {
     Hero hero = Hero.getInstance();
        if (dir == Hero.Direction.Right)
        {
        if (waterInfront(new Rectangle(x + width, y, waterSpeed, height), ID.WaterFlowRight))
        {
            if (heroOnBoat())
                hero.setX(hero.getX() + waterSpeed);
            x += waterSpeed;
        }
        else dir = Hero.Direction.Down;
        }
        else if (dir == Hero.Direction.Down)
        {
        if (waterInfront(new Rectangle(x, y + height, width, waterSpeed), ID.WaterFlowDown))
        {
            if (heroOnBoat())
                hero.setY(hero.getY() + waterSpeed);
            y += waterSpeed;
        }
        else dir = Hero.Direction.Left;
        }
        else if (dir == Hero.Direction.Left)
        {
        if (waterInfront(new Rectangle(x - waterSpeed, y, waterSpeed, height), ID.WaterFlowLeft))
        {
            if (heroOnBoat())
                hero.setX(hero.getX() - waterSpeed);
            x -= waterSpeed;
        }
        else dir = Hero.Direction.Up;
        }
        else if (dir == Hero.Direction.Up)
        {
        if (waterInfront(new Rectangle(x, y - waterSpeed, width, waterSpeed), ID.WaterFlowUp))
        {
            if (heroOnBoat())
                hero.setY(hero.getY() - waterSpeed);
            y -= waterSpeed;
        }
        else dir = Hero.Direction.Right;
        }
 }
예제 #10
0
 public void getNewDirection()
 {
     int direction = 0;
        int new_direction = 0;
        if (dir == Hero.Direction.Down)
        direction = 1;
        if (dir == Hero.Direction.Left)
        direction = 2;
        if (dir == Hero.Direction.Right)
        direction = 3;
        if (dir == Hero.Direction.Up)
        direction = 4;
        Random random = new Random();
        do
        new_direction = random.Next(5);
        while (new_direction == 0 || new_direction == direction);
        if (new_direction == 1)
        dir = Hero.Direction.Down;
        if (new_direction == 2)
        dir = Hero.Direction.Left;
        if (new_direction == 3)
        dir = Hero.Direction.Right;
        if (new_direction == 4)
        dir = Hero.Direction.Up;
 }