public void CameraMovementLive(HERO hero)
    {
        var magnitude = hero.rigidbody.velocity.magnitude;

        if (magnitude > 10f)
        {
            Camera.main.fieldOfView = Mathf.Lerp(Camera.main.fieldOfView, Mathf.Min(100f, magnitude + 40f), 0.1f);
        }
        else
        {
            Camera.main.fieldOfView = Mathf.Lerp(Camera.main.fieldOfView, 50f, 0.1f);
        }

        var num2 = hero.CameraMultiplier * (200f - Camera.main.fieldOfView) / 150f;

        this.transform.position = head.transform.position + Vector3.up * heightMulti - Vector3.up * (0.6f - cameraDistance) * 2f;
        var transform = this.transform;

        transform.position -= this.transform.forward * distance * distanceMulti * num2;
        if (hero.CameraMultiplier < 0.65f)
        {
            var transform2 = this.transform;
            transform2.position += this.transform.right * Mathf.Max((0.6f - hero.CameraMultiplier) * 2f, 0.65f);
        }

        this.transform.rotation = Quaternion.Lerp(Camera.main.transform.rotation, hero.GetComponent <SmoothSyncMovement>().correctCameraRot, Time.deltaTime * 5f);
    }
Example #2
0
    public void CameraMovementLive(HERO hero)
    {
        float magnitude = hero.rigidbody.velocity.magnitude;

        if (magnitude > 10f)
        {
            Camera.main.fieldOfView = Mathf.Lerp(Camera.main.fieldOfView, Mathf.Min((float)100f, (float)(magnitude + 40f)), 0.1f);
        }
        else
        {
            Camera.main.fieldOfView = Mathf.Lerp(Camera.main.fieldOfView, 50f, 0.1f);
        }
        float num2 = (hero.CameraMultiplier * (200f - Camera.main.fieldOfView)) / 150f;

        base.transform.position = (Vector3)((this.head.transform.position + (Vector3.up * this.heightMulti)) - ((Vector3.up * (0.6f - cameraDistance)) * 2f));
        Transform transform = base.transform;

        transform.position -= (Vector3)(((base.transform.forward * this.distance) * this.distanceMulti) * num2);
        if (hero.CameraMultiplier < 0.65f)
        {
            Transform transform2 = base.transform;
            transform2.position += (Vector3)(base.transform.right * Mathf.Max((float)((0.6f - hero.CameraMultiplier) * 2f), (float)0.65f));
        }
        base.transform.rotation = Quaternion.Lerp(Camera.main.transform.rotation, hero.GetComponent <SmoothSyncMovement>().correctCameraRot, Time.deltaTime * 5f);
    }
    public void update2()
    {
        if (flashDuration > 0f)
        {
            flashDuration -= UnityEngine.Time.deltaTime;
            if (flashDuration <= 0f)
            {
                flashDuration = 0f;
            }
            GameObject.Find("flash").GetComponent <UISprite>().alpha = flashDuration * 0.5f;
        }
        if (Gametype == GameType.Stop)
        {
            Screen.showCursor = true;
            Screen.lockCursor = false;
            return;
        }
        if (Gametype != GameType.Singleplayer && gameOver)
        {
            if (inputManager.isInputDown[InputCode.Attack1])
            {
                if (spectatorMode)
                {
                    SetSpectorMode(val: false);
                }
                else
                {
                    SetSpectorMode(val: true);
                }
            }
            if (inputManager.isInputDown[InputCode.Flare1])
            {
                GameObject[] players = GameObject.FindGameObjectsWithTag("Player");
                currentPeekPlayerIndex = (currentPeekPlayerIndex + 1) % players.Length;
                if (players.Length > 0)
                {
                    SetMainObject(players[currentPeekPlayerIndex]);
                    SetSpectorMode(val: false);
                    lockAngle = false;
                }
            }
            if (inputManager.isInputDown[InputCode.Flare2])
            {
                currentPeekPlayerIndex--;
                GameObject[] players = GameObject.FindGameObjectsWithTag("Player");
                int          num2    = players.Length;
                if (currentPeekPlayerIndex >= num2)
                {
                    currentPeekPlayerIndex = 0;
                }
                if (currentPeekPlayerIndex < 0)
                {
                    currentPeekPlayerIndex = num2 - 1;
                }
                if (num2 > 0)
                {
                    SetMainObject(players[currentPeekPlayerIndex]);
                    SetSpectorMode(val: false);
                    lockAngle = false;
                }
            }
            if (spectatorMode)
            {
                return;
            }
        }
        if (inputManager.isInputDown[InputCode.Pause])
        {
            if (IsPausing)
            {
                if (main_object != null)
                {
                    Vector3 position = base.transform.position;
                    position  = ((head == null) ? main_object.transform.position : head.transform.position);
                    position += Vector3.up * heightMulti;
                    base.transform.position = Vector3.Lerp(base.transform.position, position - base.transform.forward * 5f, 0.2f);
                }
                return;
            }
            IsPausing = !IsPausing;
            if (IsPausing)
            {
                if (Gametype == GameType.Singleplayer)
                {
                    UnityEngine.Time.timeScale = 0f;
                }
                GameObject.Find("InputManagerController").GetComponent <FengCustomInputs>().menuOn = true;
                Screen.showCursor = true;
                Screen.lockCursor = false;
            }
        }
        if (needSetHUD)
        {
            needSetHUD = false;
            SetHUDPosition();
            Screen.lockCursor = !Screen.lockCursor;
            Screen.lockCursor = !Screen.lockCursor;
        }
        if (inputManager.isInputDown[InputCode.Fullscreen])
        {
            Screen.fullScreen = !Screen.fullScreen;
            if (Screen.fullScreen)
            {
                Screen.SetResolution(960, 600, fullscreen: false);
            }
            else
            {
                Screen.SetResolution(Screen.currentResolution.width, Screen.currentResolution.height, fullscreen: true);
            }
            needSetHUD = true;
            Minimap.OnScreenResolutionChanged();
        }
        if (inputManager.isInputDown[InputCode.Restart])
        {
            Reset();
        }
        if (main_object == null)
        {
            return;
        }
        if (inputManager.isInputDown[InputCode.ChangeCamera])
        {
            switch (CameraMode)
            {
            case CAMERA_TYPE.TPS:
                CameraMode        = CAMERA_TYPE.ORIGINAL;
                Screen.lockCursor = false;
                break;

            case CAMERA_TYPE.ORIGINAL:
                CameraMode        = CAMERA_TYPE.WOW;
                Screen.lockCursor = false;
                break;

            case CAMERA_TYPE.WOW:
                CameraMode        = CAMERA_TYPE.TPS;
                Screen.lockCursor = true;
                break;
            }
            if ((int)FengGameManagerMKII.Settings[245] == 1 || main_object.GetComponent <HERO>() == null)
            {
                Screen.showCursor = false;
            }
        }
        if (inputManager.isInputDown[InputCode.ToggleCursor])
        {
            Screen.showCursor = !Screen.showCursor;
        }
        if (inputManager.isInputDown[InputCode.Focus])
        {
            TriggerAutoLock = !TriggerAutoLock;
            if (TriggerAutoLock)
            {
                lockTarget = FindNearestTitan();
                if (closestDistance >= 150f)
                {
                    lockTarget      = null;
                    TriggerAutoLock = false;
                }
            }
        }
        if (gameOver)
        {
            if (FengGameManagerMKII.InputRC.isInputHumanDown(InputCodeRC.LiveCamera))
            {
                if ((int)FengGameManagerMKII.Settings[263] == 0)
                {
                    FengGameManagerMKII.Settings[263] = 1;
                }
                else
                {
                    FengGameManagerMKII.Settings[263] = 0;
                }
            }
            HERO component = main_object.GetComponent <HERO>();
            if (component != null && (int)FengGameManagerMKII.Settings[263] == 1 && component.GetComponent <SmoothSyncMovement>().enabled&& component.isPhotonCamera)
            {
                CameraMovementLive(component);
            }
            else if (lockAngle)
            {
                base.transform.rotation = Quaternion.Lerp(base.transform.rotation, main_object.transform.rotation, 0.2f);
                base.transform.position = Vector3.Lerp(base.transform.position, main_object.transform.position - main_object.transform.forward * 5f, 0.2f);
            }
            else
            {
                MoveCamera();
            }
        }
        else
        {
            MoveCamera();
        }
        if (TriggerAutoLock && lockTarget != null)
        {
            float     z         = base.transform.eulerAngles.z;
            Transform transform = lockTarget.transform.Find("Amarture/Core/Controller_Body/hip/spine/chest/neck");
            Vector3   a         = transform.position - ((head == null) ? main_object.transform.position : head.transform.position);
            a.Normalize();
            lockCameraPosition      = ((head == null) ? main_object.transform.position : head.transform.position);
            lockCameraPosition     -= a * distance * distanceMulti * distanceOffsetMulti;
            lockCameraPosition     += Vector3.up * 3f * heightMulti * distanceOffsetMulti;
            base.transform.position = Vector3.Lerp(base.transform.position, lockCameraPosition, UnityEngine.Time.deltaTime * 4f);
            if (head != null)
            {
                base.transform.LookAt(head.transform.position * 0.8f + transform.position * 0.2f);
            }
            else
            {
                base.transform.LookAt(main_object.transform.position * 0.8f + transform.position * 0.2f);
            }
            base.transform.localEulerAngles = new Vector3(base.transform.eulerAngles.x, base.transform.eulerAngles.y, z);
            Vector2 vector = base.camera.WorldToScreenPoint(transform.position - transform.forward * lockTarget.transform.localScale.x);
            locker.transform.localPosition = new Vector3(vector.x - (float)Screen.width * 0.5f, vector.y - (float)Screen.height * 0.5f, 0f);
            if (lockTarget.GetComponent <TITAN>() != null && lockTarget.GetComponent <TITAN>().hasDie)
            {
                lockTarget = null;
            }
        }
        else
        {
            locker.transform.localPosition = new Vector3(0f, (float)(-Screen.height) * 0.5f - 50f, 0f);
        }
        Vector3 end        = (head == null) ? main_object.transform.position : head.transform.position;
        Vector3 normalized = (((head == null) ? main_object.transform.position : head.transform.position) - base.transform.position).normalized;

        end -= distance * normalized * distanceMulti;
        LayerMask  mask  = 1 << LayerMask.NameToLayer("Ground");
        LayerMask  mask2 = 1 << LayerMask.NameToLayer("EnemyBox");
        LayerMask  mask3 = (int)mask | (int)mask2;
        RaycastHit hitInfo;

        if (head != null)
        {
            if (Physics.Linecast(head.transform.position, end, out hitInfo, mask))
            {
                base.transform.position = hitInfo.point;
            }
            else if (Physics.Linecast(head.transform.position - normalized * distanceMulti * 3f, end, out hitInfo, mask2))
            {
                base.transform.position = hitInfo.point;
            }
            Debug.DrawLine(head.transform.position - normalized * distanceMulti * 3f, end, Color.red);
        }
        else if (Physics.Linecast(main_object.transform.position + Vector3.up, end, out hitInfo, mask3))
        {
            base.transform.position = hitInfo.point;
        }
        UpdateShake();
    }
