Ejemplo n.º 1
0
        public void draw(SpriteBatch sprite, WorldScreen screen)
        {
            for (var i = 0; i < map.Layers[0].Tiles.Count; i++)
               {
                   sprite.Draw(tileset, new Rectangle((int)position.X + map.Layers[0].Tiles[i].X * 16, (int)position.Y + map.Layers[0].Tiles[i].Y * 16, 16, 16), getTile(map.Layers[0].Tiles[i].Gid), Color.White);

               }

               if (Global.Collisions)
               {
                   foreach (Tile ti in Tiles)
                   {
                       if (ti.type == Tile.Type.solid)
                           sprite.Draw(collisiontex, ti.rectangle, rec(30), Color.White * 0.5f);
                       if (ti.type == Tile.Type.air)
                       {
                           //    sprite.Draw(collisiontex, ti.rectangle, rec(1), Color.White * 0.5f);
                       }

                   }
               }
                       foreach(Enemy e in enemys)
                       {
                           e.draw(sprite,screen);
                       }
               foreach(Item e in items)
               {
               e.Draw(sprite);
               }
        }
Ejemplo n.º 2
0
 public Player(WorldScreen screen)
 {
     totalhealth = 6;
     health = 6;
     speed = 1;
     action = Action.still;
     position = new Vector2(+512+75,434+100 );
     direction = Direction.down;
 }
Ejemplo n.º 3
0
        public void LoadContent(WorldScreen screen)
        {
            map = new TmxMap("Content/maps/" +mapstring+".tmx");
            Console.WriteLine("Content/maps/" + mapstring + ".tmx");
            tileset = ScreenManager.Instance.Content.Load<Texture2D>("tileset/"+tilesets);
            collisiontex= ScreenManager.Instance.Content.Load<Texture2D>("tileset/kind");
            Tiles = new List<Tile>();
            Polygon d=null;
             List< Point> lite= new List<Point>();

             enemys = new List<Enemy>();
             items = new List<Item>();
            for (var i = 0; i < map.Layers[1].Tiles.Count; i++)
            {
                Tile.Type p=Tile.Type.air;
                int id = map.Layers[1].Tiles[i].Gid;
                if (id == 172)
                {
                    enemys.Add(new Hero.World.Entitys.Enemys.Octorock(new Vector2((int)position.X + map.Layers[1].Tiles[i].X * 16, (int)position.Y + map.Layers[1].Tiles[i].Y * 16),i));

                }
                if (id == 164) p = Tile.Type.air;
                if (id == 163) p = Tile.Type.solid;
                if (id == 168) p = Tile.Type.invisibol;
                if (id == 166)
                {
                    p = Tile.Type.leftd;
                   lite = new List<Point>();
                    lite.Add(new Point(map.Layers[1].Tiles[i].X * 16, map.Layers[1].Tiles[i].Y * 16));
                    lite.Add(new Point((map.Layers[1].Tiles[i].X * 16)+16, map.Layers[1].Tiles[i].Y * 16));
                    lite.Add(new Point((map.Layers[1].Tiles[i].X * 16) +16, (map.Layers[1].Tiles[i].Y * 16)+16));
                    d= new Polygon(lite);
                }
                if (id == 165)
                {
                    p = Tile.Type.rightd;
                   lite = new List<Point>();
                    lite.Add(new Point(map.Layers[1].Tiles[i].X * 16, map.Layers[1].Tiles[i].Y * 16));
                    lite.Add(new Point((map.Layers[1].Tiles[i].X * 16) + 16, map.Layers[1].Tiles[i].Y * 16));
                    lite.Add(new Point((map.Layers[1].Tiles[i].X * 16), (map.Layers[1].Tiles[i].Y * 16) + 16));
                                 d= new Polygon(lite);
                }
                if (d == null)
                {
                    Tile t = new Tile(p,
                        new Rectangle((int)position.X+map.Layers[1].Tiles[i].X * 16, (int)position.Y + map.Layers[1].Tiles[i].Y * 16, 16, 16));
                    Tiles.Add(t);
                }
                else
                {
                    Tile t = new Tile(p,
                     new Rectangle((int)position.X + map.Layers[1].Tiles[i].X * 16, (int)position.Y+ map.Layers[1].Tiles[i].Y * 16, 16, 16), d);
                    Tiles.Add(t);
                }
                lite.Clear();
                d = null;
                //       map.Layers[0].Tiles[i].Gid
            }
             foreach (Enemy e in enemys)
             {
                 e.LoadContent(screen);
             }
        }
Ejemplo n.º 4
0
 public void update(GameTime time,WorldScreen screen)
 {
     foreach (Enemy e in enemys)
        {
        e.update(time,screen);
        }
     foreach(Item e in items)
     {
         e.Update(time);
     }
 }
