Beispiel #1
0
        public void initialize(Vector3 position, Vector3 headingDirection, float speed, float strength, float strengthUp, GameMode gameMode)
        {
            base.initialize(position, headingDirection, speed);
            healthAmount = (int)(GameConstants.HealingAmount * strength * strengthUp);

            this.gameMode = gameMode;
            if (gameMode == GameMode.MainGame)
            {
                this.graphicDevice = PlayGameScene.GraphicDevice;
                this.gameCamera = PlayGameScene.gameCamera;
                this.spriteBatch = PoseidonGame.spriteBatch;
            }
            else if (gameMode == GameMode.ShipWreck)
            {
                this.graphicDevice = ShipWreckScene.GraphicDevice;
                this.gameCamera = ShipWreckScene.gameCamera;
                this.spriteBatch = PoseidonGame.spriteBatch;
            }
            else if (gameMode == GameMode.SurvivalMode)
            {
                this.graphicDevice = SurvivalGameScene.GraphicDevice;
                this.gameCamera = SurvivalGameScene.gameCamera;
                this.spriteBatch = PoseidonGame.spriteBatch;
            }

            laserBeamTexture = IngamePresentation.healLaserBeamTexture;

            Vector3 direction2D = graphicDevice.Viewport.Project(position + headingDirection, gameCamera.ProjectionMatrix, gameCamera.ViewMatrix, Matrix.Identity)
                - graphicDevice.Viewport.Project(position, gameCamera.ProjectionMatrix, gameCamera.ViewMatrix, Matrix.Identity);
            direction2D.Normalize();
            this.forwardDir = (float)Math.Atan2(direction2D.X, direction2D.Y);
        }
Beispiel #2
0
        public override void draw(Matrix view, Matrix projection, Camera gameCamera, string techniqueName)
        {
            Matrix[] transforms = new Matrix[Model.Bones.Count];
            Model.CopyAbsoluteBoneTransformsTo(transforms);
            Matrix translationMatrix = Matrix.CreateTranslation(Position);

            Matrix rotationMatrix = Matrix.CreateRotationY(forwardDir);
            Matrix worldMatrix = rotationMatrix * translationMatrix;

            foreach (ModelMesh mesh in Model.Meshes)
            {
                foreach (BasicEffect effect in mesh.Effects)
                //foreach (Effect effect in mesh.Effects)
                {
                    effect.World = worldMatrix * transforms[mesh.ParentBone.Index];
                    effect.DiffuseColor = Color.Gold.ToVector3();
                    //effect.AmbientLightColor = Color.Red.ToVector3();
                    //effect.SpecularColor = Color.White.ToVector3();
                    //effect.SpecularPower = 10.0f;
                    effect.View = view;
                    effect.Projection = projection;

                    //effect.Alpha = 0.2f;
                    effect.LightingEnabled = true;
                    //effect.EnableDefaultLighting();
                    effect.PreferPerPixelLighting = true;

                    effect.FogEnabled = true;
                    effect.FogStart = GameConstants.FogStart;
                    effect.FogEnd = GameConstants.FogEnd;
                    effect.FogColor = fogColor.ToVector3();

                    //for our custom BasicEffect
                    //effect.CurrentTechnique = effect.Techniques[techniqueName];
                    //Matrix readlWorldMatrix = worldMatrix * transforms[mesh.ParentBone.Index];
                    ////effect.CurrentTechnique = effect.Techniques[techniqueName];
                    //effect.Parameters["World"].SetValue(readlWorldMatrix);
                    //effect.Parameters["WorldInverseTranspose"].SetValue(Matrix.Invert(readlWorldMatrix));
                    //effect.Parameters["View"].SetValue(view);
                    //effect.Parameters["Projection"].SetValue(projection);
                    //effect.Parameters["EyePosition"].SetValue(new Vector4(gameCamera.AvatarHeadOffset, 0));
                    //Matrix WorldView = readlWorldMatrix * view;
                    //EffectHelpers.SetFogVector(ref WorldView, GameConstants.FogStart, GameConstants.FogEnd, effect.Parameters["FogVector"]);
                    //effect.Parameters["FogColor"].SetValue(fogColor.ToVector3());

                    //effect.Parameters["AmbientColor"].SetValue(ambientColor.ToVector4());
                    //effect.Parameters["DiffuseColor"].SetValue(diffuseColor.ToVector4());
                    //effect.Parameters["SpecularColor"].SetValue(specularColor.ToVector4());
                }
                mesh.Draw();
            }
        }
Beispiel #3
0
        public void Update(GraphicsDevice graphicDevice, Camera gameCamera, GameTime gameTime)
        {
            EffectHelpers.GetEffectConfiguration(ref fogColor, ref ambientColor, ref diffuseColor, ref specularColor);

            Vector3 screenPos = graphicDevice.Viewport.Project(bubble3DPos, gameCamera.ProjectionMatrix, gameCamera.ViewMatrix, Matrix.Identity);
            bubble2DPos.X = screenPos.X;
            bubble2DPos.Y = screenPos.Y;
            timeLast -= (float)gameTime.ElapsedGameTime.TotalMilliseconds;
            if (timeLast >= 0)
                scale = startingScale * (2000.0f / timeLast);
            scale = MathHelper.Clamp(scale, startingScale, startingScale * 5);
            camHeightScale = (float)GameConstants.StandardCamHeight / (float)gameCamera.camHeight;
        }
