예제 #1
0
        public MainScene(Location Size) : base(Size)
        {
            ConnectionClient Connection = new ConnectionClient();

            Connection.Connect((Port) =>
            {
                if (Port != 0)
                {
                    Logger.Log("Connecting on Port " + Port);
                    Client = new Client(Port);
                }
                else
                {
                    Logger.Log("Failed to connect to remote host");
                }
                Connection.Dispose();
            });

            Player       = new Player();
            Player.Scale = 10;
            Player.Layer = 10;
            AddChild(Player);
            Players.Add(Player);

            Tiles       = new TileManager(2048, 2048, ClansGame.TestTileTexture, 8);
            Tiles.Scale = 5;

            for (int Y = 0; Y < Tiles.Height; Y++)
            {
                for (int X = 0; X < Tiles.Width; X++)
                {
                    Tiles.Set(X, Y, 3 + JRandom.Next(3), 0, 1, 0);
                }
            }

            Tiles.Layer = -1;
            AddChild(Tiles);

            Camera.Target = Player;

            Snow           = new SnowEffect(2);
            Snow.Intensity = 0;
            UI.AddChild(Snow);

            Info               = new LabelNode(Font.Default, "WASD to move + and - to change the bleeding", 20);
            Info.Position      = new Location(Size.X / 2, Size.Y * 0.3);
            Info.AnchorPoint.X = 0.5;
            Info.Color         = new Color(128, 128, 130);
            UI.AddChild(Info);

            Input.ListenForKey(Keys.I, this);
            Input.ListenForKey(Keys.O, this);
            Input.ListenForKey(Keys.P, this);
        }
예제 #2
0
 public LoadingScenePage(ResourceCache cache)
 {
     CreateSimpleScene(100);
     _text       = new Text();
     _text.Value = "Loading";
     _text.SetColor(Color.White);
     _text.HorizontalAlignment = HorizontalAlignment.Center;
     _text.VerticalAlignment   = VerticalAlignment.Center;
     //_text.SetStyleAuto(null);
     _text.SetFont("Fonts/Anonymous Pro.ttf", 32);
     _text.TextEffect = TextEffect.Stroke;
     UI.AddChild(_text);
 }
예제 #3
0
        public LoadScene(TileData[] Tiles, Location Size) : base(Size)
        {
            Button BackButton = new Button(WBGame.ButtonSprite, "Back", 15, () =>
            {
                JuixelGame.Shared.ChangeScene(new SelectionScene(Size));
            });

            BackButton.Position = new Location(10 + BackButton.Size.X / 2, 10 + BackButton.Size.Y / 2);
            UI.AddChild(BackButton);

            this.Tiles   = Tiles;
            ImporterName = new TextField("Importer", Font.Default, new Location(200, 40), 20)
            {
                Position              = new Location(Size.X * 0.3, Size.Y * 0.4),
                AnchorPoint           = 0.5,
                UsePlaceholderAsTitle = true,
                Interactive           = false
            };
            ImporterName.CustomizeBackground(() => new SpriteNode(TextureLibrary.Square)
            {
                Size = new Location(0, 4), AnchorPoint = new Location(0, 1)
            }, (Node, BackSize) => Node.Size = new Location(BackSize.X, Node.Size.Y));
            AddChild(ImporterName);

            SelectImportButton          = new Button(WBGame.ButtonSprite, "Select Importer", 20, LoadImporter);
            SelectImportButton.Position = new Location(Size.X * 0.3, Size.Y * 0.4 + ImporterName.Size.Y + 20);
            AddChild(SelectImportButton);

            ImportButton          = new Button(WBGame.ButtonSprite, "Import", 20, ImportPressed);
            ImportButton.Position = new Location(Size.X * 0.3, SelectImportButton.Position.Y + SelectImportButton.Size.Y + 20);
            ImportButton.Hidden   = true;
            AddChild(ImportButton);

            LoadButton          = new Button(WBGame.ButtonSprite, "Load Map", 20, LoadPressed);
            LoadButton.Position = new Location(Size.X * 0.7, SelectImportButton.Position.Y);
            AddChild(LoadButton);

            SpriteNode Divider = new SpriteNode(TextureLibrary.Square);

            Divider.Size        = new Location(6, 300);
            Divider.AnchorPoint = 0.5;
            Divider.Position    = Size / 2;
            AddChild(Divider);

            string DefImporter = GameSettings.GetString("default_importer", "");

            if (DefImporter != "" && File.Exists(DefImporter))
            {
                LoadImporterFromFile(DefImporter);
            }

            LoadingBack             = new SpriteNode(TextureLibrary.Square);
            LoadingBack.Size        = new Location(300, 30);
            LoadingBack.AnchorPoint = 0.5;
            LoadingBack.Color       = new Color(24, 24, 24);
            LoadingBack.Position    = new Location(Size.X / 2, Size.Y * 0.8);
            LoadingBack.Hidden      = true;
            AddChild(LoadingBack);

            LoadingBar             = new SpriteNode(TextureLibrary.Square);
            LoadingBar.AnchorPoint = LoadingBack.AnchorPoint;
            LoadingBar.Color       = new Color(54, 54, 54);
            LoadingBar.Scale.X     = 0;
            LoadingBack.AddChild(LoadingBar);

            LoadingInfo             = new LabelNode(Font.Default, "", 16);
            LoadingInfo.AnchorPoint = new Location(0.5, 1);
            LoadingInfo.Position    = new Location(LoadingBack.Position.X, LoadingBack.Position.Y - 20);
            AddChild(LoadingInfo);
        }
