示例#1
0
 public void ConsoleWriteEx(string Text, List <System.Action> Links = null)
 {
     if (WindowManager == null)
     {
         return;
     }
     GameplayAssets.ConsoleWindow console = null;
     foreach (GUI.Window w in WindowManager.Windows)
     {
         if ((w as GameplayAssets.ConsoleWindow) != null)
         {
             console = w as GameplayAssets.ConsoleWindow;
             break;
         }
     }
     if (console == null)
     {
         return;
     }
     console.AppendMessage(Text, Links);
 }
示例#2
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);
             * }
             * //*/
        }