Ejemplo n.º 1
0
    public override BaseGamePiece FindTarget()
    {
        List <ShipGamePiece> allShips = ShipManager.GetAllShips();

        //Next Turn Hex
        TileWithFacing startVec = new TileWithFacing()
        {
            position = myGamePiece.currentTile, facing = myGamePiece.currentTileFacing
        };
        TileWithFacing headingTile = startVec.Traverse(HexDirection.Forward, myGamePiece.currentVelocity);

        //Find the ship closest to where I will be if I move forward. Exclude the ship that fired me.
        ShipGamePiece closestShip         = null;
        float         closestShipDistance = float.MaxValue;

        foreach (ShipGamePiece ship in allShips)
        {
            if (ship == myGamePiece.motherGamePiece)
            {
                continue;
            }

            float distance = HexMapHelper.CrowFlyDistance(headingTile.position, myGamePiece.currentLevel, ship.currentTile, ship.currentLevel);
            if (distance < closestShipDistance)
            {
                closestShipDistance = distance;
                closestShip         = ship;
            }
        }

        currentTarget = closestShip;
        Debug.DrawLine(HexMapHelper.GetWorldPointFromTile(myGamePiece.currentTile), HexMapHelper.GetWorldPointFromTile(currentTarget.currentTile), Color.yellow, 5f);
        return(currentTarget);
    }
Ejemplo n.º 2
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);
        }
    }