Beispiel #4
0
        public void Draw(Matrix view, Matrix projection, Camera gameCamera, string techniqueName)
        {
            //Update(); //since update is only changing orientation, it is better to put here than in playgamescene & survival scene
            Matrix[] transforms = new Matrix[Model.Bones.Count];
            Model.CopyAbsoluteBoneTransformsTo(transforms);
            Matrix translateMatrix = Matrix.CreateTranslation(Position);
            Matrix rotationYmatrix = Matrix.CreateRotationY(orientation);
            Matrix worldMatrix = rotationYmatrix * translateMatrix;

            foreach (ModelMesh mesh in Model.Meshes)
            {
                //foreach (BasicEffect effect in mesh.Effects)
                foreach (Effect effect in mesh.Effects)
                {
                    //effect.World =
                    //    worldMatrix * transforms[mesh.ParentBone.Index];
                    //effect.View = view;
                    //effect.Projection = projection;

                    //effect.EnableDefaultLighting();
                    //effect.PreferPerPixelLighting = true;
                    ////effect.EmissiveColor = Color.White.ToVector3();
                    //effect.FogEnabled = true;
                    //effect.FogStart = GameConstants.FogStart;
                    //effect.FogEnd = GameConstants.FogEnd;
                    //effect.FogColor = fogColor.ToVector3();

                    //effect.AmbientLightColor = ambientColor.ToVector3();
                    //effect.DiffuseColor = diffuseColor.ToVector3();
                    //effect.SpecularColor = specularColor.ToVector3();
                    effect.Parameters["FogEnabled"].SetValue(false);
                    effect.Parameters["AmbientColor"].SetValue(Color.White.ToVector4() * 0.6f); //(ambientColor.ToVector4());
                    effect.Parameters["DiffuseColor"].SetValue(Color.White.ToVector4() * 0.6f); //(diffuseColor.ToVector4());
                    effect.Parameters["SpecularColor"].SetValue(Color.White.ToVector4() * 0.6f);//specularColor.ToVector4());

                    effect.CurrentTechnique = effect.Techniques[techniqueName];
                    Matrix readlWorldMatrix = worldMatrix * transforms[mesh.ParentBone.Index];
                    effect.Parameters["World"].SetValue(readlWorldMatrix);
                    effect.Parameters["WorldInverseTranspose"].SetValue(Matrix.Invert(readlWorldMatrix));
                    effect.Parameters["View"].SetValue(view);
                    effect.Parameters["Projection"].SetValue(projection);
                    effect.Parameters["EyePosition"].SetValue(new Vector4(gameCamera.AvatarHeadOffset, 0));
                    Matrix WorldView = readlWorldMatrix * view;
                    EffectHelpers.SetFogVector(ref WorldView, GameConstants.FogStart, GameConstants.FogEnd, effect.Parameters["FogVector"]);
                    effect.Parameters["AmbientIntensity"].SetValue(1.0f);
                    effect.Parameters["DiffuseIntensity"].SetValue(0.2f);
                    effect.Parameters["Shininess"].SetValue(1.0f);
                }
                mesh.Draw();
            }
        }
Beispiel #5
0
        public void Draw(Matrix view, Matrix projection, Camera gameCamera, string techniqueName)
        {
            EffectHelpers.GetEffectConfiguration(ref fogColor, ref ambientColor, ref diffuseColor, ref specularColor);

            Matrix[] transforms = new Matrix[Model.Bones.Count];
            Model.CopyAbsoluteBoneTransformsTo(transforms);
            Matrix translateMatrix = Matrix.CreateTranslation(Position);
            Matrix rotationYMatrix = Matrix.CreateRotationY(orientation);
            Matrix worldMatrix = rotationYMatrix * translateMatrix;

            foreach (ModelMesh mesh in Model.Meshes)
            {
                //foreach (BasicEffect effect in mesh.Effects)
                foreach (Effect effect in mesh.Effects)
                {
                    //effect.World =
                    //    worldMatrix * transforms[mesh.ParentBone.Index];
                    //effect.View = view;
                    //effect.Projection = projection;

                    //effect.EnableDefaultLighting();
                    //effect.PreferPerPixelLighting = true;

                    //effect.FogEnabled = true;
                    //effect.FogStart = GameConstants.FogStart;
                    //effect.FogEnd = GameConstants.FogEnd;
                    //effect.FogColor = GameConstants.FogColor.ToVector3();

                    //for our custom BasicEffect
                    effect.Parameters["AmbientColor"].SetValue(ambientColor.ToVector4());
                    effect.Parameters["DiffuseColor"].SetValue(diffuseColor.ToVector4());
                    effect.Parameters["SpecularColor"].SetValue(specularColor.ToVector4());

                    effect.CurrentTechnique = effect.Techniques[techniqueName];
                    Matrix readlWorldMatrix = worldMatrix * transforms[mesh.ParentBone.Index];
                    effect.Parameters["World"].SetValue(readlWorldMatrix);
                    effect.Parameters["WorldInverseTranspose"].SetValue(Matrix.Invert(readlWorldMatrix));
                    effect.Parameters["View"].SetValue(view);
                    effect.Parameters["Projection"].SetValue(projection);
                    effect.Parameters["EyePosition"].SetValue(new Vector4(gameCamera.AvatarHeadOffset, 0));
                    Matrix WorldView = readlWorldMatrix * view;
                    EffectHelpers.SetFogVector(ref WorldView, GameConstants.FogStart, GameConstants.FogEnd, effect.Parameters["FogVector"]);
                    effect.Parameters["FogColor"].SetValue(fogColor.ToVector3());
                    effect.Parameters["AmbientIntensity"].SetValue(1.0f);
                    effect.Parameters["DiffuseIntensity"].SetValue(0.2f);
                }
                mesh.Draw();
            }
        }
Beispiel #6
0
 public FlyingHammer(GameMode gameMode)
     : base()
 {
     this.timeShot = PoseidonGame.playTime.TotalSeconds;
     this.gameMode = gameMode;
     if (gameMode == GameMode.MainGame)
     {
         gameCamera = PlayGameScene.gameCamera;
     }
     else if (gameMode == GameMode.ShipWreck)
     {
         gameCamera = ShipWreckScene.gameCamera;
     }
     else if (gameMode == GameMode.SurvivalMode)
     {
         gameCamera = SurvivalGameScene.gameCamera;
     }
 }
Beispiel #7
0
 public HerculesBullet(ContentManager content, SpriteBatch spriteBatch, GameMode gameMode, float forwardDir, bool piercingArrow)
     : base()
 {
     //energyBallTexture = content.Load<Texture2D>("Image/Miscellaneous/energyBall-red");
     //this.spriteBatch = spriteBatch;
     this.forwardDir = forwardDir;
     this.gameMode = gameMode;
     if (gameMode == GameMode.MainGame)
     {
         gameCamera = PlayGameScene.gameCamera;
     }
     else if (gameMode == GameMode.ShipWreck)
     {
         gameCamera = ShipWreckScene.gameCamera;
     }
     else if (gameMode == GameMode.SurvivalMode)
     {
         gameCamera = SurvivalGameScene.gameCamera;
     }
     this.piercingArrow = piercingArrow;
     hitEnemies = new List<BaseEnemy>();
 }
