コード例 #1
0
ファイル: GolemTemplate.cs プロジェクト: foxfold/Colonies
    public void Start()
    {
        // TEMPORARY CODE to get a layer
        SortingLayer[] sortingLayers = SortingLayer.layers;
        foreach (SortingLayer sl in sortingLayers)
        {
            if (sl.name == "Ground")
            {
                movementLayer = sl;
            }
        }


        baseRenderer  = this.GetComponent <SpriteRenderer>();
        player        = (PlayerControls)FindObjectOfType(typeof(PlayerControls));
        gridCreator   = (GridCreator)FindObjectOfType(typeof(GridCreator));
        GE            = (GolemEnums)FindObjectOfType(typeof(GolemEnums));
        stats         = GE.StructGen(arms, core, frame, head, legs, torso, weapon1, weapon2);
        currentCoords = new TileCoords(Mathf.RoundToInt(transform.position.x), Mathf.RoundToInt(transform.position.y), movementLayer);


        if (faction == Faction.Player)
        {
            baseRenderer.color = new Color(0.5f, 0.5f, 1f, 1f);
        }
        else if (faction == Faction.Enemy1 || faction == Faction.Enemy2)
        {
            baseRenderer.color = new Color(1f, 0f, 0f, 1f);
        }

        player.unitDict.Add(currentCoords, this.gameObject);
    }
コード例 #2
0
ファイル: GolemTemplate.cs プロジェクト: foxfold/Colonies
    private void OnMouseDown()
    {
        if (faction == Faction.Player)
        {
            if (player.selectedUnit != null)
            {
                player.selectedUnit.GetComponent <SpriteRenderer>().color = new Color(0.5f, 0.5f, 1f, 1f);
                foreach (GameObject Obj in player.movementSquareList)
                {
                    DestroyImmediate(Obj);
                }
            }

            player.selectedUnit         = this.gameObject;
            player.selectedUnitMovement = stats.Movement;

            if (!moved)
            {
                player.Movement(currentCoords, currentCoords);
                player.unitDict.Remove(currentCoords);
                currentCoords = new TileCoords(Mathf.RoundToInt(transform.position.x), Mathf.RoundToInt(transform.position.y), movementLayer);
                player.unitDict.Add(currentCoords, this.gameObject);
                currentTile          = gridCreator.tileDict[currentCoords].GetComponent <TileData>();
                currentTile.occupied = true;
            }
            else if (!attacked)
            {
                player.Attack(currentCoords, currentCoords);
            }
        }
    }
コード例 #3
0
    public void GenerateMap()
    {
        string holderName = "Generated Map";

        if (transform.Find(holderName))
        {
            DestroyImmediate(transform.Find(holderName).gameObject);
        }

        mapHolder        = new GameObject(holderName).transform;
        mapHolder.parent = transform;

        tileMap  = new TileCoords[mapSizeX, mapSizeY];
        startPos = new TileCoords((int)(mapSizeX / 2), 0);
        goalPos  = GetGoalPosition();

        for (int i = 0; i < mapSizeX; i++)
        {
            for (int j = 0; j < mapSizeY; j++)
            {
                if ((i != startPos.x || j != startPos.y) && (i != goalPos.x || j != goalPos.y))
                {
                    tileMap[i, j] = SpawnRandomTile(i, j);
                }
                else if (i == goalPos.x && j == goalPos.y)
                {
                    tileMap[i, j] = SpawnSpecificTile(i, j, goalTile, goalPos);
                }
                else
                {
                    tileMap[i, j] = SpawnSpecificTile(i, j, startTile, startPos);
                }
            }
        }
    }
コード例 #4
0
ファイル: HexMapHelper.cs プロジェクト: GameKit28/HotJupiter
    public static float CrowFlyDistance(TileCoords hex1Tile, int hex1Height, TileCoords hex2Tile, int hex2Height)
    {
        Vector3 pos1 = GetWorldPointFromTile(hex1Tile, hex1Height);
        Vector3 pos2 = GetWorldPointFromTile(hex2Tile, hex2Height);

        return(Vector3.Distance(pos1, pos2));
    }
コード例 #5
0
    private TileCoords SpawnRandomTile(int indexX = -1, int indexY = -1)
    {
        TileCoords coord             = new TileCoords(indexX, indexY);
        int        tileToInstantiate = (int)Random.Range(0, tiles.Length);

        return(SpawnTile(indexX, indexY, tiles[tileToInstantiate], coord));
    }
