Ejemplo n.º 1
0
        /// <summary>
        /// Loads the content.
        /// </summary>
        protected override void LoadContent()
        {
            // Load content for the game or screen
            this.webUIComponent = new WebUIScreenDrawableComponent(this.GameWorld, 1280, 720, Vector2.Zero);
            this.webUIComponent.RegisterEventCallback("game:spawnLight", this.SpawnLight);

            this.backgroundSprite = new TiledSprite(this.GameWorld, "Content/stone", null, Vector2.Zero, new Vector2(this.GraphicsDeviceManager.PreferredBackBufferWidth, this.GraphicsDeviceManager.PreferredBackBufferHeight) * this.GameWorld.WorldPerPixelRatio)
            {
                LayerDepth    = 1,
                RenderOptions = SpriteRenderOptions.IsLit
            };

            var newLight = new BouncyPointLight(this.GameWorld)
            {
                Position         = new Vector3(Vector2.Zero, 0.15f),
                Velocity         = this.GetRandomVelocity(),
                Color            = this.GetRandomColor(),
                Power            = 0.25f,
                Range            = this.prng.Next(300, 500) / 100.0f,
                SpecularStrength = 2.75f,
                CastsShadows     = true,
                LayerDepth       = 2
            };

            var amLight = new AmbientLight(Color.White, 0.2f, true, 1);

            this.RenderSystem.AddPostProcessEffect(newLight);
            this.RenderSystem.AddPostProcessEffect(amLight);

            this.GameCamera.Position = new Vector2(this.GraphicsDeviceManager.PreferredBackBufferWidth, this.GraphicsDeviceManager.PreferredBackBufferHeight) * this.GameWorld.WorldPerPixelRatio * 0.5f;

            base.LoadContent();
        }
Ejemplo n.º 2
0
        private GameObject TryGenerateHouse(Main main)
        {
            int         width  = UnityEngine.Random.Range(minHouseWidth, maxHouseWidth);
            int         height = UnityEngine.Random.Range(minHouseHeight, maxHouseHeight) + 1;      //+1 for roof
            Point <int> point  = main.Tiles.GetFreeRandomPoint(width, height, maxInvisibleHorizontal, maxInvisibleVertical, emptyBorder);

            if (point == null)
            {
                Debug.Log("Cannot find place for house (" + width + ", " + height + ")");
                return(null);
            }

            GameObject house = new GameObject("House (" + width + ", " + height + ")");

            {
                int sortOrder = LocationSortOrders.GetLocationObjectSortOrder(point.y * main.TileSize);

                GameObject walls = TiledSprite.Create(wallTiles);
                walls.GetComponent <TiledSprite> ()
                .SetTiles(width, height - 1)
                .SetTileSize(main.TileSize, main.TileSize)
                .SetSortOrder(sortOrder);
                walls.transform.SetParent(house.transform, true);

                GameObject roof = TiledSprite.Create(roofTiles);
                roof.GetComponent <TiledSprite> ()
                .SetTiles(width, 1)
                .SetTileSize(main.TileSize, main.TileSize)
                .SetSortOrder(sortOrder);
                roof.transform.SetParent(house.transform, true);
                roof.transform.localPosition = new Vector3(0, (height - 1) * main.TileSize, 0);

                GameObject shadow = TiledSprite.Create(shadowTiles);
                shadow.GetComponent <TiledSprite> ()
                .SetTiles(width, 1)
                .SetTileSize(main.TileSize, main.TileSize)
                .SetSortOrder(sortOrder + 1);
                shadow.transform.SetParent(house.transform, true);
                shadow.transform.localPosition = new Vector3(0, (height - 2) * main.TileSize, 0);

                GameObject grass = TiledSprite.Create(groundToWallTiles);
                grass.GetComponent <TiledSprite> ()
                .SetTiles(width, 1)
                .SetTileSize(main.TileSize, main.TileSize)
                .SetSortOrder(sortOrder + 1);
                grass.transform.SetParent(house.transform, true);
            }

            main.Tiles.SetRect(point.x, point.y, width, height, TileType.House, true);
            house.transform.localPosition = new Vector3(point.x * main.TileSize, point.y * main.TileSize);
            return(house);
        }