Beispiel #8
0
 public static BaseEnemy MouseOnWhichEnemy(Cursor cursor, Camera gameCamera, BaseEnemy[] enemies, int enemiesAmount)
 {
     if (enemies == null) return null;
     Ray cursorRay = cursor.CalculateCursorRay(gameCamera.ProjectionMatrix, gameCamera.ViewMatrix);
     BoundingSphere sphere;
     for (int i = 0; i < enemiesAmount; i++)
     {
         //making it easier to aim
         sphere = enemies[i].BoundingSphere;
         sphere.Radius *= GameConstants.EasyAimScale;
         if (RayIntersectsBoundingSphere(cursorRay, sphere))
         {
             //cursor.SetShootingMouseImage();
             return enemies[i];
         }
     }
     //cursor.SetNormalMouseImage();
     return null;
 }
Beispiel #9
0
 public static TreasureChest MouseOnWhichChest(Cursor cursor, Camera gameCamera, List<TreasureChest> treasureChests)
 {
     if (treasureChests == null) return null;
     BoundingSphere treasureChestRealSphere;
     Ray cursorRay = cursor.CalculateCursorRay(gameCamera.ProjectionMatrix, gameCamera.ViewMatrix);
     foreach (TreasureChest treasureChest in treasureChests)
     {
         treasureChestRealSphere = treasureChest.BoundingSphere;
         treasureChestRealSphere.Center.Y = treasureChest.Position.Y;
         treasureChestRealSphere.Radius *= 1;
         if (RayIntersectsBoundingSphere(cursorRay, treasureChestRealSphere))
         {
             return treasureChest;
         }
     }
     return null;
 }
Beispiel #10
0
 public static bool MouseOnResearchFacility(Cursor cursor, Camera gameCamera, ResearchFacility researchFacility)
 {
     if (researchFacility == null) return false;
     BoundingSphere researchFacilityRealSphere;
     Ray cursorRay = cursor.CalculateCursorRay(gameCamera.ProjectionMatrix, gameCamera.ViewMatrix);
     researchFacilityRealSphere = researchFacility.BoundingSphere;
     researchFacilityRealSphere.Center.Y = researchFacility.Position.Y;
     researchFacilityRealSphere.Radius *= 1;
     if (RayIntersectsBoundingSphere(cursorRay, researchFacilityRealSphere))
     {
         return true;
     }
     else return false;
 }
Beispiel #11
0
        public override void Draw(Matrix view, Matrix projection, Camera gameCamera, string techniqueName)
        {
            if (clipPlayer == null)
            {
                // just return for now.. Some of the fishes do not have animation, so clipPlayer won't be initialized for them
                base.Draw(view, projection);
                return;
            }

            bones = clipPlayer.GetSkinTransforms();

            foreach (ModelMesh mesh in Model.Meshes)
            {
                //foreach (SkinnedEffect effect in mesh.Effects)
                foreach (Effect effect in mesh.Effects)
                {

                    //effect.SetBoneTransforms(bones);
                    //effect.View = view;
                    //effect.Projection = projection;
                    //if (isHypnotise)
                    //{
                    //    effect.DiffuseColor = Color.Red.ToVector3();
                    //}
                    //else
                    //    effect.DiffuseColor = Color.White.ToVector3();
                    effect.Parameters["AmbientColor"].SetValue(ambientColor.ToVector4());
                    effect.Parameters["DiffuseColor"].SetValue(diffuseColor.ToVector4());
                    effect.Parameters["SpecularColor"].SetValue(specularColor.ToVector4());
                    if (HydroBot.gameMode == GameMode.ShipWreck)
                    {
                        effect.Parameters["DiffuseIntensity"].SetValue(0.65f);
                        effect.Parameters["AmbientIntensity"].SetValue(0.65f);
                    }
                    else effect.Parameters["DiffuseIntensity"].SetValue(1.0f);

                    if (isHypnotise == true)
                    {
                        effect.Parameters["DiffuseColor"].SetValue(new Vector4(Color.Red.ToVector3(), 1));
                        //because somehow the red color is very hard to see
                        effect.Parameters["DiffuseIntensity"].SetValue(3.0f);
                    }
                    else
                    {
                        effect.Parameters["DiffuseColor"].SetValue(new Vector4(Vector3.One, 1));
                    }
                    //being freezed by turtle's frozen breath
                    if (speedFactor < 1.0f)
                    {
                        effect.Parameters["DiffuseColor"].SetValue(new Vector4(Color.Blue.ToVector3(), 1));
                    }

                    //effect.FogEnabled = true;
                    //effect.FogStart = GameConstants.FogStart;
                    //effect.FogEnd = GameConstants.FogEnd;
                    //effect.FogColor = GameConstants.FogColor.ToVector3();

                    //for our custom SkinnedEffect
                    effect.CurrentTechnique = effect.Techniques[techniqueName];
                    effect.Parameters["World"].SetValue(Matrix.Identity);

                    effect.Parameters["Bones"].SetValue(bones);
                    effect.Parameters["WorldInverseTranspose"].SetValue(Matrix.Invert(Matrix.Identity));
                    effect.Parameters["View"].SetValue(view);
                    effect.Parameters["Projection"].SetValue(projection);
                    effect.Parameters["EyePosition"].SetValue(new Vector4(gameCamera.AvatarHeadOffset, 0));
                    Matrix WorldView = Matrix.Identity * view;
                    EffectHelpers.SetFogVector(ref WorldView, GameConstants.FogStart, GameConstants.FogEnd, effect.Parameters["FogVector"]);
                    effect.Parameters["FogColor"].SetValue(fogColor.ToVector3());

                }
                mesh.Draw();
            }
            //Matrix[] transforms = new Matrix[Model.Bones.Count];
            //Model.CopyAbsoluteBoneTransformsTo(transforms);
            ////Matrix translateMatrix = Matrix.CreateTranslation(Position);
            ////Matrix worldMatrix = translateMatrix;
            //Matrix worldMatrix = Matrix.Identity;
            //Matrix rotationYMatrix = Matrix.CreateRotationY(ForwardDirection);
            //Matrix translateMatrix = Matrix.CreateTranslation(Position);
            //worldMatrix = rotationYMatrix * translateMatrix;

            //foreach (ModelMesh mesh in Model.Meshes)
            //{
            //    foreach (BasicEffect effect in mesh.Effects)
            //    {
            //        effect.World =
            //            worldMatrix * transforms[mesh.ParentBone.Index];
            //        effect.View = view;
            //        effect.Projection = projection;
            //        if (isHypnotise)
            //        {
            //            effect.DiffuseColor = Color.Black.ToVector3();
            //        }
            //        else
            //            effect.DiffuseColor = Color.White.ToVector3();

            //        effect.EnableDefaultLighting();
            //        effect.PreferPerPixelLighting = true;

            //        effect.FogEnabled = true;
            //        effect.FogStart = GameConstants.FogStart;
            //        effect.FogEnd = GameConstants.FogEnd;
            //        effect.FogColor = GameConstants.FogColor.ToVector3();
            //    }
            //    mesh.Draw();
            //}
        }
