示例#1
0
        public override void Initialize()
        {
            // Load background
            ResourcesService resources = game.services.Get <ResourcesService>(ServicesDefinition.Resources);

            title    = resources.Load <SpriteFont>(Constants.fontTitle);
            overview = resources.Load <Texture2D>(Constants.textureOverview);

            // Listen to mouse events
            ControlsGameplayManager gpControls = game.gameplays.Get <ControlsGameplayManager>(GameplaysDefinition.Controls);

            gpControls.OnMouseMove  += new ControlsGameplayManager.OnMouseMoveDelegate(OnMouseMove);
            gpControls.OnMouseClick += new ControlsGameplayManager.OnMouseClickDelegate(OnMouseClick);

            // Register the overview actions
            BackgroundGameplayManager gpBackground = game.gameplays.Get <BackgroundGameplayManager>(GameplaysDefinition.Background);
            InteractiveObject         viewTop      = new InteractiveObject();

            viewTop.ActivationZone = new Rectangle(10, (int)(0.5f * (Constants.windowHeight - 0.4f * overview.Height)), (int)(overview.Width * 0.4f), (int)(overview.Height * 0.133f));
            viewTop.OnAction      += () => { gpBackground.BackgroundMode = BackgroundMode.Aerial; };
            interactives.Add(viewTop);

            InteractiveObject viewOverview = new InteractiveObject();

            viewOverview.ActivationZone = new Rectangle(viewTop.ActivationZone.X, viewTop.ActivationZone.Y + viewTop.ActivationZone.Height, viewTop.ActivationZone.Width, viewTop.ActivationZone.Height);
            viewOverview.OnAction      += () => { gpBackground.BackgroundMode = BackgroundMode.Overview; };
            interactives.Add(viewOverview);

            InteractiveObject viewBottom = new InteractiveObject();

            viewBottom.ActivationZone = new Rectangle(viewTop.ActivationZone.X, viewOverview.ActivationZone.Y + viewTop.ActivationZone.Height, viewTop.ActivationZone.Width, viewTop.ActivationZone.Height);
            viewBottom.OnAction      += () => { gpBackground.BackgroundMode = BackgroundMode.Underground; };
            interactives.Add(viewBottom);
        }
        public override void Initialize()
        {
            // Load background
            ResourcesService resources = game.services.Get <ResourcesService>(ServicesDefinition.Resources);

            forest = resources.Load <Texture2D>(Constants.textureForest);
            ground = resources.Load <Texture2D>(Constants.textureGround);
            grass  = resources.Load <Texture2D>(Constants.textureGrass);
            water  = resources.Load <Texture2D>(Constants.textureWater);
        }
示例#3
0
        public override void Initialize()
        {
            // Bind the rendering callbacks
            treeGenerator.onExecute += new Generator.OnExecuteDelegate(this.OnDrawBranch);

            // First generation
            Generate();

            // Load texture
            ResourcesService resources = game.services.Get <ResourcesService>(ServicesDefinition.Resources);

            leaf   = resources.Load <Texture2D>(Constants.textureLeaf);
            branch = resources.Load <Texture2D>(Constants.textureBranch);
            cell   = resources.Load <Texture2D>(Constants.textureCell);
        }
示例#4
0
        protected void DrawRoot(UndergroundCell cell, Direction direction)
        {
            // Get the objects we need for the rendering
            ResourcesService          resources    = game.services.Get <ResourcesService>(ServicesDefinition.Resources);
            BackgroundGameplayManager gpBackground = game.gameplays.Get <BackgroundGameplayManager>(GameplaysDefinition.Background);

            // Draw the child root
            {
                // Get the texture matching the cell
                Texture2D tex = resources.Load <Texture2D>($"textures/roots/root-in-{cell.Size}");

                // Get the center of the rendering
                Vector2 center   = new Vector2(0.5f * tex.Width, 0.5f * tex.Height);
                Vector2 offset   = new Vector2(0.5f * (Constants.windowHeight * Constants.windowRatio), (float)(gpBackground.GroundLevel + 0.433f * Constants.cellWidth));
                Vector2 position = undergroundGrid.GetPosition(cell.X, cell.Y, offset, Constants.cellWidth);
                float   rotation = undergroundGrid.GetAngle(direction);

                // Render the root
                spriteBatch.Draw(tex, position, null, Color.White, rotation, center, (float)Constants.cellWidth / (float)tex.Width, SpriteEffects.None, 0f);
            }

            // Draw the parent root
            {
                // Get the texture matching the cell
                Texture2D tex = resources.Load <Texture2D>($"textures/roots/root-out-{cell.Size}");

                // Get the parent cell
                UndergroundCell  parent      = null;
                Tuple <int, int> coordinates = undergroundGrid.GetNeighbourCoordinates(cell, undergroundGrid.GetOppositeDirection(direction));
                if (undergroundGrid.IsCellCreated(coordinates.Item1, coordinates.Item2))
                {
                    parent = undergroundGrid[coordinates.Item1, coordinates.Item2];
                }
                if (parent != null)
                {
                    // Get the center of the rendering
                    Vector2 center   = new Vector2(0.5f * tex.Width, 0.5f * tex.Height);
                    Vector2 offset   = new Vector2(0.5f * (Constants.windowHeight * Constants.windowRatio), (float)(gpBackground.GroundLevel + 0.433f * Constants.cellWidth));
                    Vector2 position = undergroundGrid.GetPosition(parent.X, parent.Y, offset, Constants.cellWidth);
                    float   rotation = undergroundGrid.GetAngle(undergroundGrid.GetOppositeDirection(direction));

                    // Render the root
                    spriteBatch.Draw(tex, position, null, Color.White, rotation, center, (float)Constants.cellWidth / (float)tex.Width, SpriteEffects.None, 0f);

                    Console.WriteLine($"Draw parent {coordinates.Item1},{coordinates.Item2} with size {cell.Size}");
                }
            }
        }
示例#5
0
        public override void Initialize()
        {
            // Load sound effect
            ResourcesService resources = game.services.Get <ResourcesService>(ServicesDefinition.Resources);

            windSound          = resources.Load <SoundEffect>(Constants.soundWind).CreateInstance();
            windSound.IsLooped = true;
            windSound.Volume   = intensity;
            windSound.Play();
        }
示例#6
0
        public override void Initialize()
        {
            // Load music
            ResourcesService resources  = game.services.Get <ResourcesService>(ServicesDefinition.Resources);
            Song             background = resources.Load <Song>(Constants.musicForest);

            // Play music in loop
            MediaPlayer.Volume      = 0.4f;
            MediaPlayer.IsRepeating = true;
            MediaPlayer.Play(background);
        }