static IActorInit LoadInit(string traitName, MiniYaml my) { var info = WarGame.CreateObject <IActorInit>(traitName + "Init"); FieldLoader.Load(info, my); return(info); }
public void CacheMinimap(MapPreview preview) { bool launchPreviewLoaderThread; lock (syncRoot) { generateMinimap.Enqueue(preview); launchPreviewLoaderThread = previewLoaderThreadShutDown; previewLoaderThreadShutDown = false; } if (launchPreviewLoaderThread) { WarGame.RunAfterTick(() => { // Wait for any existing thread to exit before starting a new one. if (previewLoaderThread != null) { previewLoaderThread.Join(); } previewLoaderThread = new Thread(LoadAsyncInternal) { Name = "Map Preview Loader", IsBackground = true }; previewLoaderThread.Start(); }); } }
/// <summary> /// 加载子弹头 /// </summary> /// <param name="yaml"></param> /// <returns></returns> static object LoadWarheads(MiniYaml yaml) { var retList = new List <IWarHead>(); foreach (var node in yaml.Nodes.Where(n => n.Key.StartsWith("Warhead"))) { var ret = WarGame.CreateObject <IWarHead>(node.Value.Value + "Warhead"); FieldLoader.Load(ret, node.Value); retList.Add(ret); } return(retList); }
/// <summary> /// 加载飞行体 /// </summary> /// <param name="yaml"></param> /// <returns></returns> static object LoadProjectile(MiniYaml yaml) { MiniYaml proj; if (!yaml.ToDictionary().TryGetValue("Projectile", out proj)) { return(null); } var ret = WarGame.CreateObject <IProjectileInfo>(proj.Value + "Info"); FieldLoader.Load(ret, proj); return(ret); }
protected override void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); //string action = Intent.Action; //string type = Intent.Type; //if(Intent.ActionView.Equals(action) && !string.IsNullOrEmpty(type)) //{ //} //Android.Net.Uri fileUri = Intent.Data; //string path = fileUri.Path; RequestWindowFeature(WindowFeatures.NoTitle); Window.SetFlags(WindowManagerFlags.Fullscreen, WindowManagerFlags.Fullscreen); var wg = new WarGame(); var gameView = (AndroidGameView)wg.Services.GetService <View>(); SetContentView(gameView); wg.Run(); //gameView.TouchEnabled = true; }
void LoadAsyncInternal() { //Log.Write("debug", "MapCache.LoadAsyncInternal started"); // Milliseconds to wait on one loop when nothing to do var emptyDelay = 50; // Keep the thread alive for at least 5 seconds after the last minimap generation var maxKeepAlive = 5000 / emptyDelay; var keepAlive = maxKeepAlive; for (; ;) { List <MapPreview> todo; lock (syncRoot) { todo = generateMinimap.Where(p => p.GetMinimap() == null).ToList(); generateMinimap.Clear(); if (keepAlive > 0) { keepAlive--; } if (keepAlive == 0 && todo.Count == 0) { previewLoaderThreadShutDown = true; break; } } if (todo.Count == 0) { Thread.Sleep(emptyDelay); continue; } else { keepAlive = maxKeepAlive; } // Render the minimap into the shared sheet foreach (var p in todo) { if (p.Preview != null) { WarGame.RunAfterTick(() => { try { p.SetMinimap(sheetBuilder.Add(p.Preview)); } catch (Exception e) { //Log.Write("debug", "Failed to load minimap with exception: {0}", e); } }); } // Yuck... But this helps the UI Jank when opening the map selector significantly. Thread.Sleep(Environment.ProcessorCount == 1 ? 25 : 5); } } // The buffer is not fully reclaimed until changes are written out to the texture. // We will access the texture in order to force changes to be written out, allowing the buffer to be freed. WarGame.RunAfterTick(() => { sheetBuilder.Current.ReleaseBuffer(); sheetBuilder.Current.GetTexture(); }); //Log.Write("debug", "MapCache.LoadAsyncInternal ended"); }