private void Awake() { sInstance = this; PlayerMovement.OnStun += delegate { mKeepScanning = false; }; PlayerMovement.OnUnfreeze += delegate { mKeepScanning = true; }; mScannerMaterial.SetFloat("_Slider", 0); GameManager.OnGameReady += delegate { StartScan(); mIsDirectlyConnected = true; mIsBigConnected = true; }; OnBigDisconnection += delegate { mIsBigConnected = false; mIsDirectlyConnected = false; mKeepScanning = false; }; OnBigReconnection += delegate { mIsBigConnected = true; mIsDirectlyConnected = true; mKeepScanning = true; }; OnDirectReconnection += delegate { mIsDirectlyConnected = true; mIsBigConnected = true; StopCoroutine(nameof(DisconnectionCountdown)); }; OnDirectDisconnection += delegate { mIsDirectlyConnected = false; mTimeLeftUntilBigDisconnection = mDisconnectionTimeOut; mCurrentDownloadingSpeed = 0f; StartCoroutine(nameof(DisconnectionCountdown)); }; mPreviousAntennaRotation = mAntennaTransform.rotation; }
private void Awake() { mSlowRatio = 1f; GameManager.OnGameReady += delegate { mSlowRatio = 0f; transform.position = WifiManager.sClosestWifiPoint.transform.position; }; GameManager.OnGameOverTimeRanOut += delegate { mIsFrozen = true; }; GameManager.OnGameOverNoLivesLeft += delegate { mIsFrozen = true; }; GameManager.OnRestart += delegate { mSlowRatio = 0f; transform.position = WifiManager.sClosestWifiPoint.transform.position; mIsFrozen = false; }; if (sInstance != null) { Debug.Log("[Player] There was already an instance, wtf"); Destroy(sInstance); } sInstance = this; this.tag = "Player"; gameObject.layer = LayerMask.NameToLayer("Player"); mCharacterController = GetComponent <CharacterController>(); if (mCharacterController == null) { mCharacterController = gameObject.AddComponent <CharacterController>(); mCharacterController.center = 0.9f * Vector3.up; } mCharacterController.height = 2; mCharacterController.radius = 0.25f; mMaxRunSpeed = mMaxWalkSpeed * mRunSpeedRatio; Rigidbody rb = GetComponent <Rigidbody>(); if (rb == null) { rb = gameObject.AddComponent <Rigidbody>(); } //rb.useGravity = false; //rb.isKinematic = true; rb.constraints = RigidbodyConstraints.FreezeRotationX | RigidbodyConstraints.FreezeRotationZ; rb.interpolation = RigidbodyInterpolation.Interpolate; OnStun += delegate { mIsFrozen = true; Invoke(nameof(Unfreeze), mBiteStunTime); }; OnUnfreeze += delegate { mIsFrozen = false; }; }