예제 #1
0
    public void SetupCollectible()
    {
        if (!collectibleData)
        {
            return;
        }
        switch (collectibleData.collectibleType)
        {
        case CollectibleType.BigScrap:
            mover.onTargetReached.AddListener(TargetReached);
            if (!dropped)
            {
                mover.GoToStartPoint();
            }
            transform.eulerAngles = new Vector3(0, 0, mover.degree - 90);
            mover.moving          = true;
            break;

        case CollectibleType.Blueprint:
            var degree = Mathfx.GetAngle(Vector3.zero, transform.position);
            var radius = Vector3.Distance(transform.position, Vector3.zero);
            print("blueprint radius: " + radius + " angle: " + degree);
            if (radius > 4.5f)
            {
                mover.SetAngle(degree);
                mover.SetEndPoint(3.5f);
                mover.StartMovement(MoveType.Path, 3, mover.endPoint);
            }

            break;

        case CollectibleType.Xeno:

            if (phasesOut)
            {
                StartTimeLimit();
            }

            var xDegree  = Mathfx.GetAngle(Vector3.zero, transform.position);
            var distance = Vector3.Distance(transform.position, Vector3.zero);

            if (distance > 4.5)
            {
                mover.SetAngle(xDegree);
                mover.SetEndPoint(4f);
                mover.StartMovement(MoveType.Path, 3, mover.endPoint);
            }
            break;
        }
    }
예제 #2
0
 public override void Mobilize(int dir)
 {
     if (firstMobilize)
     {
         mover.onTargetReached.AddListener(TargetReached);
         firstMobilize = false;
     }
     if (dropped && collectibleData.moverData.dropInBounds)
     {
         var   radius   = Vector3.Distance(Vector3.zero, transform.position);
         float endPoint = -1;
         if (radius > collectibleData.moverData.maxDropRadius)
         {
             endPoint = collectibleData.moverData.maxDropRadius;
         }
         else if (radius < collectibleData.moverData.minDropRadius)
         {
             endPoint = collectibleData.moverData.minDropRadius;
         }
         if (endPoint == collectibleData.moverData.maxDropRadius || endPoint == collectibleData.moverData.minDropRadius)
         {
             var degrees = Mathfx.GetAngle(Vector3.zero, transform.position);
             mover.SetAngle(degrees);
             mover.SetEndPoint(endPoint);
             mover.StartMovement(MoveType.Path, collectibleData.moverData.speed, mover.endPoint);
         }
         else
         {
             TargetReached();
         }
     }
     else
     {
         mover.Mobilize(collectibleData.moverData.speed);
         if (!dropped)
         {
             mover.GoToStartPoint();
         }
         if (collectibleData.moverData.orientRotation)
         {
             var degrees = Mathfx.GetAngle(Vector3.zero, transform.position);
             transform.eulerAngles = new Vector3(0, 0, degrees - 90);
         }
         mover.moving = true;
     }
 }