コード例 #6
0
ファイル: BaseGamePiece.cs プロジェクト: GameKit28/HotJupiter
    // Start is called before the first frame update
    protected virtual void Start()
    {
        currentTile       = HexMapHelper.GetTileFromWorldPoint(transform.position);
        currentTileFacing = HexMapHelper.GetNeighborTiles(currentTile)[0];

        PositionAndOrientPiece();
        eventPublisher.Publish(new Events.CompletedSetup());
    }
コード例 #7
0
    // Update is called once per frame
    void Update()
    {
        Vector3    cursorWorldPos = GetPlaneIntersection();
        TileCoords selectedTile   = HexMapHelper.GetTileFromWorldPoint(cursorWorldPos);

        //Debug.Log("SelectedTile = " + selectedTile);
        transform.position = HexMapHelper.GetWorldPointFromTile(selectedTile, HexMapUI.currentUIMapLevel);
    }
コード例 #8
0
ファイル: BaseGamePiece.cs プロジェクト: GameKit28/HotJupiter
    protected virtual void OnEndPlayingPhase(GameControllerFsm.Events.EndPlayingOutTurnState @event)
    {
        currentTile       = destinationTile;
        currentTileFacing = destinationTileFacing;
        currentLevel      = destinationLevel;

        PositionAndOrientPiece();
        gameObject.SetActive(true);
    }
コード例 #9
0
ファイル: Map.cs プロジェクト: CoFFeeMaN11/gejmdzem
    public Vector3 ToVector(TileCoords _in)
    {
        Vector3 ret = new Vector3();

        ret.x = (_in.x + .5f) * tileSize;
        ret.y = (_in.y + .5f) * tileSize;
        ret  += transform.position;
        return(ret);
    }
コード例 #10
0
ファイル: GridCreator.cs プロジェクト: foxfold/Colonies
    public void PickColor(Vector2 coordinates)
    {
        TileCoords tileCoords = new TileCoords(Mathf.RoundToInt(coordinates.x), Mathf.RoundToInt(coordinates.y), sortingLayerArray[selectedLayer]);

        if (tileDict.ContainsKey(tileCoords))
        {
            selectedSprite = tileDict[tileCoords].GetComponent <SpriteRenderer>().sprite;
        }
    }
コード例 #11
0
ファイル: GridCreator.cs プロジェクト: foxfold/Colonies
 public void EraseTile(TileCoords coordinates)
 {
     // ERASE tool - Deletes existant tile, if it exists
     if (tileDict.ContainsKey(coordinates))
     {
         Undo.DestroyObjectImmediate(tileDict[coordinates]);
         tileDict.Remove(coordinates);
     }
 }
コード例 #12
0
ファイル: HexExtensions.cs プロジェクト: GameKit28/HotJupiter
 private static TileCoords GetFacingWhenEnteringPentagon(TileCoords currentHex, TileCoords newPenta, PentagonTraversalStrategy strategy)
 {
     if (strategy == PentagonTraversalStrategy.LeanLeft)
     {
         return(HexMapHelper.GetTileInPentaDirection(newPenta, currentHex, PentaDirection.BackwardRight));
     }
     else
     {
         return(currentHex); //Face backwards as default
     }
 }
コード例 #13
0
ファイル: HexMapHelper.cs プロジェクト: GameKit28/HotJupiter
    public static List <Vector3> NeighborVectors(TileCoords startTile)
    {
        Vector3        startPos        = instance.baseHexasphere.GetTileCenter(startTile.index);
        List <Vector3> neighborVectors = new List <Vector3>();

        foreach (var tile in instance.baseHexasphere.tiles[startTile.index].neighbours)
        {
            neighborVectors.Add((instance.baseHexasphere.GetTileCenter(tile.index) - startPos).normalized);
        }
        return(neighborVectors);
    }
