Beispiel #1
0
        public SkyplaneEngine(InfiniminerGame gameInstance)
        {
            this.gameInstance = gameInstance;

            // Generate a noise texture.
            randGen  = new Random();
            texNoise = new Texture2D(gameInstance.GraphicsDevice, 64, 64);
            uint[] noiseData = new uint[64 * 64];
            for (int i = 0; i < 64 * 64; i++)
            {
                if (randGen.Next(32) == 0)
                {
                    noiseData[i] = Color.White.PackedValue;
                }
                else
                {
                    noiseData[i] = Color.Black.PackedValue;
                }
            }
            texNoise.SetData(noiseData);

            // Load the effect file.
            effect = gameInstance.Content.Load <Effect>("effect_skyplane");

            // Create our vertices.
            vertexDeclaration = new VertexDeclaration(VertexPositionTexture.VertexDeclaration.GetVertexElements());
            vertices          = new VertexPositionTexture[6];
            vertices[0]       = new VertexPositionTexture(new Vector3(-210, 100, -210), new Vector2(0, 0));
            vertices[1]       = new VertexPositionTexture(new Vector3(274, 100, -210), new Vector2(1, 0));
            vertices[2]       = new VertexPositionTexture(new Vector3(274, 100, 274), new Vector2(1, 1));
            vertices[3]       = new VertexPositionTexture(new Vector3(-210, 100, -210), new Vector2(0, 0));
            vertices[4]       = new VertexPositionTexture(new Vector3(274, 100, 274), new Vector2(1, 1));
            vertices[5]       = new VertexPositionTexture(new Vector3(-210, 100, 274), new Vector2(0, 1));
        }
Beispiel #2
0
        public ParticleEngine(InfiniminerGame gameInstance)
        {
            this.gameInstance = gameInstance;
            particleEffect    = gameInstance.Content.Load <Effect>("effect_particle");
            randGen           = new Random();
            particleList      = new List <Particle>();

            vertexDeclaration = new VertexDeclaration(VertexPositionTextureShade.VertexElements);
            VertexPositionTextureShade[] vertices = GenerateVertices();
            vertexBuffer = new VertexBuffer(gameInstance.GraphicsDevice, vertices.Length * VertexPositionTextureShade.SizeInBytes, BufferUsage.WriteOnly);
            vertexBuffer.SetData(vertices);
        }
Beispiel #3
0
 static void Main(string[] args)
 {
     using (InfiniminerGame game = new InfiniminerGame(args))
     {
         try
         {
             game.Run();
         }
         catch (Exception e)
         {
             System.Windows.Forms.MessageBox.Show(e.Message + "\r\n\r\n" + e.StackTrace);
         }
     }
 }