예제 #4
0
        public CreationScene(TileData[] Tiles, Location Size) : base(Size)
        {
            Button BackButton = new Button(WBGame.ButtonSprite, "Back", 15, () =>
            {
                JuixelGame.Shared.ChangeScene(new SelectionScene(Size));
            });

            BackButton.Position = new Location(10 + BackButton.Size.X / 2, 10 + BackButton.Size.Y / 2);
            UI.AddChild(BackButton);

            char[] NumeralCharFilter = "0123456789".ToCharArray();

            WidthField = new TextField("Map Width", Font.Default, new Location(200, 40), 20)
            {
                Position              = new Location(Size.X / 2, Size.Y * 0.2),
                AnchorPoint           = 0.5,
                UsePlaceholderAsTitle = true,
                MaxCharacters         = 5,
                CharFilter            = NumeralCharFilter
            };
            WidthField.OnTextChanged += CheckReady;
            WidthField.Text           = GameSettings.GetString("map_width", "");
            WidthField.CustomizeBackground(() => new SpriteNode(TextureLibrary.Square)
            {
                Size = new Location(0, 4), AnchorPoint = new Location(0, 1)
            }, (Node, BackSize) => Node.Size = new Location(BackSize.X, Node.Size.Y));
            AddChild(WidthField);

            HeightField = new TextField("Map Height", Font.Default, new Location(200, 40), 20)
            {
                Position              = new Location(Size.X / 2, Size.Y * 0.3),
                AnchorPoint           = 0.5,
                UsePlaceholderAsTitle = true,
                MaxCharacters         = 5,
                CharFilter            = NumeralCharFilter
            };
            HeightField.OnTextChanged += CheckReady;
            HeightField.Text           = GameSettings.GetString("map_height", "");
            HeightField.CustomizeBackground(() => new SpriteNode(TextureLibrary.Square)
            {
                Size = new Location(0, 4), AnchorPoint = new Location(0, 1)
            }, (Node, BackSize) => Node.Size = new Location(BackSize.X, Node.Size.Y));
            AddChild(HeightField);

            CreateMapButton = new Button(WBGame.ButtonSprite, "Create Map", 30, () =>
            {
                CheckReady();
                if (_Ready)
                {
                    int Width  = int.Parse(WidthField.Text);
                    int Height = int.Parse(HeightField.Text);
                    GameSettings.SetString("map_width", WidthField.Text);
                    GameSettings.SetString("map_height", HeightField.Text);
                    LoadingBack.Hidden = false;
                    CreateMap(Width, Height, Tiles, UpdateLoading);
                }
            })
            {
                Position = new Location(Size.X / 2, Size.Y * 0.6),
                Alpha    = 0
            };
            AddChild(CreateMapButton);

            CreateMapPosition = CreateMapButton.Position;

            LoadingBack             = new SpriteNode(TextureLibrary.Square);
            LoadingBack.Size        = new Location(300, 30);
            LoadingBack.AnchorPoint = 0.5;
            LoadingBack.Color       = new Color(24, 24, 24);
            LoadingBack.Position    = new Location(Size.X / 2, Size.Y * 0.75);
            LoadingBack.Hidden      = true;
            AddChild(LoadingBack);

            LoadingBar             = new SpriteNode(TextureLibrary.Square);
            LoadingBar.AnchorPoint = LoadingBack.AnchorPoint;
            LoadingBar.Color       = new Color(54, 54, 54);
            LoadingBar.Scale.X     = 0;
            LoadingBack.AddChild(LoadingBar);

            LoadingInfo             = new LabelNode(Font.Default, "", 16);
            LoadingInfo.AnchorPoint = new Location(0.5, 1);
            LoadingInfo.Position    = new Location(LoadingBack.Position.X, LoadingBack.Position.Y - 20);
            AddChild(LoadingInfo);

            _CanReady = true;
            CheckReady();
        }
