public GraphicEffect(GameScene gameScene, SpriteBatch spriteBatch, SpriteFont spriteFont) { random = new Random(); bloom = new BloomComponent(gameScene.Game); // Look up the resolution and format of our main backbuffer. pp = gameScene.Game.GraphicsDevice.PresentationParameters; int width = pp.BackBufferWidth; int height = pp.BackBufferHeight; //width /= 2; //height /= 2; blurRenderTarget1 = new RenderTarget2D(gameScene.Game.GraphicsDevice, width, height, false, pp.BackBufferFormat, DepthFormat.None); blurRenderTarget2 = new RenderTarget2D(gameScene.Game.GraphicsDevice, width, height, false, pp.BackBufferFormat, DepthFormat.None); distortionRenderTarget = new RenderTarget2D(gameScene.Game.GraphicsDevice, width, height, false, pp.BackBufferFormat, DepthFormat.None); rippleRenderTarget = new RenderTarget2D(gameScene.Game.GraphicsDevice, width, height, false, pp.BackBufferFormat, DepthFormat.None); afterUnderWaterTexture = new RenderTarget2D(gameScene.Game.GraphicsDevice, width, height, false, pp.BackBufferFormat, DepthFormat.None); afterBloomTexture = new RenderTarget2D(gameScene.Game.GraphicsDevice, width, height, false, pp.BackBufferFormat, DepthFormat.None); afterEffectsRenderTarget = new RenderTarget2D(gameScene.Game.GraphicsDevice, width, height, false, pp.BackBufferFormat, DepthFormat.None); underWaterEffect = gameScene.Game.Content.Load<Effect>("Shaders/UnderWater"); screenTransitionEffect = gameScene.Game.Content.Load<Effect>("Shaders/ScreenTransition"); edgeDetectionEffect = gameScene.Game.Content.Load<Effect>("Shaders/EdgeDetectionEffect"); customBlurEffect = gameScene.Game.Content.Load<Effect>("Shaders/CustomBlur"); distortionEffect = gameScene.Game.Content.Load<Effect>("Shaders/DistortionEffect"); rippleEffect = gameScene.Game.Content.Load<Effect>("Shaders/RippleEffect"); edgeDetectionParameters = edgeDetectionEffect.Parameters; edgeDetectionEffect.CurrentTechnique = edgeDetectionEffect.Techniques["EdgeDetect"]; waveParam = rippleEffect.Parameters["wave"]; distortionParam = rippleEffect.Parameters["distortion"]; centerCoordParam = rippleEffect.Parameters["centerCoord"]; this.spriteBatch = spriteBatch; this.spriteFont = spriteFont; }
public static void UseSkill(bool mouseOnLivingObject, Vector3 pointIntersect, Cursor cursor, Camera gameCamera, GameMode gameMode, HydroBot hydroBot, GameScene gameScene, ContentManager Content, SpriteBatch spriteBatch, GameTime gameTime, List<DamageBullet> myBullet, BaseEnemy[] enemies, ref int enemiesAmount, Fish[] fish, ref int fishAmount, ref bool isCastingSkill) { if (isCastingSkill) { if (!hydroBot.clipPlayer.inRange(75, 95)) hydroBot.clipPlayer.switchRange(75, 95); //animation done playing, cast the skill now if (hydroBot.clipPlayer.donePlayingAnimation) { int healthToLose = 0; isCastingSkill = false; if (shootHammer) { ShootHammer(hydroBot, Content, myBullet, gameMode); HydroBot.skillPrevUsed[0] = PoseidonGame.playTime.TotalSeconds; HydroBot.skillPrevUsed[1] = PoseidonGame.playTime.TotalSeconds; HydroBot.firstUse[0] = false; HydroBot.firstUse[1] = false; shootHammer = false; } if (shootPiercingArrow) { ShootPiercingArrow(hydroBot, Content, spriteBatch, myBullet, gameMode); HydroBot.skillPrevUsed[0] = PoseidonGame.playTime.TotalSeconds; HydroBot.skillPrevUsed[3] = PoseidonGame.playTime.TotalSeconds; HydroBot.firstUse[0] = false; HydroBot.firstUse[3] = false; shootPiercingArrow = false; } if (shootHerculesArrow) { HydroBot.firstUse[0] = false; HydroBot.skillPrevUsed[0] = PoseidonGame.playTime.TotalSeconds; //audio.Explosion.Play(); CastSkill.UseHerculesBow(hydroBot, Content, spriteBatch, myBullet, gameMode); shootHerculesArrow = false; } if (useThorHammer) { HydroBot.firstUse[1] = false; HydroBot.skillPrevUsed[1] = PoseidonGame.playTime.TotalSeconds; PoseidonGame.audio.Explo1.Play(); gameCamera.Shake(25f, .4f); CastSkill.UseThorHammer(hydroBot.Position, hydroBot.MaxRangeX, hydroBot.MaxRangeZ, enemies, ref enemiesAmount, fish, fishAmount, HydroBot.gameMode, false); useThorHammer = false; } if (castInvincible) { HydroBot.firstUse[2] = false; HydroBot.invincibleMode = true; HydroBot.skillPrevUsed[2] = PoseidonGame.playTime.TotalSeconds; castInvincible = false; PoseidonGame.audio.armorSound.Play(); } if (castAutoExplode) { HydroBot.invincibleMode = true; HydroBot.autoExplodeMode = true; HydroBot.skillPrevUsed[2] = PoseidonGame.playTime.TotalSeconds; HydroBot.skillPrevUsed[1] = PoseidonGame.playTime.TotalSeconds; HydroBot.firstUse[2] = false; HydroBot.firstUse[1] = false; castAutoExplode = false; PoseidonGame.audio.armorSound.Play(); } if (castAutoHipno) { HydroBot.invincibleMode = true; HydroBot.autoHipnotizeMode = true; HydroBot.skillPrevUsed[2] = PoseidonGame.playTime.TotalSeconds; HydroBot.skillPrevUsed[4] = PoseidonGame.playTime.TotalSeconds; HydroBot.firstUse[2] = false; HydroBot.firstUse[4] = false; castAutoHipno = false; PoseidonGame.audio.armorSound.Play(); } if (castSonic) { HydroBot.firstUse[3] = false; HydroBot.skillPrevUsed[3] = PoseidonGame.playTime.TotalSeconds; HydroBot.supersonicMode = true; castSonic = false; PoseidonGame.audio.hermesSound.Play(); } if (castSonicHipno) { HydroBot.sonicHipnotiseMode = true; HydroBot.supersonicMode = true; HydroBot.skillPrevUsed[4] = PoseidonGame.playTime.TotalSeconds; HydroBot.skillPrevUsed[3] = PoseidonGame.playTime.TotalSeconds; HydroBot.firstUse[4] = false; HydroBot.firstUse[3] = false; castSonicHipno = false; PoseidonGame.audio.hermesSound.Play(); } if (castHipno) { HydroBot.firstUse[4] = false; PoseidonGame.audio.hipnotizeSound.Play(); useHypnotise(enemyToHipNo); HydroBot.skillPrevUsed[4] = PoseidonGame.playTime.TotalSeconds; castHipno = false; enemyToHipNo = null; } //lose health after using skill if (HydroBot.skillComboActivated && HydroBot.secondSkillID != -1 && HydroBot.secondSkillID != HydroBot.activeSkillID) healthToLose = (int)(2 * GameConstants.EnergyLostPerSkill);//GameConstants.skillHealthLoss; else healthToLose = (int)(GameConstants.EnergyLostPerSkill); //display HP loss //HydroBot.currentHitPoint -= healthToLose; //we now lose energy instead of health int energyLost = healthToLose; HydroBot.currentEnergy -= energyLost; Point point = new Point(); String point_string = "-" + energyLost.ToString() + "Energy"; point.LoadContent(PoseidonGame.contentManager, point_string, hydroBot.Position, Color.Red); if (gameMode == GameMode.ShipWreck) ShipWreckScene.points.Add(point); else if (gameMode == GameMode.MainGame) PlayGameScene.points.Add(point); else if (gameMode == GameMode.SurvivalMode) SurvivalGameScene.points.Add(point); if (!hydroBot.clipPlayer.inRange(50, 74)) hydroBot.clipPlayer.switchRange(50, 74); } return; } else //skill casting may have been aborted { shootHammer = shootPiercingArrow = shootHerculesArrow = useThorHammer = castInvincible = castAutoExplode = castAutoHipno = castSonic = castSonicHipno = castHipno = false; } bool skillUsed = false; int floatHeight; if (gameMode == GameMode.ShipWreck) floatHeight = GameConstants.ShipWreckFloatHeight; else floatHeight = GameConstants.MainGameFloatHeight; pointIntersect = CursorManager.IntersectPointWithPlane(cursor, gameCamera, floatHeight); hydroBot.ForwardDirection = CursorManager.CalculateAngle(pointIntersect, hydroBot.Position); // Hercules' Bow!!! if (HydroBot.activeSkillID == 0)// && mouseOnLivingObject) { //use skill combo if activated //cooldowns for both skills must be cleared if ((HydroBot.skillComboActivated && HydroBot.secondSkillID == 1) && //cooldowns check ((HydroBot.firstUse[0] == true && HydroBot.firstUse[1] == true)|| (PoseidonGame.playTime.TotalSeconds - HydroBot.skillPrevUsed[0] > GameConstants.coolDownForHerculesBow && PoseidonGame.playTime.TotalSeconds - HydroBot.skillPrevUsed[1] > GameConstants.coolDownForThorHammer))) { //ShootHammer(hydroBot, Content, myBullet, gameMode); //HydroBot.skillPrevUsed[0] = PoseidonGame.playTime.TotalSeconds; //HydroBot.skillPrevUsed[1] = PoseidonGame.playTime.TotalSeconds; //HydroBot.firstUse[0] = false; //HydroBot.firstUse[1] = false; shootHammer = true; skillUsed = true; } else if ((HydroBot.skillComboActivated && HydroBot.secondSkillID == 3) && ((HydroBot.firstUse[3] == true && HydroBot.firstUse[0] == true) || (PoseidonGame.playTime.TotalSeconds - HydroBot.skillPrevUsed[0] > GameConstants.coolDownForHerculesBow && PoseidonGame.playTime.TotalSeconds - HydroBot.skillPrevUsed[3] > GameConstants.coolDownForHermesSandal))) { //ShootPiercingArrow(hydroBot, Content, spriteBatch, myBullet, gameMode); //HydroBot.skillPrevUsed[0] = PoseidonGame.playTime.TotalSeconds; //HydroBot.skillPrevUsed[3] = PoseidonGame.playTime.TotalSeconds; //HydroBot.firstUse[0] = false; //HydroBot.firstUse[3] = false; shootPiercingArrow = true; skillUsed = true; } //or else use single skill //if the skill has cooled down //or this is the 1st time the user uses it else if ((PoseidonGame.playTime.TotalSeconds - HydroBot.skillPrevUsed[0] > GameConstants.coolDownForHerculesBow) || HydroBot.firstUse[0] == true) { //HydroBot.firstUse[0] = false; //HydroBot.skillPrevUsed[0] = PoseidonGame.playTime.TotalSeconds; ////audio.Explosion.Play(); //CastSkill.UseHerculesBow(hydroBot, Content, spriteBatch, myBullet, gameMode); shootHerculesArrow = true; skillUsed = true; } } //Thor's Hammer!!! if (HydroBot.activeSkillID == 1) { if ((PoseidonGame.playTime.TotalSeconds - HydroBot.skillPrevUsed[1] > GameConstants.coolDownForThorHammer) || HydroBot.firstUse[1] == true) { //HydroBot.firstUse[1] = false; //HydroBot.skillPrevUsed[1] = PoseidonGame.playTime.TotalSeconds; //PoseidonGame.audio.Explo1.Play(); //gameCamera.Shake(25f, .4f); //CastSkill.UseThorHammer(hydroBot.Position, hydroBot.MaxRangeX, hydroBot.MaxRangeZ, enemies, ref enemiesAmount, fish, fishAmount, HydroBot.gameMode, false); useThorHammer = true; skillUsed = true; } } // Achilles' Armor!!! if (HydroBot.activeSkillID == 2) { if ((HydroBot.skillComboActivated && HydroBot.secondSkillID == 4) && //cooldowns check ((HydroBot.firstUse[2] == true && HydroBot.firstUse[4] == true) || (PoseidonGame.playTime.TotalSeconds - HydroBot.skillPrevUsed[2] > GameConstants.coolDownForArchillesArmor && PoseidonGame.playTime.TotalSeconds - HydroBot.skillPrevUsed[4] > GameConstants.coolDownForHypnotise))) { //HydroBot.invincibleMode = true; //HydroBot.autoHipnotizeMode = true; //HydroBot.skillPrevUsed[2] = PoseidonGame.playTime.TotalSeconds; //HydroBot.skillPrevUsed[4] = PoseidonGame.playTime.TotalSeconds; //HydroBot.firstUse[2] = false; //HydroBot.firstUse[4] = false; castAutoHipno = true; skillUsed = true; } else if ((HydroBot.skillComboActivated && HydroBot.secondSkillID == 1) && //cooldowns check ((HydroBot.firstUse[2] == true && HydroBot.firstUse[1] == true) || (PoseidonGame.playTime.TotalSeconds - HydroBot.skillPrevUsed[2] > GameConstants.coolDownForArchillesArmor && PoseidonGame.playTime.TotalSeconds - HydroBot.skillPrevUsed[1] > GameConstants.coolDownForThorHammer))) { //HydroBot.invincibleMode = true; //HydroBot.autoExplodeMode = true; //HydroBot.skillPrevUsed[2] = PoseidonGame.playTime.TotalSeconds; //HydroBot.skillPrevUsed[1] = PoseidonGame.playTime.TotalSeconds; //HydroBot.firstUse[2] = false; //HydroBot.firstUse[1] = false; castAutoExplode = true; skillUsed = true; } else if ((PoseidonGame.playTime.TotalSeconds - HydroBot.skillPrevUsed[2] > GameConstants.coolDownForArchillesArmor) || HydroBot.firstUse[2] == true) { //HydroBot.firstUse[2] = false; //HydroBot.invincibleMode = true; //HydroBot.skillPrevUsed[2] = PoseidonGame.playTime.TotalSeconds; castInvincible = true; skillUsed = true; } //if (skillUsed) PoseidonGame.audio.armorSound.Play(); } //Hermes' Winged Sandal!!! if (HydroBot.activeSkillID == 3) { if ((HydroBot.skillComboActivated && HydroBot.secondSkillID == 4) && ((HydroBot.firstUse[3] == true && HydroBot.firstUse[4] == true) || (PoseidonGame.playTime.TotalSeconds - HydroBot.skillPrevUsed[4] > GameConstants.coolDownForHypnotise && PoseidonGame.playTime.TotalSeconds - HydroBot.skillPrevUsed[3] > GameConstants.coolDownForHermesSandal))) { //HydroBot.sonicHipnotiseMode = true; //HydroBot.supersonicMode = true; //HydroBot.skillPrevUsed[4] = PoseidonGame.playTime.TotalSeconds; //HydroBot.skillPrevUsed[3] = PoseidonGame.playTime.TotalSeconds; //HydroBot.firstUse[4] = false; //HydroBot.firstUse[3] = false; castSonicHipno = true; skillUsed = true; } else if ((PoseidonGame.playTime.TotalSeconds - HydroBot.skillPrevUsed[3] > GameConstants.coolDownForHermesSandal) || HydroBot.firstUse[3] == true) { //HydroBot.firstUse[3] = false; //HydroBot.skillPrevUsed[3] = PoseidonGame.playTime.TotalSeconds; //HydroBot.supersonicMode = true; castSonic = true; skillUsed = true; } //if (skillUsed) PoseidonGame.audio.hermesSound.Play(); } // Hypnotise skill if (HydroBot.activeSkillID == 4) { BaseEnemy enemy = CursorManager.MouseOnWhichEnemy(cursor, gameCamera, enemies, enemiesAmount); //can't hipnotize a submarine if (enemy != null && !(enemy is Submarine) && (HydroBot.firstUse[4] == true || PoseidonGame.playTime.TotalSeconds - HydroBot.skillPrevUsed[4] > GameConstants.coolDownForHypnotise)) { //HydroBot.firstUse[4] = false; //PoseidonGame.audio.hipnotizeSound.Play(); //useHypnotise(enemy); //HydroBot.skillPrevUsed[4] = PoseidonGame.playTime.TotalSeconds; castHipno = true; skillUsed = true; enemyToHipNo = enemy; } } if (skillUsed) { isCastingSkill = true; } //stop moving whether or not the skill has been casted hydroBot.reachDestination = true; pointIntersect = Vector3.Zero; }