Beispiel #1
0
        public static bool StrikeLightning(Vector2 position, Inpc npc, short damage)
        {
            if (npc.Friendly == false)
            {
                if (LineSegmentF.Lenght(npc.Boundary.Origin, position) < 256)
                {
                    LineSegmentF _ray = new LineSegmentF(npc.Boundary.Origin, position);

                    if (CompareF.LineVsMap(Game1.mapLive.MapTree, new LineObject(Game1.mapLive, _ray)).Count == 0)
                    {
                        Game1.mapLive.mapLightings.Add(new Lightning(npc.Boundary.Origin, position, Game1.debug_thin, 6));
                        Game1.mapLive.mapLightings.Add(new Lightning(npc.Boundary.Origin, position, Game1.debug_thin, 2));
                        npc.Stun();
                        npc.Push(new Vector2(0, -0.2f));
                        npc.KineticDamage(damage);
                        Camera2DGame.Shake(5, position);

                        Sound _strikeSound = new Sound(Game1.soundElectro, position);
                        Game1.Sounds3D.Add(_strikeSound);
                        Game1.Sounds3D[Game1.Sounds3D.IndexOf(_strikeSound)].Play();
                    }
                    return(true);
                }
            }

            return(false);
        }
Beispiel #2
0
        public void DrawWaterMask()
        {
            Game1.SpriteBatchGlobal.Begin(SpriteSortMode.Immediate, transformMatrix: Camera2DGame.GetViewMatrix(), samplerState: SamplerState.PointWrap);

            for (int y = Math.Max((int)(Camera2DGame.PositionPoint.Y / 32), 1); y < Math.Min((int)((Camera2DGame.PositionPoint.Y + Globals.WinRenderSize.Y) / 32) + 1, FunctionTileMap.GetLength(1)); y++)
            {
                for (int x = Math.Max((int)(Camera2DGame.PositionPoint.X / 32), 0); x < Math.Min((int)((Camera2DGame.PositionPoint.X + Globals.WinRenderSize.X) / 32) + 1, FunctionTileMap.GetLength(0)); x++)
                {
                    if (FunctionTileMap[x, y] == 2 && FunctionTileMap[x, y - 1] == 2)
                    {
                        Game1.SpriteBatchGlobal.Draw(Game1.tileMask, new Vector2(x * Globals.TileSize, y * Globals.TileSize));
                    }
                    if (FunctionTileMap[x, y] == 2 && FunctionTileMap[x, y - 1] != 2 && x % 2 == 0)
                    {
                        Game1.SpriteBatchGlobal.Draw(Game1.WaterAnimateLeft, new Vector2(x * Globals.TileSize, (y - 1) * Globals.TileSize));
                    }
                    if (FunctionTileMap[x, y] == 2 && FunctionTileMap[x, y - 1] != 2 && x % 2 == 1)
                    {
                        Game1.SpriteBatchGlobal.Draw(Game1.WaterAnimateRight, new Vector2(x * Globals.TileSize, (y - 1) * Globals.TileSize));
                    }
                }
            }

            Game1.SpriteBatchGlobal.End();
        }
Beispiel #3
0
 public static void InGameUpdate()
 {
     Game1.mapLive.Update();
     Game1.PlayerInstance.Update(MouseInput.MouseRealPosGame());
     Camera2DGame.Update();
     UIPlayer.Update();
     Game1.PlayerInstance.UpdateWeapons(MouseInput.MouseRealPosGame());
 }
