예제 #1
0
 public void Update()
 {
     BaseEnitiy[][] objectList = new BaseEnitiy[ObjectList.Count][];
     for (int y = 0; y <= ObjectList.Count - 1; y++)
     {
         objectList[y] = new BaseEnitiy[ObjectList[y].Count];
         for (int x = 0; x <= ObjectList[y].Count - 1; x++)
         {
             ObjectList[y][x].SetLayerLevel(y);
             objectList[y][x] = ObjectList[y][x];
         }
     }
     for (int y = 0; y <= ObjectList.Count - 1; y++)
     {
         for (int x = 0; x <= ObjectList[y].Count() - 1; x++)
         {
             BaseEnitiy temp;
             if (x != ObjectList[y].Count() - 1)
             {
                 if (objectList[y][x].GetPosition().Y + objectList[y][x].GetSprite().Height + objectList[y][x].GetOffset().Y
                     > objectList[y][x + 1].GetPosition().Y + objectList[y][x + 1].GetSprite().Height + objectList[y][x + 1].GetOffset().Y)
                 {
                     temp                 = objectList[y][x];
                     objectList[y][x]     = objectList[y][x + 1];
                     objectList[y][x + 1] = temp;
                     x = -1;
                 }
             }
         }
     }
     ClearVRAM();
     for (int y = 0; y <= objectList.Length - 1; y++)
     {
         List <BaseEnitiy> sdf = new List <BaseEnitiy>(objectList[y]);
         ObjectList.Add(sdf);
     }
 }
예제 #2
0
 public void AddObjects(BaseEnitiy enitiy)
 {
     Objects.Add(enitiy);
 }
예제 #3
0
        public void Update(GameTime gametime, BaseEnitiy Enitiy = null)
        {
            KeyboardState keyboardState = Keyboard.GetState();

            base.Update(gametime);
            if (GetLayerLevel() == RAM.VRAM.LayerLevel)
            {
                if (RAM.OnShip == true)
                {
                    foreach (BaseEnitiy obj in RAM.VRAM.ObjectList[RAM.VRAM.LayerLevel])
                    {
                        if (obj is AvatarSprite)
                        {
                            RAM.camera.SetPosition(new Vector2(640 - GetPosition().X, 360 - GetPosition().Y));
                            if (time.GetTimeFlag() == true)
                            {
                                if (keyboardState.IsKeyDown(Keys.Up) &&
                                    keyboardState.IsKeyDown(Keys.Left))
                                {
                                    if (RAM.MapArea.MoveOnShip((int)GetPosition().X - (RAM.TILESIZE / 8), (int)GetPosition().Y - (RAM.TILESIZE / 8)) == true)
                                    {
                                        SetPosition(new Vector2(GetPosition().X - (RAM.TILESIZE / 8), GetPosition().Y - (RAM.TILESIZE / 8)));
                                        obj.SetPosition(new Vector2(GetPosition().X - (RAM.TILESIZE / 8), GetPosition().Y - (RAM.TILESIZE / 8)));
                                    }
                                }
                                else if (keyboardState.IsKeyDown(Keys.Up) &&
                                         keyboardState.IsKeyDown(Keys.Right))
                                {
                                    if (RAM.MapArea.MoveOnShip((int)GetPosition().X + (RAM.TILESIZE / 8), (int)GetPosition().Y - (RAM.TILESIZE / 8)) == true)
                                    {
                                        SetPosition(new Vector2(GetPosition().X + (RAM.TILESIZE / 8), GetPosition().Y - (RAM.TILESIZE / 8)));
                                        obj.SetPosition(new Vector2(GetPosition().X + (RAM.TILESIZE / 8), GetPosition().Y - (RAM.TILESIZE / 8)));
                                    }
                                }
                                else if (keyboardState.IsKeyDown(Keys.Down) &&
                                         keyboardState.IsKeyDown(Keys.Left))
                                {
                                    if (RAM.MapArea.MoveOnShip((int)GetPosition().X - (RAM.TILESIZE / 8), (int)GetPosition().Y + (RAM.TILESIZE / 8)) == true)
                                    {
                                        SetPosition(new Vector2(GetPosition().X - (RAM.TILESIZE / 8), GetPosition().Y + (RAM.TILESIZE / 8)));
                                        obj.SetPosition(new Vector2(GetPosition().X - (RAM.TILESIZE / 8), GetPosition().Y + (RAM.TILESIZE / 8)));
                                    }
                                }
                                else if (keyboardState.IsKeyDown(Keys.Down) &&
                                         keyboardState.IsKeyDown(Keys.Right))
                                {
                                    if (RAM.MapArea.MoveOnShip((int)GetPosition().X + (RAM.TILESIZE / 8), (int)GetPosition().Y + (RAM.TILESIZE / 8)) == true)
                                    {
                                        SetPosition(new Vector2(GetPosition().X + (RAM.TILESIZE / 8), GetPosition().Y + (RAM.TILESIZE / 8)));
                                        obj.SetPosition(new Vector2(GetPosition().X + (RAM.TILESIZE / 8), GetPosition().Y + (RAM.TILESIZE / 8)));
                                    }
                                }
                                else if (keyboardState.IsKeyDown(Keys.Up))
                                {
                                    if (RAM.MapArea.MoveOnShip((int)GetPosition().X, (int)GetPosition().Y) == true)
                                    {
                                        SetPositionY(GetPosition().Y - (RAM.TILESIZE / 8));
                                        obj.SetPositionY(GetPosition().Y - (RAM.TILESIZE / 8));
                                    }
                                }
                                else if (keyboardState.IsKeyDown(Keys.Down))
                                {
                                    if (RAM.MapArea.MoveOnShip((int)GetPosition().X, (int)GetPosition().Y) == true)
                                    {
                                        SetPositionY(GetPosition().Y + (RAM.TILESIZE / 8));
                                        obj.SetPositionY(GetPosition().Y + (RAM.TILESIZE / 8));
                                    }
                                }
                                else if (keyboardState.IsKeyDown(Keys.Left))
                                {
                                    if (RAM.MapArea.MoveOnShip((int)GetPosition().X, (int)GetPosition().Y) == true)
                                    {
                                        SetPositionX(GetPosition().X - (RAM.TILESIZE / 8));
                                        obj.SetPositionX(GetPosition().X - (RAM.TILESIZE / 8));
                                    }
                                }
                                else if (keyboardState.IsKeyDown(Keys.Right))
                                {
                                    if (RAM.MapArea.MoveOnShip((int)GetPosition().X, (int)GetPosition().Y) == true)
                                    {
                                        SetPositionX(GetPosition().X + (RAM.TILESIZE / 8));
                                        obj.SetPositionX(GetPosition().X + (RAM.TILESIZE / 8));
                                    }
                                }
                                CheckOnFoot();
                            }
                        }
                    }
                }
            }
        }