コード例 #1
0
ファイル: RespawnManager.cs プロジェクト: looki666/Green-Hell
    public void Respawn(Being obj)
    {
        if (!obj)
        {
            return;
        }
        RespawnPoint bestRespawnPoint = this.GetBestRespawnPoint(obj.transform.position);

        DebugUtils.Assert(bestRespawnPoint, true);
        if (bestRespawnPoint)
        {
            obj.transform.position = bestRespawnPoint.transform.position;
        }
        Collider componentDeepChild = General.GetComponentDeepChild <Collider>(obj.gameObject);
        Vector3  position           = obj.transform.position;

        position.y += ((!componentDeepChild) ? 0f : componentDeepChild.bounds.size.y);
        RaycastHit raycastHit;

        if (Physics.Raycast(position, Vector3.down, out raycastHit))
        {
            obj.transform.position = raycastHit.point;
        }
        if (obj.IsPlayer())
        {
            Vector3 vector = (!bestRespawnPoint) ? Vector3.forward : bestRespawnPoint.transform.forward;
            vector.y = 0f;
            float   num  = Vector3.Angle(vector, Vector3.forward);
            Vector2 zero = Vector2.zero;
            if (Vector3.Dot(Vector3.right, vector) < 0f)
            {
                num *= -1f;
            }
            zero.x = num;
            FPPController fppcontroller = Player.Get().m_FPPController;
            fppcontroller.SetLookDev(zero);
            Vector3 position2 = obj.transform.position;
            position2.y           += Player.Get().GetComponent <CharacterController>().height * 0.5f;
            obj.transform.position = position2;
        }
    }
コード例 #2
0
 private void LateUpdate()
 {
     if (this.m_StoreStartPosition && this.m_PlayableDirectorEx && this.m_PlayableDirectorEx.m_FollowOffsetHelper)
     {
         this.m_StartPos           = this.m_PlayableDirectorEx.m_Transform.position - this.m_PlayableDirectorEx.m_RefTransform.position;
         this.m_StoreStartPosition = false;
         this.m_PrevPos            = this.m_StartPos;
         this.m_LastPos            = this.m_StartPos;
         this.m_StartRot           = Quaternion.Inverse(this.m_PlayableDirectorEx.m_RefTransform.rotation) * this.m_PlayableDirectorEx.m_Transform.rotation;
         this.m_PrevRot            = this.m_StartRot;
         this.m_LastRot            = this.m_StartRot;
         this.m_CharacterController.detectCollisions = false;
     }
     if (this.m_PlayableDirectorEx && this.m_PlayableDirectorEx.m_FollowOffsetHelper && this.m_CurrentCutscene.time >= (double)this.m_PlayTime)
     {
         this.m_PrevPos = this.m_LastPos;
         this.m_LastPos = this.m_PlayableDirectorEx.m_Transform.position - this.m_PlayableDirectorEx.m_RefTransform.position;
         this.m_PrevRot = this.m_LastRot;
         this.m_LastRot = Quaternion.Inverse(this.m_PlayableDirectorEx.m_RefTransform.rotation) * this.m_PlayableDirectorEx.m_Transform.rotation;
         Vector3 b = this.m_LastPos - this.m_PrevPos;
         this.m_CharacterController.gameObject.transform.position += b;
         this.m_CharacterController.gameObject.transform.rotation *= Quaternion.Inverse(this.m_PrevRot) * this.m_LastRot;
         float   num  = Vector3.Angle(this.m_CharacterController.transform.forward, Vector3.forward);
         Vector2 zero = Vector2.zero;
         if (Vector3.Dot(Vector3.right, this.m_CharacterController.transform.forward) < 0f)
         {
             num *= -1f;
         }
         zero.x = num;
         FPPController fppcontroller = Player.Get().m_FPPController;
         fppcontroller.SetLookDev(zero);
     }
     if (this.m_PlayableDirectorEx && !this.m_PlayableDirectorEx.m_Looped && this.m_CurrentCutscene && (this.m_CurrentCutscene.time >= this.m_CurrentCutscene.duration || this.m_CurrentCutscene.time < (double)this.m_PlayTime))
     {
         this.StopCutscene();
     }
     if (this.m_CurrentCutscene)
     {
         this.m_PlayTime = (float)this.m_CurrentCutscene.time;
     }
 }