示例#1
0
 /// <summary>
 /// The terrain was clicked.
 /// </summary>
 /// <param name="button">The mouse button.</param>
 /// <param name="clickLocation">Location on the grid that was clicked.</param>
 public void ClickedTerrain(TerrainClickedArgs args)
 {
     foreach (var controller in _currentStateControllers)
     {
         controller.TerrainClicked(args);
     }
 }
示例#2
0
        /// <summary>
        /// Event handler for clicks on the terrain.
        /// </summary>
        /// <param name="sender">not used.</param>
        /// <param name="args">The terrain click arguments.</param>
        private void Build(object sender, TerrainClickedArgs args)
        {
            if (args.Button == MouseButton.Left)
            {
                var validTerrain = GetValidTerrainUnderMouse();
                var footprint    = _building.Footprint;

                bool isValid = true;
                for (int x = 0; x < footprint.GetLength(0); ++x)
                {
                    for (int z = 0; z < footprint.GetLength(1); ++z)
                    {
                        if (footprint[x, z] && !validTerrain[x, z])
                        {
                            isValid = false;
                        }
                    }
                }

                if (isValid)
                {
                    Game.Campus.Buildings.Build(_building, args.ClickLocation);
                    SelectionManager.UpdateSelection(SelectionManager.Selected.ToMainMenu());
                }
            }
        }
 public void TerrainClicked(TerrainClickedArgs args)
 {
     if (OnTerrainClicked != null)
     {
         OnTerrainClicked.Invoke(null, args);
     }
 }
示例#4
0
 /// <summary>
 /// Handle a click event on the terrain.
 /// </summary>
 /// <param name="sender">Not used.</param>
 /// <param name="args">The terrain click arguments.</param>
 private void Clicked(object sender, TerrainClickedArgs args)
 {
     if (args.Button == MouseButton.Right)
     {
         // Cancel placing path.
         Transition(GameState.SelectingPath);
     }
 }
        /// <summary>
        /// Handle a click event on the terrain.
        /// </summary>
        /// <param name="sender">Not used.</param>
        /// <param name="args">The terrain click arguments.</param>
        private void Clicked(object sender, TerrainClickedArgs args)
        {
            if (args.Button == MouseButton.Left)
            {
                if (IsValidTerrain())
                {
                    Transition(GameState.PlacingPath, args);
                }
            }

            // DEBUGGING:
            if (args.Button == MouseButton.Right)
            {
                GameLogger.Info("IsValidTerrain: {0}; IsSmoothAndFree: {1}; IsPath: {2}",
                                IsValidTerrain(),
                                _terrain.Editor.CheckSmoothAndFree(_cursor.Position.x, _cursor.Position.y, _cursor.Position.x, _cursor.Position.y)[0],
                                Game.Campus.Paths.IsPath(_cursor.Position.x, _cursor.Position.y));
            }
        }
        /// <summary>
        /// Handle a click event on the terrain.
        /// </summary>
        /// <param name="sender">Not used.</param>
        /// <param name="args">The terrain click arguments.</param>
        private void Clicked(object sender, TerrainClickedArgs args)
        {
            if (args.Button == MouseButton.Left)
            {
                Transition(GameState.EditingTerrain, args);
            }

            if (Application.isEditor)
            {
                GameLogger.Info("Selected ({0}); Point Heights ({1}, {2}, {3}, {4})",
                                args.ClickLocation,
                                _terrain.GetVertexHeight(args.ClickLocation.x, args.ClickLocation.z),
                                _terrain.GetVertexHeight(args.ClickLocation.x + 1, args.ClickLocation.z),
                                _terrain.GetVertexHeight(args.ClickLocation.x, args.ClickLocation.z + 1),
                                _terrain.GetVertexHeight(args.ClickLocation.x + 1, args.ClickLocation.z + 1));

                if (Input.GetKey(KeyCode.LeftControl))
                {
                    int submaterial = _terrain.GetSubmaterial(args.ClickLocation.x, args.ClickLocation.z);
                    _terrain.SetSubmaterial(args.ClickLocation.x, args.ClickLocation.z, (submaterial + 1) % _terrain.SubmaterialCount, Rotation.deg270);
                }
            }
        }