Example #1
0
 private void Update()
 {
     if (isInEvent)
     {
         GameData.playerManager.inControl = false;
         if (currentEventPartIndex < eventParts.Count)
         {
             if (!eventParts[currentEventPartIndex].eventStarted)
             {
                 eventParts[currentEventPartIndex].StartEventPart();
                 SetNewCameraConstraint();
             }
             else if (eventParts[currentEventPartIndex].eventEnded)
             {
                 previousCamera = eventParts[currentEventPartIndex].cameraConstraintDuringEventPart;
                 currentEventPartIndex++;
             }
         }
         else
         {
             EndEvent();
         }
     }
     else
     {
         if (switchToTriggerEvent != null && switchToTriggerEvent.IsON() && !eventTriggered)
         {
             StartEvent();
         }
     }
 }
Example #2
0
    private Vector2 ValidPosByZoneLimits(Vector2 originPos)
    {
        correctedCameraPos = originPos;

        upEdgePos    = originPos + currentOrthographicSize * Vector2.up;
        downEdgePos  = originPos + currentOrthographicSize * Vector2.down;
        rightEdgePos = originPos + (currentOrthographicSize * mainCamera.aspect) * Vector2.right;
        leftEdgePos  = originPos + (currentOrthographicSize * mainCamera.aspect) * Vector2.left;

        /*Debug.DrawRay(upEdgePos, Vector2.down);
         * Debug.DrawRay(downEdgePos, Vector2.up);
         * Debug.DrawRay(rightEdgePos, Vector2.left);
         * Debug.DrawRay(leftEdgePos, Vector2.right);
         * Debug.DrawRay(originPos, Vector2.up * 1);*/

        if (constraintZones.Count > 0)
        {
            currentZone = constraintZones[constraintZones.Count - 1];
            float absoluteUpLimit    = (currentZone.limitRelativeToZonePos ? currentZone.transform.position.y + currentZone.upLimit : currentZone.upLimit) + edgeMargin;
            float absoluteDownLimit  = (currentZone.limitRelativeToZonePos ? currentZone.transform.position.y + currentZone.downLimit : currentZone.downLimit) - edgeMargin;
            float absoluteRightLimit = (currentZone.limitRelativeToZonePos ? currentZone.transform.position.x + currentZone.rightLimit : currentZone.rightLimit) + edgeMargin;
            float absoluteLeftLimit  = (currentZone.limitRelativeToZonePos ? currentZone.transform.position.x + currentZone.leftLimit : currentZone.leftLimit) - edgeMargin;

            if (upEdgePos.y > absoluteUpLimit && currentZone.upLimit != 0)
            {
                correctedCameraPos = new Vector2(correctedCameraPos.x, absoluteUpLimit - currentOrthographicSize);
            }

            if (downEdgePos.y < absoluteDownLimit && currentZone.downLimit != 0)
            {
                correctedCameraPos = new Vector2(correctedCameraPos.x, absoluteDownLimit + currentOrthographicSize);
            }

            if (currentZone.upLimit != 0 && currentZone.downLimit != 0 && currentZone.upLimit - currentZone.downLimit < currentOrthographicSize * 2)
            {
                correctedCameraPos = new Vector2(correctedCameraPos.x, (absoluteUpLimit + absoluteDownLimit) / 2);
            }

            if (rightEdgePos.x > absoluteRightLimit && currentZone.rightLimit != 0)
            {
                correctedCameraPos = new Vector2(absoluteRightLimit - currentOrthographicSize * mainCamera.aspect, correctedCameraPos.y);
            }

            if (leftEdgePos.x < absoluteLeftLimit && currentZone.leftLimit != 0)
            {
                correctedCameraPos = new Vector2(absoluteLeftLimit + currentOrthographicSize * mainCamera.aspect, correctedCameraPos.y);
            }

            if (currentZone.rightLimit != 0 && currentZone.leftLimit != 0 && currentZone.rightLimit - currentZone.leftLimit < currentOrthographicSize * mainCamera.aspect * 2)
            {
                correctedCameraPos = new Vector2((absoluteLeftLimit + absoluteRightLimit) / 2, correctedCameraPos.y);
            }
        }
        Debug.DrawRay(correctedCameraPos, Vector2.up, Color.green);
        return(correctedCameraPos);
    }
Example #3
0
    private void StartEvent()
    {
        if (!eventTriggered && GameManager.currentStoryStep >= neededStoryStepToTrigger && GameManager.currentStoryStep <= maxStoryStepToTrigger && !isOn)
        {
            for (int i = 0; i < eventParts.Count; i++)
            {
                eventParts[i].ResetEvent(this);
            }

            isInEvent                        = true;
            eventTriggered                   = true;
            currentEventPartIndex            = 0;
            GameData.playerManager.inControl = false;
            GameData.grappleHandler.hideAimArrow++;
            previousCamera = null;
        }
    }