Beispiel #4
0
        public static void Explode(Vector2 pos, short damage)
        {
            CircleF circle = new CircleF(pos, 128);

            foreach (IParticle prtcl in Game1.mapLive.mapParticles)
            {
                if (prtcl.Boundary != null)
                {
                    LineSegmentF Temp = new LineSegmentF(pos, prtcl.Boundary.Origin);

                    Vector2?_thru = CompareF.IntersectionLineWithOthers(Temp, Game1.mapLive.TileMapLines, null);
                    if (_thru == null)
                    {
                        prtcl.Push(Vector2.Normalize(Temp.NormalizedWithZeroSolution() * (float)(Globals.GlobalRandom.NextDouble()) * 2));
                    }
                }
            }

            int j = 0;

            foreach (Inpc npc in Game1.mapLive.MapNpcs)
            {
                if (j < 8)
                {
                    LineSegmentF Temp = new LineSegmentF(pos, npc.Boundary.Origin);

                    Vector2?_thru = CompareF.IntersectionLineWithOthers(Temp, Game1.mapLive.TileMapLines, null);

                    if (_thru == null && LineSegmentF.Lenght(pos, npc.Boundary.Origin) < 256)
                    {
                        if (npc.Friendly == false)
                        {
                            npc.KineticDamage(damage);
                        }
                        npc.Push(Vector2.Normalize(Temp.NormalizedWithZeroSolution() * (float)(Globals.GlobalRandom.NextDouble()) * 2));
                        j++;
                    }
                }
            }

            int x = 4;

            for (int i = 0; i < x; i++)
            {
                Game1.mapLive.mapParticles.Add(new ParticleSmokeBig(circle.GenerateRandomPoint()));
            }
            for (int i = 0; i < x; i++)
            {
                Game1.mapLive.mapParticles.Add(new ParticleFireBig(circle.GenerateRandomPoint()));
            }
            for (int i = 0; i < x; i++)
            {
                Game1.mapLive.mapParticles.Add(new ParticleFireSmall(circle.GenerateRandomPoint()));
            }
            Camera2DGame.Shake(10, pos);

            Sound.PlaySoundPosition(pos, Game1.soundExplosion, CustomMath.RandomAroundZero(Globals.GlobalRandom) / 2f);
        }
Beispiel #5
0
        private void ApplyGDamage(Player player, Vector2 tempVelocity)
        {
            if (player.Resolver.TouchVertical == true)
            {
                if (Math.Abs(tempVelocity.Y) > 0.5f)
                {
                    HealthMachine -= Math.Abs(tempVelocity.Y) * 8f;
                    Camera2DGame.Shake((int)(Math.Abs(tempVelocity.Y * 4f)), Camera2DGame.Boundary.Origin);
                }
            }
            if (player.Resolver.TouchHorizontal == true)
            {
                if (Math.Abs(tempVelocity.X) > 0.5f)
                {
                    HealthMachine -= Math.Abs(tempVelocity.X) * 8f;
                    Camera2DGame.Shake((int)(Math.Abs(tempVelocity.X * 4f)), Camera2DGame.Boundary.Origin);
                }
            }

            if (HealthMachine <= 0 || player.Resolver.VerticalPressure == true || player.Resolver.HorizontalPressure == true)
            {
                player.DestroyVehicle();
            }
        }
Beispiel #6
0
 public void DrawNormal()
 {
     Game1.SpriteBatchGlobal.Begin(SpriteSortMode.Immediate, BlendState.NonPremultiplied, SamplerState.LinearClamp, transformMatrix: Camera2DGame.GetViewMatrix());
     CurretnObjectControl.DrawNormal(this);
     Game1.SpriteBatchGlobal.End();
 }
Beispiel #7
0
 public void Draw()
 {
     Game1.SpriteBatchGlobal.Begin(SpriteSortMode.Immediate, BlendState.AlphaBlend, SamplerState.PointClamp, transformMatrix: Camera2DGame.GetViewMatrix());
     CurretnObjectControl.Draw(this);
     Game1.SpriteBatchGlobal.End();
 }
