public void RecalcPlayerPos() { Vector3 player_pos = standingFloor.transform.position; Vector3 angle = transform.rotation.eulerAngles; transform.rotation = Quaternion.Euler(Mathf.Round(angle.x), Mathf.Round(angle.y), Mathf.Round(angle.z)); updown = 0; if (standingFloor.name[0] == 'S') { SlopeType type = GetSlopeType(standingFloor, transform.forward); if (type == SlopeType.slope_up) { updown = 1; } else if (type == SlopeType.slope_down) { updown = -1; } } player_pos += transform.up; if (updown != 0) { player_pos -= transform.up * 0.5f; } transform.position = player_pos; RecalcPlayerZ(); // player_pos = transform.position; // transform.position = new Vector3 (Mathf.Round (player_pos.x), Mathf.Round (player_pos.y), Mathf.Round (player_pos.z)); }
private void UpdateSettings(object sender, EventArgs e) { SlopeType type = SlopeType.None; switch (_slopeTypePicker.SelectedSegment) { case 0: type = SlopeType.Degree; break; case 1: type = SlopeType.PercentRise; break; case 2: type = SlopeType.Scaled; break; } HillshadeRenderer renderer = new HillshadeRenderer( altitude: _altitudeSlider.Value, azimuth: _azimuthSlider.Value, zfactor: 1, slopeType: type, pixelSizeFactor: 1, pixelSizePower: 1, nbits: 8); _rasterLayer.Renderer = renderer; }
void MoveTo(GameObject obj, Vector3 dir) { updown = 0; if (standingFloor.name[0] == 'S') { SlopeType type = GetSlopeType(standingFloor, dir); if (type == SlopeType.slope_up) { updown = 1; } else if (type == SlopeType.slope_down) { updown = -1; } else if (type == SlopeType.half) { return; } } transform.rotation = Quaternion.LookRotation(dir, transform.up); moveDest = obj.transform.position; moveDest += transform.up; destFloor = obj; moving = 1; float maxZ = CalcMaxZ(FloorFunc(destFloor.transform.position)); if (maxZ > PlayerFloorValue().z) { ChangeZ(maxZ); } }
/// <summary> /// Pass-through constructor /// </summary> /// <param name="rInput"></param> /// <param name="rOutputRaster"></param> /// <param name="theType"></param> public Slope(Raster rInput, Raster rOutputRaster, SlopeType theType) : base(new List <Raster> { rInput }, 1, new List <Raster>() { rOutputRaster }) { _slopetype = theType; cellWidth = (double)Math.Abs(OpExtent.CellWidth); cellHeight = (double)Math.Abs(OpExtent.CellHeight); }
public static bool IsTopSlope(this Tile tile) { SlopeType slope = tile.Slope; if (!tile.IsHalfBlock) { return(slope == SlopeType.SlopeDownRight); } return(true); }
private void ApplyHillshadeButton_Click(object sender, Microsoft.UI.Xaml.RoutedEventArgs e) { // Get the current parameter values double altitude = AltitudeSlider.Value; double azimuth = AzimuthSlider.Value; SlopeType typeOfSlope = Enum.Parse <SlopeType>(SlopeTypeCombo.SelectedItem as string); // Create a hillshade renderer that uses the values selected by the user HillshadeRenderer hillshadeRenderer = new HillshadeRenderer(altitude, azimuth, ZFactor, typeOfSlope, PixelSizeFactor, PixelSizePower, PixelBitDepth); // Apply the new renderer to the raster layer _rasterLayer.Renderer = hillshadeRenderer; }
private void ApplyHillshadeButton_Click(object sender, EventArgs e) { // Get the current parameter values double altitude = AltitudeSlider.Value; double azimuth = AzimuthSlider.Value; SlopeType typeOfSlope = _slopeTypeValues[SlopeTypePicker.SelectedItem.ToString()]; // Create a hillshade renderer that uses the values selected by the user HillshadeRenderer hillshadeRenderer = new HillshadeRenderer(altitude, azimuth, ZFactor, typeOfSlope, PixelSizeFactor, PixelSizePower, PixelBitDepth); // Apply the new renderer to the raster layer _rasterLayer.Renderer = hillshadeRenderer; }
public LineDef( Vertex vertex1, Vertex vertex2, LineFlags flags, LineSpecial special, short tag, SideDef side0, SideDef side1) { Vertex1 = vertex1; Vertex2 = vertex2; Flags = flags; Special = special; Tag = tag; Side0 = side0; Side1 = side1; Dx = vertex2.X - vertex1.X; Dy = vertex2.Y - vertex1.Y; if (Dx == Fixed.Zero) { SlopeType = SlopeType.Vertical; } else if (Dy == Fixed.Zero) { SlopeType = SlopeType.Horizontal; } else { if (Dy / Dx > Fixed.Zero) { SlopeType = SlopeType.Positive; } else { SlopeType = SlopeType.Negative; } } Box = new Fixed[4]; Box[ManagedDoom.Box.Top] = Fixed.Max(vertex1.Y, vertex2.Y); Box[ManagedDoom.Box.Bottom] = Fixed.Min(vertex1.Y, vertex2.Y); Box[ManagedDoom.Box.Left] = Fixed.Min(vertex1.X, vertex2.X); Box[ManagedDoom.Box.Right] = Fixed.Max(vertex1.X, vertex2.X); FrontSector = side0?.Sector; BackSector = side1?.Sector; }
public LineDef( Vertex vertex1, Vertex vertex2, LineFlags flags, LineSpecial special, short tag, SideDef frontSide, SideDef backSide) { this.vertex1 = vertex1; this.vertex2 = vertex2; this.flags = flags; this.special = special; this.tag = tag; this.frontSide = frontSide; this.backSide = backSide; dx = vertex2.X - vertex1.X; dy = vertex2.Y - vertex1.Y; if (dx == Fixed.Zero) { slopeType = SlopeType.Vertical; } else if (dy == Fixed.Zero) { slopeType = SlopeType.Horizontal; } else { if (dy / dx > Fixed.Zero) { slopeType = SlopeType.Positive; } else { slopeType = SlopeType.Negative; } } boundingBox = new Fixed[4]; boundingBox[Box.Top] = Fixed.Max(vertex1.Y, vertex2.Y); boundingBox[Box.Bottom] = Fixed.Min(vertex1.Y, vertex2.Y); boundingBox[Box.Left] = Fixed.Min(vertex1.X, vertex2.X); boundingBox[Box.Right] = Fixed.Max(vertex1.X, vertex2.X); frontSector = frontSide?.Sector; backSector = backSide?.Sector; }
void checkCollision() { Collider2D c = Physics2D.OverlapPoint(transform.position, Alias.LAYERMASK_TILEMAP | Alias.LAYERMASK_BREAKABLE_SURFACE); if (c != null) { if (c.gameObject.layer == Alias.LAYER_TILEMAP || c.gameObject.layer == Alias.LAYER_BREAKABLE_SURFACE) { isCollTile = true; //check for slope switch (c.tag) { case "TileMapSoftSlopeL": slopeColl = SlopeType.softLeft; break; case "TileMapSoftSlopeR": slopeColl = SlopeType.softRight; break; case "TileMapHardSlopeL": slopeColl = SlopeType.hardLeft; break; case "TileMapHardSlopeR": slopeColl = SlopeType.hardRight; break; default: slopeColl = SlopeType.none; break; } } else { isCollTile = false; slopeColl = SlopeType.none; } } else { isCollTile = false; slopeColl = SlopeType.none; } }
private void InputHillshadeParamsButton_Click(object sender, EventArgs e) { // Fire the OnHillshadeInputsEntered event and provide the hillshade renderer. if (OnHillshadeInputsEntered != null) { // Read the inputs provided by the user. // - Altitude and azimuth. double altitude = _altitudeSlider.Value; double azimuth = _azimuthSlider.Value; // - Get the model from the slope type picker and read the selected type. nint selected = _slopeTypePicker.SelectedSegment; SlopeType selectedSlopeType = ((SlopeType[])Enum.GetValues(typeof(SlopeType)))[selected]; // Create a new HillshadeRenderer using the input values and constants. HillshadeRenderer hillshade = new HillshadeRenderer(altitude, azimuth, ZFactor, selectedSlopeType, PixelSizeFactor, PixelSizePower, PixelBitDepth); // Create a new HillshadeParametersEventArgs and provide the new renderer. HillshadeParametersEventArgs inputParamsEventArgs = new HillshadeParametersEventArgs(hillshade); // Raise the event with the custom arguments. OnHillshadeInputsEntered(sender, inputParamsEventArgs); } }
public LevelPlane(Project2Game game, Level level, Vector3 position, SlopeType slopeType, float slopeHeight = 16f, int xSize = Level.PreferedTileWidth, int ySize = Level.PreferedTileHeight) : base (game, level, position) { this.xSize = xSize; this.ySize = ySize; // this should be z size for consistency in 3D float frontHeight = 0f; float backHeight = 0f; if (slopeType == SlopeType.SlopeUp) { backHeight = slopeHeight; } if (slopeType == SlopeType.SlopeDown) { frontHeight = slopeHeight; } // calculate the angle of gradient var angle = (float)Math.Atan2(backHeight - frontHeight, xSize - 0); //y_2 - y_2 / x_2 - x_1 = gradient var separation = xSize; // disatance between walls (default to tile width) var wallWidth = 2.0f; // width of wall var wallHeight = 4.0f; // height of wall // vertical displacement of wall, offset so it sits on the ground var heightDisplacement = Math.Abs((backHeight - frontHeight)/2.0f) + wallHeight / 2.0f; // instantiate a wall for either side of the plane var box1 = new Box(game, game.models["box"], position + new Vector3(0f, heightDisplacement, ySize / 2.0f), new Vector3(wallWidth, wallHeight, ySize), new Vector3(0, -angle, 0)); var box2 = new Box(game, game.models["box"], position + new Vector3(separation, heightDisplacement, ySize / 2.0f), new Vector3(wallWidth, wallHeight, ySize), new Vector3(0, -angle, 0)); box1.PhysicsDescription.IsStatic = true; box2.PhysicsDescription.IsStatic = true; AddChild(box1); AddChild(box2); if (slopeType == SlopeType.Flat) { //this.physicsPuzzles.Add(new PhysicsPuzzles.SeeSaw(game, this, new Vector3(32, 0, 32))); } // add floor var floor = new FlatTerrain(game, position, (float)xSize, (float)ySize, frontHeight, backHeight); floor.PhysicsDescription.IsStatic = true; AddChild(floor); }
private void OnUpdateRendererClicked(object sender, RoutedEventArgs e) { // Define the RasterLayer that will be used to display in the map RasterLayer rasterLayer_ForDisplayInMap; // Define the ColorRamp that will be used by the BlendRenderer ColorRamp myColorRamp; // Based on ColorRamp type chosen by the user, create a different // RasterLayer and define the appropriate ColorRamp option if (ColorRamps.SelectedValue.ToString() == "None") { // The user chose not to use a specific ColorRamp, therefore // need to create a RasterLayer based on general imagery (ie. Shasta.tif) // for display in the map and use null for the ColorRamp as one of the // parameters in the BlendRenderer constructor // Load the raster file using a path on disk Raster raster_Imagery = new Raster(GetRasterPath_Imagery()); // Create the raster layer from the raster rasterLayer_ForDisplayInMap = new RasterLayer(raster_Imagery); // Set up the ColorRamp as being null myColorRamp = null; } else { // The user chose a specific ColorRamp (options: are Elevation, DemScreen, DemLight), // therefore create a RasterLayer based on an imagery with elevation // (ie. Shasta_Elevation.tif) for display in the map. Also create a ColorRamp // based on the user choice, translated into an Enumeration, as one of the parameters // in the BlendRenderer constructor // Load the raster file using a path on disk Raster raster_Elevation = new Raster(GetRasterPath_Elevation()); // Create the raster layer from the raster rasterLayer_ForDisplayInMap = new RasterLayer(raster_Elevation); // Create a ColorRamp based on the user choice, translated into an Enumeration PresetColorRampType myPresetColorRampType = (PresetColorRampType)Enum.Parse(typeof(PresetColorRampType), ColorRamps.SelectedValue.ToString()); myColorRamp = ColorRamp.Create(myPresetColorRampType, 256); } // Define the parameters used by the BlendRenderer constructor Raster raster_ForMakingBlendRenderer = new Raster(GetRasterPath_Elevation()); IEnumerable <double> myOutputMinValues = new List <double> { 9 }; IEnumerable <double> myOutputMaxValues = new List <double> { 255 }; IEnumerable <double> mySourceMinValues = new List <double>(); IEnumerable <double> mySourceMaxValues = new List <double>(); IEnumerable <double> myNoDataValues = new List <double>(); IEnumerable <double> myGammas = new List <double>(); SlopeType mySlopeType = (SlopeType)Enum.Parse(typeof(SlopeType), SlopeTypes.SelectedValue.ToString()); BlendRenderer myBlendRenderer = new BlendRenderer( raster_ForMakingBlendRenderer, // elevationRaster - Raster based on a elevation source myOutputMinValues, // outputMinValues - Output stretch values, one for each band myOutputMaxValues, // outputMaxValues - Output stretch values, one for each band mySourceMinValues, // sourceMinValues - Input stretch values, one for each band mySourceMaxValues, // sourceMaxValues - Input stretch values, one for each band myNoDataValues, // noDataValues - NoData values, one for each band myGammas, // gammas - Gamma adjustment myColorRamp, // colorRamp - ColorRamp object to use, could be null Altitude_Slider.Value, // altitude - Altitude angle of the light source Azimuth_Slider.Value, // azimuth - Azimuth angle of the light source, measured clockwise from north 1, // zfactor - Factor to convert z unit to x,y units, default is 1 mySlopeType, // slopeType - Slope Type 1, // pixelSizeFactor - Pixel size factor, default is 1 1, // pixelSizePower - Pixel size power value, default is 1 8); // outputBitDepth - Output bit depth, default is 8-bi // Set the RasterLayer.Renderer to be the BlendRenderer rasterLayer_ForDisplayInMap.Renderer = myBlendRenderer; // Set the new base map to be the RasterLayer with the BlendRenderer applied MyMapView.Map.Basemap = new Basemap(rasterLayer_ForDisplayInMap); }
private void UpdateRendererButton_Clicked(object sender, EventArgs e) { try { // Define the RasterLayer that will be used to display in the map. RasterLayer rasterLayerForDisplayInMap; // Define the ColorRamp that will be used by the BlendRenderer. ColorRamp colorRamp; // Get the user choice for the ColorRamps. string selection = Enum.GetNames(typeof(PresetColorRampType))[_colorRampsPicker.SelectedSegment]; // Based on ColorRamp type chosen by the user, create a different // RasterLayer and define the appropriate ColorRamp option. if (selection == "None") { // The user chose not to use a specific ColorRamp, therefore // need to create a RasterLayer based on general imagery (i.e. Shasta.tif) // for display in the map and use null for the ColorRamp as one of the // parameters in the BlendRenderer constructor. // Load the raster file using a path on disk. Raster rasterImagery = new Raster(DataManager.GetDataFolder("7c4c679ab06a4df19dc497f577f111bd", "raster-file", "Shasta.tif")); // Create the raster layer from the raster. rasterLayerForDisplayInMap = new RasterLayer(rasterImagery); // Set up the ColorRamp as being null. colorRamp = null; } else { // The user chose a specific ColorRamp (options: are Elevation, DemScreen, DemLight), // therefore create a RasterLayer based on an imagery with elevation // (i.e. Shasta_Elevation.tif) for display in the map. Also create a ColorRamp // based on the user choice, translated into an Enumeration, as one of the parameters // in the BlendRenderer constructor. // Load the raster file using a path on disk. Raster rasterElevation = new Raster(DataManager.GetDataFolder("caeef9aa78534760b07158bb8e068462", "Shasta_Elevation.tif")); // Create the raster layer from the raster. rasterLayerForDisplayInMap = new RasterLayer(rasterElevation); // Create a ColorRamp based on the user choice, translated into an Enumeration. PresetColorRampType myPresetColorRampType = (PresetColorRampType)Enum.Parse(typeof(PresetColorRampType), selection); colorRamp = ColorRamp.Create(myPresetColorRampType, 256); } // Define the parameters used by the BlendRenderer constructor. Raster rasterForMakingBlendRenderer = new Raster(DataManager.GetDataFolder("caeef9aa78534760b07158bb8e068462", "Shasta_Elevation.tif")); IEnumerable <double> myOutputMinValues = new List <double> { 9 }; IEnumerable <double> myOutputMaxValues = new List <double> { 255 }; IEnumerable <double> mySourceMinValues = new List <double>(); IEnumerable <double> mySourceMaxValues = new List <double>(); IEnumerable <double> myNoDataValues = new List <double>(); IEnumerable <double> myGammas = new List <double>(); // Get the user choice for the SlopeType. string slopeSelection = Enum.GetNames(typeof(SlopeType))[_slopeTypesPicker.SelectedSegment]; SlopeType mySlopeType = (SlopeType)Enum.Parse(typeof(SlopeType), slopeSelection); rasterLayerForDisplayInMap.Renderer = new BlendRenderer( rasterForMakingBlendRenderer, // elevationRaster - Raster based on a elevation source. myOutputMinValues, // outputMinValues - Output stretch values, one for each band. myOutputMaxValues, // outputMaxValues - Output stretch values, one for each band. mySourceMinValues, // sourceMinValues - Input stretch values, one for each band. mySourceMaxValues, // sourceMaxValues - Input stretch values, one for each band. myNoDataValues, // noDataValues - NoData values, one for each band. myGammas, // gammas - Gamma adjustment. colorRamp, // colorRamp - ColorRamp object to use, could be null. _altitudeSlider.Value, // altitude - Altitude angle of the light source. _azimuthSlider.Value, // azimuth - Azimuth angle of the light source, measured clockwise from north. 1, // zfactor - Factor to convert z unit to x,y units, default is 1. mySlopeType, // slopeType - Slope Type. 1, // pixelSizeFactor - Pixel size factor, default is 1. 1, // pixelSizePower - Pixel size power value, default is 1. 8); // outputBitDepth - Output bit depth, default is 8-bit. // Set the new base map to be the RasterLayer with the BlendRenderer applied. _map.Basemap = new Basemap(rasterLayerForDisplayInMap); } catch (Exception ex) { Console.WriteLine(ex); } }
private void CreateLayout() { // Create a stack layout for the entire page LinearLayout mainLayout = new LinearLayout(this) { Orientation = Orientation.Vertical }; // Create a button to show the available slope types for the user to choose from _slopeTypeButton = new Button(this) { Text = "Slope type: " + _slopeType.ToString() }; // Show a popup menu of available slope types when the button is clicked _slopeTypeButton.Click += (s, e) => { // Get the button that raised the event Button slopeChoiceButton = s as Button; // Create menu to show slope options PopupMenu slopeTypeMenu = new PopupMenu(this, slopeChoiceButton); slopeTypeMenu.MenuItemClick += (sndr, evt) => { // Get the name of the selected slope type string selectedSlope = evt.Item.TitleCondensedFormatted.ToString(); // Find and store the corresponding slope type enum foreach (SlopeType slope in Enum.GetValues(typeof(SlopeType))) { if (slope.ToString() == selectedSlope) { _slopeType = slope; _slopeTypeButton.Text = "Slope type: " + selectedSlope; } } }; // Create menu options foreach (SlopeType slope in Enum.GetValues(typeof(SlopeType))) { slopeTypeMenu.Menu.Add(slope.ToString()); } // Show menu in the view slopeTypeMenu.Show(); }; // Create a slider (SeekBar) control for selecting an azimuth angle SeekBar azimuthSlider = new SeekBar(this) { // Set the slider width and height LayoutParameters = new ViewGroup.LayoutParams(350, 60), // Set a maximum slider value of 360 (minimum is 0) Max = 360 }; // When the slider changes, show the new value in the label azimuthSlider.ProgressChanged += (s, e) => { _azimuthTextView.Text = e.Progress.ToString(); }; // Create a slider (SeekBar) control for selecting an altitude angle SeekBar altitudeSlider = new SeekBar(this) { // Set the slider width and height LayoutParameters = new ViewGroup.LayoutParams(350, 60), // Set a maximum slider value of 90 (minimum is 0) Max = 90 }; // When the slider changes, show the new value in the label altitudeSlider.ProgressChanged += (s, e) => { _altitudeTextView.Text = e.Progress.ToString(); }; // Create labels (TextViews) to show the selected altitude and azimuth values _altitudeTextView = new TextView(this); _azimuthTextView = new TextView(this); // Create a horizontal layout for the altitude slider and text LinearLayout altitudeControls = new LinearLayout(this); altitudeControls.SetGravity(GravityFlags.Center); // Add the altitude selection controls altitudeControls.AddView(new TextView(this) { Text = "Altitude:" }); altitudeControls.AddView(altitudeSlider); altitudeControls.AddView(_altitudeTextView); // Create a horizontal layout for the azimuth slider and text LinearLayout azimuthControls = new LinearLayout(this); azimuthControls.SetGravity(GravityFlags.Center); // Add the azimuth selection controls azimuthControls.AddView(new TextView(this) { Text = "Azimuth:" }); azimuthControls.AddView(azimuthSlider); azimuthControls.AddView(_azimuthTextView); // Create a button to create and apply a hillshade renderer to the raster layer _applyHillshadeButton = new Button(this) { Text = "Apply hillshade" }; // Handle the click event to apply the hillshade renderer _applyHillshadeButton.Click += ApplyHillshadeButton_Click; // Add the slope type button to the layout mainLayout.AddView(_slopeTypeButton); // Add the slider controls to the layout mainLayout.AddView(altitudeControls); mainLayout.AddView(azimuthControls); // Set the default values for the azimuth and altitude altitudeSlider.Progress = 45; azimuthSlider.Progress = 270; // Add the apply hillshade renderer button mainLayout.AddView(_applyHillshadeButton); // Create the map view _myMapView = new MapView(this); // Add the map view to the layout mainLayout.AddView(_myMapView); // Set the layout as the sample view SetContentView(mainLayout); }
/// <summary> /// Test if this instance represents the slopeType /// </summary> /// <param name="slopeType">SlopeType to test</param> /// <returns>True </returns> public virtual bool IsSlopeOf(SlopeType slopeType) { return(SlopeType == slopeType); }
public CubeBlock(SlopeType slopeType) : base() { SlopeType = slopeType; }
// Update is called once per frame void Update() { if (Input.GetMouseButtonDown(0)) { Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition); RaycastHit hit; if (Physics.Raycast(ray, out hit)) { GameObject obj = hit.transform.gameObject; FindPathTo(obj); } } if (moving > 0) { moving -= Time.deltaTime * 4; transform.Translate((Vector3.forward + Vector3.up * updown) * Time.deltaTime * 4, Space.Self); if (moving <= 0) { transform.position = moveDest; standingFloor = destFloor; destFloor = null; half_check = false; RecalcPlayerPos(); if (moveList != null) { moveListIndex += 1; if (moveListIndex < moveList.Length) { MoveTo(moveList[moveListIndex].destFloor, moveList[moveListIndex].dir); } else { moveList = null; moveListIndex = 0; } } } else if (!half_check && moving < 0.5) { half_check = true; updown = 0; if (destFloor.name[0] == 'S') { SlopeType type = GetSlopeType(destFloor, transform.forward); if (type == SlopeType.slope_up) { updown = 1; } else if (type == SlopeType.slope_down) { updown = -1; } } } return; } if (moveList != null) { return; } // --------- // -------------- if (Input.GetKey(KeyCode.UpArrow)) { animation.Play("run"); Move(Vector3.forward); } else if (Input.GetKey(KeyCode.DownArrow)) { animation.Play("run"); Move(Vector3.back); } else if (Input.GetKey(KeyCode.LeftArrow)) { animation.Play("run"); Move(Vector3.left); } else if (Input.GetKey(KeyCode.RightArrow)) { animation.Play("run"); Move(Vector3.right); } else { animation.Play("idle"); } }
/// <summary> /// Test if this instance represents the slopeType /// </summary> /// <param name="slopeType">SlopeType to test</param> /// <returns>True </returns> public virtual bool IsSlopeOf(SlopeType slopeType) { return (SlopeType == slopeType); }
// Handle the selection event for the picker. public override void Selected(UIPickerView pickerView, nint row, nint component) { // Get the selected standard deviation factor. _selectedSlopeType = (SlopeType)_slopeTypeValues.GetValue(pickerView.SelectedRowInComponent(0)); }
// Update is called once per frame void Update() { if (Input.GetMouseButtonDown(0)) { Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition); RaycastHit hit; if (Physics.Raycast(ray, out hit)) { GameObject obj = hit.transform.gameObject; FindPathTo(obj); } } if (moving > 0) { // =============Animation Test RobotFreeAnim robotAnim = GameObject.Find("robotSphere").GetComponent <RobotFreeAnim>(); robotAnim.GetAnim().SetBool("Walk_Anim", true); // ============================ moving -= Time.deltaTime * 2.5f; transform.Translate((Vector3.forward + Vector3.up * updown) * Time.deltaTime * 2.5f, Space.Self); if (moving <= 0) { transform.position = moveDest; standingFloor = destFloor; destFloor = null; half_check = false; RecalcPlayerPos(); if (moveList != null) { moveListIndex += 1; if (moveListIndex < moveList.Length) { MoveTo(moveList[moveListIndex].destFloor, moveList[moveListIndex].dir); } else { moveList = null; moveListIndex = 0; } } } else if (!half_check && moving < 0.5) { half_check = true; updown = 0; if (destFloor.name[0] == 'S') { SlopeType type = GetSlopeType(destFloor, transform.forward); if (type == SlopeType.slope_up) { updown = 1; } else if (type == SlopeType.slope_down) { updown = -1; } } } return; } // =============Animation Test else { RobotFreeAnim robotAnim = GameObject.Find("robotSphere").GetComponent <RobotFreeAnim>(); robotAnim.GetAnim().SetBool("Walk_Anim", false); } // =========================== if (moveList != null) { return; } // --------- // -------------- if (Input.GetKey(KeyCode.UpArrow)) { Move(Vector3.forward); } else if (Input.GetKey(KeyCode.DownArrow)) { Move(Vector3.back); } else if (Input.GetKey(KeyCode.LeftArrow)) { Move(Vector3.left); } else if (Input.GetKey(KeyCode.RightArrow)) { Move(Vector3.right); } // Roll else if (Input.GetKeyDown(KeyCode.Space)) { RobotFreeAnim robotAnim = GameObject.Find("robotSphere").GetComponent <RobotFreeAnim>(); if (robotAnim.GetAnim().GetBool("Roll_Anim")) { robotAnim.GetAnim().SetBool("Roll_Anim", false); } else { robotAnim.GetAnim().SetBool("Roll_Anim", true); } } }
AStarItem[] FindNearFloors(GameObject obj) { Vector3[] dirs = new Vector3[] { Vector3.forward, Vector3.right, Vector3.back, Vector3.left, }; AStarItem[] items = new AStarItem[dirs.Length]; Vector3 object_pos = obj.transform.position; Vector3 object_floor = FloorFunc(object_pos); for (int i = 0; i < dirs.Length; i++) { Vector3 dir = dirs[i]; Vector3 arranged_dir = ArrangeDir(dir); Vector3 floor_value_offset = FloorFuncWithoutArrange(dir); Vector3 next_floor = object_floor + floor_value_offset; next_floor.z = 1024; if (obj.name[0] == 'S') { SlopeType type = GetSlopeType(obj, arranged_dir); if (type == SlopeType.half) { continue; } else if (type == SlopeType.slope_down) { next_floor.x -= 1; next_floor.y -= 1; object_floor.z -= 1; } } GameObject other; Vector3 other_floor = Vector3.zero; while (other = FindFloorWithFloorValue(next_floor, true)) { other_floor = FloorFunc(other.transform.position); if (other_floor.z > object_floor.z && next_floor.x + next_floor.y > object_floor.x + object_floor.y && !(other.name[0] == 'S' && GetSlopeType(other, arranged_dir) == SlopeType.floor_down)) { next_floor.z = other_floor.z; continue; } else if (other_floor.z < object_floor.z && next_floor.x + next_floor.y < object_floor.x + object_floor.y && !(obj.name[0] == 'S' && GetSlopeType(obj, arranged_dir) == SlopeType.floor_up)) { next_floor.z = other_floor.z; continue; } break; } if (other) { items[i] = new AStarItem(other, other_floor, 0, 0, arranged_dir); continue; } next_floor.x += 1; next_floor.y += 1; next_floor.z = 1024; while (other = FindFloorWithFloorValue(next_floor, true)) { other_floor = FloorFunc(other.transform.position); if (other.name[0] == 'S' && GetSlopeType(other, arranged_dir) == SlopeType.slope_up) { break; } next_floor.z = other_floor.z; } if (other) { items[i] = new AStarItem(other, other_floor, 0, 0, arranged_dir); continue; } } return(items); }
// Update is called once per frame void Update() { if (Input.GetMouseButtonDown(0)) { anim.Play("run"); Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition); RaycastHit hit; if (Physics.Raycast(ray, out hit)) { GameObject obj = hit.transform.gameObject; FindPathTo(obj); } } if (moving > 0) { moving -= Time.deltaTime * 4; transform.Translate((Vector3.forward + Vector3.up * updown) * Time.deltaTime * 4, Space.Self); if (moving <= 0) { transform.position = moveDest; standingFloor = destFloor; destFloor = null; half_check = false; RecalcPlayerPos(); if (moveList != null) { moveListIndex += 1; if (moveListIndex < moveList.Length) { MoveTo(moveList[moveListIndex].destFloor, moveList[moveListIndex].dir); } else { moveList = null; moveListIndex = 0; } } } else if (!half_check && moving < 0.5) { half_check = true; updown = 0; if (destFloor.name[0] == 'S') { SlopeType type = GetSlopeType(destFloor, transform.forward); if (type == SlopeType.slope_up) { updown = 1; } else if (type == SlopeType.slope_down) { updown = -1; } } } return; } if (moveList != null) { return; } // --------- // -------------- if (Input.GetKey(KeyCode.UpArrow)) { anim.Play("run"); Move(Vector3.forward); } else if (Input.GetKey(KeyCode.DownArrow)) { anim.Play("run"); Move(Vector3.back); } else if (Input.GetKey(KeyCode.LeftArrow)) { anim.Play("run"); Move(Vector3.left); } else if (Input.GetKey(KeyCode.RightArrow)) { anim.Play("run"); Move(Vector3.right); } else { anim.Play("idle2"); } if (current == 1 && standingFloor.transform.position.x == 3 && standingFloor.transform.position.y == 7 && standingFloor.transform.position.z == 6) { MapMaker jump = GameObject.Find("MapMaker").GetComponent <MapMaker>(); jump.Load(2); } if (current == 2 && standingFloor.transform.position.x == 0 && standingFloor.transform.position.y == 10 && standingFloor.transform.position.z == 7) { MapMaker jump = GameObject.Find("MapMaker").GetComponent <MapMaker>(); jump.Load(3); } if (current == 3 && standingFloor.transform.position.x == -1 && standingFloor.transform.position.y == 5 && standingFloor.transform.position.z == -4) { MapMaker jump = GameObject.Find("MapMaker").GetComponent <MapMaker>(); jump.Load(4); } if (current == 4 && standingFloor.transform.position.x == 3 && standingFloor.transform.position.y == 6 && standingFloor.transform.position.z == -3) { MapMaker jump = GameObject.Find("MapMaker").GetComponent <MapMaker>(); jump.Load(5); } if (current == 5 && standingFloor.transform.position.x == -13 && standingFloor.transform.position.y == 22 && standingFloor.transform.position.z == -5) { Application.LoadLevel(2); } }
private async void OnUpdateRendererClicked(object sender, EventArgs e) { try { // Define the RasterLayer that will be used to display in the map RasterLayer rasterLayer_ForDisplayInMap; // Define the ColorRamp that will be used by the BlendRenderer ColorRamp myColorRamp; // Get the user choice for the ColorRamps UITableViewSource myUITableViewSource_ColorRamp = _ColorRamps.Source; TableSource myTableSource_ColorRamp = (TableSource)myUITableViewSource_ColorRamp; string myColorRampChoice; if (myTableSource_ColorRamp.SelectedValue == null) { // If the user does not click on a choice in the table but just clicks the // button, the selected value will be null so use the initial ColorRamp option myColorRampChoice = "Elevation"; } else { // The user clicked on an option in the table and thus the selected value // will contain a valid choice myColorRampChoice = myTableSource_ColorRamp.SelectedValue; } // Based on ColorRamp type chosen by the user, create a different // RasterLayer and define the appropriate ColorRamp option if (myColorRampChoice == "None") { // The user chose not to use a specific ColorRamp, therefore // need to create a RasterLayer based on general imagery (ie. Shasta.tif) // for display in the map and use null for the ColorRamp as one of the // parameters in the BlendRenderer constructor // Load the raster file using a path on disk Raster raster_Imagery = new Raster(await GetRasterPath_Imagery()); // Create the raster layer from the raster rasterLayer_ForDisplayInMap = new RasterLayer(raster_Imagery); // Set up the ColorRamp as being null myColorRamp = null; } else { // The user chose a specific ColorRamp (options: are Elevation, DemScreen, DemLight), // therefore create a RasterLayer based on an imagery with elevation // (ie. Shasta_Elevation.tif) for display in the map. Also create a ColorRamp // based on the user choice, translated into an Enumeration, as one of the parameters // in the BlendRenderer constructor // Load the raster file using a path on disk Raster raster_Elevation = new Raster(await GetRasterPath_Elevation()); // Create the raster layer from the raster rasterLayer_ForDisplayInMap = new RasterLayer(raster_Elevation); // Create a ColorRamp based on the user choice, translated into an Enumeration PresetColorRampType myPresetColorRampType = (PresetColorRampType)Enum.Parse(typeof(PresetColorRampType), myColorRampChoice); myColorRamp = ColorRamp.Create(myPresetColorRampType, 256); } // Define the parameters used by the BlendRenderer constructor Raster raster_ForMakingBlendRenderer = new Raster(await GetRasterPath_Elevation()); IEnumerable <double> myOutputMinValues = new List <double> { 9 }; IEnumerable <double> myOutputMaxValues = new List <double> { 255 }; IEnumerable <double> mySourceMinValues = new List <double> { }; IEnumerable <double> mySourceMaxValues = new List <double> { }; IEnumerable <double> myNoDataValues = new List <double> { }; IEnumerable <double> myGammas = new List <double> { }; // Get the user choice for the SlopeType UITableViewSource myUITableViewSource_SlopeType = _SlopeTypes.Source; TableSource myTableSource_SlopeType = (TableSource)myUITableViewSource_SlopeType; string mySlopeTypeChoice; if (myTableSource_SlopeType.SelectedValue == null) { // If the user does not click on a choice in the table but just clicks the // button, the selected value will be null so use the initial SlopeType option mySlopeTypeChoice = "Degree"; } else { // The user clicked on an option in the table and thus the selected value // will contain a valid choice mySlopeTypeChoice = myTableSource_SlopeType.SelectedValue; } SlopeType mySlopeType = (SlopeType)Enum.Parse(typeof(SlopeType), mySlopeTypeChoice); BlendRenderer myBlendRenderer = new BlendRenderer( raster_ForMakingBlendRenderer, // elevationRaster - Raster based on a elevation source myOutputMinValues, // outputMinValues - Output stretch values, one for each band myOutputMaxValues, // outputMaxValues - Output stretch values, one for each band mySourceMinValues, // sourceMinValues - Input stretch values, one for each band mySourceMaxValues, // sourceMaxValues - Input stretch values, one for each band myNoDataValues, // noDataValues - NoData values, one for each band myGammas, // gammas - Gamma adjustment myColorRamp, // colorRamp - ColorRamp object to use, could be null _Altitude_Slider.Value, // altitude - Altitude angle of the light source _Azimuth_Slider.Value, // azimuth - Azimuth angle of the light source, measured clockwise from north 1, // zfactor - Factor to convert z unit to x,y units, default is 1 mySlopeType, // slopeType - Slope Type 1, // pixelSizeFactor - Pixel size factor, default is 1 1, // pixelSizePower - Pixel size power value, default is 1 8); // outputBitDepth - Output bit depth, default is 8-bi // Set the RasterLayer.Renderer to be the BlendRenderer rasterLayer_ForDisplayInMap.Renderer = myBlendRenderer; // Set the new base map to be the RasterLayer with the BlendRenderer applied _myMapView.Map.Basemap = new Basemap(rasterLayer_ForDisplayInMap); } catch (Exception ex) { Console.WriteLine(ex); } }
void Move(Vector3 dir) { Vector3 object_pos = standingFloor.transform.position; Vector3 object_floor = FloorFunc(object_pos); Vector3 arranged_dir = ArrangeDir(dir); Vector3 floor_value_offset = FloorFuncWithoutArrange(dir); Vector3 next_floor = object_floor + floor_value_offset; next_floor.z = 1024; if (standingFloor.name[0] == 'S') { SlopeType type = GetSlopeType(standingFloor, arranged_dir); if (type == SlopeType.half) { return; } else if (type == SlopeType.slope_down) { next_floor.x -= 1; next_floor.y -= 1; object_floor.z -= 1; } } GameObject other; Vector3 other_floor = Vector3.zero; while (other = FindFloorWithFloorValue(next_floor, true)) { other_floor = FloorFunc(other.transform.position); if (other_floor.z > object_floor.z && next_floor.x + next_floor.y > object_floor.x + object_floor.y && !(other.name[0] == 'S' && GetSlopeType(other, arranged_dir) == SlopeType.floor_down)) { next_floor.z = other_floor.z; continue; } else if (other_floor.z < object_floor.z && next_floor.x + next_floor.y < object_floor.x + object_floor.y && !(standingFloor.name[0] == 'S' && GetSlopeType(standingFloor, arranged_dir) == SlopeType.floor_up)) { next_floor.z = other_floor.z; continue; } MoveTo(other, arranged_dir); return; } next_floor.x += 1; next_floor.y += 1; next_floor.z = 1024; while (other = FindFloorWithFloorValue(next_floor, true)) { other_floor = FloorFunc(other.transform.position); if (other.name[0] == 'S' && GetSlopeType(other, arranged_dir) == SlopeType.slope_up) { MoveTo(other, arranged_dir); return; } next_floor.z = other_floor.z; } }