Esempio n. 1
0
        public override void Update(Input input)
        {
            base.Update(input);
            mapX = (int)input.GetMapPos(input.MousePos).X / 16 * 16;
            mapY = (int)input.GetMapPos(input.MousePos).Y / 16 * 16;
            furniture.Position = new Vector2(mapX, mapY);

            bool draw = true;

            if (furniture.Collision(furniture.Position, level))
            {
                draw = false;
            }

            drawAllowed = draw;
            if (input.CurrentMouseState.LeftButton == ButtonState.Released)
            {
                if (drawAllowed)
                {
                    FireActivated(null);
                    Furniture instance = (Furniture)Activator.CreateInstance(typeof(T));
                    instance.Position = furniture.Position;
                    instance.mapid    = level.getClientPlayer().mapid;
                    if (Game1.online)
                    {
                        netcode.NetCode.addEntity(instance);
                    }
                    else
                    {
                        level.AddEntity(instance);
                    }
                    if (Game1.currentGamestate == GameState.Editor)
                    {
                        level.CurrentMap.entities.Add(instance);
                    }
                }
                else
                {
                    inv.drag = false;
                }
            }
        }