Beispiel #12
0
        // End----------------------------------------------------------
        /// <summary>
        /// PROJECTILES FUNCTION
        /// </summary>
        /* scene --> 1-playgamescene, 2-shipwreckscene */
        /* switch to use GameMode instead, look at the beginning of PoseidonGame for more details */
        public static void updateDamageBulletVsBarriersCollision(List<DamageBullet> bullets, SwimmingObject[] barriers, ref int size, BoundingFrustum cameraFrustum, GameMode gameMode, GameTime gameTime, HydroBot hydroBot, BaseEnemy[] enemies, int enemiesAmount, Fish[] fishes, int fishAmount, Camera gameCamera, ParticleSystem explosionParticles)
        {
            BoundingSphere sphere;
            for (int i = 0; i < bullets.Count; i++) {
                //special handling for the skill combo FlyingHammer
                if (bullets[i] is FlyingHammer)
                {
                    if (PoseidonGame.playTime.TotalSeconds - ((FlyingHammer)bullets[i]).timeShot > 1.25)
                    {
                        ((FlyingHammer)bullets[i]).explodeNow = true;
                        PoseidonGame.audio.Explo1.Play();
                        gameCamera.Shake(25f, .4f);
                        CastSkill.UseThorHammer(bullets[i].Position, hydroBot.MaxRangeX, hydroBot.MaxRangeZ, enemies, ref enemiesAmount, fishes, fishAmount, HydroBot.gameMode, false);
                    }
                }
                if (bullets[i] is FlyingHammer)
                {
                    if (((FlyingHammer)bullets[i]).explodeNow)
                    {
                        bullets.RemoveAt(i--);
                        continue;
                    }
                }
                for (int j = 0; j < size; j++) {
                    sphere = barriers[j].BoundingSphere;
                    sphere.Radius *= GameConstants.EasyHitScale;
                    //because Mutant Shark's easy hit sphere is too large
                    if (barriers[j] is MutantShark) sphere.Radius *= 0.7f;

                    if (bullets[i].BoundingSphere.Intersects(sphere))
                    {
                        if (barriers[j] is Fish && barriers[j].BoundingSphere.Intersects(cameraFrustum))
                        {
                            PoseidonGame.audio.animalYell.Play();
                        }
                        if (barriers[j] is BaseEnemy)
                        {
                            //if (((BaseEnemy)barriers[j]).isHypnotise)
                            if (bullets[i].shooter == barriers[j])
                            {
                                continue;
                            }
                            else {
                                if (bullets[i].shooter == null && !((BaseEnemy)barriers[j]).isHypnotise)
                                {
                                    ((BaseEnemy)barriers[j]).justBeingShot = true;
                                    ((BaseEnemy)barriers[j]).startChasingTime = PoseidonGame.playTime;
                                }
                            }
                            //special handling for the skill combo FlyingHammer
                            if (bullets[i] is FlyingHammer)
                            {
                                PoseidonGame.audio.bodyHit.Play();
                                Vector3 oldPosition = barriers[j].Position;
                                Vector3 pushVector = barriers[j].Position - bullets[i].Position;
                                pushVector.Normalize();
                                ((BaseEnemy)barriers[j]).stunned = true;
                                ((BaseEnemy)barriers[j]).stunnedStartTime = PoseidonGame.playTime.TotalSeconds;
                                ((BaseEnemy)barriers[j]).Position += (pushVector * GameConstants.ThorPushFactor);
                                barriers[j].Position.X = MathHelper.Clamp(barriers[j].Position.X, -hydroBot.MaxRangeX, hydroBot.MaxRangeX);
                                barriers[j].Position.Z = MathHelper.Clamp(barriers[j].Position.Z, -hydroBot.MaxRangeZ, hydroBot.MaxRangeZ);
                                barriers[j].BoundingSphere.Center = barriers[j].Position;
                                if (Collision.isBarrierVsBarrierCollision(barriers[j], barriers[j].BoundingSphere, fishes, fishAmount)
                                    || Collision.isBarrierVsBarrierCollision(barriers[j], barriers[j].BoundingSphere, enemies, enemiesAmount))
                                {
                                    barriers[j].Position = oldPosition;
                                    barriers[j].BoundingSphere.Center = oldPosition;
                                }
                            }
                        }
                        // add particle effect when certain kind of bullet hits
                        if (bullets[i] is Torpedo || bullets[i] is ChasingBullet)
                        {
                            if (explosionParticles != null)
                            {
                                for (int k = 0; k < GameConstants.numExplosionParticles; k++)
                                    explosionParticles.AddParticle(bullets[i].Position, Vector3.Zero);
                            }
                            PoseidonGame.audio.explosionSmall.Play();
                        }

                        //whether or not to reduce health of the hit object
                        bool reduceHealth = true;
                        if (bullets[i] is HerculesBullet)
                        {
                            if (!((HerculesBullet)bullets[i]).piercingArrow)
                                reduceHealth = true;
                            else
                            {
                                bool enemyHitBefore = false;
                                foreach (BaseEnemy hitEnemy in ((HerculesBullet)bullets[i]).hitEnemies)
                                {
                                    if (hitEnemy == (BaseEnemy)barriers[j])
                                        enemyHitBefore = true;
                                }
                                if (!enemyHitBefore)
                                {
                                    reduceHealth = true;
                                    ((HerculesBullet)bullets[i]).hitEnemies.Add((BaseEnemy)barriers[j]);
                                }
                                else reduceHealth = false;
                            }
                        }
                        else reduceHealth = true;

                        if (reduceHealth)
                        {
                            barriers[j].health -= bullets[i].damage;

                            if (barriers[j].BoundingSphere.Intersects(cameraFrustum))
                            {
                                Point point = new Point();
                                String point_string = "-" + bullets[i].damage.ToString() + "HP";
                                point.LoadContent(PoseidonGame.contentManager, point_string, barriers[j].Position, Color.DarkRed);
                                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);
                            }
                        }

                        //remove the bullet that hits something
                        if (bullets[i] is FlyingHammer)
                        {
                            //if (((FlyingHammer)bullets[i]).explodeNow) bullets.RemoveAt(i--);
                        }
                        //special handling for the skill combo Piercing arrow
                        //pierce through enemies
                        else if (bullets[i] is HerculesBullet)
                        {
                            if (!((HerculesBullet)bullets[i]).piercingArrow)
                                bullets.RemoveAt(i--);
                        }
                        else bullets.RemoveAt(i--);
                        break;
                    }
                }
            }
        }
