Пример #1
0
        public NPCWindow(GUI.WindowManager WM, GameObject.MapEntities.Actors.NPC NPC, GameObject.MapEntities.Actors.Player Player)
        {
            this.Player = Player;
            this.Width  = 320;
            this.Height = 512;
            GUI.Controls.RichTextDisplay greeting = new GUI.Controls.RichTextDisplay(NPC.Greeting, 180, 200, WM);
            this.Controls.Add(greeting);
            this.Title = NPC.DisplayName;
            int yoffset = greeting.Height + 2;

            if (NPC.Commands != null && NPC.Commands.Count > 0)
            {
                for (int i = 0; i < NPC.Commands.Count; i++)
                {
                    NPCMenuItem mi = new NPCMenuItem(Player, NPC.Commands[i])
                    {
                        Y = yoffset
                    };
                    yoffset += mi.Height;
                    AddControl(mi);
                }
            }
            NPCMenuItem end = NPCMenuItem.Close();

            end.Y = yoffset;
            AddControl(end);
        }
Пример #2
0
        public InventoryControl(GUI.WindowManager WM, Inventory Inventory, int Width = 8)
        {
            this.RowWidth = Width;
            int slotwidth = 40;

            this.Width     = RowWidth * slotwidth;
            this.Inventory = Inventory;
            int Rows = (int)Math.Ceiling((float)Inventory.Items.Length / (float)RowWidth);

            this.Height = Rows * slotwidth;
            for (int y = 0; y < Rows; y++)
            {
                for (int x = 0; x < RowWidth; x++)
                {
                    int      i = y * RowWidth + x;
                    ItemSlot s = new ItemSlot(Inventory.Items[i])
                    {
                        X       = x * slotwidth,
                        Y       = y * slotwidth,
                        CanGrab = true,
                        CanPut  = true
                    };
                    //s.BeforeItemChanged += new ItemSlot.ItemEventHandler((sender, e) => { if(((e as ItemSlot.ItemEventArgs).Item as GameObject.Item) ==null) e.Cancel=true; });
                    s.BeforeItemChanged += CheckItem;
                    s.ItemOut           += new ItemSlot.ItemEventHandler((sender, e) => { Inventory.Items[i] = null; });
                    s.ItemIn            += new ItemSlot.ItemEventHandler((sender, e) => { Inventory.Items[i] = ((e as ItemSlot.ItemEventArgs).Item as GameObject.Item); });
                    this.AddControl(s);
                }
            }
        }
Пример #3
0
        public FBindWindow(GUI.WindowManager WM, GameObject.MapEntities.Actors.Player Player)
        {
            this.Width  = 404;
            this.Height = 78;
            this.Title  = "Skillz";
            this.X      = 300;
            this.Y      = 450;
            int y = 0;
            int x = 0;

            //  int i = y * Width + x;

            for (int i = 0; i < 8; i++)
            {
                ItemSlot s = new ItemSlot(null);
                s.Y                  = 8;
                s.X                  = 8 + 48 * i; //8 between each
                s.CanGrab            = true;
                s.CanPut             = true;
                s.RenderCooldown     = true;
                s.BeforeItemChanged += CheckSkill;
                this.AddControl(s);
                FBinds[i] = s;
            }
        }
Пример #4
0
 public NPCWindow(GUI.WindowManager WM, GameObject.MapEntities.Actors.NPC NPC)
 {
     this.Width  = 320;
     this.Height = 512;
     GUI.Controls.RichTextDisplay greeting = new GUI.Controls.RichTextDisplay(NPC.Greeting, 180, 200, WM);
     this.Controls.Add(greeting);
     this.Title = NPC.DisplayName;
 }
Пример #5
0
 public InventoryWindow(GUI.WindowManager WM, GameObject.MapEntities.Actors.Player Player)
 {
     _ic         = new InventoryControl(WM, Player.Inventory);
     this.Width  = _ic.Width + 10;
     this.Height = _ic.Height + this.Margin.Y + this.Margin.Height;
     this.Title  = "Inventory";
     this.AddControl(_ic);
     this.X = 600;
     this.Y = 500;
 }