Example #4
0
 public void update()
 {
     if (this.flashDuration > 0f)
     {
         this.flashDuration -= Time.deltaTime;
         if (this.flashDuration <= 0f)
         {
             this.flashDuration = 0f;
         }
         GameObject.Find("flash").GetComponent <UISprite>().alpha = this.flashDuration * 0.5f;
     }
     if (gametype == GAMETYPE.STOP)
     {
         Screen.showCursor = true;
         Screen.lockCursor = false;
     }
     else
     {
         if ((gametype != GAMETYPE.SINGLE) && this.gameOver)
         {
             if (this.inputManager.isInputDown[InputCode.attack1])
             {
                 if (this.spectatorMode)
                 {
                     this.setSpectorMode(false);
                 }
                 else
                 {
                     this.setSpectorMode(true);
                 }
             }
             if (this.inputManager.isInputDown[InputCode.flare1])
             {
                 this.currentPeekPlayerIndex++;
                 int length = GameObject.FindGameObjectsWithTag("Player").Length;
                 if (this.currentPeekPlayerIndex >= length)
                 {
                     this.currentPeekPlayerIndex = 0;
                 }
                 if (length > 0)
                 {
                     this.setMainObject(GameObject.FindGameObjectsWithTag("Player")[this.currentPeekPlayerIndex], true, false);
                     this.setSpectorMode(false);
                     this.lockAngle = false;
                 }
             }
             if (this.inputManager.isInputDown[InputCode.flare2])
             {
                 this.currentPeekPlayerIndex--;
                 int num2 = GameObject.FindGameObjectsWithTag("Player").Length;
                 if (this.currentPeekPlayerIndex >= num2)
                 {
                     this.currentPeekPlayerIndex = 0;
                 }
                 if (this.currentPeekPlayerIndex < 0)
                 {
                     this.currentPeekPlayerIndex = num2;
                 }
                 if (num2 > 0)
                 {
                     this.setMainObject(GameObject.FindGameObjectsWithTag("Player")[this.currentPeekPlayerIndex], true, false);
                     this.setSpectorMode(false);
                     this.lockAngle = false;
                 }
             }
             if (this.spectatorMode)
             {
                 return;
             }
         }
         if (this.inputManager.isInputDown[InputCode.pause])
         {
             if (isPausing)
             {
                 if (this.main_object != null)
                 {
                     Vector3 position = base.transform.position;
                     position  = (this.head == null) ? this.main_object.transform.position : this.head.transform.position;
                     position += (Vector3)(Vector3.up * this.heightMulti);
                     base.transform.position = Vector3.Lerp(base.transform.position, position - ((Vector3)(base.transform.forward * 5f)), 0.2f);
                 }
                 return;
             }
             isPausing = !isPausing;
             if (isPausing)
             {
                 if (gametype == GAMETYPE.SINGLE)
                 {
                     Time.timeScale = 0f;
                 }
                 GameObject.Find("InputManagerController").GetComponent <FengCustomInputs>().menuOn = true;
                 Screen.showCursor = true;
                 Screen.lockCursor = false;
             }
         }
         if (this.needSetHUD)
         {
             this.needSetHUD = false;
             this.setHUDposition();
             Screen.lockCursor = !Screen.lockCursor;
             Screen.lockCursor = !Screen.lockCursor;
         }
         if (this.inputManager.isInputDown[InputCode.fullscreen])
         {
             Screen.fullScreen = !Screen.fullScreen;
             if (Screen.fullScreen)
             {
                 Screen.SetResolution(960, 600, false);
             }
             else
             {
                 Screen.SetResolution(Screen.currentResolution.width, Screen.currentResolution.height, true);
             }
             this.needSetHUD = true;
             Minimap.OnScreenResolutionChanged();
         }
         if (this.inputManager.isInputDown[InputCode.restart])
         {
             this.reset();
         }
         if (this.main_object != null)
         {
             RaycastHit hit;
             if (this.inputManager.isInputDown[InputCode.camera])
             {
                 if (cameraMode == CAMERA_TYPE.ORIGINAL)
                 {
                     cameraMode        = CAMERA_TYPE.WOW;
                     Screen.lockCursor = false;
                 }
                 else if (cameraMode == CAMERA_TYPE.WOW)
                 {
                     cameraMode        = CAMERA_TYPE.TPS;
                     Screen.lockCursor = true;
                 }
                 else if (cameraMode == CAMERA_TYPE.TPS)
                 {
                     cameraMode        = CAMERA_TYPE.ORIGINAL;
                     Screen.lockCursor = false;
                 }
                 if ((((int)FengGameManagerMKII.settings[0xf5]) == 1) || (this.main_object.GetComponent <HERO>() == null))
                 {
                     Screen.showCursor = false;
                 }
             }
             if (this.inputManager.isInputDown[InputCode.hideCursor])
             {
                 Screen.showCursor = !Screen.showCursor;
             }
             if (this.inputManager.isInputDown[InputCode.focus])
             {
                 triggerAutoLock = !triggerAutoLock;
                 if (triggerAutoLock)
                 {
                     this.lockTarget = this.findNearestTitan();
                     if (this.closestDistance >= 150f)
                     {
                         this.lockTarget = null;
                         triggerAutoLock = false;
                     }
                 }
             }
             if (this.gameOver && (this.main_object != null))
             {
                 if (FengGameManagerMKII.inputRC.isInputHumanDown(InputCodeRC.liveCam))
                 {
                     if (((int)FengGameManagerMKII.settings[0x107]) == 0)
                     {
                         FengGameManagerMKII.settings[0x107] = 1;
                     }
                     else
                     {
                         FengGameManagerMKII.settings[0x107] = 0;
                     }
                 }
                 HERO component = this.main_object.GetComponent <HERO>();
                 if ((((component != null) && (((int)FengGameManagerMKII.settings[0x107]) == 1)) && component.GetComponent <SmoothSyncMovement>().enabled) && component.isPhotonCamera)
                 {
                     this.CameraMovementLive(component);
                 }
                 else if (this.lockAngle)
                 {
                     base.transform.rotation = Quaternion.Lerp(base.transform.rotation, this.main_object.transform.rotation, 0.2f);
                     base.transform.position = Vector3.Lerp(base.transform.position, this.main_object.transform.position - ((Vector3)(this.main_object.transform.forward * 5f)), 0.2f);
                 }
                 else
                 {
                     this.camareMovement();
                 }
             }
             else
             {
                 this.camareMovement();
             }
             if (triggerAutoLock && (this.lockTarget != null))
             {
                 float     z         = base.transform.eulerAngles.z;
                 Transform transform = this.lockTarget.transform.Find("Amarture/Core/Controller_Body/hip/spine/chest/neck");
                 Vector3   vector2   = transform.position - ((this.head == null) ? this.main_object.transform.position : this.head.transform.position);
                 vector2.Normalize();
                 this.lockCameraPosition  = (this.head == null) ? this.main_object.transform.position : this.head.transform.position;
                 this.lockCameraPosition -= (Vector3)(((vector2 * this.distance) * this.distanceMulti) * this.distanceOffsetMulti);
                 this.lockCameraPosition += (Vector3)(((Vector3.up * 3f) * this.heightMulti) * this.distanceOffsetMulti);
                 base.transform.position  = Vector3.Lerp(base.transform.position, this.lockCameraPosition, Time.deltaTime * 4f);
                 if (this.head != null)
                 {
                     base.transform.LookAt((Vector3)((this.head.transform.position * 0.8f) + (transform.position * 0.2f)));
                 }
                 else
                 {
                     base.transform.LookAt((Vector3)((this.main_object.transform.position * 0.8f) + (transform.position * 0.2f)));
                 }
                 base.transform.localEulerAngles = new Vector3(base.transform.eulerAngles.x, base.transform.eulerAngles.y, z);
                 Vector2 vector3 = base.camera.WorldToScreenPoint(transform.position - ((Vector3)(transform.forward * this.lockTarget.transform.localScale.x)));
                 this.locker.transform.localPosition = new Vector3(vector3.x - (Screen.width * 0.5f), vector3.y - (Screen.height * 0.5f), 0f);
                 if ((this.lockTarget.GetComponent <TITAN>() != null) && this.lockTarget.GetComponent <TITAN>().hasDie)
                 {
                     this.lockTarget = null;
                 }
             }
             else
             {
                 this.locker.transform.localPosition = new Vector3(0f, (-Screen.height * 0.5f) - 50f, 0f);
             }
             Vector3 end        = (this.head == null) ? this.main_object.transform.position : this.head.transform.position;
             Vector3 vector5    = ((this.head == null) ? this.main_object.transform.position : this.head.transform.position) - base.transform.position;
             Vector3 normalized = vector5.normalized;
             end -= (Vector3)((this.distance * normalized) * this.distanceMulti);
             LayerMask mask  = ((int)1) << LayerMask.NameToLayer("Ground");
             LayerMask mask2 = ((int)1) << LayerMask.NameToLayer("EnemyBox");
             LayerMask mask3 = mask | mask2;
             if (this.head != null)
             {
                 if (Physics.Linecast(this.head.transform.position, end, out hit, (int)mask))
                 {
                     base.transform.position = hit.point;
                 }
                 else if (Physics.Linecast(this.head.transform.position - ((Vector3)((normalized * this.distanceMulti) * 3f)), end, out hit, (int)mask2))
                 {
                     base.transform.position = hit.point;
                 }
                 Debug.DrawLine(this.head.transform.position - ((Vector3)((normalized * this.distanceMulti) * 3f)), end, Color.red);
             }
             else if (Physics.Linecast(this.main_object.transform.position + Vector3.up, end, out hit, (int)mask3))
             {
                 base.transform.position = hit.point;
             }
             this.shakeUpdate();
         }
     }
 }