public void Spawn( EnvironmentCube cube ) { gameObject.SetActive( true ); transform.position = cube.GetCoordinates().GetWorldPosition(); _currentCube = cube; _canMove = true; _canAttack = true; BeginMovement(); }
public void Spawn(EnvironmentCube cube) { gameObject.SetActive(true); transform.position = cube.GetCoordinates().GetWorldPosition(); Camera.main.transform.position = new Vector3(transform.position.x, Camera.main.transform.position.y, transform.position.z); _currentCube = cube; _canMove = true; _health = MAX_HEALTH; CameraOperator.SetFocusObject(transform); CameraOperator.SnapToFocus(); CameraOperator.FollowFocusObject(); }
public GridCoordinates GetCoordinates() { return(_currentCube.GetCoordinates()); }
private EnvironmentCube GetAdjacentCube(EnvironmentCube cube, Axis axis, bool unoccupied = false, int distance = 1) { EnvironmentCube adjacent = null; while (adjacent == null) { GridCoordinates coordinates = cube.GetCoordinates(); if (axis == Axis.East) { coordinates.x += distance; } else if (axis == Axis.West) { coordinates.x -= distance; } else if (axis == Axis.North) { coordinates.z += distance; } else if (axis == Axis.South) { coordinates.z -= distance; } else if (axis == Axis.NorthEast) { coordinates.x += distance; coordinates.z += distance; } else if (axis == Axis.NorthWest) { coordinates.x -= distance; coordinates.z += distance; } else if (axis == Axis.SouthEast) { coordinates.x += distance; coordinates.z -= distance; } else if (axis == Axis.SouthWest) { coordinates.x -= distance; coordinates.z -= distance; } if (AreValidCoordinates(coordinates)) { adjacent = _grid[coordinates.x, coordinates.z]; } if (adjacent != null && unoccupied && adjacent.IsOccupied()) { adjacent = null; } if (adjacent == null) { distance--; } } return(adjacent); }