コード例 #14
0
ファイル: GridCreator.cs プロジェクト: foxfold/Colonies
    public void Fill(TileCoords coordinates, Sprite originalSprite, TileCoords originalCoords)
    {
        Stack <TileCoords> stack = new Stack <TileCoords>();

        stack.Push(coordinates);

        while (stack.Count != 0)
        {
            TileCoords coords = stack.Pop();
            // Returns if we are too far from the origin (to prevent infinite flooding)
            if (originalSprite == null && Vector2.Distance(new Vector2(originalCoords.x, originalCoords.y), new Vector2(coordinates.x, coordinates.y)) > 32)
            {
                continue;
            }

            // If no tile exists in a set of coords, it's created and set to null
            if (!tileDict.ContainsKey(coords))
            {
                if (originalSprite == null)
                {
                    SetTile(coords);
                    tileDict[coords].GetComponent <SpriteRenderer>().sprite = null;
                }
                else
                {
                    continue;
                }
            }

            // Returns if the tile is already the target sprite, or is not the sprite being replaced.
            if (tileDict[coords].GetComponent <SpriteRenderer>().sprite == selectedSprite)
            {
                continue;
            }
            if (tileDict[coords].GetComponent <SpriteRenderer>().sprite != originalSprite)
            {
                continue;
            }

            // Sets the new sprite
            SetTile(coords);

            // Produces the coordinates to test
            TileCoords North = new TileCoords(coords.x, coords.y + 1, sortingLayerArray[selectedLayer]);
            TileCoords South = new TileCoords(coords.x, coords.y - 1, sortingLayerArray[selectedLayer]);
            TileCoords East  = new TileCoords(coords.x + 1, coords.y, sortingLayerArray[selectedLayer]);
            TileCoords West  = new TileCoords(coords.x - 1, coords.y, sortingLayerArray[selectedLayer]);

            stack.Push(North);
            stack.Push(South);
            stack.Push(East);
            stack.Push(West);
        }
    }
コード例 #15
0
ファイル: HexMapHelper.cs プロジェクト: GameKit28/HotJupiter
    public static List <TileCoords> GetNeighborTiles(TileCoords tile)
    {
        List <TileCoords> neighbors = new List <TileCoords>();

        foreach (var neighbor in instance.baseHexasphere.tiles[tile.index].neighbours)
        {
            neighbors.Add(new TileCoords()
            {
                index = neighbor.index
            });
        }
        return(neighbors);
    }
コード例 #16
0
ファイル: HexMapHelper.cs プロジェクト: GameKit28/HotJupiter
    public static Vector3 GetWorldPointFromTile(TileCoords tileCoords, int level = 0)
    {
        Tile tile = instance.baseHexasphere.tiles[tileCoords.index];

        if (level == 0)
        {
            return(instance.baseHexasphere.GetTileCenter(tileCoords.index, true));
        }
        else
        {
            return(instance.baseHexasphere.GetTileCenter(tileCoords.index) + (GetTileNormal(tileCoords) * GetAltitudeFromLevel(level)));
        }
    }
コード例 #17
0
    public static Tile GetHexasphereTile(TileCoords tilePosition, int level)
    {
        Hexasphere hexasphere = instance.tileSpheres[Mathf.Clamp(level, 0, instance.tileSpheres.Count - 1)];

        if (hexasphere.tiles != null)
        {
            return(hexasphere.tiles[tilePosition.index]);
        }
        else
        {
            return(null);
        }
    }
コード例 #18
0
ファイル: Map.cs プロジェクト: CoFFeeMaN11/gejmdzem
 public Tile this[TileCoords _in]
 {
     get
     {
         if (_in.x < xSize && _in.y < ySize && _in.x >= 0 && _in.y >= 0)
         {
             return(map[_in.x, _in.y]);
         }
         else
         {
             throw new System.IndexOutOfRangeException();
         }
     }
 }
コード例 #19
0
    void OnNewTurn(GameControllerFsm.Events.BeginCommandSelectionState @event)
    {
        FindTarget();
        TileWithFacing startVec = new TileWithFacing()
        {
            position = myGamePiece.currentTile, facing = myGamePiece.currentTileFacing
        };
        TileCoords missileOkayZone = startVec.Traverse(HexDirection.Forward, myGamePiece.shipTemplete.missileTemplate.TopSpeed).position;

        if (HexMapHelper.CrowFlyDistance(missileOkayZone, myGamePiece.currentLevel, currentTarget.currentTile, currentTarget.currentLevel) < 4f)
        {
            myGamePiece.QueueMissile(true);
        }
    }