Beispiel #4
0
        public PropertyBag(InfiniminerGame gameInstance)
        {
            // Initialize our network device.
            NetConfiguration netConfig = new NetConfiguration("InfiniminerPlus");

            netClient = new NetClient(netConfig);
            netClient.SetMessageTypeEnabled(NetMessageType.ConnectionRejected, true);
            //netClient.SimulatedMinimumLatency = 0.1f;
            //netClient.SimulatedLatencyVariance = 0.05f;
            //netClient.SimulatedLoss = 0.1f;
            //netClient.SimulatedDuplicates = 0.05f;
            netClient.Start();

            // Initialize engines.
            blockEngine     = new BlockEngine(gameInstance);
            interfaceEngine = new InterfaceEngine(gameInstance);
            playerEngine    = new PlayerEngine(gameInstance);
            skyplaneEngine  = new SkyplaneEngine(gameInstance);
            particleEngine  = new ParticleEngine(gameInstance);

            // Create a camera.
            playerCamera = new Camera(gameInstance.GraphicsDevice);
            UpdateCamera();

            // Load sounds.
            if (!gameInstance.NoSound)
            {
                soundList[InfiniminerSound.DigDirt]         = gameInstance.Content.Load <SoundEffect>("sounds/dig-dirt");
                soundList[InfiniminerSound.DigMetal]        = gameInstance.Content.Load <SoundEffect>("sounds/dig-metal");
                soundList[InfiniminerSound.Ping]            = gameInstance.Content.Load <SoundEffect>("sounds/ping");
                soundList[InfiniminerSound.ConstructionGun] = gameInstance.Content.Load <SoundEffect>("sounds/build");
                soundList[InfiniminerSound.Death]           = gameInstance.Content.Load <SoundEffect>("sounds/death");
                soundList[InfiniminerSound.CashDeposit]     = gameInstance.Content.Load <SoundEffect>("sounds/cash");
                soundList[InfiniminerSound.ClickHigh]       = gameInstance.Content.Load <SoundEffect>("sounds/click-loud");
                soundList[InfiniminerSound.ClickLow]        = gameInstance.Content.Load <SoundEffect>("sounds/click-quiet");
                soundList[InfiniminerSound.GroundHit]       = gameInstance.Content.Load <SoundEffect>("sounds/hitground");
                soundList[InfiniminerSound.Teleporter]      = gameInstance.Content.Load <SoundEffect>("sounds/teleport");
                soundList[InfiniminerSound.Jumpblock]       = gameInstance.Content.Load <SoundEffect>("sounds/jumpblock");
                soundList[InfiniminerSound.Explosion]       = gameInstance.Content.Load <SoundEffect>("sounds/explosion");
                soundList[InfiniminerSound.RadarHigh]       = gameInstance.Content.Load <SoundEffect>("sounds/radar-high");
                soundList[InfiniminerSound.RadarLow]        = gameInstance.Content.Load <SoundEffect>("sounds/radar-low");
                soundList[InfiniminerSound.RadarSwitch]     = gameInstance.Content.Load <SoundEffect>("sounds/switch");
            }
        }
