public static void Initialize() { Hashtable techList = SJSON.Load(Resources.FindFile("Data/TechData.fcd")); ArrayList techs = techList["techs"] as ArrayList; foreach (Hashtable tech in techs) { BlueprintIntObject o = new BlueprintIntObject(tech["class"] as string); o.title = tech["title"] as string; o.costPerTick = (int)(double)tech["cost_per_tick"]; o.timeToBuild = (int)(double)tech["time_to_build"]; o.title = tech["title"] as string; } BackgroundGame.Scripts_IObjects = new Script(); string prefix = @"using RageRTS; using RageRTS.Behaviors; using RageEngine; using RageEngine.Utils; using RageEngine.Graphics; using SharpDX; namespace intObjects { public class "; string prefix2 = ": InteractiveObject { public "; string prefix3 = "(InteractiveObject parent, BlueprintIntObject blueprint):base(parent,blueprint){}"; string prefixend = "}}"; //foreach (BlueprintIntObject tech in BlueprintIntObject.list) { /*tech.tickCost=(ushort)((float)tech.cost/tech.time); * float tickCostFloat=(float)tech.cost/tech.time; * if (tech.tickCost != tickCostFloat) GameConsole.Add("BlueprintIntObject", tech.name + " has incorrect time & cost value ("+tech.time+","+tech.cost+")");*/ foreach (BlueprintIntObject tech in BlueprintIntObject.list) { string file = "Scripts\\" + (tech.className as string) + ".cs"; if (file == "" && file.EndsWith(".cs")) { continue; } string name = Path.GetFileNameWithoutExtension(file); StreamReader reader = Resources.GetStreamReader(file); string fileScript = reader.ReadToEnd(); BackgroundGame.Scripts_IObjects.Add(file, prefix + name + prefix2 + name + prefix3 + fileScript + prefixend); reader.Close(); } BackgroundGame.Scripts_IObjects.Compile(); }
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(); }
public BlueprintIntObjectPointer(string techName) { name = techName; this.pointer = BlueprintIntObject.Find(techName); }
public BlueprintIntObjectPointer(BlueprintIntObject tech) { name = tech.className; this.pointer = tech; }
public InteractiveObject(InteractiveObject parent, BlueprintIntObject blueprint) { this.id = ++InteractiveObject.UNIQUE_ID; this.parent = new WeakReference(parent); this.blueprint = blueprint; }