コード例 #1
0
    // Spawn a new dot
    public DotController SpawnDot(List <Waypoint> currentWaypoints)
    {
        DotController newDot = dotManager.GetNewDot();

        // add drop waypoints to the new dot
        for (int i = 0; i < currentWaypoints.Count; i++)
        {
            newDot.AddWaypoint(currentWaypoints[i]);
        }
        for (int i = 0; i < dotsToDrop.Count; i++)
        {
            Waypoint waypoint = new Waypoint(dotsToDrop[i].transform.position);
            newDot.AddWaypoint(waypoint);
        }

        // place the spawned dot
        int   dropNum   = dotsToDrop.Count + 1;
        float screenTop = screenUtil.MaxY();
        float ySpacing  = coordinateSpace.YSpacing();
        float xPos      = transform.position.x;
        float yPos      = screenTop + (ySpacing * dropNum);

        newDot.transform.position = new Vector3(xPos, yPos, 0);
        dotsToDrop.Add(newDot);
        return(newDot);
    }
コード例 #2
0
    // Use the grid spacing to calculate the touch radius for each dot
    void CalculateTouchRadius()
    {
        float xSpacing = boardCoordinateSpace.XSpacing();
        float ySpacing = boardCoordinateSpace.YSpacing();

        DotTouchDistance = Mathf.Min(xSpacing, ySpacing) * .5f;
    }
コード例 #3
0
ファイル: BoardSpace.cs プロジェクト: rcornwal/DotsGame
    // Place the board space in the correct grid position
    void CalculateScreenPosition()
    {
        float xSpacing = coordinateSpace.XSpacing();
        float ySpacing = coordinateSpace.YSpacing();
        float xOffset  = xSpacing * boardIndex.x;
        float yOffset  = ySpacing * boardIndex.y;
        float xPos     = coordinateSpace.MinX() + xOffset + (xSpacing * .5f);
        float yPos     = coordinateSpace.MinY() + yOffset + (ySpacing * .5f);

        screenPosition     = new Vector3(xPos, yPos, 0);
        transform.position = screenPosition;
    }