// 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); }
// 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); }
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))); }