Esempio n. 1
0
    public override void drawMovementIcons(UnitScript selectedUnit)
    {
        //gameControllerRef.printString("Meowsquers");
        for (int i = 0; i < adjustedLocations.Count; i++)
        {
            bool foundEnemy  = false;
            bool foundFriend = false;
            bool onlyFriends = false;
            for (int j = 0; j < adjustedLocations[i].Count; j++)
            {
                HexTile tile = gameControllerRef.getTileController().getTileFromHexCoord(selectedUnit.getOccupyingHex().getCoords() + adjustedLocations[i][j]);
                if (tile)
                {
                    InteractionIcon.createInteractionIcon("RangedIcon", tile.getCoords(), new Color(0.0f, 1.0f, 0.0f, 1.0f), 0);
                    if (!foundEnemy && !onlyFriends)
                    {
                        if (tile.getOccupyingUnit())
                        {
                            if (tile.getOccupyingUnit().getTeam() != selectedUnit.getTeam())
                            {
                                foundEnemy  = true;
                                foundFriend = false;
                                j           = -1;
                                //clearMovementIcons();
                                continue;
                            }
                            else
                            {
                                foundFriend = true;
                            }
                        }

                        if (foundFriend && j == adjustedLocations[i].Count - 1)
                        {
                            onlyFriends = true;
                            j           = -1;
                            //clearMovementIcons();
                            continue;
                        }
                    }
                    else if (foundEnemy)
                    {
                        tile.switchState(TileState.SELECTABLE);
                        //createMovementIcon("RangedIcon", tile.getCoords(), new Color(0.0f, 1.0f, 0.0f, 1.0f), 0);
                        InteractionIcon.createInteractionIcon("AttackIcon", tile.getCoords(), new Color(1.0f, 0.0f, 0.0f, 1.0f), 1);
                    }
                    else
                    {
                        //createMovementIcon("RangedIcon", tile.getCoords(), new Color(0.0f, 1.0f, 0.0f, 1.0f), 0);
                        InteractionIcon.createInteractionIcon("CrossIcon", tile.getCoords(), new Color(1.0f, 0.0f, 0.0f, 1.0f), 1);
                    }
                }
            }
        }
    }
 public override void drawMovementIcons(UnitScript selectedUnit)
 {
     if (mode == 0)
     {
         for (int i = 0; i < adjustedSelectableLocations.Count; i++)
         {
             HexTile tile = gameControllerRef.getTileController().getTileFromHexCoord(selectedUnit.getCoords() + adjustedSelectableLocations[i]);
             if (tile)
             {
                 InteractionIcon.createInteractionIcon("SelectableIcon", tile.getCoords(), new Color(1.0f, 0.8f, 0.8f, 1.0f), 0);
                 if (tile.getOccupyingUnit())
                 {
                     if (tile.getOccupyingUnitTeam() != selectedUnit.getTeam())
                     {
                         InteractionIcon.createInteractionIcon("CrossIcon", tile.getCoords(), new Color(1.0f, 0.0f, 0.0f, 1.0f), 1);
                     }
                 }
                 else
                 {
                     InteractionIcon.createInteractionIcon("CrossIcon", tile.getCoords(), new Color(1.0f, 0.0f, 0.0f, 1.0f), 1);
                 }
             }
         }
     }
     if (mode == 1)
     {
         //gameControllerRef.printString("radaradaradarada");
         for (int i = 0; i < adjustedRepositionLocations.Count; i++)
         {
             HexTile tile = gameControllerRef.getTileController().getTileFromHexCoord(selectedUnit.getCoords() + adjustedRepositionLocations[i]);
             if (tile)
             {
                 InteractionIcon.createInteractionIcon("PlaceIcon", tile.getCoords(), new Color(1.0f, 0.8f, 0.8f, 1.0f), 0);
                 if (tile.getOccupyingUnit() && tile.getOccupyingUnit() != repositioningUnit)
                 {
                     InteractionIcon.createInteractionIcon("CrossIcon", tile.getCoords(), new Color(1.0f, 0.0f, 0.0f, 1.0f), 1);
                 }
             }
         }
     }
 }
Esempio n. 3
0
 public override void drawMovementIcons(UnitScript selectedUnit)
 {
     for (int i = 0; i < jumpPositions.Count; i++)
     {
         HexTile tile = gameControllerRef.getTileController().getTileFromHexCoord(selectedUnit.getOccupyingHex().getCoords() + adjustedJumpPositions[i]);
         if (tile)
         {
             InteractionIcon.createInteractionIcon("JumpIcon", tile.getCoords(), new Color(1.0f, 0.0f, 1.0f, 1.0f), 0);
             if (tile.getOccupyingUnit())
             {
                 if (tile.getOccupyingUnit().getTeam() != selectedUnit.getTeam())
                 {
                     InteractionIcon.createInteractionIcon("AttackIcon", tile.getCoords(), new Color(1.0f, 0.0f, 0.0f, 1.0f), 1);
                 }
                 else
                 {
                     InteractionIcon.createInteractionIcon("CrossIcon", tile.getCoords(), new Color(1.0f, 0.0f, 0.0f, 1.0f), 1);
                 }
             }
         }
     }
     //MovementIcon m = new MovementIcon();
     //m.initialize("PlaceIcon", );
 }
