public void Update(GameTime game_time) { player.Update(game_time); blackhole.Update(game_time); next_spawn -= (float)game_time.ElapsedGameTime.TotalSeconds; if (next_spawn <= 0) { next_spawn += spawn_time / SCALE; Asteroid planet = new Asteroid(controller); float radius = 10; float mass = 100;// + (float)(random.NextDouble() * 200); int int_angle = random.Next(0, 360); if (planets[int_angle] == null) { float angle = (float)(int_angle * Math.PI / 180 - Math.PI); float distance; float abs_angle = Math.Abs(angle); if (abs_angle > threshhold && abs_angle < Math.PI - threshhold) { distance = Math.Abs(height / (float)(2 * Math.Sin(angle))); } else { distance = Math.Abs(width / (float)(2 * Math.Cos(angle))); } distance -= planet.Radius + blackhole.Radius; planet.Initialize(blackhole, SpriteFactory.GetSprite("Circle"), angle, distance, radius, 1.5f * mass * SCALE); planets[int_angle] = planet; } } if (player.Check(blackhole)) { Reset(); return; } for (int index = 0; index < 360; index++) { Asteroid planet = planets[index]; if (planet != null) { if (CircularObject.Collide(blackhole, planet)) { blackhole.Affect(planet); planets[index] = null; } else { planet.Update(game_time); if (player.Check(planet)) { Reset(); return; } } } } player.Test(game_time); }
public void HideCircularObjects() { Dictionary <string, List <string> > circularRefs = new Dictionary <string, List <string> > (); foreach (ProjectObject projectObject in ObjectSelection.instance.GetSelectedObjects()) { CircularObject circularObject = projectObject.circularObjects.Find(circ => circ.activity == ActivityMenu.instance.GetSelectedActivity().activity); if (circularObject != null) { foreach (ProjectStepObject circularRef in circularObject.projectStepObjects) { if (circularRefs.ContainsKey(circularRef.objectId)) { if (!circularRefs [circularRef.objectId].Contains(circularRef.activity)) { circularRefs [circularRef.objectId].Add(circularRef.activity); } } else { circularRefs.Add(circularRef.objectId, new List <string> ()); circularRefs [circularRef.objectId].Add(circularRef.activity); } } } } foreach (KeyValuePair <string, List <string> > circularRef in circularRefs) { ProjectObject projectObject = GetObjectById(circularRef.Key); if (circularRef.Value.Count >= projectObject.activities.Count) { if (projectObject.gameObject.layer != LayerMask.NameToLayer("Circular")) { SetObjectToCircular(projectObject); } } } }
internal object ParseDictionary(Dictionary <string, object> target, Dictionary <string, object> globalTypes, Type type, object input) { if (type == typeof(NameValueCollection)) { return(Helper.CreateNV(target)); } if (type == typeof(StringDictionary)) { return(Helper.CreateSD(target)); } if (target.TryGetValue("$i", out object tn)) { ReverseCircularObject.TryGetValue((int)(long)tn, out object v); return(v); } if (target.TryGetValue("$types", out tn)) { UseGlobals = true; if (globalTypes == null) { globalTypes = new Dictionary <string, object>(); } foreach (KeyValuePair <string, object> kv in (Dictionary <string, object>)tn) { globalTypes.Add((string)kv.Value, kv.Key); } } if (globalTypes != null) { UseGlobals = true; } bool found = target.TryGetValue("$type", out tn); if (found == false && type == typeof(object)) { return(target); // CreateDataset(d, globaltypes); } if (found) { if (UseGlobals) { if (globalTypes != null && globalTypes.TryGetValue((string)tn, out object tname)) { tn = tname; } } type = Reflection.Instance.GetTypeFromCache((string)tn); } if (type == null) { throw new Exception("Cannot determine type"); } string typename = type.FullName; object o = input; if (o == null) { o = Configuration.ParametricConstructorOverride ? System.Runtime.Serialization.FormatterServices.GetUninitializedObject(type) : Reflection.Instance.FastCreateInstance(type); } if (CircularObject.TryGetValue(o, out int circount) == false) { circount = CircularObject.Count + 1; CircularObject.Add(o, circount); ReverseCircularObject.Add(circount, o); } Dictionary <string, PropInfo> props = Reflection.Instance.Getproperties(type, typename, Configuration.ShowReadOnlyProperties); foreach (KeyValuePair <string, object> kv in target) { string n = kv.Key; object v = kv.Value; string name = n;//.ToLower(); if (name == "$map") { ProcessMap(o, props, (Dictionary <string, object>)target[name]); continue; } if (props.TryGetValue(name, out PropInfo pi) == false) { if (props.TryGetValue(name.ToLowerInvariant(), out pi) == false) { continue; } } if (pi.CanWrite) { if (v != null) { object oset = null; switch (pi.Type) { case PropInfoType.Int: oset = (int)Helper.AutoConv(v); break; case PropInfoType.Long: oset = Helper.AutoConv(v); break; case PropInfoType.String: oset = v.ToString(); break; case PropInfoType.Bool: oset = Helper.BoolConv(v); break; case PropInfoType.DateTime: oset = Helper.CreateDateTime((string)v, Configuration.UseUTCDateTime); break; case PropInfoType.Enum: oset = Helper.CreateEnum(pi.pt, v); break; case PropInfoType.Guid: oset = Helper.CreateGuid((string)v); break; case PropInfoType.Array: if (!pi.IsValueType) { oset = CreateArray((List <object>)v, pi.pt, pi.bt, globalTypes); } // what about 'else'? break; case PropInfoType.ByteArray: oset = Convert.FromBase64String((string)v); break; case PropInfoType.DataSet: oset = CreateDataset((Dictionary <string, object>)v, globalTypes); break; case PropInfoType.DataTable: oset = CreateDataTable((Dictionary <string, object>)v, globalTypes); break; case PropInfoType.Hashtable: // same case as Dictionary case PropInfoType.Dictionary: oset = CreateDictionary((List <object>)v, pi.pt, pi.GenericTypes, globalTypes); break; case PropInfoType.StringKeyDictionary: oset = CreateStringKeyDictionary((Dictionary <string, object>)v, pi.pt, pi.GenericTypes, globalTypes); break; case PropInfoType.NameValue: oset = Helper.CreateNV((Dictionary <string, object>)v); break; case PropInfoType.StringDictionary: oset = Helper.CreateSD((Dictionary <string, object>)v); break; case PropInfoType.Custom: oset = Reflection.Instance.CreateCustom((string)v, pi.pt); break; default: { oset = pi.IsGenericType && pi.IsValueType == false && v is List <object> ?CreateGenericList((List <object>) v, pi.pt, pi.bt, globalTypes) : (pi.IsClass || pi.IsStruct || pi.IsInterface) && v is Dictionary <string, object> ?ParseDictionary((Dictionary <string, object>) v, globalTypes, pi.pt, null) : v is List <object> ?CreateArray((List <object>) v, pi.pt, typeof(object), globalTypes) : pi.IsValueType ? ChangeType(v, pi.changeType) : v; } break; } o = pi.setter(o, oset); } } } return(o); }