コード例 #1
0
    public void StopInflating()
    {
        if (lifecycle == BalloonLifecycle.Inflating)
        {
            lifecycle = BalloonLifecycle.Inflated;

            BalloonPoint newBalloonPoint = Instantiate(balloonPointPrefab, spawnTarget.position, spawnTarget.rotation, transform).GetComponent <BalloonPoint>();

            balloonPoints.Add(newBalloonPoint);

            // First Point
            if (lastAddedBallonPoint == null)
            {
                lastAddedBallonPoint = newBalloonPoint;
            }
            // Next point
            else
            {
                newBalloonPoint.Initialize(this, inflatingTime, currentColour, 0f);

                Vector3 newDirection = newBalloonPoint.transform.position - lastAddedBallonPoint.transform.position;
                newDirection.Normalize();

                lastAddedBallonPoint.SetNext(newBalloonPoint);
                newBalloonPoint.SetPrevious(lastAddedBallonPoint);
            }

            lastAddedBallonPoint = newBalloonPoint;

            lastSpawnBalloonPoint = spawnTarget.position;
        }
    }
コード例 #2
0
    private void Update()
    {
        if (lifecycle == BalloonLifecycle.Inflating)
        {
            if (Vector3.Distance(lastSpawnBalloonPoint, spawnTarget.position) > newBalloonPointRatio)
            {
                BalloonPoint newBalloonPoint = Instantiate(balloonPointPrefab, spawnTarget.position, spawnTarget.rotation, transform).GetComponent <BalloonPoint>();

                balloonPoints.Add(newBalloonPoint);

                // First Point
                if (lastAddedBallonPoint == null)
                {
                    newBalloonPoint.Initialize(this, inflatingTime, currentColour, 0f);

                    lastAddedBallonPoint = newBalloonPoint;
                }
                // Next point
                else
                {
                    newBalloonPoint.Initialize(this, inflatingTime, currentColour, 0.03f);

                    lastAddedBallonPoint.SetNext(newBalloonPoint);
                    newBalloonPoint.SetPrevious(lastAddedBallonPoint);
                }

                lastAddedBallonPoint = newBalloonPoint;

                lastSpawnBalloonPoint = spawnTarget.position;
            }
        }
        else if (lifecycle == BalloonLifecycle.Inflated)
        {
            if (Input.GetMouseButtonDown(0))
            {
                Ray        ray = Camera.main.ScreenPointToRay(Input.mousePosition);
                RaycastHit hit;

                if (Physics.Raycast(ray, out hit, 100f))
                {
                    BalloonPoint balloonPoint = hit.collider.GetComponent <BalloonPoint>();

                    if (balloonPoint != null)
                    {
                        balloonPoint.Pierce(hit.point, deflatingTime, deflatingDelay);
                    }
                }
            }
        }

        if (lifecycle != BalloonLifecycle.Idle)
        {
            visualiser.UpdateMesh();
        }
    }
コード例 #3
0
 public void SetNext(BalloonPoint balloonPoint)
 {
     next = balloonPoint;
 }
コード例 #4
0
 public void SetPrevious(BalloonPoint balloonPoint)
 {
     previous = balloonPoint;
 }
コード例 #5
0
 public void SetLandingPoint(BalloonPoint landingPoint)
 {
     LandingPoint  = landingPoint;
     CurrentStatus = BalloonStatus.Approaching;
 }