Пример #6
0
 public SkillTreeWindow(GUI.WindowManager WM, Player Player, List <ModularAbility> globalAbilityList)
 {
     this.tree      = Player.SkillTree;
     this.abilities = globalAbilityList;
     this.Width     = 400;
     this.Height    = 500;
     this.Title     = "Skill tree";
     this.Player    = Player;
     RefreshSkillTree();
 }
Пример #7
0
 public ConsoleWindow(GUI.WindowManager WM)
 {
     this.WM            = WM;
     this.Width         = 320;
     this.Height        = 436;
     this.messages      = new GUI.Controls.RichTextDisplay("", this.Width - this.Margin.X - this.Margin.Width, this.Height - this.Margin.Y - this.Margin.Height - 20, WM);
     this.messages.Flip = true;
     this.messages.AddLine("Click ^BEGINLINK ^0000E7 here ^ENDLINK ^FFFFFF to write a ^BEGINLINK ^0000E7 message! Actually, the rest of this text as well. ^ENDLINK hahaha", new List <Action> {
         new Action(() => { Console.Write("^FF0000 It works!"); }), new Action(() => { Console.Write("^FFFF00 Hidden link"); })
     });
     AddControl(messages);
     this.AnchorBottom = true;
 }
Пример #8
0
        public InventoryControl(GUI.WindowManager WM, Inventory Inventory, int Width = 8)
        {
            this.RowWidth = Width;
            int slotwidth = 40;

            this.Width     = RowWidth * slotwidth;
            this.Inventory = Inventory;
            int Rows = (int)Math.Ceiling((float)Inventory.Items.Length / (float)RowWidth);

            this.Height = Rows * slotwidth;
            for (int y = 0; y < Rows; y++)
            {
                for (int x = 0; x < RowWidth; x++)
                {
                    int      i = y * RowWidth + x;
                    ItemSlot s = new ItemSlot(Inventory.Items[i])
                    {
                        X       = x * slotwidth,
                        Y       = y * slotwidth,
                        CanGrab = true,
                        CanPut  = true
                    };
                    //s.BeforeItemChanged += new ItemSlot.ItemEventHandler((sender, e) => { if(((e as ItemSlot.ItemEventArgs).Item as GameObject.Item) ==null) e.Cancel=true; });
                    s.BeforeItemChanged += CheckItem;
                    s.ItemOut           += new ItemSlot.ItemEventHandler((sender, e) => { Inventory.Items[i] = s.Item as GameObject.Item;
                                                                                          Inventory.Prepare();
                                                                                          Inventory.Changed = true; });
                    s.ItemIn += new ItemSlot.ItemEventHandler((sender, e) => {
                        GameObject.Item itemin = ((e as ItemSlot.ItemEventArgs).Item as GameObject.Item);

                        if (s.Item != null && itemin != null && itemin.CanStackWith(s.Item as GameObject.Item))
                        {
                            itemin.StackSize  += (s.Item as GameObject.Item).StackSize;
                            e.Cancel           = true;
                            s.Item             = itemin;
                            WM.MouseGrab       = null;
                            Inventory.Items[i] = (s.Item as GameObject.Item);
                            Inventory.Prepare();
                            Inventory.Changed = true;
                        }
                        else
                        {
                            Inventory.Prepare();
                            Inventory.AddItem(itemin, i);
                            Inventory.Commit();
                        }
                    });
                    this.AddControl(s);
                }
            }
        }