Esempio n. 4
0
    public override void drawMovementIcons(UnitScript selectedUnit)
    {
        for (int i = 0; i < adjustedDirections.Count; i++)
        {
            int     j = 0;
            Vector2 currentTileLoc = selectedUnit.getOccupyingHex().getCoords();
            HexTile lastTile       = null;
            InteractionIcon.createInteractionIcon("PathIcon", selectedUnit.getCoords(), Color.cyan, 3);
            while (j < ranges[i] || ranges[i] == -1)
            {
                currentTileLoc += adjustedDirections[i];

                HexTile currentTile = gameControllerRef.getTileController().getTileFromHexCoord(currentTileLoc);

                //prevTile = currentTile;
                if (currentTile)
                {
                    if (currentTile.getOccupyingUnit())
                    {
                        if (currentTile.getOccupyingUnit().getTeam() != selectedUnit.getTeam())
                        {
                            lastTile = currentTile;
                            InteractionIcon.createInteractionIcon("AttackIcon", currentTile.getCoords(), Color.red, 4);
                        }
                        else
                        {
                            InteractionIcon.createInteractionIcon("CrossIcon", currentTile.getCoords(), Color.red, 4);
                        }
                        break;
                    }
                    lastTile = currentTile;
                }
                else
                {
                    InteractionIcon.createInteractionIcon("CrossIcon", currentTileLoc, Color.red, 4);
                    break;
                }
                j++;
            }

            if (lastTile)
            {
                InteractionIcon m = InteractionIcon.createInteractionIcon("PathConnectionIcon", selectedUnit.getCoords(), Color.cyan, 1);
                Vector2         lastTileCoords  = TileController.hexCoordToPixelCoord(lastTile.getCoords());
                Vector2         startTileCoords = TileController.hexCoordToPixelCoord(selectedUnit.getCoords());

                Vector2 Q    = lastTileCoords - startTileCoords;
                float   dist = Q.magnitude * 100 - 15;
                if (dist < 0)
                {
                    dist = 0;
                }
                float angle = Mathf.Atan2(Q.y, Q.x) * 180 / Mathf.PI;
                //gameControllerRef.printString(dist.ToString());
                m.transform.Rotate(Vector3.forward, angle);
                m.transform.localScale = new Vector2(dist / 24, 1.0f);

                InteractionIcon mHead = InteractionIcon.createInteractionIcon("ArrowHeadIcon", lastTileCoords, Color.cyan, 2, true);
                mHead.transform.Rotate(Vector3.forward, angle);

                InteractionIcon.createInteractionIcon("PathIcon", lastTileCoords, Color.cyan, 1, true);
            }
        }
    }
Esempio n. 5
0
    public override void drawMovementIcons(UnitScript selectedUnit)
    {
        for (int i = 0; i < adjustedPathList.Count; i++)
        {
            bool    blocked  = false;
            HexTile lastTile = selectedUnit.getOccupyingHex();
            InteractionIcon.createInteractionIcon("PathIcon", selectedUnit.getCoords(), new Color(0.0f, 0.0f, 1.0f, 1.0f), 2);
            for (int j = 0; j < adjustedPathList[i].Count; j++)
            {
                Vector2 tileCoords = selectedUnit.getOccupyingHex().getCoords() + adjustedPathList[i][j].pos;
                HexTile tile       = gameControllerRef.getTileController().getTileFromHexCoord(tileCoords);
                if (tile)
                {
                    Color color = new Color(0.0f, 0.0f, 1.0f, 1.0f);
                    int   depth = 2;//to allow blocked symbols to appear under non-blocked ones
                    if (blocked)
                    {
                        color = new Color(0.2f, 0.2f, 0.2f, 1.0f);
                        depth = 1;
                    }
                    if (tile.getOccupyingUnit())
                    {
                        if (!blocked)
                        {
                            blocked = true;
                            if (tile.getOccupyingUnitTeam() == selectedUnit.getTeam() || !adjustedPathList[i][j].moveable)
                            {
                                InteractionIcon.createInteractionIcon("CrossIcon", tileCoords, new Color(1.0f, 0.0f, 0.0f, 0.4f), 3);
                            }
                            else
                            {
                                InteractionIcon.createInteractionIcon("AttackIcon", tileCoords, new Color(1.0f, 0.0f, 0.0f, 1.0f), 3);
                            }
                        }
                    }

                    Vector2         lastCoords    = TileController.hexCoordToPixelCoord(lastTile.getCoords());
                    Vector2         currentCoords = TileController.hexCoordToPixelCoord(tileCoords);
                    InteractionIcon m             = InteractionIcon.createInteractionIcon("PathConnectionIcon", lastCoords, color, 0, true);

                    Vector2 Q    = currentCoords - lastCoords;
                    float   dist = Q.magnitude * 100;

                    if (adjustedPathList[i][j].moveable)
                    {
                        InteractionIcon.createInteractionIcon("PathSelectableIcon", tileCoords, color, depth);
                        dist -= 15;
                        if (dist < 0)
                        {
                            dist = 0;
                        }
                    }
                    else
                    {
                        InteractionIcon.createInteractionIcon("PathIcon", tileCoords, color, depth);
                    }

                    float angle = Mathf.Atan2(Q.y, Q.x) * 180 / Mathf.PI;
                    gameControllerRef.printString(dist.ToString());
                    m.transform.Rotate(Vector3.forward, angle);
                    m.transform.localScale = new Vector2(dist / 24, 1.0f);

                    lastTile = tile;
                }
                else
                {
                    InteractionIcon.createInteractionIcon("CrossIcon", tileCoords, new Color(1.0f, 0.0f, 0.0f, 0.4f), 3);
                    break;
                }
            }
        }
    }
