Beispiel #1
0
    public void MinusLight()
    {
        HaloLight.range     -= AddHaloAmount;
        HaloLight.intensity -= AddHaloAmount;

        if (HaloLight.intensity <= 0)
        {
            MySceneManager MySceneManagerScript = MySceneManaObj.GetComponent <MySceneManager>();

            MySceneManagerScript.RestartLevel();
        }
    }
Beispiel #2
0
    // Update is called once per frame
    void Update()
    {
        if (CameraTransArray == null || CameraTransArray.Count == 0)
        {
            return;
        }

        JourneyTime = Time.time - StartTime;
        float timePerc = JourneyTime / Vector3.Distance(StartPos, TargetPos) * Speed;

        // Finished this little trip.
        if (timePerc >= 1)
        {
            MoveDirection = Vector3.zero;

            // Check if there is next element in the array, if not, stop all the moving.
            if (NextPosIndex < CameraTransArray.Count)
            {
                Transform nextTrans = (Transform)CameraTransArray[NextPosIndex++];
                MoveCameraToPoint(nextTrans);
            }
        }
        else
        {
            transform.position = Vector3.Lerp(StartPos, TargetPos, timePerc);
        }

        // Check if the playe is outside of the camera view.

        Vector3 screePoint = Camera.main.WorldToViewportPoint(PlayerObj.transform.position);
        bool    onScreen   = screePoint.x > 0 && screePoint.x < 1 && screePoint.y > 0 && screePoint.y < 1 && screePoint.z > 0;

        if (!onScreen)
        {
            MySceneManager MySceneManagerScript = MySceneManaObj.GetComponent <MySceneManager>();

            MySceneManagerScript.RestartLevel();
        }


        //  Check if the Camera has reached the last position.
        if (LevelCheckTime == 0 && IsTheLastPos())
        {
            LevelCheckTime = Time.time + TimeLeftForLevelEnd;
        }
        else if (LevelCheckTime <= Time.time && IsTheLastPos())
        {
            if (PlayerMoveScript.FriendResued >= PlayerMoveScript.FriendNeedForThisLevel)
            {
                // Need to make sure this is one time thing.
                if (!ChangedLevel)
                {
                    MySceneManager MySceneManagerScript = MySceneManaObj.GetComponent <MySceneManager>();

                    MySceneManagerScript.NextLevel();

                    ChangedLevel = true;
                }
            }
            else
            {
                MySceneManager MySceneManagerScript = MySceneManaObj.GetComponent <MySceneManager>();

                MySceneManagerScript.RestartLevel();
            }
        }
    }