Ejemplo n.º 3
0
        public GameObject CreateGrass(Main main)
        {
            GameObject grass = TiledSprite.Create(tiles);

            grass.name = "Grass";

            grass.GetComponent <TiledSprite> ()
            .SetTiles(main.Tiles.Width, main.Tiles.Height)
            .SetTileSize(main.TileSize, main.TileSize)
            .SetSortOrder(LocationSortOrders.Grass)
            .ForceUpdate();

            return(grass);
        }
Ejemplo n.º 4
0
        public override void Update()
        {
            if (occupant != null)
            {
                // update occupant
                occupant.Update();

                // check for reaping
                if (occupant is TempSprite sprite && sprite.ShouldReap())
                {
                    occupant = null;
                }
            }
        }
Ejemplo n.º 5
0
        private void InitializeBackground()
        {
            TiledSprite borderBackground = new TiledSprite(LEVEL_WIDTH * ROOM_WIDTH * BLOCK_WIDTH * 2, LEVEL_HEIGHT * ROOM_HEIGHT * BLOCK_HEIGHT * 2);

            borderBackground.LoadTexture("level/borderTile");
            borderBackground.Position = new Vector2(-Controller.LevelBorderSize.X, -Controller.LevelBorderSize.Y);

            this.AddChild(borderBackground);

            TiledSprite levelBackground = new TiledSprite(LEVEL_WIDTH * ROOM_WIDTH * BLOCK_WIDTH, LEVEL_HEIGHT * ROOM_HEIGHT * BLOCK_HEIGHT);

            levelBackground.LoadTexture("level/levelTile");

            this.AddChild(levelBackground);
        }
Ejemplo n.º 6
0
        private GameObject CreateRoad(int startX, int startY, int roadWidth, bool vertical, Main main)
        {
            GameObject result = TiledSprite.Create(tiles);

            result.name = "Road (" + (vertical ? "vertical" : "horizontal") + " width " + roadWidth + ")";

            result.GetComponent <TiledSprite> ()
            .SetTiles(vertical ? roadWidth : main.Tiles.Width, vertical ? main.Tiles.Height : roadWidth)
            .SetTileSize(main.TileSize, main.TileSize)
            .SetSortOrder(LocationSortOrders.Roads)
            .ForceUpdate();

            result.transform.localPosition = new Vector3(startX * main.TileSize, startY * main.TileSize, 0);
            return(result);
        }
Ejemplo n.º 7
0
        private void GenerateSpritePalette()
        {
            _spritePalette = new List <TiledSprite>();

            foreach (var tile in TilePalette)
            {
                if (tile.TilesetName == "")
                {
                    continue;
                }
                if (TilesetManager.GetTileset(tile.TilesetName) != null)
                {
                    TiledSprite paletteSprite = new TiledSprite(TilesetManager.GetTileset(tile.TilesetName),
                                                                Vector2.Zero, new Vector2(4, 4), tile.TilesetIndex);
                    _spritePalette.Add(paletteSprite);
                }
            }

            _generatedPalette = true;
        }
Ejemplo n.º 8
0
        public override void Draw(SpriteBatch spriteBatch)
        {
            for (int i = 0; i < Map.MapTiles.Length; i++)
            {
                if (Tiles[Map.MapTiles[i]].TextureName == "")
                {
                    continue;
                }

                TiledSprite tmpSprite = _tiles[Map.MapTiles[i] - 1];
                tmpSprite.Position = new Vector2((i % Map.Size.X) * tmpSprite.TileWidth, (float)Math.Floor(i / Map.Size.X) * tmpSprite.TileHeight);
                tmpSprite.Rect     = new Rectangle(tmpSprite.Position.ToPoint(), new Point((int)tmpSprite.TileWidth, (int)tmpSprite.TileHeight));

                Rectangle sourceRect = new Rectangle((int)(tmpSprite.TileWidth / tmpSprite.Scale.X * (tmpSprite.TileIndex % tmpSprite.Columns)),
                                                     y: (int)(tmpSprite.TileHeight / tmpSprite.Scale.Y * (tmpSprite.TileIndex / tmpSprite.Columns)), width: (int)(tmpSprite.TileWidth / tmpSprite.Scale.X),
                                                     height: (int)(tmpSprite.TileHeight / tmpSprite.Scale.Y));

                spriteBatch.Draw(tmpSprite.Texture, tmpSprite.Rect, sourceRect, Color.White);
            }
            //spriteBatch.Draw();
        }