Пример #9
0
        public EquipWindow(GUI.WindowManager WM, GameObject.MapEntities.Actors.Player Player)
        {
            this.Width  = 400 + 6 + 6;
            this.Height = 400 + 6 + 16;
            this.Title  = "Equipment";
            this.X      = 400;
            this.Y      = 400;

            GUI.Controls.TextureContainer tx = new GUI.Controls.TextureContainer(Gameplay.Textures["equipdoll"], WM);
            this.AddControl(tx);

            int y = 0;
            int x = 0;

            Point[] slots = new Point[]
            {
                new Point(314, 83),
                new Point(50, 83),
                new Point(175, 129),
                new Point(175, 244),
                new Point(104, 105),
                new Point(180, 346),
                new Point(89, 35),
                new Point(180, 10),
                new Point(270, 35),
                new Point(180, 74),
                new Point(314, 126),
                new Point(135, 74),
                new Point(230, 74),
                new Point(72, 190),
                new Point(288, 190),
            };
            ItemSlot s;

            for (int i = 0; i < GameObject.Items.ItemEquip.EquipSlot.Max; i++)
            {
                s   = makeslot(i, Player);
                s.X = slots[i].X;
                s.Y = slots[i].Y;
                tx.AddControl(s);
            }
        }
Пример #10
0
 public ConsoleWindow(GUI.WindowManager WM, Gameplay GameRef)
 {
     this.WM            = WM;
     this.gameRef       = GameRef;
     this.Width         = 320;
     this.Height        = 436;
     this.messages      = new GUI.Controls.RichTextDisplay("", this.Width - this.Margin.X - this.Margin.Width, this.Height - this.Margin.Y - this.Margin.Height - 20, WM);
     this.messages.Flip = true;
     this.messages.AddLine("Click ^BEGINLINK ^0000E7 here ^ENDLINK ^FFFFFF to write a ^BEGINLINK ^0000E7 message! Actually, the rest of this text as well. ^ENDLINK hahaha", new List <Action> {
         new Action(() => { Console.Write("^FF0000 It works!"); }), new Action(() => { Console.Write("^FFFF00 Hidden link"); })
     });
     AddControl(messages);
     GUI.Controls.TextBox textBox = new GUI.Controls.TextBox();
     textBox.Height            = 20;
     textBox.Width             = this.Width - this.Margin.X - this.Margin.Width;
     textBox.Y                 = messages.Height;
     textBox.OnSubmit         += TextBox_OnSubmit;
     textBox.KeepFocusOnSubmit = true;
     AddControl(textBox);
     this.AnchorBottom = true;
 }