Beispiel #13
0
 public static ShipWreck MouseOnWhichShipWreck(Cursor cursor, Camera gameCamera, List<ShipWreck> shipWrecks)
 {
     if (shipWrecks == null) return null;
     BoundingSphere shipRealSphere;
     Ray cursorRay = cursor.CalculateCursorRay(gameCamera.ProjectionMatrix, gameCamera.ViewMatrix);
     foreach (ShipWreck shipWreck in shipWrecks)
     {
         shipRealSphere = shipWreck.BoundingSphere;
         shipRealSphere.Center.Y = shipWreck.Position.Y;
         shipRealSphere.Radius *= 1;
         if (RayIntersectsBoundingSphere(cursorRay, shipRealSphere))
         {
             return shipWreck;
         }
     }
     //cursor.SetNormalMouseImage();
     return null;
 }
Beispiel #14
0
 public static void MouseOnWhichPowerPack(Cursor cursor, Camera gameCamera, List<Powerpack> powerPacks, ref Powerpack cursorOnPowerPack, ref Powerpack botOnPowerPack, HydroBot hydroBot)
 {
     bool foundBotOnPowerpack = false, foundCursorOnPowerpack = false;
     if (hydroBot == null) foundBotOnPowerpack = true;
     if (cursor == null) foundCursorOnPowerpack = true;
     BoundingSphere botPowerPackBoundingSphere = new BoundingSphere();
     if (!foundBotOnPowerpack)
         botPowerPackBoundingSphere = new BoundingSphere(hydroBot.BoundingSphere.Center, 5);
     if (powerPacks == null) return;
     Ray cursorRay = new Ray();
     if (cursor != null)
         cursorRay = cursor.CalculateCursorRay(gameCamera.ProjectionMatrix, gameCamera.ViewMatrix);
     foreach (Powerpack powerPack in powerPacks)
     {
         if (!foundBotOnPowerpack)
         {
             if (powerPack.BoundingSphere.Intersects(botPowerPackBoundingSphere))
             {
                 foundBotOnPowerpack = true;
                 botOnPowerPack = powerPack;
             }
         }
         if (!foundCursorOnPowerpack)
         {
             if (RayIntersectsBoundingSphere(cursorRay, powerPack.BoundingSphere))
             {
                 foundCursorOnPowerpack = true;
                 cursorOnPowerPack = powerPack;
             }
         }
         if (foundBotOnPowerpack && foundCursorOnPowerpack) return;
     }
 }
Beispiel #15
0
 public static bool InShootingRange(HydroBot hydroBot, Cursor cursor, Camera gameCamera, float planeHeight)
 {
     Vector3 pointIntersect = IntersectPointWithPlane(cursor, gameCamera, planeHeight);
     Vector3 mouseDif = pointIntersect - hydroBot.Position;
     float distanceFromTank = mouseDif.Length();
     if (distanceFromTank < GameConstants.BotShootingRange)
         return true;
     else
         return false;
 }
Beispiel #16
0
        public override void Draw(Matrix view, Matrix projection, Camera gameCamera, string techniqueName)
        {
            if (clipPlayer == null)
            {
                // just return for now. Some of the fishes do not have animation, so clipPlayer won't be initialized for them
                base.Draw(view, projection);
                return;
            }

            bones = clipPlayer.GetSkinTransforms();

            foreach (ModelMesh mesh in Model.Meshes)
            {
                //foreach (SkinnedEffect effect in mesh.Effects)
                foreach (Effect effect in mesh.Effects)
                {
                    //for standard Skinned Effect
                    //effect.SetBoneTransforms(bones);
                    //effect.View = view;
                    //effect.Projection = projection;

                    //if (isPoissoned) {
                    //    effect.DiffuseColor = Color.Green.ToVector3();
                    //}
                    //else {
                    //    effect.DiffuseColor = Color.White.ToVector3();
                    //}

                    //effect.FogEnabled = true;
                    //effect.FogStart = GameConstants.FogStart;
                    //effect.FogEnd = GameConstants.FogEnd;
                    //effect.FogColor = GameConstants.FogColor.ToVector3();

                    //for our custom SkinnedEffect
                    effect.CurrentTechnique = effect.Techniques[techniqueName];
                    effect.Parameters["World"].SetValue(Matrix.Identity);

                    effect.Parameters["Bones"].SetValue(bones);
                    effect.Parameters["WorldInverseTranspose"].SetValue(Matrix.Invert(Matrix.Identity));
                    effect.Parameters["View"].SetValue(view);
                    effect.Parameters["Projection"].SetValue(projection);
                    effect.Parameters["EyePosition"].SetValue(new Vector4(gameCamera.AvatarHeadOffset, 0));
                    Matrix WorldView = Matrix.Identity * view;
                    effect.Parameters["AmbientColor"].SetValue(ambientColor.ToVector4());
                    effect.Parameters["DiffuseColor"].SetValue(diffuseColor.ToVector4());
                    effect.Parameters["SpecularColor"].SetValue(specularColor.ToVector4());
                    if (isPoissoned == true)
                    {
                        effect.Parameters["DiffuseColor"].SetValue(new Vector4(Color.Green.ToVector3(), 1));
                    }
                    else
                    {
                        effect.Parameters["DiffuseColor"].SetValue(new Vector4(Vector3.One, 1));
                    }
                    EffectHelpers.SetFogVector(ref WorldView, GameConstants.FogStart, GameConstants.FogEnd, effect.Parameters["FogVector"]);
                    effect.Parameters["FogColor"].SetValue(fogColor.ToVector3());
                    effect.Parameters["DiffuseIntensity"].SetValue(0.5f);
                }
                mesh.Draw();
                if (isBigBoss == true)
                {
                    foreach (Effect effect in mesh.Effects)
                    {
                        effect.CurrentTechnique = effect.Techniques["BalloonShading"];
                        effect.Parameters["gWorldXf"].SetValue(Matrix.Identity);
                        effect.Parameters["gWorldITXf"].SetValue(Matrix.Invert(Matrix.Identity));
                        effect.Parameters["Bones"].SetValue(bones);
                        effect.Parameters["gWvpXf"].SetValue(Matrix.Identity * view * projection);
                        effect.Parameters["gViewIXf"].SetValue(Matrix.Invert(view));
                        effect.Parameters["gInflate"].SetValue(0.065f);
                        effect.Parameters["gGlowColor"].SetValue(new Vector3(0, 255, 0));
                        //effect.Parameters["gGlowExpon"].SetValue(1.5f);
                    }
                }
                mesh.Draw();
            }
        }