Esempio n. 6
0
    public override void drawMovementIcons(UnitScript selectedUnit)
    {
        for (int i = 0; i < adjustedDirections.Count; i++)
        {
            HexTile currentTile = selectedUnit.getOccupyingHex();
            HexTile prevTile    = null;
            //Color drawingColor = Color.yellow;
            Color drawingColor = new Color(0.2f, 0.2f, 0.2f, 1.0f);
            int   j            = 0;
            while (j < ranges[i] || ranges[i] == -1)
            {
                Vector2 currentTileCoords = currentTile.getCoords() + adjustedDirections[i];
                currentTile = gameControllerRef.getTileController().getTileFromHexCoord(currentTile.getCoords() + adjustedDirections[i]);
                if (j >= blockingExtent[i])
                {
                    if (currentTile)
                    {
                        if (currentTile.getOccupyingUnit())
                        {
                            if (currentTile.getOccupyingUnit().getTeam() == selectedUnit.getTeam())
                            {
                                InteractionIcon.createInteractionIcon("CrossIcon", currentTileCoords, Color.red, 4);
                                break;
                            }
                            else
                            {
                                InteractionIcon.createInteractionIcon("AttackIcon", currentTileCoords, Color.red, 4);
                                drawingColor = Color.yellow;
                            }
                        }
                        else
                        {
                            drawingColor = Color.yellow;
                        }
                        prevTile = currentTile;
                    }
                    else
                    {
                        InteractionIcon.createInteractionIcon("CrossIcon", currentTileCoords, Color.red, 4);
                        break;
                    }
                }
                else
                {
                    if (currentTile)
                    {
                        prevTile = currentTile;//Have arrow go to the blocked tile
                        if (currentTile.getOccupyingUnit())
                        {
                            InteractionIcon.createInteractionIcon("CrossIcon", currentTileCoords, Color.red, 4);
                            break;
                        }
                        InteractionIcon.createInteractionIcon("CrossIcon", currentTileCoords, new Color(0.2f, 0.2f, 0.2f, 1.0f), 0);
                    }
                    else
                    {
                        InteractionIcon.createInteractionIcon("CrossIcon", currentTileCoords, Color.red, 4);
                        //drawingColor = new Color(0.2f, 0.2f, 0.2f, 1.0f);
                        //prevTile = currentTile;
                        break;
                    }
                }

                j++;
            }

            if (prevTile)
            {
                InteractionIcon m = InteractionIcon.createInteractionIcon("PathConnectionIcon", selectedUnit.getCoords(), drawingColor, 1);
                Vector2         lastTileCoords  = TileController.hexCoordToPixelCoord(prevTile.getCoords());
                Vector2         startTileCoords = TileController.hexCoordToPixelCoord(selectedUnit.getCoords());

                Vector2 Q    = lastTileCoords - startTileCoords;
                float   dist = Q.magnitude * 100 - 15;
                if (dist < 0)
                {
                    dist = 0;
                }
                float angle = Mathf.Atan2(Q.y, Q.x) * 180 / Mathf.PI;
                //gameControllerRef.printString(dist.ToString());
                m.transform.Rotate(Vector3.forward, angle);
                m.transform.localScale = new Vector2(dist / 24, 1.0f);

                InteractionIcon mHead = InteractionIcon.createInteractionIcon("ArrowHeadIcon", lastTileCoords, drawingColor, 2, true);
                mHead.transform.Rotate(Vector3.forward, angle);

                InteractionIcon.createInteractionIcon("PathIcon", lastTileCoords, drawingColor, 3, true);
            }

            InteractionIcon.createInteractionIcon("PathIcon", selectedUnit.getCoords(), drawingColor, 3);
        }
    }