//--------------------------------------------------------------------------------------------------------------------------------------------------- // // Copyright (C)2007 DarkWynter Studios. All rights reserved. // //--------------------------------------------------------------------------------------------------------------------------------------------------- // {Contact : darkwynter.com for licensing information //--------------------------------------------------------------------------------------------------------------------------------------------------- namespace DarkWynter.Engine.GameObjects { #region Using Statements using System; using System.Collections.Generic; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Audio; using Microsoft.Xna.Framework.Content; using Microsoft.Xna.Framework.Graphics; using Microsoft.Xna.Framework.Input; using Microsoft.Xna.Framework.Storage; using System.Xml; using System.Diagnostics; using Xclna.Xna.Animation.Content; using Xclna.Xna.Animation; using Audio; using Physics; using Globals; using ObjectLib; using Utilities; using Controllers; using DarkWynter.Stream; using Init; #endregion /// /// Player Is Hit... /// public struct Hit { /// /// Point of impact storage /// public Vector3 POI; /// /// Type of hit /// public int type; /// /// Pitch and Yaw /// public Quaternion pitchyaw; /// /// Steps in the animation /// public float step; } /// /// Base class for Human and AI /// public class Player : GameObject { #region Attributes /// /// Player using terrainMod /// public bool terrainModEnabled = false; /// /// Type of the targeted object /// public Enums_Engine.ObjectType targetObject; /// /// List of where the player has been hit /// protected List hitWhere = new List(); private Enums_Engine.AttackType activeShield = Enums_Engine.AttackType.NONE; /// /// Last Attack mode selected /// protected Enums_Engine.AttackType lastModeSelected = Enums_Engine.AttackType.NONE; //protected Enums_Engine.PlayerState currentState = Enums_Engine.PlayerState.NORMAL; private GameObject gameObject; /// /// Player sounds /// public PlayerSounds pSounds; // Physics /// /// Target point /// public Vector3 lookAtPoint = new Vector3(); //public Sensor collisionSensor; /// /// Invert controller /// public bool controlsInverted = false; private Stopwatch mannaIncrement = new Stopwatch(); private Stopwatch RateOfFire = new Stopwatch(); private Stopwatch energyStabalizeTimer = new Stopwatch(); /// /// Timer before the player is respawned /// public Stopwatch respawnTimer = new Stopwatch(); private Stopwatch spawnDoneTimer = new Stopwatch(); // player immortal after spawn /// /// Player ID /// public int playerIndex; /// /// Player health /// public float health; /// /// Player manna /// public float manna; /// /// ID of player who killed this player /// public int killedBy = -1; /// /// Kill count /// public int kills; /// /// Mass value of attack /// public int attackMagnitude = 30; /// /// Thermal value of attack /// protected int attackTemperature = 30; /// /// Number of keys collected /// public int numberOfKeysFound = 0; /// /// Respawn position /// public Vector3 spawnPosition = new Vector3(); /// /// Terrain Mod target location /// public Vector3 terrainModTarget = Vector3.Zero; private bool firingEnergyBeam = false; private float[] materialDiffuse = { 1.0f, 1.0f, 1.0f, 1.0f }; // Indicators for Human /// /// Indicates if Human was hurt /// protected bool damageIndicator = false; /// /// Indicates if Human gained/lost manna /// protected bool mannaIndicator = false; /// /// Indicates if Human picked up a key /// protected bool keyIndicator = false; /// /// Index of killing player /// protected string killInfo = ""; /// /// Particle which killed the player /// protected Particle killingParticle = null; /// /// Stop rumble on the controller /// public bool stopRumble = false; /// /// Attack amount /// +ve = player is attacking, -ve = player is defending and 0 = doing nothing /// protected float attackAmount = 0.0f; /// /// First person view enabled/disabled /// public bool fpvEnabled = false; /// /// Draw object to use for drawing the shield /// public Draw drawShield; /// /// GameObject the player is holding, if it has picked one up /// public GameObject holdingObject; #endregion #region Methods #region Initialization /// /// Default constructor /// public Player(Load gameObjectLoader) : base(gameObjectLoader) { mass.velocity = new Vector3(0, 0, 0); mass.mass = 10.0f; mass.scale = new Vector3(1.0f); mass.energy = 0.0f; mass.staticFrictionCoefficient = 0.25f; mass.dynamicFrictionCoefficient = 0.35f; mass.COR = 0.6f; mass.objectHeight = Statics_Engine.PlayerSettings.DEFAULT_PLAYER_HEIGHT; mass.lastMaxHeight = 0; mass.boundingVolume = new BoundingVolume(new BoundingSphere(new Vector3(10, 20, 10), 10.0f)); //All player variables need to be reset health = 0; manna = 0; drawShield = new Draw(Enums_Stream.DrawMethod.Shield_Draw, "ShieldShaderMain"); } /// /// Load information from XML /// /// ObjectLibrary /// True if load was successful public override bool Load(ObjectLibrary objectLibrary) { // Audio // pSounds = new PlayerSounds(); // Retrieve XML info modelAnimated = bool.Parse(load.node.Attributes["animated"].Value); if (modelAnimated) { draw = new Draw(Enums_Stream.DrawMethod.Animated_Draw, "SkinnedPlayerShaderMain"); drawAIVision = new Draw(Enums_Stream.DrawMethod.Animated_Draw, "AI_Vision_PlayerShaderMain"); } else { draw = new Draw(Enums_Stream.DrawMethod.BasicGameObject_Draw, "BasicLightingShaderMain"); drawAIVision = new Draw(Enums_Stream.DrawMethod.BasicGameObject_Draw, "AI_Vision_PlayerShaderMain"); } // Load Textures draw.textureList.Clear(); draw.textureList.Add(Statics_Engine.SystemSettings.content.Load(load.node.Attributes["texture"].Value)); draw.textureList.Add(Statics_Engine.SystemSettings.content.Load(load.node.Attributes["bumpTexture"].Value)); drawAIVision.textureList.Clear(); drawAIVision.textureList.Add(Statics_Engine.SystemSettings.content.Load(load.node.Attributes["texture"].Value)); drawAIVision.textureList.Add(Statics_Engine.SystemSettings.content.Load(load.node.Attributes["bumpTexture"].Value)); // Load Animated Model draw.model = Statics_Engine.SystemSettings.content.Load(load.node.Attributes["model"].Value); mass.scale = new Vector3(float.Parse(load.node.Attributes["maxScale"].Value)); foreach (ModelMesh mesh in draw.model.Meshes) { for (int i = 0; i < mesh.MeshParts.Count; i++) { ModelMeshPart part = mesh.MeshParts[i]; part.Effect = ShaderParameters.DrawFX.effect; } } drawAIVision.model = draw.model; draw.initialTransform = Matrix.Identity; if (modelAnimated) { // Create Animators animator = new ModelAnimator(draw.model); idle = new AnimationController(animator.Animations["idle"]); walk = new AnimationController(animator.Animations["idle"]); die = new AnimationController(animator.Animations["idle"]); RunController(idle); // Create Animation Transforms if (load.node.Attributes["typeID"].Value == "dojoboy" || load.node.Attributes["typeID"].Value == "dojogirl") { draw.initialTransform = Matrix.CreateRotationY((float)(-Math.PI / 2.0f)) * Matrix.CreateTranslation(new Vector3(0, -Statics_Engine.PlayerSettings.DEFAULT_PLAYER_HEIGHT / 2.0f, 0)); } } // Load non-animated Model drawShield.model = Statics_Engine.SystemSettings.content.Load("Content/_models/Shield"); foreach (ModelMesh mesh in drawShield.model.Meshes) { for (int i = 0; i < mesh.MeshParts.Count; i++) { // Add effect to mesh mesh.MeshParts[i].Effect = ShaderParameters.DrawFX.effect; } } draw.textureList.Add(Statics_Engine.SystemSettings.content.Load("Content/_textures/RockQuartz")); draw.textureList.Add(Statics_Engine.SystemSettings.content.Load("Content/_textures/EarthParticleLava")); draw.textureList.Add(Statics_Engine.SystemSettings.content.Load("Content/_textures/Water")); draw.textureList.Add(Statics_Engine.SystemSettings.content.Load("Content/_textures/AirParticleCold")); // Reset the Rate of Fire limiter RateOfFire = new Stopwatch(); RateOfFire.Start(); energyStabalizeTimer = new Stopwatch(); energyStabalizeTimer.Start(); mannaIncrement = new Stopwatch(); mannaIncrement.Start(); kills = 0; killedBy = -1; terrainModEnabled = false; lastModeSelected = Enums_Engine.AttackType.EARTH; #region Multi-Coordinate Loading try { // Convert into 0-127 coordinates if (load.node.Attributes["grid"].Value == "unit") { // Xml between 0-1 spawnPosition.X = Statics_Engine.TerrainSettings.collisionMapSize * float.Parse(load.node.Attributes["x"].Value); spawnPosition.Z = Statics_Engine.TerrainSettings.collisionMapSize * float.Parse(load.node.Attributes["z"].Value); } if (load.node.Attributes["grid"].Value == "tile") { // Xml between 0-127 spawnPosition.X = Statics_Engine.TerrainSettings.terrainScaleFactor * float.Parse(load.node.Attributes["x"].Value); spawnPosition.Z = Statics_Engine.TerrainSettings.terrainScaleFactor * float.Parse(load.node.Attributes["z"].Value); } if (load.node.Attributes["grid"].Value == "coord") { // X and Z between 0-8192 spawnPosition.X = float.Parse(load.node.Attributes["x"].Value); spawnPosition.Z = float.Parse(load.node.Attributes["z"].Value); } // Set spawn height using 0-127 coordinates spawnPosition.Y = mass.objectHeight / 2.0f + objectLibrary.terrain.GetTerrainHeight( spawnPosition.X / Statics_Engine.TerrainSettings.terrainScaleFactor, spawnPosition.Z / Statics_Engine.TerrainSettings.terrainScaleFactor); Statics_Engine.PlayerSettings.spawnPosYStorage = spawnPosition.Y; } catch { System.Diagnostics.Debug.WriteLine( "Error- Player.cs::Load() Incorrect spawn position in xml: " + spawnPosition.ToString()); return false; } // X and Z between 0-8192 SetSpawnPoint(spawnPosition); #endregion mass.boundingVolume.UpdateSphere(mass.currentPosition); return true; } #endregion #region Life, death, and taxes /// /// Check if this player is a human /// /// True if human public bool IsHuman() { if (playerIndex < 1) { return true; } return false; } /// /// Check if player is alive /// /// True if alive public bool IsAlive() { return (health > 0); } /// /// Set the player's spawn point /// /// Spawn point public void SetSpawnPoint(Vector3 spawn) { spawnPosition = Vector3.Zero + spawn; mass.SetPosition(spawnPosition, new Vector3(Statics_Engine.TerrainSettings.collisionMapSize / 2, 0, Statics_Engine.TerrainSettings.collisionMapSize / 2)); } /// /// Respawn our player /// public void SpawnPlayer() { // Remove from map //Statics.lookupMap.RemoveLast(this.mass); //Statics.lookupMap.RemoveCurrent(this.mass); mass.SetPosition(spawnPosition, new Vector3( Statics_Engine.TerrainSettings.collisionMapSize / 2, 0, Statics_Engine.TerrainSettings.collisionMapSize / 2)); mass.boundingVolume = new BoundingVolume( new BoundingSphere( new Vector3( spawnPosition.X, mass.objectHeight / 2.0f, spawnPosition.Z ), mass.scale.Y / 2)); mass.velocity = Vector3.Zero; mass.totalForce = Vector3.Zero; killedBy = -1; killInfo = ""; killingParticle = null; health = 100; manna = 100; activeShield = Enums_Engine.AttackType.NONE; // Reset the Rate of Fire limiter RateOfFire.Reset(); RateOfFire.Start(); energyStabalizeTimer.Reset(); energyStabalizeTimer.Start(); mannaIncrement.Reset(); mannaIncrement.Start(); //stop the respawn timer respawnTimer.Stop(); respawnTimer.Reset(); //start the invincibility timer spawnDoneTimer.Reset(); spawnDoneTimer.Start(); //Statics.lookupMap.SetPosition(this.mass); } /// /// Change Manna of Player /// /// Modification amount. /// public bool ChangeManna(float diff) { if (manna + diff < 0) { //don't have enough return false; } manna += diff; if (manna < 0) { manna = 0; } else if (manna > 100) { manna = 100; } return true; } /// /// Change the player's health /// /// Change in health /// ObjectLibrary public void ChangeHealth(float diff, ObjectLibrary objectLibrary) { if (spawnDoneTimer.IsRunning) { return; } if (diff < 0) { // Play audio for each human foreach (Player player in objectLibrary.humans) { if (player.IsAlive()) { Audio.Hit(pSounds, mass.currentPosition, player.mass.currentPosition); } } } health += diff; if (health < 0) { health = 0; } else if (health > 100) { health = 100; } } /// /// Kill the player /// /// Player to kill public void Kill(int killerID) { killedBy = killerID; //Begin their respawn timer respawnTimer.Reset(); respawnTimer.Start(); } /// /// Kill the player and assign kill credit /// /// Player to kill /// Object Library that killer belongs to. public void Kill(int killerID, ObjectLibrary objectLibrary) { Kill(killerID); AssignKillCredit(objectLibrary); } /// /// Assign kill credit to responsible player /// /// ObjectLibrary public void AssignKillCredit(ObjectLibrary objectLibrary) { // They were alive going into this method if they come out dead then // We know someone killed them and can assign credit // If the player did not suicide find out who killed them if (killedBy != playerIndex) { if (killedBy < 1) { // Find the killer who is human for (int i = 0; i < objectLibrary.humans.Count; i++) { // Assign credit to the killer if (killedBy == objectLibrary.humans[i].playerIndex) { objectLibrary.humans[i].kills++; } } } else { // Find the bot that killed for (int i = 0; i < objectLibrary.bots.Count; i++) { // Assign credit to the killer if (killedBy == objectLibrary.bots[i].playerIndex) { objectLibrary.bots[i].kills++; } } } } else { kills--; } } /// /// Check if the player was hit by a particle /// /// Particle /// ObjectLibrary /// Indicates if the particle needs to be recycled (True) public bool PlayerHitByParticle(Particle particle, ObjectLibrary objectLibrary) { if ((particle.hasCollided != playerIndex && particle.ownerID != playerIndex) || (particle.hurtOwner == true && particle.ownerID == playerIndex)) { // We know player is hit... determine which direction Vector3 toParticle = new Vector3(particle.mass.currentPosition.X - mass.currentPosition.X, particle.mass.currentPosition.Y - mass.currentPosition.Y, particle.mass.currentPosition.Z - mass.currentPosition.Z); Vector3 playerLook = new Vector3(mass.normalVector.X, 0, mass.normalVector.Z); playerLook.Normalize(); Vector3 cross = Vector3.Cross(toParticle, playerLook); if (cross.Y < 0) { hitWhere.Add(Enums_Engine.HitWhere.LEFT); } else { hitWhere.Add(Enums_Engine.HitWhere.RIGHT); } // Player shielded properly.. no damage and absorbs the particle if ((activeShield == Enums_Engine.AttackType.EARTH && particle.particleType == Enums_Engine.ParticleType.Earth) || (activeShield == Enums_Engine.AttackType.WATER && particle.particleType == Enums_Engine.ParticleType.Water) || (activeShield == Enums_Engine.AttackType.WIND && particle.particleType == Enums_Engine.ParticleType.Air)) { // Correct shield -> player absorbs manna ChangeManna(Statics_Engine.PlayerSettings.SHIELD_MANNA_GAIN * particle.mass.mass); if (IsHuman()) { mannaIndicator = true; } //Get rid of it altogether //Statics.lookupMap.RemoveLast(particle.mass); //Statics.lookupMap.RemoveCurrent(particle.mass); //if (Statics.lookupMap.DynamicContains(particle.mass)) //{ // Statics.lookupMap.RemoveDynamic(particle.mass); //} particle.mass.ClearValues(); particle.mass.deadObject = true; return true; } else { // Wrong shield -> player loses health ChangeHealth(DamageCalculations(particle.mass, mass), objectLibrary); // If tornado.. apply random force! if (particle.particleType == Enums_Engine.ParticleType.Air) { mass.AddForce(new Vector3(0, particle.mass.mass * 100000, 0)); } // If the player is dead and they haven't been assigned who killed them then do so if (!IsAlive() && killedBy == -1) { Kill(particle.ownerID); if (playerIndex < 1) { //Its a human.. set its killedby HUD info //((Human)this).SetKilledByInfo(particle); killingParticle = particle; } } } particle.hasCollided = playerIndex; particle.hasCollidedTimer = Stopwatch.StartNew(); } return false; } private float DamageCalculations(Mass particleMass, Mass playerMass) { float damage = 0.0f; Particle particle = ((Particle)particleMass.gameObjectPointer); // ~ about between 0 and 1 for slow to fast float particleVelocityRatio = particleMass.velocity.Length() / 2000.0f; // Velocity.Length() range~ // Earth: 200-1600 // Water: 400-1700 // Air: 500-1700 // Particle type based damage modifier if (particle.particleType == Enums_Engine.ParticleType.Earth) { if (particleMass.energy > 0.3f) { //lava hurts more if (particleMass.velocity.Length() < 50) { //its slower.. it hurts more? damage = 25.0f; } else { damage = 10.0f; } } else { //frozen rock and rock are the same damage = 5.0f + particleVelocityRatio; } } else if (particle.particleType == Enums_Engine.ParticleType.Water) { if (particleMass.energy > 0.5f) { //boiling water hurts alot if (particleMass.velocity.Length() < 50) { damage = 25.0f; } else { damage = 20.0f; } } else if (particleMass.energy < 0.0f) { //frozen ice hurts a bit more damage = 3.0f + particleVelocityRatio; } else { //regular water doesn't hurt that much if (particleMass.velocity.Length() < 50) { //slow water doesn't hurt damage = 0.0f; } else { damage = 10.0f; } } } else //air particle is all the same { damage = 0.1f + particleVelocityRatio; } float totalDamage = -damage * (1 + (particleMass.mass / 5.0f)) * Statics_Engine.PlayerSettings.DIRECT_HEALTH_LOSS; Debug.WriteLine("Particle type=" + particle.particleType.ToString() + ",mass=" + particleMass.mass + ", vRatio=" + particleVelocityRatio + ", v=" + particleMass.velocity.Length() + " damage=" + damage + "...total= " + totalDamage + ".... energy=" + particleMass.energy); return totalDamage; } #endregion #region UpdateCalls private void UpdateController(ObjectLibrary objectLibrary) { lookAtPoint = new Vector3(); if (modelAnimated) { currentAnimation.Update(Statics_Engine.SystemSettings.elementalGameTime); if (currentAnimation != idle) { RunController(idle); } } // Incrementaly regenerate players manna if (mannaIncrement.ElapsedMilliseconds >= Statics_Engine.PlayerSettings.MANNA_INCREMENT_RATE) { mannaIncrement.Reset(); mannaIncrement.Start(); ChangeManna(+2); } // Player fall damage applied if (mass.fallingDamageMultiplier != 0.0f) { ChangeHealth(-mass.fallingDamageMultiplier * Statics_Engine.PlayerSettings.FALLING_HEALTH_LOSS, objectLibrary); mass.fallingDamageMultiplier = 0.0f; if (IsAlive() == false) { Kill(playerIndex, objectLibrary); // Killed himself if (playerIndex < 1) { killInfo = "SPLAT!!!"; } } } // Set the LookAt point if (terrainModEnabled) { lookAtPoint = DarkWynterEngine.majikWand.LookAtTerrainPoint(objectLibrary, this); if (lookAtPoint.X < 0.0f) { lookAtPoint = new Vector3(0.0f, 500.0f, 0.0f); } } // Check the player's overall velocity if (mass.velocity.Length() > Statics_Engine.PlayerSettings.MAX_VELOCITY) { // If NOT falling //if (Math.Abs(mass.velocity.Y) < Math.Abs(mass.velocity.X) || Math.Abs(mass.velocity.Y) < Math.Abs(mass.velocity.Z)) //{ mass.velocity.Normalize(); mass.velocity *= Statics_Engine.PlayerSettings.MAX_VELOCITY; //} } activeShield = Enums_Engine.AttackType.NONE; if (attackAmount != 0.0f) { Attack(objectLibrary); attackAmount = 0.0f; } //Rotate(DarkWynterGame.playerController.gameInput.playerRotation); //Translate(DarkWynterGame.playerController.gameInput.playerMotion); //Zoom(); //ToggleMovementType(); //AttackMagnitude(); //AttackTemperature(); //AttackMode(); //Attack(objectLibrary); //Jump(objectLibrary); //AttackModeSwitching(); } /// /// Method called when a mode switch event has been triggered /// /// Increment/decrement amount public void AttackModeSwitching(int value) { if (lastModeSelected == Enums_Engine.AttackType.TERRAIN && value > 0) { lastModeSelected = Enums_Engine.AttackType.EARTH; } else if (lastModeSelected == Enums_Engine.AttackType.EARTH && value < 0) { lastModeSelected = Enums_Engine.AttackType.TERRAIN; } else if (value > 0) { lastModeSelected++; } else { lastModeSelected--; } if (lastModeSelected == Enums_Engine.AttackType.TERRAIN) { terrainModEnabled = true; } else { terrainModEnabled = false; } } /// /// Method called when a mode switch event has been triggered /// /// Increment/decrement amount public void AttackModeSwitching(bool value) { if (lastModeSelected == Enums_Engine.AttackType.TERRAIN && value) { lastModeSelected = Enums_Engine.AttackType.EARTH; } else if (lastModeSelected == Enums_Engine.AttackType.EARTH && !value) { lastModeSelected = Enums_Engine.AttackType.TERRAIN; } else if (value) { lastModeSelected++; } else { lastModeSelected--; } if (lastModeSelected == Enums_Engine.AttackType.TERRAIN) { terrainModEnabled = true; } else { terrainModEnabled = false; } } public void AttackMode(Enums_Engine.AttackType weapon) { lastModeSelected = weapon; if (lastModeSelected == Enums_Engine.AttackType.TERRAIN) { terrainModEnabled = true; } else { terrainModEnabled = false; } } /// /// Method called when a jump event has been triggered /// /// Object Library public virtual void Jump(ObjectLibrary objectLibrary) { // See if player is jumping if (CheckPlayerOnTerrain(objectLibrary) == false) { mass.AddForce(new Vector3(0, Statics_Engine.PlayerSettings.IN_AIR_JUMP_CONSTANT, 0)); } else { mass.AddForce(new Vector3(0, Statics_Engine.PlayerSettings.JUMP_CONSTANT, 0)); } if (modelAnimated) { RunController(die); } } /// /// Method invoked when the attack/defend button is pressed /// /// Attack/defend amount public void ChangeAttackAmount(float change) { attackAmount += change; if (attackAmount > 1.0f) attackAmount = 1.0f; else if (attackAmount < -1.0f) attackAmount = -1.0f; } /// /// Method for updating the rumble when an attack/defend button is pressed /// protected virtual void UpdateAttackRumble() { } /// /// Method called when the player detects that an attack/defend has been invoked /// /// Object Library public void Attack(ObjectLibrary objectLibrary) { UpdateAttackRumble(); if (lastModeSelected == Enums_Engine.AttackType.TERRAIN) { if (targetObject == Enums_Engine.ObjectType.TERRAIN) { // Get player start height float terrainHeightBefore = objectLibrary.terrain.GetTerrainHeight( this.mass.currentPosition.X / Statics_Engine.TerrainSettings.terrainScaleFactor, this.mass.currentPosition.Z / Statics_Engine.TerrainSettings.terrainScaleFactor); // Modify terrain int modRadius = (int)(this.attackMagnitude / 25) + 1; TerrainModRequest modRequest = new TerrainModRequest(attackAmount * 0.01f, this.lookAtPoint, this.lookAtPoint + Vector3.One, modRadius, Enums_Engine.TerrainModType.ADDITIVE ); MajikWand.TerrainMod(modRequest); // Get terrain end height float terrainHeightAfter = objectLibrary.terrain.GetTerrainHeight( this.mass.currentPosition.X / Statics_Engine.TerrainSettings.terrainScaleFactor, this.mass.currentPosition.Z / Statics_Engine.TerrainSettings.terrainScaleFactor); // Reset player to new height bool isJumping = !this.CheckPlayerOnTerrain(objectLibrary); if (terrainHeightBefore != terrainHeightAfter && isJumping == false) { this.mass.currentPosition.Y = terrainHeightAfter + mass.objectHeight * 1.5f; } } } // Attack has been triggered if (attackAmount > 0.0f && manna > Statics_Engine.PlayerSettings.ATTACK_MANNA_COST) { ChangeManna(-Math.Abs(attackAmount) * 0.1f); switch (lastModeSelected) { case Enums_Engine.AttackType.FIRE: { // Play audio for each human foreach (Player player in objectLibrary.humans) { if (player.IsAlive()) { Audio.FireAttack(pSounds, mass.currentPosition, player.mass.currentPosition); } } firingEnergyBeam = true; // Fire Attack //UseEnergyBeam(objectLibrary, DarkWynterGame.playerController.gameInput.attack); Attack_Bullet(Enums_Engine.BulletType.Water, objectLibrary); break; } case Enums_Engine.AttackType.EARTH: { Attack_Swarm(objectLibrary); break; } case Enums_Engine.AttackType.WATER: { Attack_Grenade(Enums_Engine.ParticleType.Water, objectLibrary); break; } case Enums_Engine.AttackType.WIND: { Attack_Grenade(Enums_Engine.ParticleType.Air, objectLibrary); break; } } } // Defend has been triggered else if(manna > Statics_Engine.PlayerSettings.SHIELD_MANNA_COST) { ChangeManna(Math.Abs(attackAmount) * 0.1f); activeShield = lastModeSelected; } } /// /// Method called when the temperature button has been pressed /// /// Increment = true; Decrement = false public void AttackTemperature(bool increment) { Audio.MenuDPad(); if(increment) { attackTemperature += 5; if (attackTemperature > 100) { attackTemperature = 100; } } else { attackTemperature -= 5; if (attackTemperature < 1) { attackTemperature = 1; } } } /// /// Method called when the magnitude button has been pressed /// /// Increment = true; Decrement = false public void AttackMagnitude(bool increment) { Audio.MenuDPad(); if (increment) { attackMagnitude += 5; if (attackMagnitude > 100) { attackMagnitude = 100; } } else { attackMagnitude -= 5; if (attackMagnitude < 1) { attackMagnitude = 1; } } } /// /// Method called when the movement toggle button has been pressed /// public void ToggleMovementType() { // Toggle movement type if (mass.movementType == Enums_Engine.MovementType.WALK) { mass.movementType = Enums_Engine.MovementType.HOVER; } else { mass.movementType = Enums_Engine.MovementType.WALK; mass.totalForce = Vector3.Zero; mass.velocity = Vector3.Zero; } } /// /// Method called when the zoom toggle button has been pressed /// /// Increment zoom = true; Decrement zoom = false public void Zoom(bool increment) { // Zoom Control if (increment) { Statics_Stream.RenderSettings.zoomFactor += 0.5f; if (Statics_Stream.RenderSettings.zoomFactor > 5.0f) { Statics_Stream.RenderSettings.zoomFactor = 5.0f; } } else { Statics_Stream.RenderSettings.zoomFactor -= 0.5f; if (Statics_Stream.RenderSettings.zoomFactor < 1.0f) { Statics_Stream.RenderSettings.zoomFactor = 1.0f; } } } /// /// Method called when the motion buttons have been pressed /// /// Vector 2 amount of translation to induce public override void Translate(Vector2 value) { base.Translate(value); if (terrainModEnabled) { terrainModTarget = Vector3.Zero; } if (modelAnimated) { RunController(walk); } } /// /// Method called when the rotation buttons have been pressed /// /// Vector 2 amount of rotation public override void Rotate(Vector2 value) { if (controlsInverted) { base.Rotate(new Vector2(value.X, -value.Y)); } else { base.Rotate(new Vector2(value.X, value.Y)); } if (terrainModEnabled) { terrainModTarget = Vector3.Zero; } } /// /// Toggle First Person View /// public virtual void FPVToggle() { } /// /// Update player /// /// ObjectLibrary public override void Update(ref ObjectLibrary objectLibrary) { if (energyStabalizeTimer.ElapsedMilliseconds > 3000) { //update player's energy value if (mass.energy < 0.0f) { mass.ChangeEnergy(0.01f); } else if (mass.energy > 0.0f) { mass.ChangeEnergy(-0.01f); } energyStabalizeTimer.Reset(); energyStabalizeTimer.Start(); } if (modelAnimated) { if (currentAnimation != null) { currentAnimation.Update(Statics_Engine.SystemSettings.elementalGameTime); } animator.Update(); } // Update controls if not dead....... if (IsAlive() && Statics_Engine.SystemSettings.WINDOW_IN_FOCUS) { UpdateController(objectLibrary); } mass.Update(); //mass.isMoving = true; //if (mass.isMoving && !Statics.dynamicList.Contains(mass)) //{ // Statics.dynamicList.Add(mass); //} mass.boundingVolume.UpdateSphere(mass.currentPosition); Vector3 sensorDistance; if (mass.movementType == Enums_Engine.MovementType.WALK) { sensorDistance = mass.sensorDirection + Vector3.Zero; } else { sensorDistance = mass.velocity + Vector3.Zero; } if (sensorDistance.Length() > Statics_Engine.PlayerSettings.MAX_SENSOR_DISTANCE) { sensorDistance.Normalize(); sensorDistance = sensorDistance * Statics_Engine.PlayerSettings.MAX_SENSOR_DISTANCE; } //collisionSensor.mass.SetPosition(mass.currentPosition + sensorDistance, // mass.currentPosition + sensorDistance * 1.5f); if (spawnDoneTimer.IsRunning) { if (spawnDoneTimer.ElapsedMilliseconds >= Statics_Engine.PlayerSettings.SPAWN_DONE_DELAY) { spawnDoneTimer.Stop(); spawnDoneTimer.Reset(); } } // Play audio for each human foreach (Player player in objectLibrary.humans) { if (player.IsAlive()) { //if (DarkWynterGame.playerController.gameInput.playerMotion.Length() > 0) //{ // Audio.Walking(pSounds, mass.currentPosition, player.mass.currentPosition); //} //if (DarkWynterGame.playerController.gameInput.jump) //{ // Audio.Jump(pSounds, mass.currentPosition, player.mass.currentPosition); //} } } } #endregion #region Collision Responses /// /// Add Player specific responses to an object to object collision involving this and collidedObject. /// Uses collidedObject.collisionWithPlayerResponse to determine health and manna bonuses and damage. /// /// Object that collided with this Player. /// Resultant force of collision /// ObjectLibrary /// True = this object has to be recycled public override bool ObjectCollisionResponse(GameObject collidedObject, Vector3 resultantForce, ObjectLibrary objectLibrary) { // collidedObject will be absorbed by the player so we don't need to calculate collision forces switch (collidedObject.collisionWithPlayerResponse) { case Enums_Engine.CollisionResponses.HEALTHBONUS: ChangeHealth((collidedObject.collisionMultiplier * resultantForce.Length()) * 1.0f, objectLibrary); break; case Enums_Engine.CollisionResponses.HEALTHLOSS: mass.AddForce(resultantForce); ChangeHealth((collidedObject.collisionMultiplier * resultantForce.Length()) * -1.0f, objectLibrary); break; case Enums_Engine.CollisionResponses.MANNABONUS: ChangeManna(collidedObject.collisionMultiplier * 1.0f); break; case Enums_Engine.CollisionResponses.MANNALOSS: mass.AddForce(resultantForce); ChangeManna(collidedObject.collisionMultiplier * -1.0f); break; case Enums_Engine.CollisionResponses.NONE: mass.AddForce(resultantForce); break; } // Player did not absorb the colliding object return false; } /// /// Add Player specific responses to an object-terrain collision /// If on the terrain, Player is either in WALK or HOVER mode. /// Walk mode sets Player to the Terrain height at Player's location in the heightmap /// Hover mode uses force-based motion /// /// Current Terrain public override void TerrainCollisionResponse(Terrain terrain) { base.GetObjectHeight(terrain); // Add Gravity if player is above terrain if (heightDifference < 0.0f) { mass.AddForce(mass.mass * Statics_Engine.GameSettings.accelDueToGravity); } else if (heightDifference > 0.0f) { #region Walk if (mass.movementType == Enums_Engine.MovementType.WALK) { if (heightDifference < mass.objectHeight) { // Set the height manually mass.currentPosition.Y = localTerrainHeight + (mass.objectHeight / 2.0f); } else { mass.KickBack(5.0f); } } #endregion #region Hover else if (mass.movementType == Enums_Engine.MovementType.HOVER) { // Call base first base.TerrainCollisionResponse(terrain); // Zero out bounce energy from collision when player lands on the terrain. // This stops the user from bounce-missing the landing at high velocities. if (mass.totalForce.Y < 0.0f) { mass.totalForce.Y = 0.0f; } if (mass.velocity.Y < -100.0f) { mass.velocity = Vector3.Zero; } if (mass.velocity.Y < 0.0f) { mass.velocity.Y = 0.0f; } // Zero out trivial movement if (velocityTangentialComponent.Length() < 100.5f && totalForceTangentialComponent.Length() < 100.5f) { mass.totalForce.X = 0.0f; mass.totalForce.Z = 0.0f; mass.acceleration = Vector3.Zero; mass.velocity = Vector3.Zero; } else { // Pass components to AddFriction // - Friction coefficients // - The normal force on the body // - The direction of friction mass.AddFriction( mass.dynamicFrictionCoefficient + terrain.mass.dynamicFrictionCoefficient, gravityNormalComponent.Length() * mass.mass, -velocityTangentialComponent); } // Add terrain rebound force to object mass.AddForce((heightDifference * terrain.playerSurfaceTension * surfaceNormal));// + //(totalForceNormalComponent + (velocityNormalComponent * mass.mass / Statics.SystemSettings.dt))); } #endregion mass.lastMaxHeight = 0; } } #endregion #region Draw Calls /// /// General case draw function /// public override Draw Draw() { // Did we die?? if (IsAlive() == false) { return null; } //check spawn done delay if (spawnDoneTimer.IsRunning) { float ratio = (float)spawnDoneTimer.ElapsedMilliseconds / (float)Statics_Engine.PlayerSettings.SPAWN_DONE_DELAY; SetDiffuseAlpha(ratio); } else { SetDiffuseAlpha(255); } // Calculate ObjectSpace(Rotation) and WorldSpace(Translation) Transformation Matrix draw.matrix = draw.initialTransform * Matrix.CreateScale(mass.scale) * Matrix.CreateFromQuaternion(mass.currentRotation) * Matrix.CreateTranslation(mass.currentPosition); if (modelAnimated) { currentAnimation.Update(Statics_Engine.SystemSettings.elementalGameTime); draw.animator = animator; } if (holdingObject != null) { holdingObject.mass.currentPosition = this.mass.currentPosition; holdingObject.Draw(); } return draw; } /// /// Draw player's shield around the player when it is enabled /// public Draw DrawShield() { // HACK: THIS IS TO SEE THE PLAYER AT ALL TIMES if (activeShield != Enums_Engine.AttackType.NONE) { drawShield.matrix = Matrix.CreateScale(mass.boundingVolume.radius * 5) * Matrix.CreateTranslation(mass.currentPosition); switch (activeShield) { case Enums_Engine.AttackType.EARTH: { ShaderParameters.DrawFX.modelTexture1.SetValue(draw.textureList[2]); break; } case Enums_Engine.AttackType.FIRE: { ShaderParameters.DrawFX.modelTexture1.SetValue(draw.textureList[3]); break; } case Enums_Engine.AttackType.WATER: { ShaderParameters.DrawFX.modelTexture1.SetValue(draw.textureList[4]); break; } case Enums_Engine.AttackType.WIND: { ShaderParameters.DrawFX.modelTexture1.SetValue(draw.textureList[5]); break; } } return drawShield; } return null; } /// /// Draw the player model for AI-Vision pass /// public override void DrawAIVision() { drawAIVision.matrix = drawAIVision.initialTransform * Matrix.CreateScale(mass.scale) * Matrix.CreateFromQuaternion(mass.currentRotation) * Matrix.CreateTranslation(mass.currentPosition); if (modelAnimated) { currentAnimation.Update(Statics_Engine.SystemSettings.elementalGameTime); drawAIVision.animator = animator; } drawAIVision.DoDraw(); } /// /// Draw HUD elements /// /// Sprite Batch public virtual void DrawHUD(SpriteBatch spriteBatch) { } #endregion #region Player Abilities private void UseEnergyBeam(ObjectLibrary objectLibrary, float elementUse) { Vector3 lookAtPoint = new Vector3(-1.0f); // Get the particles information from LookAtPoint and store it in the local vector3 lookAtPoint lookAtPoint = DarkWynterEngine.majikWand.LookAtObject(objectLibrary, this); // Check if the target object was a particle or a player if (targetObject == Enums_Engine.ObjectType.PARTICLE || targetObject == Enums_Engine.ObjectType.PLAYER) { if (targetObject == Enums_Engine.ObjectType.PARTICLE) { // Reference the particle from lookupMap LinkedList linkedList = new LinkedList(); //Statics.lookupMap.GetListXZ((int)lookAtPoint.X / Statics.TerrainSettings.terrainScaleFactor, //(int)lookAtPoint.Z / Statics.TerrainSettings.terrainScaleFactor); int j = 0; foreach (Mass massObj in linkedList) { if (j == (int)lookAtPoint.Y) { gameObject = massObj.gameObjectPointer; break; } j++; } } else //its a player { if ((int)lookAtPoint.Y < 4) { //its a human gameObject = objectLibrary.humans[(int)lookAtPoint.Y]; } else { //its a bot gameObject = objectLibrary.bots[(int)lookAtPoint.Y - 4]; } } if (gameObject == null) { //didn't find it.. probably won't happen but just in case return; } // Expel or absorb energy float cost = 0; /* if (elementUse < 0) { if (targetObject == Enums_Engine.ObjectType.PARTICLE) { //absorb manna from particle cost = -Statics.PlayerSettings.PARTICLE_ABSORB_MANNA_COST * -elementUse; } else { //absorb health from player cost = -Statics.PlayerSettings.PLAYER_ABSORB_MANNA_COST * -elementUse; } } else { //expel cost = -Statics.PlayerSettings.EXPEL_MANNA_COST * elementUse; } */ if (targetObject == Enums_Engine.ObjectType.PARTICLE) { if (Math.Abs(gameObject.mass.energy) <= 1.0f && ChangeManna(cost)) { float dEnergy = elementUse; //If we use dpad: float dEnergy = (particleThermalValue - 37) / 40.0f; gameObject.mass.ChangeEnergy(dEnergy * 0.01f); if (gameObject.mass.objectType == Enums_Engine.ObjectType.PARTICLE) { ((Particle)gameObject).ownerID = playerIndex; } gameObject.mass.isChanging = true; if (elementUse < 0) { //add manna ChangeManna(Statics_Engine.PlayerSettings.PARTICLE_ABSORB_MANNA_GAIN * -elementUse); if (IsHuman()) { mannaIndicator = true; } } } } else { if (Math.Abs(gameObject.mass.energy) <= 1.0f && ChangeManna(cost)) { float dEnergy = elementUse; //If we use dpad: float dEnergy = (particleThermalValue - 37) / 40.0f; gameObject.mass.ChangeEnergy(dEnergy * 0.01f); if (elementUse < 0) { //add health from player ChangeHealth(Statics_Engine.PlayerSettings.PLAYER_ABSORB_HEALTH_GAIN * -elementUse, objectLibrary); ((Player)gameObject).ChangeHealth(-Statics_Engine.PlayerSettings.PLAYER_ABSORB_HEALTH_GAIN * -elementUse, objectLibrary); } else { //hurt player ((Player)gameObject).ChangeHealth(-Statics_Engine.PlayerSettings.EXPEL_HEALTH_LOSS * elementUse, objectLibrary); } //check if we killed the player if (((Player)gameObject).IsAlive() == false) { ((Player)gameObject).Kill(playerIndex, objectLibrary); if (((Player)gameObject).IsHuman()) { //set killed info on screen for human string s; if (IsHuman()) { s = "Player " + (playerIndex + 1); } else { s = "Bot " + (playerIndex + 1); } killInfo = "ZAPPED by " + s; } } } } } } private void Attack_Grenade(Enums_Engine.ParticleType type, ObjectLibrary objectLibrary) { // Enable shooting again if Rate Of Fire timer returns greater than the static fire rate if (RateOfFire.Elapsed.TotalMilliseconds > Statics_Engine.PlayerSettings.RATE_OF_FIRE + ((float)attackMagnitude * 10.0f)) { // Reset the rate of fire counter RateOfFire.Reset(); RateOfFire.Start(); // Charge Manna if (ChangeManna(-Statics_Engine.PlayerSettings.ATTACK_MANNA_COST * ((attackMagnitude + attackTemperature) / 10.0f))) { // Start the attack objectLibrary.Attack_Grenade(playerIndex, type, mass.currentPosition + 5 * mass.normalVector, mass.normalVector, attackMagnitude, attackTemperature); } } } private void Attack_Bullet(Enums_Engine.BulletType type, ObjectLibrary objectLibrary) { // Enable shooting again if Rate Of Fire timer returns greater than the static fire rate if (RateOfFire.Elapsed.TotalMilliseconds > Statics_Engine.PlayerSettings.RATE_OF_FIRE + ((float)attackMagnitude * 10.0f)) { // Reset the rate of fire counter RateOfFire.Reset(); RateOfFire.Start(); // Charge Manna if (ChangeManna(-Statics_Engine.PlayerSettings.ATTACK_MANNA_COST * ((attackMagnitude + attackTemperature) / 10.0f))) { // Start the attack objectLibrary.Attack_Bullet(playerIndex, type, mass.currentPosition + 5 * mass.normalVector, mass.normalVector, attackMagnitude, attackTemperature); } } } private void Attack_Swarm(ObjectLibrary objectLibrary) { // Enable shooting again if Rate Of Fire timer returns greater than the static fire rate //if (RateOfFire.Elapsed.TotalMilliseconds > Statics.PlayerSettings.RATE_OF_FIRE + ((float)attackMagnitude * 10.0f)) //{ // Reset the rate of fire counter // RateOfFire.Reset(); //RateOfFire.Start(); // Charge Manna //if (ChangeManna(-Statics.PlayerSettings.ATTACK_MANNA_COST * ((attackMagnitude + attackTemperature) / 10.0f))) //{ // Start the attack objectLibrary.Attack_GpuParticle(playerIndex, mass.currentPosition + 5 * mass.normalVector, mass.normalVector, attackMagnitude, attackTemperature); //} //} } /// /// Check to see if the player is flying or on the ground /// /// ObjectLibrary /// On ground = True public bool CheckPlayerOnTerrain(ObjectLibrary objectLibrary) { base.GetObjectHeight(objectLibrary.terrain); // Get difference between average and player if (heightDifference < 0.0f) { // In the Air return false; } else { // On the Ground return true; } } #endregion #region Set the Player's color. /// /// Set player's red component /// /// Red component (0-255) public void SetDiffuseRed(float red) { materialDiffuse[0] = (1.0f * red) / 255.0f; } /// /// Set player's green component /// /// Green component (0-255) public void SetDiffuseGreen(float green) { materialDiffuse[1] = (1.0f * green) / 255.0f; } /// /// Set player's blue component /// /// Blue component (0-255) public void SetDiffuseBlue(float blue) { materialDiffuse[2] = (1.0f * blue) / 255.0f; } /// /// Set player's alpha component /// /// Alpha component (0-255) public void SetDiffuseAlpha(float alpha) { materialDiffuse[3] = alpha; } private float[] GetDiffuseColor() { return materialDiffuse; } #endregion #endregion } } # region Legacy Code /* /// /// Draw the energy beam /// /// ObjectLibrary public void DrawEnergyBeam(ObjectLibrary objectLibrary) { if (lastModeSelected == Enums_Engine.AttackType.FIRE && firingEnergyBeam) { firingEnergyBeam = false; Vector3 startPosition = mass.currentPosition + mass.perpVector + mass.normalVector - mass.upVector * 3; Vector3 targetPosition; float[] diffuse = { 1, 1, 1, 1 }; // Get the particles information from LookAtPoint and store it in the local vector3 lookAtPoint Vector3 lookPoint = majikWand.LookAtObject(objectLibrary, this); // Check if the target object was Earth if (targetObject == Enums_Engine.ObjectType.PARTICLE) { targetPosition = mass.currentPosition + mass.normalVector * lookPoint.Length(); } else { targetPosition = mass.currentPosition + mass.normalVector * Statics_Engine.PlayerSettings.TERRAIN_MOD_RANGE; } draw.matrix = Matrix.Identity; ShaderParameters.DrawFX.World.SetValue(draw.matrix); ShaderParameters.DrawFX.materialDiffuse.SetValue(diffuse); //fire texture ShaderParameters.DrawFX.modelTexture1.SetValue(draw.textureList[4]); //water texture ShaderParameters.DrawFX.modelTexture2.SetValue(draw.textureList[3]); //should interpolate ShaderParameters.DrawFX.particleEnergyValue.SetValue((attackAmount / 2.0f) + 0.5f); VertexPositionTexture[] list = new VertexPositionTexture[6]; float size = 1.0f; list[0].Position = startPosition - mass.perpVector * size;// new Vector3(-size, 0, 0); //list[0].Color = new Color(0, 0, 0); list[0].TextureCoordinate = new Vector2(0, 1); list[1].Position = targetPosition - mass.perpVector * size + mass.normalVector * size;// new Vector3(-size, 0, size); //list[1].Color = new Color(0, 255, 0); list[1].TextureCoordinate = new Vector2(0, 0); list[2].Position = targetPosition + mass.perpVector * size + mass.normalVector * size;//new Vector3(size, 0, size); //list[2].Color = new Color(0, 0, 255); list[2].TextureCoordinate = new Vector2(1, 0); list[3].Position = list[0].Position;//new Vector3(-size, 0, 0); //list[3].Color = new Color(255, 255, 255); list[3].TextureCoordinate = list[0].TextureCoordinate; list[4].Position = list[2].Position;//new Vector3(size, 0, size); //list[4].Color = new Color(0, 0, 0); list[4].TextureCoordinate = list[2].TextureCoordinate; list[5].Position = startPosition + mass.normalVector * size;//new Vector3(0, 0, size); //list[5].Color = new Color(0, 100, 0); list[5].TextureCoordinate = new Vector2(1, 1); // Technique ShaderParameters.DrawFX.effect.CurrentTechnique = ShaderParameters.DrawFX.effect.Techniques["EnergyBeamShaderMain"]; ShaderParameters.DrawFX.effect.Begin(); foreach (EffectPass pass in ShaderParameters.DrawFX.effect.CurrentTechnique.Passes) { pass.Begin(); Statics_Stream.RenderSettings.graphics.GraphicsDevice.DrawUserPrimitives(PrimitiveType.TriangleList, list, 0, 2); pass.End(); } ShaderParameters.DrawFX.effect.End(); } } //public void Attack1(ObjectLibrary objectLibrary) //{ // DarkWynterGame.playerController.gameInput.attack = 0.5f; // DarkWynterGame.playerController.gameInput.attackAmount = 0.5f; // // Player Attack // if (DarkWynterGame.playerController.gameInput.attack != 0) // { // // Does player have enough manna? // if (manna > Statics_Engine.PlayerSettings.ATTACK_MANNA_COST) // { // // Is terrainMod switch on // if (lastModeSelected == Enums_Engine.AttackType.TERRAIN) // { // if (ChangeManna(-Math.Abs(DarkWynterGame.playerController.gameInput.attack) * 0.1f)) // { // if (targetObject == Enums_Engine.ObjectType.TERRAIN) // { // majikWand.TerrainMod(DarkWynterGame.playerController.gameInput.attack, objectLibrary, this); // } // } // } // // must be an attack or defend // else // { // // Check if fire button was used // if (manna > DarkWynterGame.playerController.gameInput.attack / 2.0f) // { // if (lastModeSelected == Enums_Engine.AttackType.FIRE) // { // if (ChangeManna(-Statics_Engine.PlayerSettings.ENERGY_BEAM_MANNA_COST)) // { // // Play audio for each human // foreach (Player player in objectLibrary.humans) // { // if (player.IsAlive()) // { // Audio.FireAttack(pSounds, mass.currentPosition, player.mass.currentPosition); // } // } // // Fire Attack // //UseEnergyBeam(objectLibrary, DarkWynterGame.playerController.gameInput.attack); // Attack_Bullet(Enums_Engine.BulletType.Water, objectLibrary); // } // } // } // // Check if particle Attack was initiated // if (DarkWynterGame.playerController.gameInput.attackAmount > 0.0f && manna > Statics_Engine.PlayerSettings.ATTACK_MANNA_COST) // { // // AND make sure they are not shielding at the same time // if (DarkWynterGame.playerController.gameInput.defendAmount == 0.0f) // { // // Attack // if (lastModeSelected == Enums_Engine.AttackType.EARTH) // { // //Attack_Grenade(Particle.ParticleType.Earth, objectLibrary); // Attack_Swarm(objectLibrary); // } // else if (lastModeSelected == Enums_Engine.AttackType.WATER) // { // Attack_Grenade(Enums_Engine.ParticleType.Water, objectLibrary); // } // else if (lastModeSelected == Enums_Engine.AttackType.WIND) // { // Attack_Grenade(Enums_Engine.ParticleType.Air, objectLibrary); // } // } // } // // Player uses shield // if (DarkWynterGame.playerController.gameInput.defendAmount > 0.0f && manna > Statics_Engine.PlayerSettings.SHIELD_MANNA_COST) // { // activeShield = lastModeSelected; // } // else // { // activeShield = Enums_Engine.AttackType.NONE; // } // } // } // } // // If triggers not pressed at all // else // { // activeShield = Enums_Engine.AttackType.NONE; // } //} //public void AttackMode() //{ // // Check for Attack request from user // if (DarkWynterGame.playerController.gameInput.terrainModToggle) // { // terrainModEnabled = !terrainModEnabled; // } // if (terrainModEnabled && DarkWynterGame.playerController.gameInput.attack != 0) // { // DarkWynterGame.playerController.gameInput.modeSwitch = Enums_Engine.AttackType.TERRAIN; // } // else if (DarkWynterGame.playerController.gameInput.attackAmount > 0) // { // DarkWynterGame.playerController.gameInput.modeSwitch = Enums_Engine.AttackMode.ATTACK; // } // else // { // DarkWynterGame.playerController.gameInput.modeSwitch = Enums_Engine.AttackMode.NONE; // } //} */ #endregion