Beispiel #5
0
        public InterfaceEngine(InfiniminerGame gameInstance)
        {
            this.gameInstance = gameInstance;
            spriteBatch       = new SpriteBatch(gameInstance.GraphicsDevice);

            // Load textures.
            texCrosshairs = gameInstance.Content.Load <Texture2D>("ui/tex_ui_crosshair");
            texBlank      = new Texture2D(gameInstance.GraphicsDevice, 1, 1);
            texBlank.SetData(new uint[1] {
                0xFFFFFFFF
            });
            texRadarBackground  = gameInstance.Content.Load <Texture2D>("ui/tex_radar_background");
            texRadarForeground  = gameInstance.Content.Load <Texture2D>("ui/tex_radar_foreground");
            texRadarPlayerSame  = gameInstance.Content.Load <Texture2D>("ui/tex_radar_player_same");
            texRadarPlayerAbove = gameInstance.Content.Load <Texture2D>("ui/tex_radar_player_above");
            texRadarPlayerBelow = gameInstance.Content.Load <Texture2D>("ui/tex_radar_player_below");
            texRadarPlayerPing  = gameInstance.Content.Load <Texture2D>("ui/tex_radar_player_ping");
            texRadarNorth       = gameInstance.Content.Load <Texture2D>("ui/tex_radar_north");
            texHelp             = gameInstance.Content.Load <Texture2D>("menus/tex_menu_help");

            texToolRadarRed     = gameInstance.Content.Load <Texture2D>("tools/tex_tool_radar_red");
            texToolRadarBlue    = gameInstance.Content.Load <Texture2D>("tools/tex_tool_radar_blue");
            texToolRadarGold    = gameInstance.Content.Load <Texture2D>("tools/tex_tool_radar_screen_gold");
            texToolRadarDiamond = gameInstance.Content.Load <Texture2D>("tools/tex_tool_radar_screen_diamond");
            texToolRadarLED     = gameInstance.Content.Load <Texture2D>("tools/tex_tool_radar_led");
            texToolRadarPointer = gameInstance.Content.Load <Texture2D>("tools/tex_tool_radar_pointer");
            texToolRadarFlash   = gameInstance.Content.Load <Texture2D>("tools/tex_tool_radar_flash");

            texToolBuild       = gameInstance.Content.Load <Texture2D>("tools/tex_tool_build");
            texToolBuildCharge = gameInstance.Content.Load <Texture2D>("tools/tex_tool_build_charge");
            texToolBuildBlast  = gameInstance.Content.Load <Texture2D>("tools/tex_tool_build_blast");
            texToolBuildSmoke  = gameInstance.Content.Load <Texture2D>("tools/tex_tool_build_smoke");

            texToolDetonatorDownRed  = gameInstance.Content.Load <Texture2D>("tools/tex_tool_detonator_down_red");
            texToolDetonatorUpRed    = gameInstance.Content.Load <Texture2D>("tools/tex_tool_detonator_up_red");
            texToolDetonatorDownBlue = gameInstance.Content.Load <Texture2D>("tools/tex_tool_detonator_down_blue");
            texToolDetonatorUpBlue   = gameInstance.Content.Load <Texture2D>("tools/tex_tool_detonator_up_blue");

            drawRect = new Rectangle(gameInstance.GraphicsDevice.Viewport.Width / 2 - 1024 / 2,
                                     gameInstance.GraphicsDevice.Viewport.Height / 2 - 768 / 2,
                                     1024,
                                     1024);

            // Load icons.
            blockIcons[BlockType.BankBlue]   = gameInstance.Content.Load <Texture2D>("icons/tex_icon_bank_blue");
            blockIcons[BlockType.BankRed]    = gameInstance.Content.Load <Texture2D>("icons/tex_icon_bank_red");
            blockIcons[BlockType.Explosive]  = gameInstance.Content.Load <Texture2D>("icons/tex_icon_explosive");
            blockIcons[BlockType.Jump]       = gameInstance.Content.Load <Texture2D>("icons/tex_icon_jump");
            blockIcons[BlockType.Ladder]     = gameInstance.Content.Load <Texture2D>("icons/tex_icon_ladder");
            blockIcons[BlockType.SolidBlue]  = gameInstance.Content.Load <Texture2D>("icons/tex_icon_solid_blue");
            blockIcons[BlockType.SolidRed]   = gameInstance.Content.Load <Texture2D>("icons/tex_icon_solid_red");
            blockIcons[BlockType.Shock]      = gameInstance.Content.Load <Texture2D>("icons/tex_icon_spikes");
            blockIcons[BlockType.TransBlue]  = gameInstance.Content.Load <Texture2D>("icons/tex_icon_translucent_blue");
            blockIcons[BlockType.TransRed]   = gameInstance.Content.Load <Texture2D>("icons/tex_icon_translucent_red");
            blockIcons[BlockType.BeaconRed]  = gameInstance.Content.Load <Texture2D>("icons/tex_icon_beacon");
            blockIcons[BlockType.BeaconBlue] = gameInstance.Content.Load <Texture2D>("icons/tex_icon_beacon");
            blockIcons[BlockType.Road]       = gameInstance.Content.Load <Texture2D>("icons/tex_icon_road");
            blockIcons[BlockType.None]       = gameInstance.Content.Load <Texture2D>("icons/tex_icon_deconstruction");

            // Load fonts.
            uiFont    = gameInstance.Content.Load <SpriteFont>("font_04b08");
            radarFont = gameInstance.Content.Load <SpriteFont>("font_04b03b");
        }