Ejemplo n.º 9
0
 public void PlaceExplosion(Player owner)
 {
     occupant = new Explosion(owner, this, Game);
 }
Ejemplo n.º 10
0
 public void PlaceBomb(Player owner)
 {
     occupant = new Bomb(owner, this, Game);
 }
Ejemplo n.º 11
0
 public void PlaceWall()
 {
     occupant = new Wall(this, Game);
 }
Ejemplo n.º 12
0
        /// <summary>
        /// Loads the content.
        /// </summary>
        protected override void LoadContent()
        {
            this.consoleFont = this.Content.Load <SpriteFont>("Content\\LucidaConsole");

            // Create Tiled Sprites
            RectangleF bounds = this.RenderSystem.GetCameraRenderBounds();

            this.background = new TiledSprite(this.GameWorld, "Content/floortile", "Content/floortilenormal", null, bounds.Position, Vector2.Zero, bounds.AreaBounds)
            {
                RenderScale   = new Vector2(0.4f, 0.4f),
                RenderOptions = SpriteRenderOptions.IsLit
            };

            SimpleSprite test = new SimpleSprite(this.GameWorld, "Content/box", null, false)
            {
                Position             = new Vector2(8, 7),
                RenderScale          = new Vector2(0.4f, 0.4f),
                RenderOptions        = SpriteRenderOptions.CastsShadows | SpriteRenderOptions.IsLit,
                SpecularReflectivity = 0,
                LayerDepth           = 1
            };

            test.Body.BodyType            = FarseerPhysics.Dynamics.BodyType.Static;
            test.Body.CollisionCategories = FarseerPhysics.Dynamics.Category.Cat1;
            test.Body.Friction            = 0;
            test.Body.Restitution         = 1.0f;

            if (this.IsDebug)
            {
                var x = new DebugSprite(this.GameWorld, test);
            }

            SimpleSprite test2 = new SimpleSprite(this.GameWorld, "Content/box", null, false)
            {
                Position             = new Vector2(10, 8),
                Rotation             = -MathHelper.PiOver2,
                RenderScale          = new Vector2(0.4f, 0.4f),
                RenderOptions        = SpriteRenderOptions.CastsShadows | SpriteRenderOptions.IsLit,
                SpecularReflectivity = 0,
                LayerDepth           = 2
            };

            test2.Body.BodyType            = FarseerPhysics.Dynamics.BodyType.Static;
            test2.Body.CollisionCategories = FarseerPhysics.Dynamics.Category.Cat1;
            test2.Body.Friction            = 0;
            test2.Body.Restitution         = 1.0f;

            if (this.IsDebug)
            {
                var x = new DebugSprite(this.GameWorld, test2);
            }

            SimpleSprite test3 = new SimpleSprite(this.GameWorld, "Content/gear", null, true)
            {
                Position             = new Vector2(20, 8),
                Rotation             = -MathHelper.PiOver2,
                RenderScale          = new Vector2(0.4f, 0.4f),
                RenderOptions        = SpriteRenderOptions.CastsShadows | SpriteRenderOptions.IsLit,
                SpecularReflectivity = 0,
                LayerDepth           = 2
            };

            test3.Body.BodyType            = FarseerPhysics.Dynamics.BodyType.Static;
            test3.Body.CollisionCategories = FarseerPhysics.Dynamics.Category.Cat1;
            test3.Body.Friction            = 0;
            test3.Body.Restitution         = 1.0f;

            if (this.IsDebug)
            {
                var x = new DebugSprite(this.GameWorld, test3);
            }

            this.amLight = new AmbientLight(Color.White, 0.02f, true, 1);
            this.RenderSystem.AddPostProcessEffect(this.amLight);

            mouseLight = new PointLight(this.GameWorld)
            {
                Color                 = Color.White,
                Power                 = 1f,
                Range                 = 8,
                SpecularStrength      = 4.75f,
                CastsShadows          = true,
                MinShadowBlurDistance = .5f,
                MaxShadowBlurDistance = 1.5f
            };
            lightCount++;

            if (this.IsDebug)
            {
                DebugSimulatedPostProcess y = new DebugSimulatedPostProcess(this.GameWorld, mouseLight);
            }

            this.RenderSystem.AddPostProcessEffect(mouseLight);

            // https://www.youtube.com/watch?v=BExTagcymo0
            // George Ellinas - Pulse (George Ellinas Remix) (Free - Creative Commons MP3)
            // http://creativecommons.org/licenses/by/3.0/
            this.song          = Content.Load <Song>("Content/George_Ellinas_-_Pulse_(George_Ellinas_remix)_LoopEdit");
            MediaPlayer.Volume = 0.1f;
            MediaPlayer.Play(song);


            base.LoadContent();
        }