Beispiel #8
0
        public void DrawNormal()
        {
            Game1.SpriteBatchGlobal.Begin(SpriteSortMode.Immediate, BlendState.NonPremultiplied, SamplerState.PointWrap, transformMatrix: Camera2DGame.GetViewMatrix());

            if (ShowGround == true)
            {
                Game1.SpriteBatchGlobal.Draw(Game1.Textures["tileTopNormal"], sourceRectangle: new Rectangle(0, 0, FunctionTileMap.GetLength(0) * Globals.TileSize + 1920, Globals.TileSize), position: new Vector2(-1920 / 2, (FunctionTileMap.GetLength(1) - 1) * Globals.TileSize));

                Game1.SpriteBatchGlobal.Draw(Game1.Textures["tileNormal"], sourceRectangle: new Rectangle(0, 0, FunctionTileMap.GetLength(0) * Globals.TileSize + 1920, Globals.TileSize * 20), position: new Vector2(-1920 / 2, (FunctionTileMap.GetLength(1) - 1) * Globals.TileSize + Globals.TileSize));
            }

            foreach (IDecoration dcr in mapDecorations)
            {
                if ((dcr as DecorationStatic).IsFront == false)
                {
                    dcr.DrawNormal();
                }
            }

            if (BackgroundTileMap != null)
            {
                for (int y = Math.Max((int)(Camera2DGame.PositionPoint.Y / 32), 0); y < Math.Min((int)((Camera2DGame.PositionPoint.Y + Globals.WinRenderSize.Y) / 32) + 1, BackgroundTileMap.GetLength(1)); y++)
                {
                    for (int x = Math.Max((int)(Camera2DGame.PositionPoint.X / 32), 0); x < Math.Min((int)((Camera2DGame.PositionPoint.X + Globals.WinRenderSize.X) / 32) + 1, BackgroundTileMap.GetLength(0)); x++)
                    {
                        if (Camera2DGame.Position.Y - Globals.TileSize < y * Globals.TileSize && y * Globals.TileSize < Camera2DGame.Position.Y + Globals.WinRenderSize.Y + Globals.TileSize)
                        {
                            if (Camera2DGame.Position.X - Globals.TileSize < x * Globals.TileSize && x * Globals.TileSize < Camera2DGame.Position.X + Globals.WinRenderSize.X + Globals.TileSize)
                            {
                                if (BackgroundTileMap[x, y] == 1)
                                {
                                    Game1.SpriteBatchGlobal.Draw(Game1.Textures["tilesNormal"], new Vector2(x * Globals.TileSize, y * Globals.TileSize), sourceRectangle: new Rectangle(32, 32, 32, 32));
                                }
                                if (BackgroundTileMap[x, y] == 2)
                                {
                                    Game1.SpriteBatchGlobal.Draw(Game1.Textures["tilesNormal"], new Vector2(x * Globals.TileSize, y * Globals.TileSize), sourceRectangle: new Rectangle(32, 0, 32, 32));
                                }
                                if (BackgroundTileMap[x, y] == 3)
                                {
                                    Game1.SpriteBatchGlobal.Draw(Game1.Textures["tilesNormal"], new Vector2(x * Globals.TileSize, y * Globals.TileSize), sourceRectangle: new Rectangle(0, 0, 32, 32));
                                }
                                if (BackgroundTileMap[x, y] == 4)
                                {
                                    Game1.SpriteBatchGlobal.Draw(Game1.Textures["tilesNormal"], new Vector2(x * Globals.TileSize, y * Globals.TileSize), sourceRectangle: new Rectangle(64, 0, 32, 32));
                                }
                                if (BackgroundTileMap[x, y] == 5)
                                {
                                    Game1.SpriteBatchGlobal.Draw(Game1.Textures["tilesNormal"], new Vector2(x * Globals.TileSize, y * Globals.TileSize), sourceRectangle: new Rectangle(0, 32, 32, 32));
                                }
                                if (BackgroundTileMap[x, y] == 6)
                                {
                                    Game1.SpriteBatchGlobal.Draw(Game1.Textures["tilesNormal"], new Vector2(x * Globals.TileSize, y * Globals.TileSize), sourceRectangle: new Rectangle(64, 32, 32, 32));
                                }
                            }
                        }
                    }
                }
            }

            foreach (ICrate crt in mapCrates)
            {
                crt.DrawNormal();
            }

            foreach (ITriggers trgr in mapTriggers)
            {
                trgr.DrawNormal();
            }

            foreach (IRectanglePhysics mvbl in MapMovables)
            {
                mvbl.DrawNormal();
            }

            foreach (Inpc npc in MapNpcs)
            {
                if (npc is CarryBase == false)
                {
                    npc.DrawNormal();
                }
            }

            Game1.SpriteBatchGlobal.End();

            Game1.PlayerInstance.DrawNormal();

            Game1.SpriteBatchGlobal.Begin(SpriteSortMode.Immediate, BlendState.NonPremultiplied, SamplerState.PointWrap, transformMatrix: Camera2DGame.GetViewMatrix());

            foreach (Inpc npc in MapNpcs)
            {
                if (npc is CarryBase == true)
                {
                    npc.DrawNormal();
                }
            }

            foreach (IDecoration dcr in mapDecorations)
            {
                if ((dcr as DecorationStatic).IsFront == true)
                {
                    dcr.DrawNormal();
                }
            }

            foreach (IProjectile prjctl in MapProjectiles)
            {
                prjctl.DrawNormal();
            }
            Game1.SpriteBatchGlobal.End();

            Game1.SpriteBatchGlobal.Begin(SpriteSortMode.Immediate, BlendState.NonPremultiplied, SamplerState.PointWrap, transformMatrix: Camera2DGame.GetViewMatrix());

            foreach (IParticle prtcl in mapParticles)
            {
                prtcl.DrawNormal();
            }

            Game1.SpriteBatchGlobal.End();
        }
