public static new void ParseParmSet(ref ParameterSet actorParm, ref ParameterSet worldParm) { if (worldParm.HasParm("Strength")) actorParm.AddParm("Strength", worldParm.GetFloat("Strength")); if (worldParm.HasParm("Direction")) actorParm.AddParm("Direction", worldParm.GetVector3("Direction")); }
public static void ParseParmSet(ref ParameterSet actorParm, ref ParameterSet worldParm) { if (worldParm.HasParm("DieOnTrigger")) actorParm.AddParm("DieOnTrigger", worldParm.GetBool("DieOnTrigger")); if (worldParm.HasParm("InputAction")) actorParm.AddParm("InputAction", worldParm.GetString("InputAction")); }
public static new void ParseParmSet(ref ParameterSet actorParm, ref ParameterSet worldParm) { System.Diagnostics.Debug.Assert(worldParm.HasParm("InputAction"), "ButtonPushTriggerVolume requires an input action!"); actorParm.AddParm("InputAction", worldParm.GetString("InputAction")); if (worldParm.HasParm("KillOnButtonPush")) actorParm.AddParm("KillOnButtonPush", worldParm.GetBool("KillOnButtonPush")); }
/// <summary> /// Read trigger specific parameters from the world parm and add them to the actor parm /// </summary> /// <param name="parm"></param> /// <returns></returns> public static new void ParseParmSet(ref ParameterSet actorParm, ref ParameterSet worldParm) { if (worldParm.HasParm("TextPosition")) actorParm.AddParm("TextPosition", worldParm.GetVector2("TextPosition")); if (worldParm.HasParm("Text")) actorParm.AddParm("Text", worldParm.GetString("Text")); }
public static new void ParseParmSet(ref ParameterSet actorParm, ref ParameterSet worldParm) { System.Diagnostics.Debug.Assert(worldParm.HasParm("NewDir"), "Rotate Camera requires a new direction!"); actorParm.AddParm("NewDir", worldParm.GetVector3("NewDir")); if (worldParm.HasParm("RotateRight")) actorParm.AddParm("RotateRight", worldParm.GetBool("RotateRight")); if(worldParm.HasParm("RotationTime")) actorParm.AddParm("RotationTime", worldParm.GetFloat("RotationTime")); }
public RModel(ParameterSet parm) { ModelInfo m; m.modelName = parm.GetString("ModelName"); Name = m.modelName; ShadowDrawLists = new FastList<RModelInstance>[Sun.NUM_CASCADES]; for (int i = 0; i < ShadowDrawLists.Length; i++) ShadowDrawLists[i] = new FastList<RModelInstance>(); if (parm.HasParm("BumpMap")) IsBumpMapped = true; if (parm.HasParm("Shininess")) Shininess = parm.GetFloat("Shininess"); if (parm.HasParm("SpecularPower")) SpecularPower = parm.GetFloat("SpecularPower"); if (parm.HasParm("SpecularMap")) IsSpecularMapped = true; if (parm.HasParm("CastsShadows")) CastsShadows = parm.GetBool("CastsShadows"); if (parm.HasParm("ReceivesShadows")) ReceivesShadows = parm.GetBool("ReceivesShadows"); if (parm.HasParm("AlphaBlend")) AlphaBlend = parm.GetBool("AlphaBlend"); m.textureName = ""; if (parm.HasParm("Texture")) m.textureName = parm.GetString("Texture"); modelDictionary.Add(m, this); Renderer.Instance.AddRModel(this); }
/// <summary> /// Read trigger specific parameters from the world parm and add them to the actor parm /// </summary> /// <param name="parm"></param> /// <returns></returns> public static new void ParseParmSet(ref ParameterSet actorParm, ref ParameterSet worldParm) { if (worldParm.HasParm("Volume")) actorParm.AddParm("Volume", worldParm.GetFloat("Volume")); if (worldParm.HasParm("Pitch")) actorParm.AddParm("Pitch", worldParm.GetFloat("Pitch")); if (worldParm.HasParm("Pan")) actorParm.AddParm("Pan", worldParm.GetFloat("Pan")); if (worldParm.HasParm("Type")) actorParm.AddParm("Type", worldParm.GetString("Type")); System.Diagnostics.Debug.Assert(worldParm.HasParm("SoundName"), "PlaySoundTriggerVolume requires a sound name!"); actorParm.AddParm("SoundName", worldParm.GetString("SoundName")); }
public Sun(ParameterSet parm) { if (parm.HasParm("SunColor")) lightColor = parm.GetVector4("SunColor"); if (parm.HasParm("AmbientLightColor")) ambientLightColor = parm.GetVector4("AmbientLightColor"); Vector2 sunAngles = Vector2.Zero; if (parm.HasParm("SunAngles")) sunAngles = parm.GetVector2("SunAngles"); if ( shadowMap == null ) shadowMap = new RenderTarget2D(Renderer.Instance.GraphicsDevice, SHADOW_MAP_WIDTH_HEIGHT * NUM_CASCADES, SHADOW_MAP_WIDTH_HEIGHT, false, SurfaceFormat.Single, DepthFormat.Depth24); SetSunDirectionFromSphericalCoords(sunAngles.X, sunAngles.Y); }
public static RModelInstance GetRModelInstance(ParameterSet parm) { if (parm.HasParm("ModelType")) if (parm.GetString("ModelType") == "Skinned") return new SkinnedRModelInstance(parm); return new RModelInstance(parm); }
private void InitEnemyPools(ref ParameterSet Parm) { availableWeakAI = new LinkedList<AI>(); availableRangedAI = new LinkedList<AI>(); availableHeavyAI = new LinkedList<AI>(); //add the number of enemies in the file Vector3 zero = Vector3.Zero; int num; if (Parm.HasParm("EnemyWeakPoolSize")) num = Parm.GetInt("EnemyWeakPoolSize"); else num = 0; for(int i = 0; i < num; i++) PreLoad("EnemyWeak", ref zero, ref zero); if (Parm.HasParm("EnemyRangedPoolSize")) num = Parm.GetInt("EnemyRangedPoolSize"); else num = 0; for (int i = 0; i < num; i++) PreLoad("EnemyRanged", ref zero, ref zero); if (Parm.HasParm("EnemyHeavyPoolSize")) num = Parm.GetInt("EnemyHeavyPoolSize"); else num = 0; for(int i = 0; i < num; i++) PreLoad("EnemyHeavy", ref zero, ref zero); ShutdownAll(); }
public static AnimationPlayer[] CreateAnimationList(Stage stage, ref ParameterSet parm, ref RModelInstance m) { SkinnedRModelInstance modelInstance = m as SkinnedRModelInstance; AnimationPlayer[] anims = new AnimationPlayer[(int)AnimationTypes.COUNT]; if (parm.HasParm("AttackAnimation")) anims[(int)AnimationTypes.Attack] = new AnimationPlayer(AnimationClip.LoadClip(parm.GetString("AttackAnimation")), modelInstance); if (parm.HasParm("IdleAnimation")) anims[(int)AnimationTypes.Idle] = new AnimationPlayer(AnimationClip.LoadClip(parm.GetString("IdleAnimation")), modelInstance); if (parm.HasParm("DeathAnimation")) anims[(int)AnimationTypes.Die] = new AnimationPlayer(AnimationClip.LoadClip(parm.GetString("DeathAnimation")), modelInstance); if (parm.HasParm("WalkAnimation")) anims[(int)AnimationTypes.Walk] = new AnimationPlayer(AnimationClip.LoadClip(parm.GetString("WalkAnimation")), modelInstance); if (parm.HasParm("BlockAnimation")) anims[(int)AnimationTypes.Block] = new AnimationPlayer(AnimationClip.LoadClip(parm.GetString("BlockAnimation")), modelInstance); if (parm.HasParm("TakeDamageAnimation")) anims[(int)AnimationTypes.TakeDamage] = new AnimationPlayer(AnimationClip.LoadClip(parm.GetString("TakeDamageAnimation")), modelInstance); return anims; }
public void Convert(ref ParameterSet parm) { if (parm.HasParm("Health")) startingHealth = this.health = parm.GetFloat("Health"); switch (actor.Name) { case "EnemyWeak": if (Stage.ActiveStage.Parm.HasParm("AIWeakHealthScalar")) health *= Stage.ActiveStage.Parm.GetFloat("AIWeakHealthScalar"); break; case "EnemyRanged": if (Stage.ActiveStage.Parm.HasParm("AIRangedHealthScalar")) health *= Stage.ActiveStage.Parm.GetFloat("AIRangedHealthScalar"); break; case "EnemyHeavy": if (Stage.ActiveStage.Parm.HasParm("AIHeavyHealthScalar")) health *= Stage.ActiveStage.Parm.GetFloat("AIHeavyHealthScalar"); break; } infiniteHealth = false; startsWithShield = shielded = false; percDamageAbsorbedByShield = 0; numHitsForDisarm = 0; if (parm.HasParm("InfiniteHealth")) infiniteHealth = parm.GetBool("InfiniteHealth"); if (parm.HasParm("Shielded")) startsWithShield = this.shielded = parm.GetBool("Shielded"); if (parm.HasParm("ShieldDmgAbsorbPerc")) this.percDamageAbsorbedByShield = parm.GetFloat("ShieldDmgAbsorbPerc"); if (parm.HasParm("ShutdownInsteadOfKill")) shutdownInsteadOfKill = parm.GetBool("ShutdownInsteadOfKill"); if (parm.HasParm("NumHitsForDisarm")) numHitsForDisarm = startingHitsForDisarm = parm.GetInt("NumHitsForDisarm"); }
/// <summary> /// Read trigger specific parameters from the world parm and add them to the actor parm /// </summary> /// <param name="parm"></param> /// <returns></returns> public static new void ParseParmSet(ref ParameterSet actorParm, ref ParameterSet worldParm) { if (worldParm.HasParm("Count")) actorParm.AddParm("Count", worldParm.GetInt("Count")); if (worldParm.HasParm("Freq")) actorParm.AddParm("Freq", worldParm.GetFloat("Freq")); if (worldParm.HasParm("SpawnInWaves")) actorParm.AddParm("SpawnInWaves", worldParm.GetBool("SpawnInWaves")); if (worldParm.HasParm("DelayForFirst")) actorParm.AddParm("DelayForFirst", worldParm.GetFloat("DelayForFirst")); if (worldParm.HasParm("ConstantSpawns")) actorParm.AddParm("ConstantSpawns", worldParm.GetBool("ConstantSpawns")); if (worldParm.HasParm("EnemyList")) actorParm.AddParm("EnemyList", worldParm.GetBool("EnemyList")); System.Diagnostics.Debug.Assert(worldParm.HasParm("ActorType"), "SpawnActorTriggerVolume requires an actor type to spawn!"); actorParm.AddParm("ActorType", worldParm.GetString("ActorType")); System.Diagnostics.Debug.Assert(worldParm.HasParm("SpawnPos"), "SpawnActorTriggerVolume requires a position to spawn at!"); actorParm.AddParm("SpawnPos", worldParm.GetString("SpawnPos")); }
public void PostLoadInit(ParameterSet parm) { Green = input.GetInputAction("A"); Red = input.GetInputAction("B"); PauseGame = input.GetInputAction("IsPauseGame"); MenuSelect = input.GetInputAction("IsMenuSelect"); MenuCancel = input.GetInputAction("IsMenuCancel"); MenuUp = input.GetInputAction("IsMenuUp"); MenuDown = input.GetInputAction("IsMenuDown"); MenuRight = input.GetInputAction("IsMenuRight"); MenuLeft = input.GetInputAction("IsMenuLeft"); if (parm.HasParm("DontPause")) dontPause = parm.GetBool("DontPause"); }
public override void PostLoadInit(ParameterSet Parm) { int index = 0; while (Parm.HasParm("Light" + index)) { string keyString = "Light" + index; string lightType = Parm.GetString(keyString); switch (lightType) { case "Directional": { // read directional light parameters and create light Vector3 direction = Parm.GetVector3(keyString + "Direction"); Vector4 color = Parm.GetVector4(keyString + "Color"); float intensity = Parm.GetFloat(keyString + "Intensity"); directionalLights.Add(new DirectionalLight(direction, color, intensity)); } break; case "Spot": { Vector3 position = Parm.GetVector3(keyString + "Position"); Vector3 direction = Parm.GetVector3(keyString + "Direction"); Vector4 color = Parm.GetVector4(keyString + "Color"); float intensity = Parm.GetFloat(keyString + "Intensity"); spotLights.Add(new SpotLight(DeferredRenderer.Instance.GraphicsDevice, position, direction, color, intensity, true, 1024, spotCookie)); } break; case "Point": { Vector3 position = Parm.GetVector3(keyString + "Position"); float radius = Parm.GetFloat(keyString + "Radius"); Vector4 color = Parm.GetVector4(keyString + "Color"); float intensity = Parm.GetFloat(keyString + "Intensity"); pointLights.Add(new PointLight(DeferredRenderer.Instance.GraphicsDevice, position, radius, color, intensity, true, 256)); } break; } index++; } }
public override void PreLoadInit(ParameterSet Parm) { if (Parm.HasParm("FirstScreen")) { Initialize(Parm.GetString("FirstScreen")); } }
public override void PreLoadInit(ParameterSet Parm) { setupCollisionGroups(); if (Parm.HasParm("Gravity")) { string[] gravity = Parm.GetString("Gravity").Split(); float x = float.Parse(gravity[0], System.Globalization.CultureInfo.InvariantCulture); float y = float.Parse(gravity[1], System.Globalization.CultureInfo.InvariantCulture); float z = float.Parse(gravity[2], System.Globalization.CultureInfo.InvariantCulture); Space.ForceUpdater.Gravity = new Vector3(x, y, z); } }
//note if we keep the base values the same, a lot of this code can be removed public override void ConvertTo(EnemyType e, ref ParameterSet parm) { if ((e != EnemyType.Heavy && e != EnemyType.HeavyAOE) || e == type) return; bloodOnDamage = true; if (parm.HasParm("Speed")) speed = parm.GetFloat("Speed"); if (parm.HasParm("AttackDamage")) attackDmg = parm.GetFloat("AttackDamage"); if (parm.HasParm("AttackRange")) attackRange = (float)Math.Pow(parm.GetFloat("AttackRange"), 2); if (parm.HasParm("PercAnimationBeforeAttack")) percAnimBeforeAttack = parm.GetFloat("PercAnimationBeforeAttack"); if (parm.HasParm("TimeForAttack")) attackTime = parm.GetFloat("TimeForAttack"); pointsForKilling = 50; if (parm.HasParm("PointsForKilling")) pointsForKilling = parm.GetInt("PointsForKilling"); spawnerIndex = -1; if (Stage.ActiveStage.Parm.HasParm("AIHeavySpeedScalar")) speed *= Stage.ActiveStage.Parm.GetFloat("AIHeavySpeedScalar"); if (Stage.ActiveStage.Parm.HasParm("AIHeavyDamageScalar")) { float increase = Stage.ActiveStage.Parm.GetFloat("AIHeavyDamageScalar"); attackDmg *= increase; attackSpecialDmg *= increase; } //look for more parms here if (parm.HasParm("TurnSpeed")) turnSpeed = parm.GetFloat("TurnSpeed"); if (parm.HasParm("TimeForAttackSpecial")) timeForAttackSpecial = parm.GetInt("TimeForAttackSpecial"); if (parm.HasParm("PercAnimationBeforeAttackRight")) percAnimBeforeAttackRight = parm.GetFloat("PercAnimationBeforeAttackRight"); if (parm.HasParm("PercAnimationBeforeAttackSpecial")) percAnimBeforeAttackSpecial = parm.GetFloat("PercAnimationBeforeAttackSpecial"); if (parm.HasParm("AttackSpecialDamage")) attackSpecialDmg = parm.GetFloat("AttackSpecialDamage"); if (parm.HasParm("MinPunches")) minPunches = parm.GetInt("MinPunches"); if (parm.HasParm("MaxPunches")) maxPunches = parm.GetInt("MaxPunches"); if (parm.HasParm("SlamAttackForce")) attackForce = parm.GetFloat("SlamAttackForce"); if (parm.HasParm("EndWithSlam")) shouldSlam = parm.GetBool("EndWithSlam"); jumpSpeed = 10; if (actor.PhysicsObject.physicsType == PhysicsObject.PhysicsType.CylinderCharacter) { actor.PhysicsObject.CylinderCharController.HorizontalMotionConstraint.Speed = speed; actor.PhysicsObject.CollisionInformation.CollisionRules.Group = PhysicsQB.heavyAIGroup; } actor.GetAgent<HealthAgent>().Convert(ref parm); shouldAttack = true; target = PlayerAgent.Player; state = AIState.Moving; FaceTargetSnappedToPlane(); type = e; }
public RModelInstance(ParameterSet parm) { model = RModel.GetRModel(parm); if (parm.HasParm("DontDraw")) dontDraw = parm.GetBool("DontDraw"); }
public static void ParseParmSet(ref ParameterSet actorParm, ref ParameterSet worldParm) { if (worldParm.HasParm("Health")) actorParm.AddParm("Health", worldParm.GetFloat("Health")); }
private static RModel CreateRModel(ParameterSet parm) { // if we have a model type, read it and create the right rmodel type if (parm.HasParm("ModelType")) { switch (parm.GetString("ModelType")) { case "Skinned": return new SkinnedRModel(parm); case "Static": return new StaticRModel(parm); case "Water": return new WaterRModel(parm); case "EditorManipulator": return new EditorManipulatorRModel(parm); default: System.Diagnostics.Debug.Assert(false, "Invalid model type: " + parm.GetString("ModelType")); break; } } // default to static return new StaticRModel(parm); }
// used by skinnedrmodel, staticrmodel, waterrmodel to load basic parameters protected Model BasicModelLoad(ParameterSet parm, out bool initialized) { Microsoft.Xna.Framework.Graphics.Model model = Renderer.Instance.LookupModel("Models/" + Name, out initialized); diffuse = null; bumpMap = null; specularMap = null; if (parm.HasParm("Texture")) diffuse = Renderer.Instance.LookupTexture("Models/" + parm.GetString("Texture")); else diffuse = Renderer.Instance.LookupTexture("DefaultDiffuse"); if (IsBumpMapped) bumpMap = Renderer.Instance.LookupTexture("Models/" + parm.GetString("BumpMap")); if (IsSpecularMapped) specularMap = Renderer.Instance.LookupTexture("Models/" + parm.GetString("SpecularMap")); return model; }
public static RModel GetRModel(ParameterSet parm) { ModelInfo m; m.modelName = parm.GetString("ModelName"); m.textureName = ""; if (parm.HasParm("Texture")) m.textureName = parm.GetString("Texture"); if (modelDictionary.ContainsKey(m)) return modelDictionary[m]; else return CreateRModel(parm); }
/// <summary> /// Read trigger specific parameters from the world parm and add them to the actor parm /// </summary> /// <param name="parm"></param> /// <returns></returns> public static new void ParseParmSet(ref ParameterSet actorParm, ref ParameterSet worldParm) { //check for the bare minimum required parms System.Diagnostics.Debug.Assert(worldParm.HasParm("ControllerInput0"), "TutorialStopTriggerVolume requires a ControllerInput0!"); System.Diagnostics.Debug.Assert(worldParm.HasParm("GuitarInput0"), "TutorialStopTriggerVolume requires a GuitarInput0!"); System.Diagnostics.Debug.Assert(worldParm.HasParm("ControllerImage0"), "TutorialStopTriggerVolume requires a ControllerImage0!"); System.Diagnostics.Debug.Assert(worldParm.HasParm("GuitarImage0"), "TutorialStopTriggerVolume requires a GuitarImage0!"); System.Diagnostics.Debug.Assert(worldParm.HasParm("ControllerImagePos0"), "TutorialStopTriggerVolume requires a ControllerImagePos0!"); System.Diagnostics.Debug.Assert(worldParm.HasParm("ControllerImageSize0"), "TutorialStopTriggerVolume requires a ControllerImageSize0!"); System.Diagnostics.Debug.Assert(worldParm.HasParm("GuitarImagePos0"), "TutorialStopTriggerVolume requires a GuitarImagePos0!"); System.Diagnostics.Debug.Assert(worldParm.HasParm("GuitarImageSize0"), "TutorialStopTriggerVolume requires a GuitarImageSize0!"); int count = 0; while (worldParm.HasParm("ControllerInput"+count)) { actorParm.AddParm("ControllerInput"+count, worldParm.GetString("ControllerInput"+count)); actorParm.AddParm("GuitarInput"+count, worldParm.GetString("GuitarInput"+count)); actorParm.AddParm("ControllerImage"+count, worldParm.GetString("ControllerImage"+count)); actorParm.AddParm("GuitarImage"+count, worldParm.GetString("GuitarImage"+count)); actorParm.AddParm("ControllerImagePos"+count, worldParm.GetString("ControllerImagePos"+count)); actorParm.AddParm("ControllerImageSize"+count, worldParm.GetString("ControllerImageSize"+count)); actorParm.AddParm("GuitarImagePos"+count, worldParm.GetString("GuitarImagePos"+count)); actorParm.AddParm("GuitarImageSize"+count, worldParm.GetString("GuitarImageSize"+count)); //optional parms if (worldParm.HasParm("StrumRequired"+count)) actorParm.AddParm("StrumRequired"+count, worldParm.GetBool("StrumRequired"+count)); if (worldParm.HasParm("AllInputsRequired"+count)) actorParm.AddParm("AllInputsRequired"+count, worldParm.GetBool("AllInputsRequired"+count)); if (worldParm.HasParm("SpawnEnemy"+count)) actorParm.AddParm("SpawnEnemy"+count, worldParm.GetBool("SpawnEnemy"+count)); if (worldParm.HasParm("KillEnemies"+count)) actorParm.AddParm("KillEnemies"+count, worldParm.GetBool("KillEnemies"+count)); if (worldParm.HasParm("TriggerDelay"+count)) actorParm.AddParm("TriggerDelay"+count, worldParm.GetFloat("TriggerDelay"+count)); count++; } if (worldParm.HasParm("EndLevel")) actorParm.AddParm("EndLevel", worldParm.GetBool("EndLevel")); actorParm.AddParm("Num", count); }
public override void ConvertTo(EnemyType e, ref ParameterSet parm) { //we can't return if we are a weak shielded cause we have to do models swaps and such. if ((e != EnemyType.Weak && e != EnemyType.WeakShielded) || e == type && type == EnemyType.Weak) return; /*actor.modelInstance.Shown = false; if (e == EnemyType.Weak) { actor.modelInstance = weakModel; enemyAnimationAgent.Animations = weakAnims; } else { actor.modelInstance = shieldModel; enemyAnimationAgent.Animations = shieldAnims; } actor.modelInstance.Shown = true;*/ bloodOnDamage = true; if (parm.HasParm("Speed")) speed = parm.GetFloat("Speed"); if (parm.HasParm("AttackDamage")) attackDmg = parm.GetFloat("AttackDamage"); if (parm.HasParm("AttackRange")) attackRange = (float)Math.Pow(parm.GetFloat("AttackRange"), 2); if (parm.HasParm("PercAnimationBeforeAttack")) percAnimBeforeAttack = parm.GetFloat("PercAnimationBeforeAttack"); if (parm.HasParm("TimeForAttack")) attackTime = parm.GetFloat("TimeForAttack"); pointsForKilling = 50; if (parm.HasParm("PointsForKilling")) pointsForKilling = parm.GetInt("PointsForKilling"); spawnerIndex = -1; if (Stage.ActiveStage.Parm.HasParm("AIWeakSpeedScalar")) speed *= Stage.ActiveStage.Parm.GetFloat("AIWeakSpeedScalar"); if (Stage.ActiveStage.Parm.HasParm("AIWeakDamageScalar")) attackDmg *= Stage.ActiveStage.Parm.GetFloat("AIWeakDamageScalar"); jumpSpeed = 10; if (actor.PhysicsObject.physicsType == PhysicsObject.PhysicsType.CylinderCharacter) { actor.PhysicsObject.CylinderCharController.HorizontalMotionConstraint.Speed = speed; actor.PhysicsObject.CollisionInformation.CollisionRules.Group = PhysicsQB.normalAIGroup; } if (parm.HasParm("EdgeDistWhileRunning")) wallOffset = parm.GetFloat("EdgeDistWhileRunning"); actor.GetAgent<HealthAgent>().Convert(ref parm); shouldAttack = true; disarmed = false; target = PlayerAgent.Player; state = AIState.Moving; FaceTargetSnappedToPlane(); type = e; }
// position and rotation come from world parm file, which we dont have access to here /*public PhysicsObject(PhysicsType physicsType, Model model, Vector3 position, float mass) { this.physicsType = physicsType; int id = idCounter++; if (DisableMass) mass = -1.0f; switch (physicsType) { case PhysicsType.Box: spaceObject = PhysicsHelpers.ModelToPhysicsBox(model, position, mass); // boxes contain a broadphase entry which is what shows up in ray casts, so we need to make sure its tag is set to the right id // this will need to be done fore anything that is an ibroadphaseentryowner ((IBroadPhaseEntryOwner)spaceObject).Entry.Tag = id; break; case PhysicsType.StaticMesh: spaceObject = PhysicsHelpers.ModelToStaticMesh(model, new BEPUphysics.MathExtensions.AffineTransform(position)); //staticmesh's are not ibroadphaseentryowners...they will turn directly on the raycast, so nothing else to set the tag on break; case PhysicsType.None: spaceObject = null; this.position = position; return; } spaceObject.Tag = id; Stage.ActiveStage.GetQB<PhysicsQB>().Space.Add(spaceObject); }*/ /// <summary> /// Create a physics object /// </summary> /// <param name="actor">Actor that we are attached to</param> /// <param name="Parm">Actor's parm file</param> /// <param name="model">Actors model (so we can size the collider)</param> /// <param name="position">Position (from world parm)</param> /// <param name="rotation">Rotation (from world parm)</param> public PhysicsObject(Actor actor, ParameterSet Parm, Model model, Vector3 position, Vector3 rotation, Stage stage) { // **rotation comes in from file as ( pitch, yaw, roll )** this.actor = actor; this.physicsType = GameLib.PhysicsObject.PhysicsTypeFromString(Parm.GetString("PhysicsType")); this.position = position; this.rotation = Matrix.CreateFromYawPitchRoll(rotation.Y, rotation.X, rotation.Z); if (ForceStaticMesh) this.physicsType = PhysicsType.StaticMesh; switch (this.physicsType) { case PhysicsType.Box: { float mass; if (DisableMass) mass = -1.0f; else mass = Parm.GetFloat("Mass"); BEPUphysics.Entities.Entity entity = PhysicsHelpers.ModelToPhysicsBox(model, position, mass, rotation.X, rotation.Y, rotation.Z); entity.CollisionInformation.OwningActor = actor; spaceObject = entity; break; } case PhysicsType.StaticMesh: BEPUphysics.Collidables.StaticMesh mesh = PhysicsHelpers.ModelToStaticMesh(model, new BEPUphysics.MathExtensions.AffineTransform(Quaternion.CreateFromRotationMatrix( this.rotation ), position)); mesh.OwningActor = actor; spaceObject = mesh; break; case PhysicsType.Character: { float mass = Parm.GetFloat("Mass"); float scaleRadius = 1.0f; if (Parm.HasParm("ScaleRadius")) scaleRadius = Parm.GetFloat("ScaleRadius"); characterController = PhysicsHelpers.ModelToCharacterController(model, position, mass, scaleRadius); spaceObject = characterController.Body; characterController.Body.CollisionInformation.OwningActor = actor; stage.GetQB<PhysicsQB>().AddToSpace(CharacterController); return; } case PhysicsType.CylinderCharacter: { float mass = Parm.GetFloat("Mass"); float scaleRadius = 1.0f; if (Parm.HasParm("ScaleRadius")) scaleRadius = Parm.GetFloat("ScaleRadius"); if (Parm.HasParm("ColliderDims")) { Vector2 v = Parm.GetVector2("ColliderDims"); cylinderCharController = new CylinderCharacterController(position, v.Y, v.X, mass); } else cylinderCharController = PhysicsHelpers.ModelToCylinderCharacterController(model, position, mass, scaleRadius); cylinderCharController.Body.Orientation = Quaternion.CreateFromYawPitchRoll(rotation.Y, rotation.X, rotation.Z); spaceObject = cylinderCharController.Body; cylinderCharController.Body.CollisionInformation.OwningActor = actor; stage.GetQB<PhysicsQB>().AddToSpace(cylinderCharController); return; } case PhysicsType.TriggerVolume: { DetectorVolume detectorVolume = new DetectorVolume(PhysicsHelpers.ModelToTriangleMesh(model, position)); detectorVolume.OwningActor = actor; spaceObject = detectorVolume; detectorVolume.EntityBeganTouching += new EntityBeginsTouchingVolumeEventHandler(detectorVolume_EntityBeganTouching); detectorVolume.EntityStoppedTouching += new EntityStopsTouchingVolumeEventHandler(detectorVolume_EntityStoppedTouching); break; } case PhysicsType.None: spaceObject = null; this.position = position; this.rotation = Matrix.CreateFromYawPitchRoll(rotation.Y, rotation.X, rotation.Z); return; } stage.GetQB<PhysicsQB>().AddToSpace(spaceObject); }
public override void ConvertTo(EnemyType e, ref ParameterSet parm) { if ((e != EnemyType.Ranged && e != EnemyType.RangedPogo) || e == type) return; bloodOnDamage = true; if (parm.HasParm("Speed")) speed = parm.GetFloat("Speed"); if (parm.HasParm("AttackDamage")) attackDmg = parm.GetFloat("AttackDamage"); if (parm.HasParm("AttackRange")) attackRange = (float)Math.Pow(parm.GetFloat("AttackRange"), 2); if (parm.HasParm("PercAnimationBeforeAttack")) percAnimBeforeAttack = parm.GetFloat("PercAnimationBeforeAttack"); if (parm.HasParm("TimeForAttack")) attackTime = parm.GetFloat("TimeForAttack"); pointsForKilling = 50; if (parm.HasParm("PointsForKilling")) pointsForKilling = parm.GetInt("PointsForKilling"); spawnerIndex = -1; if (Stage.ActiveStage.Parm.HasParm("AIRangedSpeedScalar")) speed *= Stage.ActiveStage.Parm.GetFloat("AIRangedSpeedScalar"); if (Stage.ActiveStage.Parm.HasParm("AIRangedDamageScalar")) attackDmg *= Stage.ActiveStage.Parm.GetFloat("AIRangedDamageScalar"); missileOffset = Vector2.Zero; if (actor.Parm.HasParm("MissileOffset")) missileOffset = actor.Parm.GetVector2("MissileOffset"); timeForPogoSkip = .1f; percAnimForSplat = .45f; maxRocketJumps = minRocketJumps = minRocketAttacks = maxRocketAttacks = 0; if (parm.HasParm("MaxJumps")) maxRocketJumps = parm.GetInt("MaxJumps"); if (parm.HasParm("MinJumps")) minRocketJumps = parm.GetInt("MinJumps"); if (parm.HasParm("MaxAttacks")) maxRocketAttacks = parm.GetInt("MaxAttacks"); if (parm.HasParm("MinAttacks")) minRocketAttacks = parm.GetInt("MinAttacks"); if (parm.HasParm("PogoStartTime")) pogoStartTime = parm.GetFloat("PogoStartTime"); jumpSpeed = 22; if (actor.PhysicsObject.physicsType == PhysicsObject.PhysicsType.CylinderCharacter) { actor.PhysicsObject.CylinderCharController.HorizontalMotionConstraint.Speed = speed; actor.PhysicsObject.CollisionInformation.CollisionRules.Group = PhysicsQB.normalAIGroup; } actor.GetAgent<HealthAgent>().Convert(ref parm); shouldAttack = true; target = PlayerAgent.Player; state = AIState.Moving; FaceTargetSnappedToPlane(); type = e; }