Exemplo n.º 1
0
    public void SetWayController(WaypointsController wayControl)
    {
        iWayController = wayControl;
        wayControl     = null;

        // Grab total waypoint
        _totalWaypoints = iWayController.GetTotal();

        // Make sure that if you use SetRerversePath to set shouldReversePathFollowing that you call
        // SetReversePath for the first time Before SetWayController, otherwise it won't set the first
        // waypoint correcly
        if (ShouldReversePathFollowing)
        {
            currentWaypointNum = _totalWaypoints - 1;
        }
        else
        {
            currentWaypointNum = 0;
        }

        Init();

        // Get the first waypoint from the waypoint controller
        currentWaypointTransform = iWayController.GetWaypoint(currentWaypointNum);

        if (StartAtFirstWaypoint)
        {
            // Position at the currentwaypointTransform position
            iTransform.position = currentWaypointTransform.position;
        }
    }
Exemplo n.º 2
0
    public void StartEffect(Transform _otherOccupier)
    {
        waypointsController = ball.GetComponent <WaypointsController>();

        ignoreCollisionsBall = ball.GetComponent <IgnoreCollisions>();
        ConnectionEffect otherConnectionEffect = _otherOccupier.GetComponent <ConnectionEffect>();

        connectionActive = true;

        if (!otherConnectionEffect.connectionActive)
        {
            otherConnectionEffect.StartEffect(transform);
        }

        ignoreCollisionsBall.AddActiveCollision(otherConnectionEffect.Ball.GetComponent <Collider>());
        ignoreCollisionsBall.RemoveActiveCollision(myHead.GetComponent <Collider>());

        ball.GetComponent <RandomDirectionPush>().Executing = false;

        ball.GetComponent <ControlledBounce>().ControlBounce = false;

        //only spawn the waypoints if i am a student
        if (isStudent)
        {
            SpawnWayPoints(_otherOccupier);
        }
    }
Exemplo n.º 3
0
 void Awake()
 {
     if (Instance == null)
     {
         Instance = this;
     }
     else
     {
         Destroy(gameObject);
     }
 }
Exemplo n.º 4
0
    void SpawnWayPoints(Transform _otherOccupier)
    {
        Vector2 vectorToTarget = transform.position - _otherOccupier.position;

        float totalDistance = Vector3.Distance(transform.position, _otherOccupier.position);

        float editedDistance = totalDistance * symbolSize;

        List <Vector2> waypointPosition = new List <Vector2>();

        WaypointsController otherWaypointsController = _otherOccupier.GetComponentInChildren <WaypointsController>();

        //add points:

        //point 1
        waypointPosition.Add(transform.position);

        //point 2
        waypointPosition.Add(transform.position + (transform.up + transform.right) * editedDistance);

        //point 3
        waypointPosition.Add((Vector2)transform.position - vectorToTarget / 2);

        //point 4
        waypointPosition.Add(_otherOccupier.position + (_otherOccupier.right + _otherOccupier.up) * editedDistance);

        //point 5
        waypointPosition.Add(_otherOccupier.position);

        //point 6
        waypointPosition.Add(_otherOccupier.position + (_otherOccupier.right + -_otherOccupier.up) * editedDistance);

        //point 7
        waypointPosition.Add((Vector2)transform.position - vectorToTarget / 2);

        //point 8
        waypointPosition.Add(transform.position + (transform.right + -transform.up) * editedDistance);

        for (int i = 0; i < waypointPosition.Count; i++)
        {
            waypointsController.AddWaypoint(waypointPosition[i]);
            otherWaypointsController.AddWaypoint(waypointPosition[i]);
        }

        otherWaypointsController.WaypointIndex = 4;
        otherWaypointsController.SetBackwards(true);
        otherWaypointsController.StartPatrolling();
        waypointsController.StartPatrolling();
    }
Exemplo n.º 5
0
 void Awake()
 {
     WaypointsController.AddWayPoint(transform);
 }