Example #1
0
 public void SetSelectedCommandPoint(CommandPointFsm point)
 {
     selectedCommandPoint = point;
     gamePiece.SetDestination(selectedCommandPoint.destinationTile, selectedCommandPoint.destinationFacingTile, selectedCommandPoint.destinationLevel);
     gamePiece.currentVelocity = selectedCommandPoint.endVelocity;
     Debug.DrawLine(HexMapHelper.GetWorldPointFromTile(gamePiece.currentTile), HexMapHelper.GetWorldPointFromTile(selectedCommandPoint.destinationTile), Color.cyan, 5f);
 }
Example #2
0
 public void NewPointSelected(CommandPointFsm selectedPoint)
 {
     Debug.Log("Selecting Command Point: " + selectedPoint);
     foreach (var point in availableCommandPoints)
     {
         if (point != selectedPoint)
         {
             point.SelectPoint(false);
         }
     }
     pieceController.SetSelectedCommandPoint(selectedPoint);
 }
Example #3
0
    private CommandPointFsm InstantiateCommandPoint(TileWithFacing tileVec, int level, int endVelocity)
    {
        CommandPointFsm commandPoint = GameObject.Instantiate(commandPointPrefab, transform.position, transform.rotation, transform).GetComponent <CommandPointFsm>();

        commandPoint.SetNavigationSystem(this);

        commandPoint.SetSource(pieceController.worldModel.transform.position, HexMapHelper.GetFacingVector(pieceController.gamePiece.currentTile, pieceController.gamePiece.currentTileFacing));
        commandPoint.SetDestination(tileVec.position, tileVec.facing, level);
        commandPoint.SetEndVelocity(endVelocity);
        if (!pieceController.isPlayerControlled)
        {
            commandPoint.gameObject.SetActive(false);
        }

        availableCommandPoints.Add(commandPoint);
        return(commandPoint);
    }
Example #4
0
    public override CommandPointFsm SelectCommand()
    {
        var availableCommands = pieceController.navigationSystem.GetAvailableCommandPoints();

        if (currentTarget != null)
        {
            // Missile know where their target will be
            TileCoords targetDestinationTile       = currentTarget.GetDestinationTile();
            int        targetDestinationLevel      = currentTarget.GetDestinationLevel();
            Vector3    targetDestinationWorldSpace = HexMapHelper.GetWorldPointFromTile(targetDestinationTile, targetDestinationLevel);

            CommandPointFsm closestPoint     = null;
            float           closestPointDist = float.MaxValue;

            foreach (CommandPointFsm point in availableCommands)
            {
                if (point.destinationTile == targetDestinationTile && point.destinationLevel == targetDestinationLevel)
                {
                    return(point);
                }

                float distance = Vector3.Distance(targetDestinationWorldSpace, HexMapHelper.GetWorldPointFromTile(point.destinationTile, point.destinationLevel));
                if (distance < closestPointDist)
                {
                    closestPoint     = point;
                    closestPointDist = distance;
                }
            }

            return(closestPoint);
        }
        else
        {
            return(base.SelectCommand());
        }
    }