コード例 #1
0
ファイル: MainWindow.cs プロジェクト: marwahaha/FacCom
        public MainWindow()
        {
            InitializeComponent();

            Title     = this.Text;
            Main.Form = this;

            this.AllowDrop  = true;
            this.DragEnter += new DragEventHandler(Form_DragEnter);
            this.DragDrop  += new DragEventHandler(Form_DragDrop);

            renderWindow1.MouseUp    += new MouseEventHandler(Window_MouseUp);
            renderWindow1.MouseDown  += new MouseEventHandler(Window_MouseDown);
            renderWindow1.MouseMove  += new MouseEventHandler(Window_MouseMove);
            renderWindow1.MouseWheel += new MouseEventHandler(Window_MouseWheel);
            renderWindow1.MouseHover += new EventHandler(Window_MouseHover);
            renderWindow1.MouseEnter += new EventHandler(Window_MouseHover);
            renderWindow1.KeyDown    += new KeyEventHandler(Window_KeyDown);
            renderWindow1.KeyUp      += new KeyEventHandler(Window_KeyUp);

            mapFile = RawMap.Load(OpenedFile);

            this.Text = Title + "  -  " + OpenedFile;
        }
コード例 #2
0
ファイル: InGameScreen.cs プロジェクト: marwahaha/FacCom
        public override void Initialize()
        {
            instance = this;

            ShaderManager.Add("VS_Debug", Resources.GetShader("VS", "VS", "Debug.fx")).SetInputLayout(VertexColor.Elements);
            ShaderManager.Add("PS_Debug", Resources.GetShader("PS", "PS", "Debug.fx"));

            ShaderManager.Add("VS_UI3D", Resources.GetShader("VS", "VS", "UI3D.fx")).SetInputLayout(VertexTextureColor.Elements);
            ShaderManager.Add("PS_UI3D", Resources.GetShader("PS", "PS", "UI3D.fx"));

            ShaderManager.Add("VS_Model", Resources.GetShader("VS", "VS", "Model.fx")).SetInputLayout(VertexTextureColor.Elements);
            ShaderManager.Add("PS_Model", Resources.GetShader("PS", "PS", "Model.fx"));

            ShaderManager.Add("VS_Terrain", Resources.GetShader("VS", "VS", "Terrain.fx")).SetInputLayout(VertexTexture.Elements);
            ShaderManager.Add("PS_Terrain", Resources.GetShader("PS", "PS", "Terrain.fx"));

            ShaderManager.Add("VS_Water", Resources.GetShader("VS", "VS", "Water.fx")).SetInputLayout(VertexTexture.Elements);
            ShaderManager.Add("PS_Water", Resources.GetShader("PS", "PS", "Water.fx"));


            SceneManager.Initialize();

            InputManager.AssignKey("up", new[] { "Z" });
            InputManager.AssignKey("down", new[] { "S" });
            InputManager.AssignKey("left", new[] { "Q" });
            InputManager.AssignKey("right", new[] { "D" });

            InputManager.AssignKey("zoom_in", new[] { "Add" });
            InputManager.AssignKey("zoom_out", new[] { "Subtract" });

            //---------------------------------------------------------------------------------------------------
            RawMap mapFile;
            string mapname = "(2) Germanium Island";

            mapFile = RawMap.Load(mapname);

            ForegroundGame.Map = new TerrainInfo();

            ForegroundGame.Map.width  = mapFile.Width;
            ForegroundGame.Map.height = mapFile.Height;

            ForegroundGame.Map.altitudeData = new float[mapFile.Width, mapFile.Height];
            for (int y = 0; y < mapFile.Height; y++)
            {
                for (int x = 0; x < mapFile.Width; x++)
                {
                    float h = mapFile.Data[x + y * mapFile.Width];
                    ForegroundGame.Map.altitudeData[x, y] = h;
                    if (h > ForegroundGame.Map.maxAltitude)
                    {
                        ForegroundGame.Map.maxAltitude = h;
                    }
                }
            }

            ForegroundGame.Map.accessibilityArray = mapFile.Accessibilty_Array;

            GlobalConstantVars.SunColor = mapFile.Sun_Color;

            GlobalConstantVars.SunDirection.X = (float)Math.Sin(mapFile.Sun_Rotation) * (float)Math.Cos(mapFile.Sun_Height);
            GlobalConstantVars.SunDirection.Y = (float)Math.Sin(mapFile.Sun_Height);
            GlobalConstantVars.SunDirection.Z = (float)Math.Cos(mapFile.Sun_Rotation) * (float)Math.Cos(mapFile.Sun_Height);
            GlobalConstantVars.SunDirection.Normalize();

            GlobalConstantVars.AmbientColor = new Vector4(mapFile.Ambient_Color, mapFile.Ambient);


            ForegroundGame.Map.waterColor = new Vector4(mapFile.Water_Color, mapFile.Water_Density);
            ForegroundGame.Map.waterLevel = mapFile.Water_Level;
            ForegroundGame.Map.WaterBump  = Resources.GetTexture("Maps/Shared/wave");

            ForegroundGame.Map.ColorMap   = Resources.GetTexture("Maps/" + mapname + "/_colorMap.png", false);
            ForegroundGame.Map.TextureMap = Resources.GetTexture("Maps/" + mapname + "/_textureMap.png", false);

            ForegroundGame.Map.Shore  = RageEngine.ContentPipeline.Resources.GetTexture("Maps/Shared/shore.jpg");
            ForegroundGame.Map.Clouds = RageEngine.ContentPipeline.Resources.GetTexture("Maps/Shared/clouds.jpg");

            string[] texturesWithNormal = new string[mapFile.Textures.Length * 2];
            for (uint i = 0; i < mapFile.Textures.Length; i++)
            {
                texturesWithNormal[i * 2]     = "Maps/Shared/" + mapFile.Textures[i];
                texturesWithNormal[i * 2 + 1] = "Maps/Shared/" + mapFile.Textures[i] + "_bump";
            }
            ForegroundGame.Map.TextureArray = Resources.GetTextureArray(texturesWithNormal);

            ForegroundGame.Map.Load();

            var Map_Dimensions = new Point3D(ForegroundGame.Map.width, 1000, ForegroundGame.Map.height);
            var Map_Division   = new Point3D(100, 1, 100);

            BackgroundGame.IntObjsLQDB = new LocalityQueryProximityDatabase <InteractiveObject>(Map_Dimensions, Map_Division);

            BackgroundGame.MapSpace = new MapSpace(ForegroundGame.Map);

            terrain = new Terrain(ForegroundGame.Map);
            SceneManager.Add(terrain);
            ForegroundGame.TerrainDebug = new TerrainDebug(ForegroundGame.Map);
            SceneManager.Add(ForegroundGame.TerrainDebug);
            SceneManager.Add(new TerrainWater(ForegroundGame.Map));
            //--------------------------------------------------------------------------------------------------

            ForegroundGame.startegicIcons    = Resources.GetTexture("Textures/startegicIcon.png", false);
            ForegroundGame.selectionBrackets = Resources.GetTexture("Textures/selectionBrackets.png", false);
            ForegroundGame.unitPlaceholder   = Resources.GetTexture("Textures/unitplaceholder.png", false);


            camera = new TopDownCamera();
            SceneManager.Camera = camera;

            uitest            = new WebWindow(200, Display.Height, "UI/InGame/index.html");
            uitest.position.X = Display.Width - 200;

            uitest.Bind("GlobalBuildClick", _globalBuildClick);
            uitest.Bind("BuildClick", _globalBuildClick);

            InputManager.MouseDown += new Action <MouseInputEventArgs>(Input_MouseDown);
            InputManager.MouseUp   += new Action <MouseInputEventArgs>(Input_MouseUp);
            InputManager.MouseMove += new Action <MouseInputEventArgs>(Input_MouseMove);
            InputManager.Wheel     += new Action <MouseInputEventArgs>(Input_Wheel);


            ForegroundGame.IntObjsManager = new InteractiveObject2DManager();

            SceneManager.Add(ForegroundGame.IntObjsManager);



            BlueprintIntObject.Initialize();
            //BlueprintProjectile.Initialize("Scripts/Projectiles/");


            int column = 0, line = 0;

            for (int i = 0; i < 200; i++)
            {
                if (line > 17)
                {
                    column++; line = 0;
                }
                InteractiveObject obj = BackgroundGame.Scripts_IObjects.Make <InteractiveObject>("Engy", new Type[2] {
                    typeof(InteractiveObject), typeof(BlueprintIntObject)
                }, null, BlueprintIntObject.Find("Engy"));                                                                                                                                                            //new Engy(null,BlueprintIntObject.list);
                obj.Init(0, new FVector2((fint)(150 + column * 2), (fint)(100 + line * 2)), 0);
                BackgroundGame.IntObjs.Add(obj);
                line++;
            }
            camera.ZoomLevel = 50;
            camera.Position  = new Vector2(170, 120);

            Task.Factory.StartNew(UpdateThread, TaskCreationOptions.LongRunning);
            ForegroundGame.timer.Start();
        }