public virtual void GetObjectData(SerializationInfo info, StreamingContext context) { info.AddValue("AllowedPenetrationDepth", AllowedPenetrationDepth); info.AddValue("DampingCoef", DampingCoef); info.AddValue("Gravity", Gravity, Gravity.GetType()); info.AddValue("Bodies", Bodies, Bodies.GetType()); info.AddValue("SpeedCoef", SpeedCoef); info.AddValue("StickCoef", StickCoef); info.AddValue("MaxUpdatePerBody", MaxUpdatePerBody); info.AddValue("Speed", Speed); info.AddValue("Ropes", Ropes, Ropes.GetType()); info.AddValue("ShowTriangles", ShowTriangles); }
public void damage(float dmg, float stun, Vector2 dir, float knockback, IKillable idiot) { if (shielding) { dir.GetType(); } if (!shielding) { stunned = stun; knockbackV = dir.normalized * knockback; health -= dmg; } else if (idiot != null) { idiot.damage(0, stun / 1.2f, -dir, knockback, this); } }
public virtual void GetObjectData(SerializationInfo info, StreamingContext context) { //info.AddValue("Collide", Collide, Collide.GetType()); info.AddValue("Mesh", Mesh, Mesh.GetType()); info.AddValue("IsStatic", IsStatic); info.AddValue("IsFree", IsFree); info.AddValue("AttachToGravity", AttachToGravity); info.AddValue("Force", Force, Force.GetType()); info.AddValue("Acceleration", Acceleration, Acceleration.GetType()); info.AddValue("Velocity", Velocity, Velocity.GetType()); info.AddValue("MaxSpeed", MaxSpeed, MaxSpeed.GetType()); info.AddValue("MaxAcceleration", MaxAcceleration, MaxAcceleration.GetType()); info.AddValue("GravityNormal", GravityNormal, GravityNormal.GetType()); info.AddValue("PreventSlippingOnSlopes", PreventSlippingOnSlopes); info.AddValue("Convex", Convex); info.AddValue("Entity", Entity, typeof(object)); info.AddValue("_mass", _mass); info.AddValue("_inverseMass", _inverseMass); info.AddValue("NotCollideWith", NotCollideWith.ToArray(), typeof(Body[])); //info.AddValue("NotCollideWith", NotCollideWith, NotCollideWith.GetType()); }
public void MinimumOperator_Verify_Identity_Value() { var a = new Vector2(2, 2); var b = new Vector3(3, 3, 3); var e = new Vector3(2, 2, 3); var min = ScriptableObject.CreateInstance <Operator.Minimum>(); min.SetOperandType(0, a.GetType()); min.SetOperandType(1, b.GetType()); min.inputSlots[0].value = a; min.inputSlots[1].value = b; var context = new VFXExpression.Context(VFXExpressionContextOption.CPUEvaluation); var resultVector3Expression = context.Compile(min.outputSlots[0].GetExpression()); var r = resultVector3Expression.Get <Vector3>(); Assert.AreEqual(e.x, r.x); Assert.AreEqual(e.y, r.y); Assert.AreEqual(e.z, r.z); }
/// <summary> /// Loads all possible blocks into Level from a text file /// </summary> /// <param name="blocksFile">File to read in block data from</param> public void LoadBlocks(string blocksFile) { StreamReader reader = new StreamReader(blocksFile); while (reader.Peek() >= 0) { Dictionary<string, string> blockLoader = new Dictionary<string, string>(); blockLoader.Add("id", ""); blockLoader.Add("imageFile", ""); blockLoader.Add("activePassability", "FULLY_PASSABLE"); blockLoader.Add("inactivePassability", "FULLY_PASSABLE"); blockLoader.Add("onStep", "false"); blockLoader.Add("activeTime", Int32.MaxValue.ToString()); blockLoader.Add("inactiveTime", Int32.MaxValue.ToString()); blockLoader.Add("frameTime", "0.25"); blockLoader.Add("blockType", "Block"); blockLoader.Add("isDefault", "false"); blockLoader.Add("effectDelay", "0.1"); List<Effect> effects = new List<Effect>(); Condition passabilityCondition = new Condition(); while (reader.Peek() != '#') { String[] line = reader.ReadLine().Split(delimeter, StringSplitOptions.RemoveEmptyEntries); if (blockLoader.ContainsKey(line[0])) { blockLoader[line[0]] = line[1]; } if (line[0].Equals("effect")) { // check to see if its a class if (classes.ContainsKey(line[1])) { effects.Add(new Effect(new GameAction(classes[line[1]], classes[line[1]].GetMethod(line[2]), new object[0]))); } else { // assume (gameValueKey, operator, value) if (line.Length == 4) { effects.Add(new Effect(line[1], new Modifier(line[2], line[3]))); } } } if (line[0].Equals("passabilityCondition")) { if (classes.ContainsKey(line[1])) { passabilityCondition = new Condition(classes[line[1]].GetMethod(line[2]), new object[0]); } } } reader.ReadLine(); string id = blockLoader["id"]; Texture2D spriteSheet = Content.Load<Texture2D>("Blocks/" + blockLoader["imageFile"]); Vector2 position = new Vector2(0, 0); bool onStep = Boolean.Parse(blockLoader["onStep"]); int[,] activePassability = classes["Block"].GetField(blockLoader["activePassability"]).GetValue(new Block("null", spriteSheet, position)) as int[,]; int[,] inactivePassability = classes["Block"].GetField(blockLoader["inactivePassability"]).GetValue(new Block("null", spriteSheet, position)) as int[,]; float activeTime = (float)Double.Parse(blockLoader["activeTime"]); float inActiveTime = (float)Double.Parse(blockLoader["inactiveTime"]); float frameTime = (float)Double.Parse(blockLoader["frameTime"]); float effectDelay = (float)Double.Parse(blockLoader["effectDelay"]); object[] constructorParameters = { id, spriteSheet, position, effects, onStep, activePassability, inactivePassability, passabilityCondition, activeTime, inActiveTime, frameTime, effectDelay }; Type[] constructorParameterTypes = { id.GetType(), spriteSheet.GetType(), position.GetType(), effects.GetType(), onStep.GetType(), activePassability.GetType(), inactivePassability.GetType(), passabilityCondition.GetType(), activeTime.GetType(), inActiveTime.GetType(), frameTime.GetType(), effectDelay.GetType()}; ConstructorInfo constructor = classes[blockLoader["blockType"]].GetConstructor(constructorParameterTypes); Block block = constructor.Invoke(constructorParameters) as Block; Level.possibleBlocks.Add(id, block); if(Boolean.Parse(blockLoader["isDefault"])) { Level.defaultBlock = block; } } }
public void SpawnObject(Type type, Vector2 vec, Vector2 pos) { //Spara konstruktorn ConstructorInfo constructor = type.GetConstructor(new Type[] { vec.GetType(), pos.GetType() }); //Så här kör man konstuktorn constructor.Invoke(new object[] { vec, pos }); //Skicka JObject o = new JObject(); o[vec.GetType()] = JToken.FromObject(vec); o[pos.GetType()] = JToken.FromObject(vec); nugetta.SendGameMessage(o.ToString(), ""); }