Beispiel #9
0
        public void Draw()
        {
            Game1.SpriteBatchGlobal.Begin(transformMatrix: Camera2DGame.GetViewMatrix(), samplerState: SamplerState.PointWrap, sortMode: SpriteSortMode.Immediate);

            Game1.Game1Self.GraphicsDevice.Clear(Color.CornflowerBlue);

            if (ShowBoundary == true)
            {
                Game1.EffectSlide.Parameters["UV"].SetValue(new Vector2(0, _time));
                Game1.EffectSlide.CurrentTechnique.Passes[0].Apply();
                Game1.SpriteBatchGlobal.Draw(Game1.boundary, position: new Vector2(-64, 0), sourceRectangle: new Rectangle(0, 0, 64, FunctionTileMap.GetLength(1) * Globals.TileSize));
                Game1.SpriteBatchGlobal.Draw(Game1.boundary, position: new Vector2(FunctionTileMap.GetLength(0) * Globals.TileSize, 0), sourceRectangle: new Rectangle(0, 0, 64, FunctionTileMap.GetLength(1) * Globals.TileSize), effects: SpriteEffects.FlipHorizontally);
                Game1.EffectBaseColor.CurrentTechnique.Passes[0].Apply();
            }

            if (ShowGround == true)
            {
                Game1.SpriteBatchGlobal.Draw(Game1.tileTop, sourceRectangle: new Rectangle(0, 0, FunctionTileMap.GetLength(0) * Globals.TileSize / 2 + 1920 / 2, Globals.TileSize / 2), position: new Vector2(-1920 / 2, (FunctionTileMap.GetLength(1) - 1) * Globals.TileSize), scale: new Vector2(2));
                Game1.SpriteBatchGlobal.Draw(Game1.Tile03, sourceRectangle: new Rectangle(0, 0, FunctionTileMap.GetLength(0) * Globals.TileSize / 2 + 1920 / 2, Globals.TileSize * 10), position: new Vector2(-1920 / 2, (FunctionTileMap.GetLength(1) - 1) * Globals.TileSize + Globals.TileSize), scale: new Vector2(2));
            }

            foreach (IDecoration dcr in mapDecorations)
            {
                if ((dcr as DecorationStatic).IsFront == false)
                {
                    dcr.Draw();
                }
            }

            if (BackgroundTileMap != null)
            {
                for (int y = Math.Max((int)(Camera2DGame.PositionPoint.Y / 32), 0); y < Math.Min((int)((Camera2DGame.PositionPoint.Y + Globals.WinRenderSize.Y) / 32) + 1, BackgroundTileMap.GetLength(1)); y++)
                {
                    for (int x = Math.Max((int)(Camera2DGame.PositionPoint.X / 32), 0); x < Math.Min((int)((Camera2DGame.PositionPoint.X + Globals.WinRenderSize.X) / 32) + 1, BackgroundTileMap.GetLength(0)); x++)
                    {
                        if (Camera2DGame.Position.Y - Globals.TileSize < y * Globals.TileSize && y * Globals.TileSize < Camera2DGame.Position.Y + Globals.WinRenderSize.Y + Globals.TileSize)
                        {
                            if (Camera2DGame.Position.X - Globals.TileSize < x * Globals.TileSize && x * Globals.TileSize < Camera2DGame.Position.X + Globals.WinRenderSize.X + Globals.TileSize)
                            {
                                if (BackgroundTileMap[x, y] == 1)
                                {
                                    Game1.SpriteBatchGlobal.Draw(Game1.Textures["TilesSand"], new Vector2(x * Globals.TileSize, y * Globals.TileSize), sourceRectangle: new Rectangle(32, 32, 32, 32));
                                }
                                if (BackgroundTileMap[x, y] == 2)
                                {
                                    Game1.SpriteBatchGlobal.Draw(Game1.Textures["TilesSand"], new Vector2(x * Globals.TileSize, y * Globals.TileSize), sourceRectangle: new Rectangle(32, 0, 32, 32));
                                }
                                if (BackgroundTileMap[x, y] == 3)
                                {
                                    Game1.SpriteBatchGlobal.Draw(Game1.Textures["TilesSand"], new Vector2(x * Globals.TileSize, y * Globals.TileSize), sourceRectangle: new Rectangle(0, 0, 32, 32));
                                }
                                if (BackgroundTileMap[x, y] == 4)
                                {
                                    Game1.SpriteBatchGlobal.Draw(Game1.Textures["TilesSand"], new Vector2(x * Globals.TileSize, y * Globals.TileSize), sourceRectangle: new Rectangle(64, 0, 32, 32));
                                }
                                if (BackgroundTileMap[x, y] == 5)
                                {
                                    Game1.SpriteBatchGlobal.Draw(Game1.Textures["TilesSand"], new Vector2(x * Globals.TileSize, y * Globals.TileSize), sourceRectangle: new Rectangle(0, 32, 32, 32));
                                }
                                if (BackgroundTileMap[x, y] == 6)
                                {
                                    Game1.SpriteBatchGlobal.Draw(Game1.Textures["TilesSand"], new Vector2(x * Globals.TileSize, y * Globals.TileSize), sourceRectangle: new Rectangle(64, 32, 32, 32));
                                }
                            }
                        }
                    }
                }
            }

            if (ForegroundTileMap != null)
            {
                for (int y = Math.Max((int)(Camera2DGame.PositionPoint.Y / 32), 0); y < Math.Min((int)((Camera2DGame.PositionPoint.Y + Globals.WinRenderSize.Y) / 32) + 1, ForegroundTileMap.GetLength(1)); y++)
                {
                    for (int x = Math.Max((int)(Camera2DGame.PositionPoint.X / 32), 0); x < Math.Min((int)((Camera2DGame.PositionPoint.X + Globals.WinRenderSize.X) / 32) + 1, ForegroundTileMap.GetLength(0)); x++)
                    {
                    }
                }
            }

            if (DrawFunctionMap == true)
            {
                for (int y = Math.Max((int)(Camera2DGame.PositionPoint.Y / 32), 0); y < Math.Min((int)((Camera2DGame.PositionPoint.Y + Globals.WinRenderSize.Y) / 32) + 1, FunctionTileMap.GetLength(1)); y++)
                {
                    for (int x = Math.Max((int)(Camera2DGame.PositionPoint.X / 32), 0); x < Math.Min((int)((Camera2DGame.PositionPoint.X + Globals.WinRenderSize.X) / 32) + 1, FunctionTileMap.GetLength(0)); x++)
                    {
                        if (Camera2DGame.Position.Y - Globals.TileSize < y * Globals.TileSize && y * Globals.TileSize < Camera2DGame.Position.Y + Globals.WinRenderSize.Y + Globals.TileSize)
                        {
                            if (Camera2DGame.Position.X - Globals.TileSize < x * Globals.TileSize && x * Globals.TileSize < Camera2DGame.Position.X + Globals.WinRenderSize.X + Globals.TileSize)
                            {
                                if (FunctionTileMap[x, y] == 1)
                                {
                                    Game1.SpriteBatchGlobal.Draw(Game1.tileBack1, new Vector2(x * Globals.TileSize, y * Globals.TileSize), scale: new Vector2(2));
                                }
                                if (FunctionTileMap[x, y] == 2)
                                {
                                    Game1.SpriteBatchGlobal.Draw(Game1.waterTex, new Vector2(x * Globals.TileSize, y * Globals.TileSize), scale: new Vector2(2));
                                }
                            }
                        }
                    }
                }
            }

            foreach (ICrate crt in mapCrates)
            {
                crt.Draw();
            }

            foreach (ITriggers trgr in mapTriggers)
            {
                trgr.Draw();
            }

            foreach (IRectanglePhysics mvbl in MapMovables)
            {
                mvbl.Draw();
            }

            foreach (IPickable pick in mapPickables)
            {
                pick.Draw();
            }

            foreach (Inpc npc in MapNpcs)
            {
                if (npc is CarryBase == false)
                {
                    npc.Draw();
                }
            }

            Game1.SpriteBatchGlobal.End();

            Game1.PlayerInstance.Draw();

            Game1.SpriteBatchGlobal.Begin(transformMatrix: Camera2DGame.GetViewMatrix(), samplerState: SamplerState.PointWrap, sortMode: SpriteSortMode.Immediate);

            foreach (Inpc npc in MapNpcs)
            {
                if (npc is CarryBase == true)
                {
                    npc.Draw();
                }
            }

            foreach (IDecoration dcr in mapDecorations)
            {
                if ((dcr as DecorationStatic).IsFront == true)
                {
                    dcr.Draw();
                }
            }

            foreach (IEffect lght in mapLightings)
            {
                lght.Draw();
            }

            foreach (IProjectile prjctl in MapProjectiles)
            {
                prjctl.Draw();
            }

            foreach (IParticle prtcl in mapParticles)
            {
                prtcl.Draw();
            }

            Game1.SpriteBatchGlobal.End();

            Game1.SpriteBatchGlobal.Begin(samplerState: SamplerState.PointWrap, sortMode: SpriteSortMode.Immediate);
            Effects.ColorEffect(new Vector4(1f, 1f, 1f, _transparency));
            Game1.SpriteBatchGlobal.Draw(Game1.Transition, Vector2.Zero);
            Game1.EffectBaseColor.CurrentTechnique.Passes[0].Apply();
            Game1.SpriteBatchGlobal.End();
        }