コード例 #20
0
ファイル: GridCreator.cs プロジェクト: foxfold/Colonies
    public void UseTool(Vector2 coordinates)
    {
        sortingLayerArray = SortingLayer.layers;
        TileCoords tileCoords = new TileCoords(Mathf.RoundToInt(coordinates.x), Mathf.RoundToInt(coordinates.y), sortingLayerArray[selectedLayer]);

        switch (interaction)
        {
        case Interaction.Draw:
            if (brushSize == 1)
            {
                SetTile(tileCoords);
            }
            else
            {
                ranCoords = new List <TileCoords>();
                Brush(tileCoords, tileCoords);
                ranCoords.Clear();
            }
            break;

        case GridCreator.Interaction.Erase:
            EraseTile(tileCoords);
            break;

        case GridCreator.Interaction.Fill:
            if (!tileDict.ContainsKey(tileCoords))
            {
                SetTile(tileCoords);
                tileDict[tileCoords].GetComponent <SpriteRenderer>().sprite = null;
            }
            ranCoords = new List <TileCoords>();
            Fill(tileCoords, tileDict[tileCoords].GetComponent <SpriteRenderer>().sprite, tileCoords);
            ranCoords.Clear();
            break;

        case GridCreator.Interaction.Clear:
            if (!tileDict.ContainsKey(tileCoords))
            {
                SetTile(tileCoords);
                tileDict[tileCoords].GetComponent <SpriteRenderer>().sprite = null;
            }
            ranCoords = new List <TileCoords>();
            Clear(tileCoords, tileDict[tileCoords].GetComponent <SpriteRenderer>().sprite, tileCoords);
            ranCoords.Clear();
            break;
        }
    }
コード例 #21
0
ファイル: GridCreator.cs プロジェクト: foxfold/Colonies
    public void Clear(TileCoords coordinates, Sprite originalSprite, TileCoords originalCoords)
    {
        if (originalSprite == null)
        {
            return;
        }
        Stack <TileCoords> stack = new Stack <TileCoords>();

        stack.Push(coordinates);

        while (stack.Count != 0)
        {
            TileCoords coords = stack.Pop();

            // If no tile exists in a set of coords, it's created and set to null
            if (!tileDict.ContainsKey(coords))
            {
                continue;
            }

            // Returns if the tile is already the target sprite, or is not the sprite being replaced.
            if (tileDict[coords].GetComponent <SpriteRenderer>().sprite == null)
            {
                continue;
            }
            if (tileDict[coords].GetComponent <SpriteRenderer>().sprite != originalSprite)
            {
                continue;
            }

            // Sets the new sprite
            EraseTile(coords);

            // Produces the coordinates to test
            TileCoords North = new TileCoords(coords.x, coords.y + 1, sortingLayerArray[selectedLayer]);
            TileCoords South = new TileCoords(coords.x, coords.y - 1, sortingLayerArray[selectedLayer]);
            TileCoords East  = new TileCoords(coords.x + 1, coords.y, sortingLayerArray[selectedLayer]);
            TileCoords West  = new TileCoords(coords.x - 1, coords.y, sortingLayerArray[selectedLayer]);

            stack.Push(North);
            stack.Push(South);
            stack.Push(East);
            stack.Push(West);
        }
    }
コード例 #22
0
    void Start()
    {
        //Randomly Generate Model
        GameObject prefab = template.modelPrefabs.RandomItem();

        GameObject.Instantiate(prefab, Vector3.zero, Quaternion.identity, modelHolder);

        if (pivotPosition.index == 0)
        {
            pivotPosition = HexMapHelper.GetTileFromWorldPoint(transform.position);
        }
        TileCoords pivotFacing = HexMapHelper.GetNeighborTiles(pivotPosition).RandomItem();

        transform.position             = HexMapHelper.GetWorldPointFromTile(pivotPosition, pivotLevel);
        modelHolder.transform.rotation = HexMapHelper.GetRotationFromFacing(pivotPosition, pivotFacing);

        footprint = new StaticFootprint(template.footprint, pivotPosition, pivotFacing, pivotLevel);
    }
コード例 #23
0
    public void SetDestination(TileCoords tileCoords, TileCoords facingTile, int level)
    {
        destinationTile       = tileCoords;
        destinationFacingTile = facingTile;
        destinationLevel      = level;

        //Position the sprite within the Hex
        sprite.transform.position = HexMapHelper.GetWorldPointFromTile(tileCoords, level) + ((HexMapHelper.GetFacingVector(tileCoords, facingTile) * HexMapHelper.HexWidth * 0.3f));

        //Face the sprite the correct direction
        sprite.transform.rotation = HexMapHelper.GetRotationFromFacing(tileCoords, facingTile);

        //Color the sprite based on height
        sprite.GetComponentInChildren <SpriteRenderer>().color = HexMapUI.GetLevelColor(level);

        SetSpline(sourcePosition, sourceHeading,
                  HexMapHelper.GetWorldPointFromTile(tileCoords, level), HexMapHelper.GetFacingVector(tileCoords, facingTile));
    }
