Example #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);
    }
Example #2
0
 // Start dropping current dot down to this space's screen position
 public void DropDot(float dropSpeed)
 {
     if (currentDot.IsDropping)
     {
         currentDot.AddWaypoint(new Waypoint(screenPosition));
     }
     currentDot.Drop(dropSpeed);
 }
Example #3
0
    // Recursively propogates up adjacent spaces to find a new dot
    DotController FindNextDot(BoardSpace space, List <Waypoint> waypoints)
    {
        AdjacentSpaces adjacent      = space.GetAdjacentSpaces();
        Waypoint       spaceWaypoint = new Waypoint(screenPosition);

        if (space.IsTopSpace)
        {
            BoardSpaceSpawner boardSpaceSpawner = space.GetSpawner();
            DotController     dot = space.GetCurrentDot();

            // Spawn a new dot to drop
            if (space.IsEmpty || dot.FlaggedToDrop)
            {
                waypoints.Add(spaceWaypoint);
                DotController newDot = boardSpaceSpawner.SpawnDot(waypoints);
                newDot.FlaggedToDrop = true;
                return(newDot);
            }

            // Current dot is valid
            waypoints.Add(spaceWaypoint);
            for (int i = 0; i < waypoints.Count; i++)
            {
                dot.AddWaypoint(waypoints[i]);
            }
            dot.FlaggedToDrop = true;
            return(dot);
        }

        BoardSpace    nextSpace = adjacent.Top;
        DotController nextDot   = nextSpace.GetCurrentDot();

        // Propogate up adjacent dots
        if (nextSpace.IsEmpty || nextDot.FlaggedToDrop)
        {
            waypoints.Add(spaceWaypoint);
            return(FindNextDot(nextSpace, waypoints));
        }

        // Found valid dot
        waypoints.Add(spaceWaypoint);
        for (int i = 0; i < waypoints.Count; i++)
        {
            nextDot.AddWaypoint(waypoints[i]);
        }
        nextDot.FlaggedToDrop = true;
        return(nextDot);
    }