Beispiel #10
0
        public void DrawLayer2()
        {
            Game1.SpriteBatchGlobal.Begin(SpriteSortMode.Immediate, BlendState.AlphaBlend, SamplerState.PointClamp, transformMatrix: Camera2DGame.GetViewMatrixLayer2());

            foreach (IDecoration dcr in mapDecorationsLayer2)
            {
                dcr.Draw();
            }

            Game1.SpriteBatchGlobal.End();
        }
Beispiel #11
0
        private static void DrawFinal(IMap map)
        {
            Game1.GraphicsGlobal.GraphicsDevice.SetRenderTargets(Game1.FinalScreen);
            Game1.SpriteBatchGlobal.Begin(SpriteSortMode.Immediate, BlendState.AlphaBlend, SamplerState.PointWrap);
            Game1.SpriteBatchGlobal.Draw(Game1.WaterWithoutLights, Vector2.Zero);
            Game1.SpriteBatchGlobal.End();
            if (map is Map)
            {
                Game1.SpriteBatchGlobal.Begin(SpriteSortMode.Immediate, BlendState.AlphaBlend, SamplerState.PointWrap, transformMatrix: Camera2DGame.GetViewMatrix());

                foreach (Inpc ui in (map as Map).MapNpcs)
                {
                    if (ui as IUI != null)
                    {
                        (ui as IUI).DrawUI();
                    }
                }

                Game1.SpriteBatchGlobal.End();
            }
            Game1.SpriteBatchGlobal.Begin(SpriteSortMode.Immediate, BlendState.AlphaBlend, SamplerState.PointWrap);
            if (Game1.State == GlobalState.inGame)
            {
                UIPlayer.Draw();
            }
            foreach (UIInformer info in Game1.InfoList.Reverse <UIInformer>())
            {
                info.Position = new Vector2(8, Game1.InfoList.IndexOf(info) * 32 + 8);
                info.Draw();
            }
            Game1.SpriteBatchGlobal.End();
        }
Beispiel #12
0
 private static void DrawLights(IMap map)
 {
     RenderTargetsSettings.SetAndClear(Game1.Lights, new Color(map.LightLevel));
     Game1.SpriteBatchGlobal.Begin(SpriteSortMode.Immediate, BlendState.Additive, SamplerState.PointClamp, transformMatrix: Camera2DGame.GetViewMatrix());
     map.DrawLights();
     Game1.SpriteBatchGlobal.End();
     Game1.SpriteBatchGlobal.Begin(SpriteSortMode.Immediate, BlendState.Additive, SamplerState.PointClamp);
     Game1.SpriteBatchGlobal.Draw(Game1.LightNormalHolder, Vector2.Zero);
     Game1.SpriteBatchGlobal.End();
 }