Ejemplo n.º 13
0
        public GameState()
        {
            this.BigText = new Label("Player 1 is out", Controller.FontController.GetFont("bigFont"));
            this.BigText.HorizontalAlign = HorizontalAlign.CENTER;
            this.BigText.Visable         = false;
            this.BigText.Width           = 1800;
            this.BigText.Height          = 1000;

            Controller.LayerController.AddLayer("bombLayer");
            FatBomb.state      = this;
            Vetbol.state       = this;
            CapturePoint.state = this;
            TiledSprite bg = new TiledSprite(2000, 2000);

            bg.LoadTexture("background");
            bg.Depth = 0f;

            tilemap = new Tilemap();
            tilemap.LoadMap("Content/testmap.tmx", 32, 32);
            this.AddChild(bg);
            this.AddChild(tilemap);

            this.players = new List <Vetbol>();

            playerSpawn = tilemap.RemoveTiles(7);
            int playerRespawn = rnd.Next(playerSpawn.Count);

            List <Tile> capturePointTiles = tilemap.RemoveTiles(3);

            foreach (Tile tile in capturePointTiles)
            {
                CapturePoint capturepoint = new CapturePoint();
                capturepoint.Position = tile.Position + (new Vector2(-27, -61));
                capturePoints.Add(capturepoint);
                AddChild(capturepoint);
            }

            NotUsedSpawnPoints = new List <Tile>();
            NotUsedSpawnPoints.AddRange(playerSpawn);


            for (int i = 0; i < Controller.Input.getPadStateList.Where(c => c.IsConnected).Count(); i++)
            {
                this.players.Add(new Vetbol((PlayerIndex)i));
            }

            for (int j = 0; j < players.Count; j++)
            {
                this.players[j].score    = playerStartScore;
                this.players[j].Position = this.getAvailablePosition();
                this.AddChild(this.players[j]);
            }
            lastPlayerAlive = players[0];

            this.BombPool = new Pool <FatBomb>(50, false, FatBomb.IsValid, this.NewBomb);

            soundEffectBomb = Controller.Content.Load <SoundEffect>("sounds/explode");

            this.AddChild(this.BigText);

            this.hud = new HUD(this.players, respawnTime);
            this.AddChild(hud);

            deadSound = Controller.Content.Load <SoundEffect>("sounds/dead");
            ECGsound  = Controller.Content.Load <SoundEffect>("sounds/ecg");
        }
