// Use this for initialization void Start() { if (instance == null) { instance = this; } }
// Use this for initialization void Start() { GameObject gridContainer = GameObject.FindGameObjectWithTag("GridContainer"); _gridContainer = gridContainer.GetComponent <HexGridManager>(); _occupant = _gridContainer.CreateOccupant(gameObject, 1); }
// Use this for initialization void Start() { GameObject gridContainer = GameObject.FindGameObjectWithTag("GridContainer"); _gridManager = gridContainer.GetComponent< HexGridManager >(); _navAgent = GetComponent< NavMeshAgent >(); _occupant = _gridManager.CreateOccupant(gameObject, 1); }
public override void InitGrid(HexGridManager <MapCell> grid, bool isPlaying) { MapController map = (MapController)grid; if (isPlaying) { float xOffset = Random.Range(0.0f, 10000.0f); float yOffset = Random.Range(0.0f, 10000.0f); foreach (HexCoords point in map.coords) { float perlinX = (map.GridToWorld(point).x *perlinScale) + xOffset; float perlinY = (map.GridToWorld(point).y *perlinScale) + yOffset; float value = Mathf.PerlinNoise(perlinX, perlinY); MapCell mapCell = map[point]; if (value <= walkable) { mapCell.terrainType = TerrainType.open; } else { mapCell.terrainType = TerrainType.notWalkable; } } } }
public override void InitGrid(HexGridManager <MapCell> grid, bool isPlaying) { MapController map = (MapController)grid; if (isPlaying && (unitPrefab != null) && (unitRecipe != null)) { Debug.Log("Spawning " + count + " " + unitPrefab.name + " (" + unitRecipe.name + ")"); for (int idx = 0; idx < count; idx++) { MapUnit newUnit = Instantiate(unitPrefab); newUnit.facing = HexFacingMethods.random; newUnit.team = team; newUnit.LoadRecipe(unitRecipe); HexCoords spawnLoc = map.coords .Where(unitPrefab.CanEnter) .Where(unitPrefab.CanStay) .RandomPick(); map.PlaceUnit(newUnit, spawnLoc); foreach (MapCell cell in newUnit.GetThreatArea().Select(map.CellAt)) { cell.AddThreat(newUnit); } } } }
public override void InitGrid(HexGridManager <MapCell> grid, bool isPlaying) { MapController map = (MapController)grid; foreach (HexCoords loc in HexCoords.O.CompoundRing(0, radius)) { map.InitCell(loc, Instantiate(cellPrefab)); } }
// Instantiate a space ship at hex coord (u,v). GameObject CreateSpaceShip(Vector2 uv) { var sprite = Instantiate(ShipSprite) as SpriteRenderer; // Make the ship a child of the ShipManager gameobject. sprite.name = "ship " + uv; sprite.transform.parent = transform; sprite.transform.position = HexGridManager.GetTransformCoordinates(uv); return(sprite.gameObject); }
// Use this for initialization void Start() { GameObject gridContainer = GameObject.FindGameObjectWithTag("GridContainer"); _gridContainer = gridContainer.GetComponent< HexGridManager >(); _navAgent = GetComponent< NavMeshAgent >(); GameObject swarmGameObject = GameObject.FindGameObjectWithTag ("SwarmTarget"); _target = swarmGameObject.GetComponent< SwarmTarget > (); _occupant = _gridContainer.CreateOccupant(gameObject, 1); _gridContainer.PositionToGrid(transform.position, ref currentGrid); }
private void Awake() { if (Instance == null) { Instance = this; } else { Destroy(this.gameObject); } _gridManager = GetComponent <HexGridManager>(); _bubbleSOs = Resources.LoadAll <BubbleSO>("SoAssets/RegularBubbles"); //if (_bubbleSOs != null) Debug.Log(_bubbleSOs.Length); }
void Update() { if (Input.GetMouseButtonDown(0)) { // Check the hexagon clicked. Debug.Log(HexGridManager.GetHexCoordinates(Camera.main.ScreenToWorldPoint(Input.mousePosition))); } // Draw the Vectrosity arrow. arrow.points3.Clear(); arrow.points3.Add(pos2); arrow.points3.Add(pos1); arrow.Draw(); arrow.textureOffset = Time.time * AnimationSpeed % 1; }
// Use this for initialization void Start() { GameObject gridContainer = GameObject.FindGameObjectWithTag("GridContainer"); _gridContainer = gridContainer.GetComponent <HexGridManager>(); _navAgent = GetComponent <NavMeshAgent>(); GameObject swarmGameObject = GameObject.FindGameObjectWithTag("SwarmTarget"); _target = swarmGameObject.GetComponent <SwarmTarget> (); _occupant = _gridContainer.CreateOccupant(gameObject, 1); _gridContainer.PositionToGrid(transform.position, ref currentGrid); }
public override void OnInspectorGUI() { DrawDefaultInspector(); HexGridManager hexManager = (HexGridManager)target; if (GUILayout.Button("Rebuild Grid From NavMesh")) { NavMeshBuilder.BuildNavMesh(); hexManager.RebuildFromNavMesh(); } if (GUILayout.Button("Report Stats")) { hexManager.ReportStats(); } }
public override void InitGrid(HexGridManager <MapCell> grid, bool isPlaying) { MapController map = (MapController)grid; if (isPlaying) { MapCell crashSite = map.InitCell(HexCoords.O); crashSite.type = CellType.moonCrashSite; map.PlaceUnit(Instantiate(unitPrefab), crashSite); foreach (HexCoords loc in crashSite.loc.neighbors) { map.InitCell(loc).type = CellType.moonPlain; } foreach (HexCoords loc in crashSite.loc.CompoundRing(2, 10).Where(x => !map.InBounds(x))) { map.InitCell(loc); } } }
public InternalOccupant(HexGridManager manager) { _manager = manager; _id = IdCounter++; }
void OnMouseUp() { // When mouse is released, the arrow must point to the center of the hex. pos2 = HexGridManager.GetTransformCoordinates(HexGridManager.GetHexCoordinates(Camera.main.ScreenToWorldPoint(Input.mousePosition))); }
// Move a space ship to destination (in hexagonal coordinate) in given time duration (in second). void MoveSpaceShip(GameObject spaceShip, Vector2 destination, float duration) { var dest = HexGridManager.GetTransformCoordinates(destination); LeanTween.move(spaceShip, dest, duration).setEase(LeanTweenType.easeInQuad); }
public IntVector2(int _x, int _y) { _manager = null; x = _x; y = _y; }
public IntVector2(HexGridManager manager) { _manager = manager; x = 0; y = 0; }
/// <summary> /// The set method for setting the value of the instance property /// </summary> /// <param name="hgm"></param> public static void setInstance(HexGridManager hgm) { instance = hgm; }