Beispiel #17
0
        public SurvivalGameScene(Game game, GraphicsDeviceManager graphic, ContentManager content, GraphicsDevice GraphicsDevice, SpriteBatch spriteBatch, Vector2 pausePosition, Rectangle pauseRect, Texture2D actionTexture, CutSceneDialog cutSceneDialog, Radar radar, Texture2D stunnedTexture)
            : base(game)
        {
            graphics = graphic;
            Content = content;
            GraphicDevice = GraphicsDevice;
            this.spriteBatch = spriteBatch;
            this.pausePosition = pausePosition;
            this.pauseRect = pauseRect;
            this.actionTexture = actionTexture;
            this.game = game;
            this.radar = radar;
            this.stunnedIconTexture = stunnedTexture;
            roundTime = TimeSpan.FromSeconds(2592000);
            random = new Random();

            gameCamera = new Camera(GameMode.SurvivalMode);
            boundingSphere = new GameObject();
            hydroBot = new HydroBot(GameConstants.MainGameMaxRangeX, GameConstants.MainGameMaxRangeZ, GameConstants.MainGameFloatHeight, GameMode.SurvivalMode);

            if (File.Exists("SurvivalMode"))
            {
                ObjectsToSerialize objectsToSerialize = new ObjectsToSerialize();
                Serializer serializer = new Serializer();
                string SavedFile = "SurvivalMode";
                objectsToSerialize = serializer.DeSerializeObjects(SavedFile);
                hydroBot = objectsToSerialize.hydrobot;
            }

            //stop spinning the bar
            IngamePresentation.StopSpinning();

            HydroBot.gamePlusLevel = 0;
            HydroBot.gameMode = GameMode.SurvivalMode;
            for (int index = 0; index < GameConstants.numberOfSkills; index++)
            {
                HydroBot.skills[index] = true;
            }

            skillTextures = new Texture2D[GameConstants.numberOfSkills];
            bulletTypeTextures = new Texture2D[GameConstants.numBulletTypes];

            // for the mouse or touch
            cursor = new Cursor(game, spriteBatch);
            //Components.Add(cursor);

            bubbles = new List<Bubble>();
            points = new List<Point>();

            //loading winning, losing textures
            winningTexture = IngamePresentation.winningTexture;
            losingTexture = IngamePresentation.losingTexture;
            scaredIconTexture = IngamePresentation.scaredIconTexture;

            isAncientKilled = false;

            // Instantiate the factory Button
            float buttonScale = 1.0f;
            if (game.Window.ClientBounds.Width <= 900)
            {
                buttonScale = 0.8f; // scale the factory panel icons a bit smaller in small window mode
            }
            factoryButtonPanel = new ButtonPanel(4, buttonScale);

            this.Load();

            gameBoundary = new GameBoundary();
            gameBoundary.LoadGraphicsContent(GraphicDevice);
        }
Beispiel #18
0
 /// <summary>
 /// Handles input for Windows.
 /// </summary>
 private void UpdateWindowsInput(GraphicsDevice graphicDevice, Camera gameCamera, BoundingFrustum frustum)
 {
     if (targetToLock == null)
     {
         MouseState mouseState = Mouse.GetState();
         position.X = mouseState.X;
         position.Y = mouseState.Y;
     }
     else
     {
         Vector3 screenPos = graphicDevice.Viewport.Project(targetToLock.Position, gameCamera.ProjectionMatrix,
             gameCamera.ViewMatrix, Matrix.Identity);
         position.X = screenPos.X;
         position.Y = screenPos.Y;
         //release lock if enemy is out of camera frustum
         if (!targetToLock.BoundingSphere.Intersects(frustum)) targetToLock = null;
     }
 }
Beispiel #19
0
 public void Update(GraphicsDevice graphicDevice, Camera gameCamera, GameTime gameTime, BoundingFrustum frustum)
 {
     // We use different input on each platform:
     // On Xbox, we use the GamePad's DPad and left thumbstick to move the cursor around the screen.
     // On Windows, we directly map the cursor to the location of the mouse.
     // On Windows Phone, we use the primary touch point for the location of the cursor.
     #if XBOX
     UpdateXboxInput(gameTime);
     #elif WINDOWS
     UpdateWindowsInput(graphicDevice, gameCamera, frustum);
     #elif WINDOWS_PHONE
     UpdateWindowsPhoneInput();
     #endif
 }