Ejemplo n.º 14
0
        public override void Load()
        {
            bump_sfx = Content.Get <Effect>("menu");

            size = Game.ScreenSize;

            background = new TiledSprite(Content.Get <Texture2D>("bg3"), size.W, size.H);
            background.SetScrollSpeed(0.02f, 0.02f);

            sprite = new Sprite(Content.Get <Texture2D>("particles"), 96, 64, 32, 32);

            tweenedSprite = new Sprite(Content.Get <Texture2D>("zazaka"));

            tweenedValue = new RangedValue(50, 300);

            tweener = new Tweener();

            tweener
            .Tween(0, tweenedValue, 50)
            .Easing(EasingFunctions.QuadraticInOut)
            .RepeatForever()
            .AutoReverse();


            sprite.SetColor(Color.Red);
            sprite.SetOrigin(0.5f, 0.5f);

            timer = new Timer();

            animated_sprite = new MultiframeSprite(
                TextureAtlas.FromGrid(
                    Content.Get <Texture2D>("spritesheet"), 4, 4
                    )
                );

            timer.Every(16, () => animated_sprite.SetColor(RandomEx.NextColor()));

            animated_sprite.SetFrameSpeed(5);

            animated_sprite
            .AddAnimation(
                "idle_up",
                0
                )
            .AddAnimation(
                "idle_horiz",

                4
                )
            .AddAnimation(
                "idle_down",
                8
                )
            .AddAnimation(
                "walk_up",
                0, 1, 2, 3
                )
            .AddAnimation(
                "walk_horiz",
                4, 5, 6, 7
                )
            .AddAnimation(
                "walk_down",
                8, 9, 10, 11
                )
            .SetAnimation("idle_horiz");


            _trail = new ParticleEmitter(
                new Sprite(Content.Get <Texture2D>("particles"), 0, 0, 32, 32),
                new ParticleEmitterProps
            {
                MaxParticles                = 500,
                Emission                    = 500,
                ImmediateFullEmission       = false,
                LifeTime                    = -1,
                Relative                    = true,
                ParticleLife                = new Range <float>(0.5f, 1.0f),
                InitialPositionDisplacement = new Range <Vector2>(new Vector2(-10, -10), new Vector2(10, 10)),
                Direction                   = 0,
                StartColor                  = Color.Cyan,
                EndColor                    = Color.Fuchsia,
                StartOpacity                = 1.0f,
                EndOpacity                  = 0.0f,
                StartScale                  = new Range <float>(1.0f, 2.0f),
                EndScale                    = 0.5f,
                Speed           = new Range <float>(20.0f, 100.0f),
                Spread          = 0.1f,
                Gravity         = 100.0f,
                SpinSpeed       = 10.0f,
                RadialAccel     = 20.0f,
                TangentialAccel = 30.0f
            });

            _explosion = new ParticleEmitter(
                new Sprite(Content.Get <Texture2D>("particles"), 0, 64, 32, 32),
                new ParticleEmitterProps
            {
                MaxParticles                = 1000,
                Emission                    = 200,
                ImmediateFullEmission       = true,
                LifeTime                    = 0.2f,
                Relative                    = false,
                ParticleLife                = new Range <float>(0.2f, 0.5f),
                InitialPositionDisplacement = new Range <Vector2>(new Vector2(-10, -10), new Vector2(10, 10)),
                Direction                   = 0,
                Spread          = Calc.TWO_PI,
                StartColor      = Color.Red,
                EndColor        = Color.Gray,
                StartOpacity    = 1.0f,
                EndOpacity      = 0.0f,
                StartScale      = 1.0f,
                EndScale        = 0.5f,
                Speed           = new Range <float>(100.0f, 150.0f),
                Gravity         = 500.0f,
                SpinSpeed       = 50.0f,
                RadialAccel     = 50.0f,
                TangentialAccel = 50.0f
            }
                );

            _trail.FireAt(particle_x, particle_y);
        }
Ejemplo n.º 15
0
 public override void LoadContent(ContentManager contentManager)
 {
     _cursorTile  = new TiledSprite(TilesetManager.GetTileset(_tilesetName), Vector2.Zero, _spriteScale, _tilesetIndex);
     _tilesetTile = new TiledSprite(TilesetManager.GetTileset(_tilesetName), Vector2.Zero, _spriteScale, _tilesetIndex);
 }