示例#1
0
        protected void Start()
        {
            // Pick a horizontal boundary to appear from.
            GameObject    boundary = GameController.instance.boundaries.GetRandomBoundary(true);
            BoundaryPlane plane    = boundary.GetComponent <BoundaryPlane>();

            Vector3 boundaryPosition = boundary.transform.position;

            Vector3 scale = Vector3.Scale(boundaryPosition, plane.GetAxis());

            // Determine the position to instantiate at
            Vector3 position = boundaryPosition - (boundaryPosition.normalized * 10f);

            position.y = Vector3.Magnitude(scale) - 25;
            Vector3 forward  = -position;
            Vector3 velocity = forward * this.TranslationSpeed;

            velocity.y = 0;

            this.transform.position = position;
            this.transform.forward  = forward;
            this.rigidbody.velocity = velocity;

            Debug.Log("Balloon spawned at " + position + " going towards " + velocity);
        }
示例#2
0
        protected void WrapEntity(GameObject boundary)
        {
            // Get the MonoBehaviour of the boundary instance.
            BoundaryPlane plane = boundary.GetComponent <BoundaryPlane>();

            // Get the axis of this boundary plane.
            Vector3 planeAxis = plane.GetAxis();

            // Calculate the position of this entity on the opposing side.
            Vector3 currentPosition = this.transform.position;
            Vector3 targetPosition  = currentPosition + Vector3.Scale(currentPosition, (planeAxis * -2f));

            // Translate the current entity to that point.
            this.transform.position = targetPosition;

            // Set which boundary to ignore (because when we wrap, we will end up colliding with the opposing boundary)
            this.ignoreBoundary = this.boundaryManager.GetMirrorBoundary(plane.cardinal);
        }