private static void Main(string[] args) { // Set up platform helper if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) { Platform = new PlatformWindows(); } else { Logger.CreateErrorLog($"Unsupported platform detected."); } Thread.CurrentThread.Name = "Starforge"; Settings.ConfigDirectory = Platform.GetAppDataFolder(); // Create folder for Starforge configs if it doesn't already exist if (!Directory.Exists(Settings.ConfigDirectory)) { try { Directory.CreateDirectory(Settings.ConfigDirectory); } catch (Exception e) { Logger.CreateErrorLog(e.ToString()); } } string logOld = Path.Combine(Settings.ConfigDirectory, "log_old.txt"); string log = Path.Combine(Settings.ConfigDirectory, "log.txt"); if (File.Exists(logOld)) { File.Delete(logOld); } if (File.Exists(log)) { File.Move(log, logOld); } Logger.SetOutputStream(new StreamWriter(File.OpenWrite(log))); Logger.Log("Launching Starforge."); if (Type.GetType("Mono.Runtime") != null) { Logger.Log("Detected Mono runtime"); } AppDomain.CurrentDomain.UnhandledException += GlobalExceptionHandler; Settings.LoadConfig(Path.Combine(Settings.ConfigDirectory, "settings.cfg")); using (Engine e = new Engine()) { Instance = e; e.Run(); } Logger.Log("FNA window closed."); Logger.Log("Writing configuration changes."); Settings.WriteConfig(Path.Combine(Settings.ConfigDirectory, "settings.cfg")); }
public void Spawn(GameObject spawnPrefab) { GameObject newObj = objectPooler.SpawnFromPool(spawnPrefab.name, Vector3.zero, Quaternion.identity);//Pool newObj.name = spawnPrefab.name; PlatformBase newObjBase = newObj.GetComponent <PlatformBase>(); if (newObjBase.Type == PoolTag.Up) { newObj.transform.position = currentTile.GetComponent <PlatformBase>().upPosTarget.position; } if (newObjBase.Type == PoolTag.Left) { newObj.transform.position = currentTile.GetComponent <PlatformBase>().leftPosTarget.position; } foreach (Transform item in newObjBase.waypointParent) { WayPointsManager.Instance.wayPoints.Add(item.transform); } newObj.transform.position = new Vector3(newObj.transform.position.x, 15, newObj.transform.position.z); currentTile = newObj; activeAllPlatform.Add(currentTile); newObj.transform.DOMoveY(-1, 1).SetDelay(activeAllPlatform.IndexOf(currentTile) * .3f).SetEase(Ease.InQuart); }
public static OpenALAudioAdapter TryCreate(PlatformBase _) { var newCtx = new OpenALAudioAdapter(); newCtx.AudioDevice = Alc.OpenDevice(null); if (newCtx.AudioDevice == IntPtr.Zero) { Engine.Log.Error("Couldn't find an OpenAL device.", MessageSource.OpenAL); return(null); } var attr = new int[0]; newCtx.AudioContext = Alc.CreateContext(newCtx.AudioDevice, attr); if (newCtx.AudioContext == IntPtr.Zero) { Engine.Log.Error("Couldn't create OpenAL context.", MessageSource.OpenAL); return(null); } bool success = Alc.MakeContextCurrent(newCtx.AudioContext); if (!success) { Engine.Log.Error("Couldn't make OpenAL context current.", MessageSource.OpenAL); return(null); } return(newCtx); }
public void AddTask(PlatformBase paramRunnable) { lock (ProtocolList) { ProtocolList.AddLast(paramRunnable); } }
public static void InitializeNoGraphic(PlatformBase platform) { Platform = platform; NoGraphic = true; Graphic = new GraphicManager(null, null); Resources = new ResourcesManager(); }
//Spawns enemies on platforms 20 units away from the player void SpawnEnemy() { if (currentEnemies >= gameManager.maxEnemies) { return; } bool isDone = false; Vector2 point = Vector2.zero; while (!isDone) { PlatformBase platform = Level.platforms[Random.Range(0, Level.platforms.Length)]; point = platform.Pivot + new Vector2(Random.Range(1, platform.Width), 1.1f); //check player distance if (Vector2.Distance(point, player.transform.position) >= 20) { isDone = true; } } //spawn enemy //will change when more enemies are added Enemy newEnemy = Instantiate(enemyPrefab, point, Quaternion.identity, transform); newEnemy.player = player; newEnemy.enemySpawner = this; currentEnemies++; }
private void PlatformSet() { #if UNITY_IOS Communicate.AddComponent <CommunicateWithOC>(); #elif UNITY_ANDROID Communicate.AddComponent <CommunicateWithJava>(); #endif PlatformBase.Init(); }
public void PlatformTests() { var plat = PlatformBase.CreateDetectedPlatform(new Configurator { HostSize = new Vector2(320, 260), RenderSize = new Vector2(320, 260), DebugMode = true }); Assert.True(plat != null); if (plat == null) { return; } var deskPlat = (DesktopPlatform)plat; Monitor primaryMonitor = deskPlat.Monitors[0]; Assert.True(primaryMonitor != null); Assert.True(plat.Context != null); Assert.Equal(plat.Size, new Vector2(320, 260)); Assert.True(plat.IsFocused); var resizes = new List <Vector2>(); plat.OnResize += t => { resizes.Add(t); }; plat.Position = new Vector2(10, 100); EventualConsistencyHostWait(plat); Assert.Equal(plat.Position, new Vector2(10, 100)); Assert.Equal(plat.Size, new Vector2(320, 260)); plat.Size = new Vector2(960, 540); EventualConsistencyHostWait(plat); Assert.Equal(plat.Size, new Vector2(960, 540)); plat.WindowState = WindowState.Minimized; EventualConsistencyHostWait(plat); Assert.True(!plat.IsFocused); plat.WindowState = WindowState.Maximized; EventualConsistencyHostWait(plat); Assert.Equal(plat.Size.X, primaryMonitor.Width); // Don't check Y as taskbars can be different size. Assert.True(plat.IsFocused); plat.WindowState = WindowState.Minimized; EventualConsistencyHostWait(plat); Assert.True(!plat.IsFocused); plat.WindowState = WindowState.Normal; EventualConsistencyHostWait(plat); Assert.True(plat.IsFocused); // Check that the on resize function was called correctly and with the correct sizes. Assert.Equal(resizes[0], new Vector2(960, 540)); // initial size set Assert.Equal(resizes[1].X, primaryMonitor.Width); // maximized Assert.Equal(resizes[^ 1], new Vector2(960, 540)); // restoring from the maximized state.
private void Spawn() { PlatformBase currentPlatform = platformPool.GetInctance(); currentPlatform.DisablePlatform(); currentPlatform.transform.position = Vector3.forward * currentPlatformPos.z; currentPlatformPos.z += platformData.PlatformLenght; currentPlatform.EnablePlatform(); platformPool.SetInstance(currentPlatform); }
public static WasApiAudioContext TryCreate(PlatformBase _) { // ReSharper disable once SuspiciousTypeConversion.Global if (new MMDeviceEnumeratorComObject() is IMMDeviceEnumerator enumerator) { return(new WasApiAudioContext(enumerator)); } Win32Platform.CheckError("Couldn't create multimedia enumerator.", true); return(null); }
public static void Initialize(PlatformBase platform) { Platform = platform; MonoGame = new MonoGameHandler(); MonoGame.OnInitialize += MonoGameOnInitialize; MonoGame.OnLoadContent += MonoGameOnLoadContent; MonoGame.OnUnloadContent += MonoGameOnUnloadContent; MonoGame.OnUpdate += MonoGameOnUpdate; MonoGame.OnDraw += MonoGameOnDraw; }
/// <summary> /// Perform engine setup. /// </summary> /// <param name="configurator">An optional engine configuration - will be passed to the light setup.</param> public static void Setup(Configurator configurator = null) { // Call light setup if needed. if (Status < EngineStatus.LightSetup) { LightSetup(configurator); } if (Status >= EngineStatus.Setup) { return; } // Mount default assets. The platform should add it's own specific sources and stores. AssetLoader = LoadDefaultAssetLoader(); // Create the platform, window, audio, and graphics context. Host = PlatformBase.GetInstanceOfDetected(configurator); if (Host == null) { SubmitError(new Exception("Platform couldn't initialize.")); return; } InputManager = Host; Audio = Host.Audio; // Errors in host initialization can cause this. if (Status == EngineStatus.Stopped) { return; } // Now that the context is created, the renderer can be created. GLThread.BindThread(); Renderer = new RenderComposer(); Renderer.Setup(); // Now "game-mode" modules can be created. SceneManager = new SceneManager(); // Setup plugins. foreach (IPlugin p in Configuration.Plugins) { p.Initialize(); } if (Status == EngineStatus.Stopped) { return; } Status = EngineStatus.Setup; }
public static void Init(PlatformBase platform, TargetIdiom idiom) { Platform = platform; platform.Init(idiom); Device.OS = TargetPlatform.Other; Device.Idiom = idiom; Registrar.RegisterAll(new[] { typeof(ExportRendererAttribute) }); NamedSizes.Register(); Forms.IsInitialized = true; }
private void Update() { if (Platform != null) { return; } Platform = GameSparks.GetComponent <PlatformBase>(); if (Platform != null) { OnGameSparksInitializationCompleted.Invoke(); } }
public CPlatform() { #if UNITY_STANDALONE m_cPlatform = new PlatformForIOS(); #endif #if UNITY_IPHONE && IOS platform = new PlatformForIOS(); #endif #if UNITY_IPHONE && IOSPP platform = new PlatformPPIOS(); #endif #if UNITY_ANDROID platform = new PlatformForIOS(); #endif }
public static void EventualConsistencyHostWait(PlatformBase plat = null) { if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) { return; } plat ??= Engine.Host; plat?.Update(); Task.Delay(100).Wait(); plat?.Update(); Task.Delay(100).Wait(); plat?.Update(); Task.Delay(100).Wait(); plat?.Update(); }
private void CreatePlatforms() { PlatformBase currentPlatform = platformData.PlatformFactory.GetInstance(); currentPlatform.SetLaneController(laneData); currentPlatform.SetObstaclesData(obstaclesData); currentPlatform.SetCollectablesData(collectablesData); currentPlatform.SetCollectablesController(collectablesController); currentPlatform.transform.SetParent(platformData.PlatformHolder); currentPlatform.transform.position = Vector3.forward * currentPlatformPos.z; currentPlatformPos.z += platformData.PlatformLenght; currentPlatform.gameObject.SetActive(true); currentPlatform.Init(); currentPlatform.EnablePlatform(); platformPool.SetInstance(currentPlatform); }
public IEnumerator SendPlatfom(PlatformBase nProtocol) { string Url = ConfigsManager.Inst.GetClientConfig(ClientConfigs.PlatformIP); Dictionary <string, string> heads = new Dictionary <string, string>(); heads.Add("cscode", Convert.ToString(nProtocol.m_Type)); heads.Add("Method", "POST"); heads.Add("Content-Type", "application/x-www-form-urlencoded"); JsonData newData = new JsonData(); nProtocol.marshal(ref newData); byte[] btBodys = Encoding.UTF8.GetBytes(newData.ToJson()); WWW w = new WWW(Url, btBodys, heads); while (!w.isDone) { yield return(false); } if (w.error != null) { Debug.Log("SendPlatfom w.error" + w.error); yield return(false); } Dictionary <string, string> responseHeaders = w.responseHeaders; foreach (KeyValuePair <string, string> response in responseHeaders) { Debug.Log("responseHeaders Value : " + response.Value + " \nresponseHeaders Key : " + response.Key); } string cscode = responseHeaders["CSCODE"]; if (cscode != string.Empty) { JsonData jsonData = JsonMapper.ToObject(w.text); PlatformBase protocol = PlatformBase.JsonDataObject(Int32.Parse(cscode)); if (protocol != null) { protocol.unmarshal(jsonData); AddTask(protocol); } } }
public void run() { if (ProtocolList.Count != 0) { lock (ProtocolList) { do { PlatformBase localRunnable = (PlatformBase)ProtocolList.First.Value; if (localRunnable != null) { localRunnable.Process(); } ProtocolList.RemoveFirst(); }while (ProtocolList.Count != 0); } } }
private void TryGeneratePlatforms() { var playerPosition = player.transform.position; var up = playerPosition.y + Camera.main.orthographicSize + _halfPlatformHeight; PlatformBase platformBase = GetRandomPlatformType(); while (up > _activePlatforms[_activePlatforms.Count() - 1].transform.position.y) { var spawnPosition = new Vector3(); spawnPosition.x = Random.Range(_levelWidth, -_levelWidth); spawnPosition.y = _activePlatforms[_activePlatforms.Count() - 1].transform.position.y + Random.Range(minY, maxY); var platform = Instantiate(platformBase, spawnPosition, Quaternion.identity); _activePlatforms.Add(platform); if (enemiesManager.CanCreateEnemy((int)player.MaxHeight)) { platform.InstantiateEnemy(enemy, enemiesManager); } } }
private void initData() { var platformValue = Request.QueryString["Platform"]; var platformType = (Common.Enums.PlatformType) int.Parse(platformValue); var platform = PlatformBase.GetPlatform(platformType); for (var i = 0; i < platform.AutoPayInterfaces.Count(); i++) { var ddlPayInterface = new DropDownList(); foreach (var item in platform.AutoPayInterfaces) { ddlPayInterface.Items.Add(new ListItem(item.GetDescription(), ((byte)item).ToString())); } ddlPayInterface.Items.Insert(0, new ListItem("-请选择-", "")); ddlPayInterface.ID = "ddlPayInterface_" + i; this.divPayInterface.Controls.Add(ddlPayInterface); } var companies = CompanyService.GetCompanies(CompanyType.Provider | CompanyType.Purchaser | CompanyType.Supplier, true); txtProviderCompany.SetCompanyType(CompanyType.Provider); }
public void SendPlatform(PlatformBase protocol) { StartCoroutine(HttpManager.GetInstance().SendPlatfom(protocol)); }
private Platform() { this.platform = Init(); }
public void Init(IntPtr nativeDeviceHandle, IntPtr nativeWindowHandle, PlatformBase platform) { _platform = platform; _eglLib = platform.LoadLibrary("libEGL"); if (_eglLib == IntPtr.Zero) { Engine.Log.Error("Couldn't load EGL.", MessageSource.Egl); return; } IntPtr gles = platform.LoadLibrary("libGLESv2"); if (gles == IntPtr.Zero) { Engine.Log.Error("Couldn't load GLES.", MessageSource.Egl); return; } string extensions = Egl.QueryString(IntPtr.Zero, Egl.Query.EGL_EXTENSIONS); Egl.Error err = Egl.GetError(); if (extensions == null || err != Egl.Error.Success) { Engine.Log.Error($"Couldn't load extensions. {err}", MessageSource.Egl); extensions = ""; } _display = Egl.GetDisplay(nativeDeviceHandle); if (_display == IntPtr.Zero) { Engine.Log.Error($"Couldn't initialize display. {Egl.GetError()}", MessageSource.Egl); return; } var majorVersion = 3; int majorVer = majorVersion; var minorVer = 0; if (RenderDoc.Loaded) { minorVer = 1; } if (!Egl.Init(_display, ref majorVer, ref minorVer)) { Engine.Log.Error($"Couldn't initialize Egl. {Egl.GetError()}", MessageSource.Egl); return; } // Pick config var totalConfigs = 0; Egl.GetConfigs(_display, null, 0, ref totalConfigs); if (totalConfigs == 0) { Engine.Log.Error($"No configs for current display. {Egl.GetError()}", MessageSource.Egl); return; } var configs = new IntPtr[totalConfigs]; Egl.GetConfigs(_display, configs, totalConfigs, ref totalConfigs); if (totalConfigs == 0) { Engine.Log.Error($"No configs for current display. {Egl.GetError()}", MessageSource.Egl); return; } int configHandle = SupportedPixelFormat(configs); if (configHandle == 0) { Engine.Log.Error("No valid config found.", MessageSource.Egl); return; } IntPtr config = configs[configHandle - 1]; if (!Egl.BindAPI(Egl.API.EGL_OPENGL_ES_API)) { Engine.Log.Error($"Couldn't bind EGL API. {Egl.GetError()}", MessageSource.Egl); return; } int[] attributes = { (int)Egl.ContextAttribute.EGL_CONTEXT_CLIENT_VERSION, majorVersion, 0x3038 // EGL_NONE }; _context = Egl.CreateContext(_display, config, IntPtr.Zero, attributes); if (_context == IntPtr.Zero) { Engine.Log.Error($"Context creation failed. {Egl.GetError()}", MessageSource.Egl); return; } _surface = Egl.CreateWindowSurface(_display, config, nativeWindowHandle, null); if (_surface == IntPtr.Zero) { Engine.Log.Error($"Surface creation failed. {Egl.GetError()}", MessageSource.Egl); return; } Valid = true; }
/// <summary> /// This sets the applications platform. /// </summary> /// <param name="platform">The platform.</param> /// <param name="displayMetrics">The required display metrics.</param> public void SetPlatform(PlatformBase platform, DisplayMetrics displayMetrics) { platform.CreateDisplay(displayMetrics); Platform = platform; Display = platform.Display; }
private PlatformBase Init() { IsMono = Type.GetType("Mono.Runtime") != null; switch (Environment.OSVersion.Platform) { case PlatformID.MacOSX: platform = new MacOSXPlatform(); break; case PlatformID.Unix: platform = new UnixPlatform(); break; default: platform = new WindowsPlatform(); break; } return platform; }
public static void GenerateLevel(LevelPrototype levelData) { /*Summary of the platform generation: * This function is static, do not make objects of this class, only call it. * * How this code works: * 1. A list is declared to store all the platforms that are spawned * 2. A 2 dimensional int array is declared to store each tile position (this is important for rope spawning) * 3. Enter a while loop that will execute until the length of the platforms list is > our defined platform max count, * or the code exceeds a max iteration count * 4. A random point is generated within the size of the map * 5. The code now checks if the random point is valid against the perlin noise field (if the value of the nosie field * at that point is greater than the PerlinThreshold (defined in LevelData), then the code will continue) * 6. The random width of the platform is generated * 7. The random position of the platform is tested against all other platforms that exist, if it is too close, the point * is thrown away, and the while loop will start over * 8. If the platform has passed all the previous tests, it will now be added to the list of platforms * 9. The appropriate points in the 2D int array are set to 1 to store the platform tiles * 10. The ropes are generated (see summary below), and this class returns an array of platforms */ LevelPrototype ld = levelData; List <PlatformBase> platforms = new List <PlatformBase> (); int[,] levelArray = new int[ld.MapRadius, ld.MapRadius]; int iterationCount = 0; //prevent an infinite loop while (platforms.Count < ld.PlatformCount) { if (iterationCount >= ld.PlatformCount * 100) { // Debug.Log ("Stopping platform generation at " + platforms.Count); break; } Vector2 randomPoint = new Vector2(Random.Range(0, ld.MapRadius / 2), Random.Range(0, ld.MapRadius)); if (Mathf.PerlinNoise(randomPoint.x / ld.PerlinScale, randomPoint.y / ld.PerlinScale) < ld.PerlinThreshold) { continue; } int platformWidth = Random.Range(5, 40); bool tooClose = false; foreach (PlatformBase pb in platforms) { if (Vector2.Distance(pb.Pivot + Vector2.right * platformWidth / 2f, randomPoint) < ld.MinDistance || Mathf.Abs(randomPoint.y - pb.Pivot.y) < 3) { tooClose = true; break; } } if (!tooClose) { PlatformBase pb = new PlatformBase(randomPoint, platformWidth); #region Temporary Gate spawning stuff List <PlatformObjectData> po = new List <PlatformObjectData> (); //make start gate if (platforms.Count == 0) { PlatformObjectData startGate = ScriptableObject.CreateInstance <PlatformObjectData> (); startGate.position = new Vector2(pb.Pivot.x + Random.Range(1, platformWidth) + 0.5f, pb.Pivot.y + 1.5f); startGate.Object = levelData.PlatformObjects[0].Object; Level.StartGate = startGate; } //make end gate if (platforms.Count == 1) { PlatformObjectData endGate = ScriptableObject.CreateInstance <PlatformObjectData>(); endGate.position = new Vector2(pb.Pivot.x + Random.Range(1, platformWidth) + 0.5f, pb.Pivot.y + 1.5f); endGate.Object = levelData.PlatformObjects[1].Object; Level.EndGate = endGate; } pb.PlatformObjects = po.ToArray(); #endregion platforms.Add(pb); for (int i = 0; i < pb.Width; i++) { levelArray [(int)pb.Pivot.x + i, (int)pb.Pivot.y] = 1; } } iterationCount++; } Level.platforms = GenerateRopes(platforms.ToArray(), levelArray); }
internal NullWindow(PlatformBase platform) : base(platform) { }