Ejemplo n.º 5
0
 public void UpdateView(WorldScreen screen)
 {
     if (active == false)
     {
         _pos = screen.currentlay.position;
         _posto = _pos;
         active = true;
     }
     else
     {
         if (isTransitioning)
         {
             _posto = screen.currentlay.position;
             oldpos = _pos;
             wait = false;
         }
     }
 }
Ejemplo n.º 6
0
        public void CameraCheck(WorldScreen world)
        {
            if (!ScreenManager.Instance.cam.isTransitioning)
            {
                try
                {
                    if (position.X > ScreenManager.Instance.cam.recCamera().X + ScreenManager.Instance.cam.recCamera().Width)
                    {

                        world.ActualVec.Y++;
                        world.currentlay = world.OverWorld[(int)world.ActualVec.X, (int)world.ActualVec.Y];
                        ScreenManager.Instance.cam.isTransitioning = true;
                        ScreenManager.Instance.cam.wait = true;
                    }
                    if (position.X < ScreenManager.Instance.cam.recCamera().X)
                    {
                        world.ActualVec.Y--;
                        world.currentlay = world.OverWorld[(int)world.ActualVec.X, (int)world.ActualVec.Y];
                        ScreenManager.Instance.cam.isTransitioning = true;
                        ScreenManager.Instance.cam.wait = true;
                    }
                    if (position.Y > ScreenManager.Instance.cam.recCamera().Y + ScreenManager.Instance.cam.recCamera().Height)
                    {
                        world.ActualVec.X++;
                        world.currentlay = world.OverWorld[(int)world.ActualVec.X, (int)world.ActualVec.Y];
                        ScreenManager.Instance.cam.isTransitioning = true;
                        ScreenManager.Instance.cam.wait = true;
                    }
                    if (position.Y < ScreenManager.Instance.cam.recCamera().Y)
                    {
                        world.ActualVec.X--;
                        world.currentlay = world.OverWorld[(int)world.ActualVec.X, (int)world.ActualVec.Y];
                        ScreenManager.Instance.cam.isTransitioning = true;
                        ScreenManager.Instance.cam.wait = true;
                    }
                }
                catch (Exception e) { }
            }
        }
Ejemplo n.º 7
0
 public void MoveUp(WorldScreen screen)
 {
     action = Action.walk;
     direction = Direction.up;
     ActualAnimation = getAnimation("runup");
     if (!MoveCollision(new Vector2(position.X, position.Y - speed), screen))
     {
             position.Y -= speed;
     }
 }
Ejemplo n.º 8
0
        public void update(GameTime time, WorldScreen world)
        {
            checkCollision(world);

            if (action != Action.attack)
            {
                action = Action.still;
                if (InputManager.Instance.keyDown(Keys.Down))
                    MoveDown(world);
                else if (InputManager.Instance.keyDown(Keys.Up))
                    MoveUp(world);
                else if (InputManager.Instance.keyDown(Keys.Left))
                    MoveLeft(world);
                else if (InputManager.Instance.keyDown(Keys.Right))
                    MoveRight(world);
                if (InputManager.Instance.keyPressed(Keys.X))
                Aaction();
            }
            else
            {
            action_atack();
            }

            CameraCheck(world);
            if (action == Action.still)
            {
                getCurrentAnim();
            }
            ActualAnimation.update(time, position);
            Keyboard();
        }
Ejemplo n.º 9
0
 public void MoveRight(WorldScreen screen)
 {
     action = Action.walk;
     direction = Direction.right;
     ActualAnimation = getAnimation("runright");
     if (!MoveCollision(new Vector2(position.X + speed, position.Y), screen))
     {
             position.X += speed;
     }
 }
Ejemplo n.º 10
0
 public void MoveLeft(WorldScreen screen)
 {
     action = Action.walk;
     direction = Direction.left;
     ActualAnimation = getAnimation("runleft");
     if (!MoveCollision(new Vector2(position.X - speed, position.Y), screen))
     {
             position.X -= speed;
     }
 }
Ejemplo n.º 11
0
 public void MoveDown(WorldScreen screen)
 {
     action = Action.walk;
     direction = Direction.down;
     ActualAnimation = getAnimation("rundown");
     if (!MoveCollision(new Vector2(position.X,position.Y+speed),screen ))
     {
             position.Y += speed;
     }
 }
Ejemplo n.º 12
0
 public bool MoveCollision(Vector2 position,WorldScreen screen)
 {
     foreach (Tile t in screen.currentlay.Tiles)
     {
        if(t.type==Tile.Type.solid)
         if (t.rectangle.Intersects(new Rectangle((int)position.X+4,(int)position.Y+8,9,8)))
         {
             return true;
         }
     }
     return false;
 }
Ejemplo n.º 13
0
 public void checkCollision(WorldScreen screen)
 {
     foreach(Enemy e in screen.currentlay.enemys )
        {
        if(recSword().Intersects(e.rectangle()))
        {
            e.dmg(1);
        }
        }
 }