Beispiel #6
0
        public BlockEngine(InfiniminerGame gameInstance)
        {
            this.gameInstance = gameInstance;

            // Initialize the block list.
            downloadList = new BlockType[MAPSIZE, MAPSIZE, MAPSIZE];
            blockList    = new BlockType[MAPSIZE, MAPSIZE, MAPSIZE];
            for (ushort i = 0; i < MAPSIZE; i++)
            {
                for (ushort j = 0; j < MAPSIZE; j++)
                {
                    for (ushort k = 0; k < MAPSIZE; k++)
                    {
                        downloadList[i, j, k] = BlockType.None;
                        blockList[i, j, k]    = BlockType.None;
                    }
                }
            }

            // Initialize the face lists.
            faceMap = new Dictionary <uint, bool> [(byte)BlockTexture.MAXIMUM, NUMREGIONS];
            for (BlockTexture blockTexture = BlockTexture.None; blockTexture < BlockTexture.MAXIMUM; blockTexture++)
            {
                for (int r = 0; r < NUMREGIONS; r++)
                {
                    faceMap[(byte)blockTexture, r] = new Dictionary <uint, bool>();
                }
            }

            // Initialize the texture map.
            blockTextureMap = new BlockTexture[(byte)BlockType.MAXIMUM, 6];
            for (BlockType blockType = BlockType.None; blockType < BlockType.MAXIMUM; blockType++)
            {
                for (BlockFaceDirection faceDir = BlockFaceDirection.XIncreasing; faceDir < BlockFaceDirection.MAXIMUM; faceDir++)
                {
                    blockTextureMap[(byte)blockType, (byte)faceDir] = BlockInformation.GetTexture(blockType, faceDir);
                }
            }

            // Load the textures we'll use.
            blockTextures = new IMTexture[(byte)BlockTexture.MAXIMUM];
            blockTextures[(byte)BlockTexture.None]          = new IMTexture(null);
            blockTextures[(byte)BlockTexture.Dirt]          = new IMTexture(gameInstance.Content.Load <Texture2D>("blocks/tex_block_dirt"));
            blockTextures[(byte)BlockTexture.Rock]          = new IMTexture(gameInstance.Content.Load <Texture2D>("blocks/tex_block_rock"));
            blockTextures[(byte)BlockTexture.Ore]           = new IMTexture(gameInstance.Content.Load <Texture2D>("blocks/tex_block_ore"));
            blockTextures[(byte)BlockTexture.Gold]          = new IMTexture(gameInstance.Content.Load <Texture2D>("blocks/tex_block_silver"));
            blockTextures[(byte)BlockTexture.Diamond]       = new IMTexture(gameInstance.Content.Load <Texture2D>("blocks/tex_block_diamond"));
            blockTextures[(byte)BlockTexture.HomeRed]       = new IMTexture(gameInstance.Content.Load <Texture2D>("blocks/tex_block_home_red"));
            blockTextures[(byte)BlockTexture.HomeBlue]      = new IMTexture(gameInstance.Content.Load <Texture2D>("blocks/tex_block_home_blue"));
            blockTextures[(byte)BlockTexture.SolidRed]      = new IMTexture(gameInstance.Content.Load <Texture2D>("blocks/tex_block_red"));
            blockTextures[(byte)BlockTexture.SolidBlue]     = new IMTexture(gameInstance.Content.Load <Texture2D>("blocks/tex_block_blue"));
            blockTextures[(byte)BlockTexture.Ladder]        = new IMTexture(gameInstance.Content.Load <Texture2D>("blocks/tex_block_ladder"));
            blockTextures[(byte)BlockTexture.LadderTop]     = new IMTexture(gameInstance.Content.Load <Texture2D>("blocks/tex_block_ladder_top"));
            blockTextures[(byte)BlockTexture.Spikes]        = new IMTexture(gameInstance.Content.Load <Texture2D>("blocks/tex_block_spikes"));
            blockTextures[(byte)BlockTexture.Jump]          = new IMTexture(gameInstance.Content.Load <Texture2D>("blocks/tex_block_jump"));
            blockTextures[(byte)BlockTexture.JumpTop]       = new IMTexture(gameInstance.Content.Load <Texture2D>("blocks/tex_block_jump_top"));
            blockTextures[(byte)BlockTexture.Explosive]     = new IMTexture(gameInstance.Content.Load <Texture2D>("blocks/tex_block_explosive"));
            blockTextures[(byte)BlockTexture.Metal]         = new IMTexture(gameInstance.Content.Load <Texture2D>("blocks/tex_block_metal"));
            blockTextures[(byte)BlockTexture.DirtSign]      = new IMTexture(gameInstance.Content.Load <Texture2D>("blocks/tex_block_dirt_sign"));
            blockTextures[(byte)BlockTexture.BankTopRed]    = new IMTexture(gameInstance.Content.Load <Texture2D>("blocks/tex_block_bank_top_red"));
            blockTextures[(byte)BlockTexture.BankLeftRed]   = new IMTexture(gameInstance.Content.Load <Texture2D>("blocks/tex_block_bank_left_red"));
            blockTextures[(byte)BlockTexture.BankFrontRed]  = new IMTexture(gameInstance.Content.Load <Texture2D>("blocks/tex_block_bank_front_red"));
            blockTextures[(byte)BlockTexture.BankRightRed]  = new IMTexture(gameInstance.Content.Load <Texture2D>("blocks/tex_block_bank_right_red"));
            blockTextures[(byte)BlockTexture.BankBackRed]   = new IMTexture(gameInstance.Content.Load <Texture2D>("blocks/tex_block_bank_back_red"));
            blockTextures[(byte)BlockTexture.BankTopBlue]   = new IMTexture(gameInstance.Content.Load <Texture2D>("blocks/tex_block_bank_top_blue"));
            blockTextures[(byte)BlockTexture.BankLeftBlue]  = new IMTexture(gameInstance.Content.Load <Texture2D>("blocks/tex_block_bank_left_blue"));
            blockTextures[(byte)BlockTexture.BankFrontBlue] = new IMTexture(gameInstance.Content.Load <Texture2D>("blocks/tex_block_bank_front_blue"));
            blockTextures[(byte)BlockTexture.BankRightBlue] = new IMTexture(gameInstance.Content.Load <Texture2D>("blocks/tex_block_bank_right_blue"));
            blockTextures[(byte)BlockTexture.BankBackBlue]  = new IMTexture(gameInstance.Content.Load <Texture2D>("blocks/tex_block_bank_back_blue"));
            blockTextures[(byte)BlockTexture.TeleSideA]     = new IMTexture(gameInstance.Content.Load <Texture2D>("blocks/tex_block_teleporter_a"));
            blockTextures[(byte)BlockTexture.TeleSideB]     = new IMTexture(gameInstance.Content.Load <Texture2D>("blocks/tex_block_teleporter_b"));
            blockTextures[(byte)BlockTexture.TeleTop]       = new IMTexture(gameInstance.Content.Load <Texture2D>("blocks/tex_block_teleporter_top"));
            blockTextures[(byte)BlockTexture.TeleBottom]    = new IMTexture(gameInstance.Content.Load <Texture2D>("blocks/tex_block_teleporter_bottom"));
            blockTextures[(byte)BlockTexture.Lava]          = new IMTexture(gameInstance.Content.Load <Texture2D>("blocks/tex_block_lava"));
            blockTextures[(byte)BlockTexture.Road]          = new IMTexture(gameInstance.Content.Load <Texture2D>("blocks/tex_block_road"));
            blockTextures[(byte)BlockTexture.RoadTop]       = new IMTexture(gameInstance.Content.Load <Texture2D>("blocks/tex_block_road_top"));
            blockTextures[(byte)BlockTexture.RoadBottom]    = new IMTexture(gameInstance.Content.Load <Texture2D>("blocks/tex_block_road_bottom"));
            blockTextures[(byte)BlockTexture.BeaconRed]     = new IMTexture(gameInstance.Content.Load <Texture2D>("blocks/tex_block_beacon_top_red"));
            blockTextures[(byte)BlockTexture.BeaconBlue]    = new IMTexture(gameInstance.Content.Load <Texture2D>("blocks/tex_block_beacon_top_blue"));
            blockTextures[(byte)BlockTexture.TransRed]      = new IMTexture(gameInstance.Content.Load <Texture2D>("blocks/tex_block_trans_red"));
            blockTextures[(byte)BlockTexture.TransBlue]     = new IMTexture(gameInstance.Content.Load <Texture2D>("blocks/tex_block_trans_blue"));

            // Load our effects.
            basicEffect = gameInstance.Content.Load <Effect>("effect_basic");

            // Build vertex lists.
            vertexBuffers   = new DynamicVertexBuffer[(byte)BlockTexture.MAXIMUM, NUMREGIONS];
            vertexListDirty = new bool[(byte)BlockTexture.MAXIMUM, NUMREGIONS];
            for (int i = 0; i < (byte)BlockTexture.MAXIMUM; i++)
            {
                for (int j = 0; j < NUMREGIONS; j++)
                {
                    vertexListDirty[i, j] = true;
                }
            }

            // Initialize any graphics stuff.
            vertexDeclaration = new VertexDeclaration(VertexPositionTextureShade.VertexElements);

            // Initialize the bloom engine.
            if (gameInstance.RenderPretty)
            {
                bloomPosteffect = new BloomComponent();
                bloomPosteffect.Load(gameInstance.GraphicsDevice, gameInstance.Content);
            }
            else
            {
                bloomPosteffect = null;
            }
        }
Beispiel #7
0
 public PlayerEngine(InfiniminerGame gameInstance)
 {
     this.gameInstance = gameInstance;
 }