示例#1
0
    private void SpawnNodeAtDistance(float distanceTravelled)
    {
        // Get the coordinates of the point at the distance travelled
        Vector3 pointOnPath = pathCreator.path.GetPointAtDistance(distanceTravelled);
        // Spawn a new node under the parent transform at those coordinates
        NumberNode newNode = Instantiate(numberBall, pointOnPath, Quaternion.identity, parentTransform).GetComponent <NumberNode>();

        newNode.Init();
        // Set the pathfollower's distance travelled acoordingly
        newNode.pathFollower.SetDistanceTravelled(distanceTravelled);
        // Set the node state to be in the gutter
        newNode.SetState(NodeState.GUTTER);
        // Disable the node's motor as the pathfollower takes care of movement in the gutter
        newNode.nodeMotor.enabled = false;
        newNode.SetColorToValue();
        // Add the node to the node manager
        NodeManager.AddNode(newNode);
    }
示例#2
0
 void Update()
 {
     if (!GameStateManager.IsPaused())
     {
         if (timeStamp < Time.time)
         {
             LayerMask nodeMask = LayerMask.GetMask("NodeLayer");
             if (!Physics2D.OverlapCircle(transform.position, NumberNode.RADIUS, nodeMask))
             {
                 NumberNode newNode = Instantiate(numberBall, pathStart, Quaternion.identity, parentTransform).GetComponent <NumberNode>();
                 NodeManager.AddNode(newNode);
                 newNode.SetState(NodeState.FORWARD);
                 newNode.Init();
                 newNode.SetValue(Random.Range(NumberList.BOUND_LOW, NumberList.BOUND_HIGH));
                 timeStamp = Time.time + cooldown;
             }
         }
     }
 }