Пример #11
0
        public void Init(GraphicsDevice device, ContentManager content)
        {
            GameModel.ModelGeometryCompiler.ModelBaseDir = "Scenes\\GameplayAssets\\Models\\";
            GameObject.IO.MagicFileReader mr      = new GameObject.IO.MagicFileReader();
            List <CharacterTemplate>      classes = mr.ReadClassFile();
            List <ModularAbility>         skills  = mr.ReadAbilityFile();

            abilities = skills;
            RotateMap = true;
            World     = new World(device, 100)
            {
                Player = new GameObject.MapEntities.Actors.Player(classes[0], skills)
            };
            World.Terrain.RenderDistance = 3;
            Generator = new WorldGen.WorldGenerator(World.Terrain.BlockSize, World, 4);
            World.Terrain.WaterHeight       = Generator.WaterHeight;
            World.Player.WorldSpawn         = World;
            World.Player.Abilities[0].Level = 1;
            World.Player.Abilities[1].Level = 2;
            World.Player.Abilities[2].Level = 5;
            if (OverheadMapTex == null)
            {
                OverheadMapTex = new RenderTarget2D(device, 256, 256, false, device.PresentationParameters.BackBufferFormat, device.PresentationParameters.DepthStencilFormat);
            }
            b = new SpriteBatch(device);


            #region load game textures
            Textures = new Dictionary <string, Texture2D>();
            Textures["grass_overworld"] = LoadTex2D(device, "graphics\\terraintiles.png");
            Textures["waterbump"]       = LoadTex2D(device, "graphics\\waterbump.jpg");
            Textures["rock"]            = LoadTex2D(device, "graphics\\rock.jpg");
            Textures["sand"]            = LoadTex2D(device, "graphics\\sand.png");
            Textures["point_sphere"]    = LoadTex2D(device, "graphics\\sphere.png");
            Textures["ray"]             = LoadTex2D(device, "graphics\\ray.png");
            Textures["mapsprites"]      = LoadTex2D(device, "graphics\\mapsprites.png");
            Textures["mapnavring"]      = LoadTex2D(device, "graphics\\mapnavring.png");
            Textures["mapoverlay"]      = LoadTex2D(device, "graphics\\mapoverlay.png");
            Textures["equipdoll"]       = LoadTex2D(device, "graphics\\vitruvian.png");
            Textures["dummy"]           = LoadTex2D(device, "graphics\\gray.png");
            Fonts          = new Dictionary <string, SpriteFont>();
            Fonts["font1"] = content.Load <SpriteFont>("font1");
            Fonts["font1"].DefaultCharacter = '#';
            Fonts["fontN"] = content.Load <SpriteFont>("LargeFontX");
            Fonts["fontN"].DefaultCharacter = '#';
            Fonts["FX"] = content.Load <SpriteFont>("FX");
            GameModel.Model.TexturePool = Textures;
            #endregion

            GameModel.ModelPart.Textures = Textures;
            TerrainEffect = content.Load <Effect>("legacy");
            World.Terrain.TerrainEffect = TerrainEffect;
            World.ModelEffect           = TerrainEffect;
            World.Camera          = World.Player.GetTheCamera();
            World.Player.Position = new Vector3(0, 0, 0);
            World.Terrain.QThread = new Thread(new ThreadStart(ProcessQ));
            World.Terrain.QThread.Start();


            #region GUI - onlybasics
            GUIRenderer                   = new GUI.Renderer(device);
            GUIRenderer.WindowSkin        = Texture2D.FromStream(device, new System.IO.FileStream("graphics\\winskin.png", System.IO.FileMode.Open));
            GUIRenderer.InventoryPartsMap = Texture2D.FromStream(device, new System.IO.FileStream("graphics\\itemparts.png", System.IO.FileMode.Open));
            GUIRenderer.AbilityMap        = Texture2D.FromStream(device, new System.IO.FileStream("graphics\\icons.png", System.IO.FileMode.Open));
            GUIRenderer.GUIEffect         = content.Load <Effect>("GUI");
            GUIRenderer.UIFont            = Fonts["font1"];
            GUIRenderer.FloatFont         = Fonts["fontN"];
            WindowManager                 = new GUI.WindowManager();
            WindowManager.Renderer        = GUIRenderer;
            wlist            = new Dictionary <string, GUI.Window>();
            wlist["console"] = new GameplayAssets.ConsoleWindow(WindowManager, this);
            WindowManager.Add(wlist["console"]);


            Terrain.Console.WriteCallback      = new Action <string>(ConsoleWrite);
            _3DGame.Console.WriteCallback      = new Action <string>(ConsoleWrite);
            _3DGame.Console.WriteCallbackEx    = new Action <string, List <Action> >(ConsoleWriteEx);
            GameObject.Console.WriteCallback   = new Action <string>(ConsoleWrite);
            GameObject.Console.WriteCallbackEx = new Action <string, List <Action> >(ConsoleWriteEx);
            GUI.Console.WriteCallback          = new Action <string>(ConsoleWrite);
            #endregion


            GameObject.Items.Material.MaterialTemplates.Load();

            //GameObject.AbilityLogic.AbilityLoader l = new GameObject.AbilityLogic.AbilityLoader("Mage");
            //World.Player.Abilities = l.LoadAbilities();


            #region GUI - the rest of it
            wlist["status"] = new GameplayAssets.StatusWindow(WindowManager, World.Player);
            WindowManager.Add(wlist["status"]);
            wlist["nav"] = new GameplayAssets.Windows.NavWindow(World.Player, OverheadMapTex);
            WindowManager.Add(wlist["nav"]);
            wlist["target"] = new GameplayAssets.Windows.TargetWindow(WindowManager, World.Player);
            WindowManager.Add(wlist["target"]);
            wlist["inventory"] = new GameplayAssets.Windows.InventoryWindow(WindowManager, World.Player);
            WindowManager.Add(wlist["inventory"]);
            wlist["equipment"] = new GameplayAssets.Windows.EquipWindow(WindowManager, World.Player);
            WindowManager.Add(wlist["equipment"]);
            wlist["skills"] = new GameplayAssets.Windows.SkillTreeWindow(WindowManager, World.Player, abilities);
            WindowManager.Add(wlist["skills"]);
            wlist["fbinds"] = new GameplayAssets.Windows.FBindWindow(WindowManager, World.Player);
            WindowManager.Add(wlist["fbinds"]);

            ScreenResized(device);
            #endregion

            /*WorldGen.ObjectPopulator p = new WorldGen.ObjectPopulator(new Random(1));
             * List<MapEntity> elist = p.GenerateObjectsTest(3);
             * foreach(MapEntity me in elist)
             * {
             *  me.WorldSpawn = World;
             *  World.Entities.Add(me);
             * }
             * //*/
        }