コード例 #24
0
ファイル: GridCreator.cs プロジェクト: foxfold/Colonies
    public void Brush(TileCoords coordinates, TileCoords originalCoords)
    {
        // TODO - Keep list of all coordinates already run, return if those are re-run

        // Returns if this tile has already been checked
        if (ranCoords.Contains(coordinates))
        {
            return;
        }

        // Returns if we are too far from the origin (to prevent infinite flooding)
        if (Vector2.Distance(new Vector2(originalCoords.x, originalCoords.y), new Vector2(coordinates.x, coordinates.y)) > brushSize - 1)
        {
            return;
        }

        // If no tile exists in a set of coords, it's created and set to null
        if (!tileDict.ContainsKey(coordinates))
        {
            SetTile(coordinates);
        }

        // Sets the new sprite
        SetTile(coordinates);
        ranCoords.Add(coordinates);

        // Produces the coordinates to test
        TileCoords North = new TileCoords(coordinates.x, coordinates.y + 1, sortingLayerArray[selectedLayer]);
        TileCoords South = new TileCoords(coordinates.x, coordinates.y - 1, sortingLayerArray[selectedLayer]);
        TileCoords East  = new TileCoords(coordinates.x + 1, coordinates.y, sortingLayerArray[selectedLayer]);
        TileCoords West  = new TileCoords(coordinates.x - 1, coordinates.y, sortingLayerArray[selectedLayer]);

        // Recursively runs testing the directional tiles
        Brush(North, originalCoords);
        Brush(South, originalCoords);
        Brush(East, originalCoords);
        Brush(West, originalCoords);
    }
コード例 #25
0
    private void PaintMap()
    {
        Vector2 mousePos = Event.current.mousePosition;

        mousePos.y = Camera.current.pixelHeight - mousePos.y;
        //Debug.Log(Camera.current.ScreenPointToRay(mousePos));
        if (editedMap == null)
        {
            return;
        }
        TileCoords test = editedMap.FromVector(Camera.current.ScreenPointToRay(mousePos).origin);

        if (!editedMap.Exists(test.x, test.y))
        {
            return;
        }
        var tile = editedMap[test.x, test.y];
        SerializedObject   serializedObject = new SerializedObject(tile);
        SerializedProperty property         = serializedObject.FindProperty("type");

        switch (currentMode)
        {
        case TileEditorType.STANDARD:
            property.intValue = (int)TileType.STANDARD;
            break;

        case TileEditorType.FOREST:
            property.intValue = (int)TileType.FOREST;
            break;

        case TileEditorType.ROCKS:
            property.intValue = (int)TileType.ROCKS;
            break;
        }
        //serializedObject.Update();
        serializedObject.ApplyModifiedProperties();
        SceneView.RepaintAll();
    }
コード例 #26
0
    public static void SpawnMissile(TileCoords tileCoords, TileCoords tileFacing, int level, BaseGamePiece spawningPiece, MissileStats template)
    {
        GameObject newMissile = SimplePool.Spawn(
            instance.missilePrefab,
            Vector3.zero,
            Quaternion.identity,
            instance.gamePieceHolder);

        newMissile.GetComponentInChildren <MissileGamePiece>().currentTileFacing = tileFacing;
        newMissile.GetComponentInChildren <MissileGamePiece>().currentTile       = tileCoords;
        newMissile.GetComponentInChildren <MissileGamePiece>().currentLevel      = level;
        newMissile.GetComponentInChildren <MissileGamePiece>().PositionAndOrientPiece();

        newMissile.GetComponentInChildren <PieceController>().worldBase.transform.position  = HexMapHelper.GetWorldPointFromTile(tileCoords, level);
        newMissile.GetComponentInChildren <PieceController>().worldModel.transform.rotation = HexMapHelper.GetRotationFromFacing(tileCoords, tileFacing);

        newMissile.GetComponentInChildren <NavigationSystem>().GenerateCommandPoints();

        newMissile.GetComponentInChildren <MissileBrain>().FindTarget();
        var selectedCommand = newMissile.GetComponentInChildren <MissileBrain>().SelectCommand();

        newMissile.GetComponentInChildren <PieceController>().SetSelectedCommandPoint(selectedCommand);
    }
