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 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 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")); }
/// <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 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"); }
// 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 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 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; }
/// <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); }
//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 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; }
public static void ParseParmSet(ref ParameterSet actorParm, ref ParameterSet worldParm) { if (worldParm.HasParm("Health")) actorParm.AddParm("Health", worldParm.GetFloat("Health")); }