Пример #12
0
        public void Init(GraphicsDevice device)
        {
            Assets.Textures["tiles1"]    = Texture2D.FromStream(device, new System.IO.FileStream("graphics\\tiles2.png", System.IO.FileMode.Open));
            Assets.Textures["walls"]     = Texture2D.FromStream(device, new System.IO.FileStream("graphics\\walls2.png", System.IO.FileMode.Open));
            Assets.Textures["items"]     = Texture2D.FromStream(device, new System.IO.FileStream("graphics\\itemsprites.png", System.IO.FileMode.Open));
            Assets.Textures["creatures"] = Texture2D.FromStream(device, new System.IO.FileStream("graphics\\creatures.png", System.IO.FileMode.Open));
            Assets.Textures["winskin"]   = Texture2D.FromStream(device, new System.IO.FileStream("graphics\\winskin.png", System.IO.FileMode.Open));
            // Assets.Textures["creatures"] = Texture2D.FromStream(device, new System.IO.FileStream("graphics\\creatures.png", System.IO.FileMode.Open));
            this.Map = new Components.Map(40, 40);
            //*
            player           = new Components.MapCreature();
            player.ParentMap = this.Map;
            player.Name      = "Colonist 1";
            player.WorkProfile[Components.WorkTypes.Hauling] = true;
            this.Map.Objects.Add(player);
            player           = new Components.MapCreature();
            player.ParentMap = this.Map;
            player.Name      = "Colonist 2";
            player.WorkProfile[Components.WorkTypes.Construction] = true;
            this.Map.Objects.Add(player);
            player           = new Components.MapCreature();
            player.ParentMap = this.Map;
            player.Name      = "Colonist 3";
            player.WorkProfile[Components.WorkTypes.Hauling] = true;
            this.Map.Objects.Add(player);
            //*/
            player           = new Components.MapCreature();
            player.ParentMap = this.Map;
            player.Name      = "Colonist 4";
            player.WorkProfile[Components.WorkTypes.Construction] = true;
            this.Map.Objects.Add(player);

            /*/
             * player = new Components.MapCreature();
             * player.ParentMap = this.Map;
             * player.Name = "Colonist 5";
             * this.Map.Objects.Add(player);
             * player = new Components.MapCreature();
             * player.ParentMap = this.Map;
             * player.Name = "Colonist 6";
             * this.Map.Objects.Add(player);
             * player = new Components.MapCreature();
             * player.ParentMap = this.Map;
             * player.Name = "Colonist 7";
             * this.Map.Objects.Add(player);
             * player = new Components.MapCreature();
             * player.ParentMap = this.Map;
             * player.Name = "Colonist 8";
             * this.Map.Objects.Add(player);
             * //*/
            WM                     = new GUI.WindowManager();
            WM.Renderer            = new GUI.Renderer(device);
            WM.Renderer.GUIEffect  = Assets.Effects["GUI"];
            WM.Renderer.UIFont     = Assets.SpriteFonts["UIFontO"];
            WM.Renderer.WindowSkin = Assets.Textures["winskin"];
            GUI.ToolTipWindow t = new GUI.ToolTipWindow(WM, "GUI successfully installed!", 0, 0, false);
            Console.WriteCallback   = new Action <string>(ConsoleWrite);
            Console.WriteCallbackEx = new Action <string, List <Action> >(ConsoleWriteEx);
            t.AnchorBottom          = true;
            t.AnchorRight           = true;
            WM.Add(t);
            WM.Add(new Windows.ConsoleWindow(WM));
            WM.Screen.X = 0;
            WM.Screen.Y = 0;

            ScreenResized(device);
        }
