Пример #1
0
 public void Update()
 {
     foreach (var item in GameObjectsManager.GetObjects())
     {
         item.Value.Update();
         item.Value.Draw(App.Context, camera.PosX - camera.camOffsetX, camera.PosY - camera.camOffsetY);
     }
 }
Пример #2
0
        public static T Instantiate <T>(int id, int x, int y, int width, int height, string resource) where T : GameObject, new()
        {
            T g = new T();

            GameObjectsManager.AddObject(id, g);
            g.SetResource(resource);
            g.SetPosition(x, y);
            g.SetSize(width, height);
            g.SetPivot(0.5f, 1);

            g.Init();
            return(g);
        }
Пример #3
0
        public void Update()
        {
            App.ClearContext();

            foreach (var item in GameObjectsManager.GetObjects())
            {
                item.Value.Update();
                if (camera != null)
                {
                    item.Value.Draw(App.Context, camera.PosX - camera.camOffsetX, camera.PosY - camera.camOffsetY);
                }
                else
                {
                    item.Value.Draw(App.Context, item.Value.PosX, item.Value.PosY);
                }
            }
        }
Пример #4
0
        private void App_OnClick(MouseEvent arg1, int arg2, int arg3)
        {
            var clickX   = player.PosX + arg2 - camera.camOffsetX;
            var clickY   = player.PosY + arg3 - camera.camOffsetY;
            int maxOrder = 0;

            GameObject clicked = null;

            foreach (var item in GameObjectsManager.GetObjects())
            {
                if (Click.Clicked(item.Value, clickX, clickY))
                {
                    if (item.Value.ObjectId == player.ObjectId)
                    {
                        continue;
                    }

                    if (clicked == null)
                    {
                        clicked = item.Value;
                    }

                    if (maxOrder <= item.Value.order)
                    {
                        maxOrder = item.Value.order;
                        clicked  = item.Value;
                    }
                }
            }

            if (clicked != null)
            {
                clicked.Click();

                if (clicked.ObjectId == map.ObjectId)
                {
                    SetPlayerDestination(arg2, arg3);
                }
            }
        }
Пример #5
0
 public static void Destroy <T>(T go) where T : GameObject
 {
     GameObjectsManager.RemoveObject(go.ObjectId);
 }