コード例 #27
0
    private void PrepareForBuilding()
    {
        basicTileDictionary = new Dictionary <TileCoords, Transform>();
        bckgrTileDictionary = new Dictionary <TileCoords, Transform>();

        for (int i = 0; i < basicTileParent.childCount; i++)
        {
            Transform  tile = basicTileParent.GetChild(i);
            TileCoords key  = new TileCoords(tile);
            if (basicTileDictionary.ContainsKey(key))
            {
                DestroyImmediate(tile.gameObject);
                Debug.LogWarning("Deleted duplicate tile!");
            }
            else
            {
                basicTileDictionary.Add(key, tile);
            }
        }

        for (int i = 0; i < backgroundTileParent.childCount; i++)
        {
            Transform  tile = backgroundTileParent.GetChild(i);
            TileCoords key  = new TileCoords(tile);
            if (bckgrTileDictionary.ContainsKey(key))
            {
                DestroyImmediate(tile.gameObject);
                Debug.LogWarning("Deleted duplicate tile!");
            }
            else
            {
                bckgrTileDictionary.Add(key, tile);
            }
        }

        building = true;
    }
コード例 #28
0
    // Start is called before the first frame update
    void Start()
    {
        TileCoords     startTile = HexMapHelper.GetTileFromWorldPoint(transform.position);
        TileWithFacing startVec  = new TileWithFacing()
        {
            position = startTile,
            facing   = HexMapHelper.GetNeighborTiles(startTile)[facingIndex]
        };

        List <TileWithLevel> footprintParts = new List <TileWithLevel>();

        footprintParts.Add(new TileWithLevel()
        {
            position = startVec.position, level = level
        });

        List <Vector3> lineNodes  = new List <Vector3>();
        TileWithFacing currentVec = startVec;

        for (int nodeIndex = 0; nodeIndex < maxLength; nodeIndex++)
        {
            currentVec = currentVec.Traverse(HexDirection.Forward);
            if (currentVec.position == startVec.position)
            {
                break;
            }
            lineNodes.Add(HexMapHelper.GetWorldPointFromTile(currentVec.position, level));
            footprintParts.Add(new TileWithLevel()
            {
                position = currentVec.position, level = level
            });
        }
        line.positionCount = lineNodes.Count;
        line.SetPositions(lineNodes.ToArray());

        footprint = new StaticFootprint(footprintParts);
    }
コード例 #29
0
ファイル: HexExtensions.cs プロジェクト: GameKit28/HotJupiter
    public static TileWithFacing Traverse(this TileWithFacing startVec, HexDirection direction, int steps = 1, PentagonTraversalStrategy strategy = PentagonTraversalStrategy.LeanLeft)
    {
        TileCoords currentTile   = startVec.position;
        TileCoords currentFacing = startVec.facing;

        for (int step = 0; step < steps; step++)
        {
            TileCoords newTile;
            if (HexMapHelper.GetTileShape(currentTile) == TileShape.Hexagon)
            {
                newTile = HexMapHelper.GetTileInHexDirection(currentTile, currentFacing, direction);
            }
            else
            {
                //We're stepping out of a Pentagon using HexDirection. What do we do?
                newTile = GetNewTileWhenLeavingPentagon(currentTile, currentFacing, direction, strategy);
            }
            direction = HexDirection.Forward;

            if (HexMapHelper.GetTileShape(newTile) == TileShape.Hexagon)
            {
                currentFacing = HexMapHelper.GetTileInHexDirection(newTile, currentTile, HexDirection.Backward);
            }
            else
            {
                //We're stepping into a Pentagon with Hex Directions. What do we do?
                currentFacing = GetFacingWhenEnteringPentagon(currentTile, newTile, strategy);
            }

            currentTile = newTile;
        }
        return(new TileWithFacing()
        {
            position = currentTile, facing = currentFacing
        });
    }
コード例 #30
0
ファイル: HexMapHelper.cs プロジェクト: GameKit28/HotJupiter
    public static TileCoords GetTileInPentaDirection(TileCoords startTile, TileCoords startFacing, PentaDirection direction)
    {
        Tile tile = instance.baseHexasphere.tiles[startTile.index];

        if (tile.neighbours.Length == 5)
        {
            //count tiles until we find the current facing
            for (int neighborIndex = 0; neighborIndex < tile.neighbours.Length; neighborIndex++)
            {
                Tile neighborTile = tile.neighbours[neighborIndex];
                if (neighborTile.index == startFacing.index)
                {
                    return(new TileCoords {
                        index = tile.neighbours[(neighborIndex + (int)direction) % 5].index
                    });
                }
            }
            throw new Exception("Failed to Find Neighbor");
        }
        else
        {
            throw new Exception("The startTile is not a Pentagon. Use GetTileInHexDirection instead.");
        }
    }