Beispiel #20
0
 public static Factory MouseOnWhichFactory(Cursor cursor, Camera gameCamera, List<Factory> factories)
 {
     if (factories == null) return null;
     BoundingSphere factoryRealSphere;
     Ray cursorRay = cursor.CalculateCursorRay(gameCamera.ProjectionMatrix, gameCamera.ViewMatrix);
     foreach (Factory factory in factories)
     {
         factoryRealSphere = factory.BoundingSphere;
         factoryRealSphere.Center.Y = factory.Position.Y;
         factoryRealSphere.Radius *= 1;
         if (RayIntersectsBoundingSphere(cursorRay, factoryRealSphere))
         {
             return factory;
         }
     }
     return null;
 }
Beispiel #21
0
 public static Fish MouseOnWhichFish(Cursor cursor, Camera gameCamera, Fish[] fish, int fishAmount)
 {
     if (fish == null) return null;
     BoundingSphere sphere;
     Ray cursorRay = cursor.CalculateCursorRay(gameCamera.ProjectionMatrix, gameCamera.ViewMatrix);
     for (int i = 0; i < fishAmount; i++)
     {
         sphere = fish[i].BoundingSphere;
         sphere.Radius *= GameConstants.EasyAimScale;
         if (RayIntersectsBoundingSphere(cursorRay, sphere))
         {
             return fish[i];
         }
     }
     //cursor.SetNormalMouseImage();
     return null;
 }
Beispiel #22
0
 public static Vector3 IntersectPointWithPlane(Cursor cursor, Camera gameCamera, float planeHeight)
 {
     Ray cursorRay = cursor.CalculateCursorRay(gameCamera.ProjectionMatrix, gameCamera.ViewMatrix);
     float t = (planeHeight - cursorRay.Position.Y) / cursorRay.Direction.Y;
     float x = cursorRay.Position.X + cursorRay.Direction.X * t;
     float z = cursorRay.Position.Z + cursorRay.Direction.Z * t;
     return new Vector3(x, planeHeight, z);
 }
Beispiel #23
0
 public static void MouseOnWhichResource(Cursor cursor, Camera gameCamera, List<Resource> resources, ref Resource cursorOnResource, ref Resource botOnResource, HydroBot hydroBot)
 {
     bool foundBotOnResource = false, foundCursorOnResource = false;
     if (hydroBot == null) foundBotOnResource = true;
     if (cursor == null) foundCursorOnResource = true;
     BoundingSphere botPowerPackBoundingSphere = new BoundingSphere();
     if (!foundBotOnResource)
         botPowerPackBoundingSphere = new BoundingSphere(hydroBot.BoundingSphere.Center, 5);
     if (resources == null) return;
     Ray cursorRay = new Ray();
     if (cursor != null)
         cursorRay = cursor.CalculateCursorRay(gameCamera.ProjectionMatrix, gameCamera.ViewMatrix);
     foreach (Resource resource in resources)
     {
         if (!foundBotOnResource)
         {
             if (resource.BoundingSphere.Intersects(botPowerPackBoundingSphere))
             {
                 foundBotOnResource = true;
                 botOnResource = resource;
             }
         }
         if (!foundCursorOnResource)
         {
             if (RayIntersectsBoundingSphere(cursorRay, resource.BoundingSphere))
             {
                 foundCursorOnResource = true;
                 cursorOnResource = resource;
             }
         }
         if (foundBotOnResource && foundCursorOnResource) return;
     }
 }
Beispiel #24
0
        public static void updateProjectileHitBot(HydroBot hydroBot, List<DamageBullet> enemyBullets, GameMode gameMode, BaseEnemy[] enemies, int enemiesAmount, ParticleSystem explosionParticles, Camera gameCamera, Fish[] fishes, int fishAmount)
        {
            for (int i = 0; i < enemyBullets.Count; ) {
                if (enemyBullets[i].BoundingSphere.Intersects(hydroBot.BoundingSphere)) {
                    if (!HydroBot.invincibleMode)
                    {
                        HydroBot.currentHitPoint -= enemyBullets[i].damage;
                        if (gameMode == GameMode.MainGame || gameMode == GameMode.ShipWreck)
                            PlayGameScene.healthLost += enemyBullets[i].damage;

                        PoseidonGame.audio.botYell.Play();

                        Point point = new Point();
                        String point_string = "-" + enemyBullets[i].damage.ToString() + "HP";
                        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);
                    }
                    //when auto hipnotize mode is on
                    //whoever hits the bot will be hipnotized
                    if (HydroBot.autoHipnotizeMode)
                    {
                        if (enemyBullets[i].shooter != null && !enemyBullets[i].shooter.isHypnotise)
                            CastSkill.useHypnotise(enemyBullets[i].shooter);
                    }
                    if (HydroBot.autoExplodeMode)
                    {
                        PoseidonGame.audio.Explo1.Play();
                        gameCamera.Shake(12.5f, .2f);
                        CastSkill.UseThorHammer(hydroBot.Position, hydroBot.MaxRangeX, hydroBot.MaxRangeZ, enemies, ref enemiesAmount, fishes, fishAmount, HydroBot.gameMode, true);
                    }

                    // add particle effect when certain kind of bullet hits
                    if (enemyBullets[i] is Torpedo || enemyBullets[i] is ChasingBullet)
                    {
                        if (explosionParticles != null)
                        {
                            for (int k = 0; k < GameConstants.numExplosionParticles; k++)
                                explosionParticles.AddParticle(enemyBullets[i].Position, Vector3.Zero);
                        }
                        PoseidonGame.audio.explosionSmall.Play();
                    }

                    enemyBullets.RemoveAt(i);

                }
                else { i++;  }
            }
        }