Пример #13
0
        public void Init(GraphicsDevice device, ContentManager content)
        {
            Fonts          = new Dictionary <string, SpriteFont>();
            Fonts["font1"] = content.Load <SpriteFont>("font1");

            GUIRenderer                   = new GUI.Renderer(device);
            GUIRenderer.WindowSkin        = Texture2D.FromStream(device, new System.IO.FileStream("graphics\\winskin.png", System.IO.FileMode.Open));
            GUIRenderer.InventoryPartsMap = Texture2D.FromStream(device, new System.IO.FileStream("graphics\\itemparts.png", System.IO.FileMode.Open));
            GUIRenderer.AbilityMap        = Texture2D.FromStream(device, new System.IO.FileStream("graphics\\icons.png", System.IO.FileMode.Open));
            GUIRenderer.GUIEffect         = content.Load <Effect>("GUI");
            GUIRenderer.UIFont            = Fonts["font1"];

            Fonts["font1"].DefaultCharacter = '#';
            WindowManager          = new GUI.WindowManager();
            WindowManager.Renderer = GUIRenderer;
            b = new SpriteBatch(device);

            map = new WorldMap(800, 800);
            Texture2D colortex = Texture2D.FromStream(device, new System.IO.FileStream("graphics\\minecraftgrass.png", System.IO.FileMode.Open));

            map.ColourMap = new Color[colortex.Width * colortex.Height];
            colortex.GetData <Color>(map.ColourMap);
            map.ColourMapSize = new Point(colortex.Width, colortex.Height);
            int seed = new System.Random().Next(100);

            Simplex.Seed = seed;
            WorldMapFeatureGenerator.Seed = seed;
            //WorldMapFeatureGenerator.MakeEllipse(map, 30, 30, 720, 440);
            //WorldMapFeatureGenerator.MakeEllipse(map, 30, 500, 320, 240);
            //WorldMapFeatureGenerator.MakeEllipse(map, 430, 500, 350, 200);
            WorldMapFeatureGenerator.MakeEllipse(map, 30, 30, 720, 640);
            WorldMapFeatureGenerator.FillOcean(map);
            for (int x = 0; x < map.Width; x++)
            {
                for (int y = 0; y < map.Height; y++)
                {
                    if (map.TileData[x, y] == WorldMap.TileType.Unfilled)
                    {
                        map.ElevationData[x, y] = 0.1f;
                    }
                }
            }
            WorldMapFeatureGenerator.Replace(map, WorldMap.TileType.Unfilled, WorldMap.TileType.Plain);
            map.OceanDistanceField = WorldMapFeatureGenerator.DoDistanceField(map, map.OceanDistanceField, WorldMap.TileType.Ocean);
            List <Point> rivers = WorldMapFeatureGenerator.DoRivers(map, 10);

            map.RiverDistanceField = WorldMapFeatureGenerator.DoDistanceField(map, map.RiverDistanceField, WorldMap.TileType.River);
            WorldMapFeatureGenerator.DoTemperature(map);
            WorldMapFeatureGenerator.DoMountains(map, 6666);
            WorldMapFeatureGenerator.DoHumidity(map);
            map.Towns = WorldMapFeatureGenerator.PlaceTownCentres(map, 50, 60, rivers, 30);
            WorldMapFeatureGenerator.GrowTowns(map, 3, 100);
            map.TileData[36, 14] = WorldMap.TileType.Beach;
            Texture2D result = map.TilesToTexture(device);

            CreateWorldAssets.Windows.MapWindow mw = new CreateWorldAssets.Windows.MapWindow(result);
            WindowManager.Add(mw);


            ScreenResized(device);
        }