예제 #5
0
        public MapScene(MapDataLoader Loader, TileData[] Tiles, Location Size) : base(Size)
        {
            Loading             = new LabelNode(Font.Default, "Loading...", 30);
            Loading.Position    = Size / 2;
            Loading.AnchorPoint = 0.5;
            AddChild(Loading);

            Map              = new Map(Loader, new IntLocation((int)Size.X, (int)Size.Y), Tiles);
            Map.OnBlockLoad += StopLoading;
            Map.Position     = Size / 2 - Map.Size / 2;
            AddChild(Map);

            OnResize += OnWindowResize;

            Zoom          = new LabelNode(Font.Default, "", 20);
            Zoom.Color    = Color.LightGray;
            Zoom.Position = new Location(100, 10);
            UI.AddChild(Zoom);

            Action          = new LabelNode(Font.Default, "", 20);
            Action.Color    = Color.LightGray;
            Action.Position = new Location(100, 30);
            UI.AddChild(Action);

            SpriteNode InfoBack = new SpriteNode(TextureLibrary.Square);

            InfoBack.Size     = new Location(220, 55);
            InfoBack.Layer    = -1;
            InfoBack.Color    = Color.Black;
            InfoBack.Alpha    = 0.4f;
            InfoBack.Position = Zoom.Position - 5;
            UI.AddChild(InfoBack);

            DrawToolPreview = new SpriteNode(new Sprite(WBGame.TileSheet, GetDrawPreviewRect()))
            {
                AnchorPoint = new Location(1, 0),
                Size        = 32,
                Position    = new Location(Size.X - 10, 10)
            };
            UI.AddChild(DrawToolPreview);

            Button BackButton = new Button(WBGame.ButtonSprite, "Back", 15, () =>
            {
                JuixelGame.Shared.ChangeScene(new SelectionScene(Size));
            });

            BackButton.Position = new Location(10 + BackButton.Size.X / 2, 10 + BackButton.Size.Y / 2);
            UI.AddChild(BackButton);

            BlockUp = new Button(WBGame.ButtonSprite, "Block Up", 15, () =>
            {
                if (Loading.Hidden)
                {
                    StartLoading();
                    Map.SaveTempBlock();
                    Map.LoadBlock(Map.BlockX, Map.BlockY + 1);
                }
            });
            BlockUp.Position = new Location(Size.X / 2, 30);
            UI.AddChild(BlockUp);

            BlockDown = new Button(WBGame.ButtonSprite, "Block Down", 15, () =>
            {
                if (Loading.Hidden)
                {
                    StartLoading();
                    Map.SaveTempBlock();
                    Map.LoadBlock(Map.BlockX, Map.BlockY - 1);
                }
            });
            BlockDown.Position = new Location(Size.X / 2, Size.Y - 30);
            UI.AddChild(BlockDown);

            BlockLeft = new Button(WBGame.ButtonSprite, "Block Left", 15, () =>
            {
                if (Loading.Hidden)
                {
                    StartLoading();
                    Map.SaveTempBlock();
                    Map.LoadBlock(Map.BlockX - 1, Map.BlockY);
                }
            });
            BlockLeft.Rotation = -90;
            BlockLeft.Position = new Location(30, Size.Y / 2);
            UI.AddChild(BlockLeft);

            BlockRight = new Button(WBGame.ButtonSprite, "Block Right", 15, () =>
            {
                if (Loading.Hidden)
                {
                    StartLoading();
                    Map.SaveTempBlock();
                    Map.LoadBlock(Map.BlockX + 1, Map.BlockY);
                }
            });
            BlockRight.Rotation = 90;
            BlockRight.Position = new Location(Size.X - 30, Size.Y / 2);
            UI.AddChild(BlockRight);

            UpdateBlockButtons();
        }