Beispiel #25
0
 public static void MouseOnWhichTrash(Cursor cursor, Camera gameCamera, List<Trash> trashes,ref Trash cursorOnTrash,ref Trash botOnTrash, HydroBot hydroBot)
 {
     bool foundBotOnTrash = false, foundCursorOnTrash = false;
     if (hydroBot == null) foundBotOnTrash = true;
     BoundingSphere botTrashBoundingSphere = new BoundingSphere();
     if (!foundBotOnTrash)
         botTrashBoundingSphere = new BoundingSphere(hydroBot.BoundingSphere.Center, 20);
     if (trashes == null) return;
     BoundingSphere trashRealSphere;
     Ray cursorRay = new Ray();
     if (cursor != null)
         cursorRay = cursor.CalculateCursorRay(gameCamera.ProjectionMatrix, gameCamera.ViewMatrix);
     foreach (Trash trash in trashes)
     {
         trashRealSphere = trash.BoundingSphere;
         trashRealSphere.Center.Y = trash.Position.Y;
         trashRealSphere.Radius *= 5;
         if (!foundBotOnTrash)
         {
             if (trash.BoundingSphere.Intersects(botTrashBoundingSphere))
             {
                 foundBotOnTrash = true;
                 botOnTrash = trash;
             }
         }
         if (!foundCursorOnTrash)
         {
             if (RayIntersectsBoundingSphere(cursorRay, trashRealSphere))
             {
                 foundCursorOnTrash = true;
                 cursorOnTrash = trash;
             }
         }
         if (foundBotOnTrash && foundCursorOnTrash) return;
     }
 }
Beispiel #26
0
 public static bool MouseOnObject(Cursor cursor, BoundingSphere boundingSphere, Vector3 center, Camera gameCamera)
 {
     Ray cursorRay = cursor.CalculateCursorRay(gameCamera.ProjectionMatrix, gameCamera.ViewMatrix);
     BoundingSphere boundingSphiro;
     boundingSphiro = boundingSphere;
     boundingSphiro.Center = center;
     if (CursorManager.RayIntersectsBoundingSphere(cursorRay, boundingSphiro))
         return true;
     return false;
 }
Beispiel #27
0
 public static bool MouseOnEnemy(Cursor cursor, Camera gameCamera, BaseEnemy[] enemies, int enemiesAmount)
 {
     Ray cursorRay = cursor.CalculateCursorRay(gameCamera.ProjectionMatrix, gameCamera.ViewMatrix);
     BoundingSphere sphere;
     for (int i = 0; i < enemiesAmount; i++)
     {
         //making it easier to aim
         sphere = enemies[i].BoundingSphere;
         //boss is already big
         if (!enemies[i].isBigBoss)
             sphere.Radius *= GameConstants.EasyAimScale;
         if (RayIntersectsBoundingSphere(cursorRay, sphere))
         {
             cursor.SetShootingMouseImage();
             return true;
         }
     }
     cursor.SetNormalMouseImage();
     return false;
 }
Beispiel #28
0
        public void Draw(Matrix view, Matrix projection, Camera gameCamera, string techniqueName)
        {
            Matrix[] transforms = new Matrix[Model.Bones.Count];
            Model.CopyAbsoluteBoneTransformsTo(transforms);
            Matrix translateMatrix = Matrix.CreateTranslation(Position);
            Matrix rotationYMatrix = Matrix.CreateRotationY(orientation);
            Matrix worldMatrix = rotationYMatrix * translateMatrix;

            foreach (ModelMesh mesh in Model.Meshes)
            {
                int effectId = 0;
                //foreach (BasicEffect effect in mesh.Effects)
                foreach (Effect effect in mesh.Effects)
                {
                    //effect.World =
                    //    worldMatrix * transforms[mesh.ParentBone.Index];
                    //effect.View = view;
                    //effect.Projection = projection;

                    //effect.EnableDefaultLighting();
                    //effect.PreferPerPixelLighting = true;

                    ////effect.DiffuseColor = Color.Green.ToVector3();

                    //effect.FogEnabled = true;
                    //effect.FogStart = GameConstants.FogStart;
                    //effect.FogEnd =  GameConstants.FogEnd;
                    //effect.FogColor = GameConstants.FogColor.ToVector3();

                    //for our custom BasicEffect
                    effect.Parameters["AmbientColor"].SetValue(ambientColor.ToVector4());
                    effect.Parameters["DiffuseColor"].SetValue(diffuseColor.ToVector4());
                    effect.Parameters["SpecularColor"].SetValue(specularColor.ToVector4());
                    Matrix readlWorldMatrix = worldMatrix * transforms[mesh.ParentBone.Index];
                    effect.CurrentTechnique = effect.Techniques[techniqueName];
                    effect.Parameters["World"].SetValue(readlWorldMatrix);
                    effect.Parameters["WorldInverseTranspose"].SetValue(Matrix.Invert(readlWorldMatrix));
                    effect.Parameters["View"].SetValue(view);
                    effect.Parameters["Projection"].SetValue(projection);
                    effect.Parameters["EyePosition"].SetValue(new Vector4(gameCamera.AvatarHeadOffset, 0));
                    Matrix WorldView = readlWorldMatrix * view;
                    EffectHelpers.SetFogVector(ref WorldView, GameConstants.FogStart, GameConstants.FogEnd, effect.Parameters["FogVector"]);
                    effect.Parameters["FogColor"].SetValue(fogColor.ToVector3());
                    if (partId == effectId)
                    {
                        //if (listTimeTrashProcessing.Count > 0)
                            effect.Parameters["Texture"].SetValue(currentPartTexture); // If execution enters this block, currentPartTexture has been already put in place in Update function. Just need to find a way to set texture here.
                        //effect.Parameters["FogColor"].SetValue(currentFogColor);
                        //else
                        //    effect.Parameters["Texture"].SetValue(animationTextures[0]);
                    }
                    // set texture for factory level if any
                    if (levelPartId >= 0 && levelPartId == effectId && currentLevelTexture != null)
                    {
                        effect.Parameters["Texture"].SetValue(currentLevelTexture);
                    }
                    effectId++;
                }
                mesh.Draw();
            }
        }
Beispiel #29
0
 public virtual void Draw(Matrix view, Matrix projection, Camera gameCamera, string techniqueName)
 {
 }
Beispiel #30
0
 public static bool MouseOnFish(Cursor cursor, Camera gameCamera, Fish[] fish, int fishAmount)
 {
     BoundingSphere sphere;
     Ray cursorRay = cursor.CalculateCursorRay(gameCamera.ProjectionMatrix, gameCamera.ViewMatrix);
     for (int i = 0; i < fishAmount; i++)
     {
         sphere = fish[i].BoundingSphere;
         sphere.Radius *= GameConstants.EasyAimScale;
         if (RayIntersectsBoundingSphere(cursorRay, sphere))
         {
             cursor.SetOnFishMouseImage();
             return true;
         }
     }
     cursor.SetNormalMouseImage();
     return false;
 }