예제 #1
0
 public void SoulVision()                           //鏡頭前進為靈視狀態
 {
     if (!Input.GetKey(KeyCode.E) && !IsPossessing) //只要在靈視狀態下放開靈視鍵則退出靈視
     {
         CameraState = "SoulVisionOver";
     }
     if (FowardAndBackTime < FowardStop)//0.25秒移動到到指定位置
     {
         SoulPower.SetActive(true);
         FowardAndBackTime += Time.deltaTime;
         VectorMoveDistance = MoveEnd.transform.position - NormalPosition;//距離為終點減正常位置
         Move = VectorMoveDistance * Time.deltaTime * 5;
         transform.position += Move;
         CameraNowPosition   = transform.position;
     }
     else if (FowardAndBackTime >= FowardStop)                           //到指定位置後開啟靈視效果和準心 並可以進入附身
     {
         NowCharacter.transform.rotation = Quaternion.Euler(0, rotX, 0); //靈視狀態下腳色轉動
         FowardAndBackTime  = FowardStop;
         CameraNowPosition  = MoveEnd.transform.position;
         transform.position = MoveEnd.transform.position;
         SoulVisionEffect.SetActive(true);
         Crosshairs.SetActive(true);
         CanPossess = true;
     }
 }
예제 #2
0
 public void ResetValue()//重置一些前進後退中用到的值 以防下次進入其他模式出問題
 {
     SoulPower.SetActive(false);
     CanPossess        = false; //不能附身
     IsPossessing      = false; //可以進入靈視
     FowardAndBackTime = 0;     //前進後退的計時為0
     PossessTime       = 0;     //前進後退的計時為0
 }
예제 #3
0
    public bool IsPossessing = false; //附身中為true直到附身結束切回正常狀態才會被重置為false


    // Use this for initialization
    void Start()
    {
        PossessedSystem = GameObject.Find("Pine").GetComponent <PossessedSystem>();
        SoulPower       = GameObject.Find("SoulPower");
        playerManager   = GameObject.Find("PlayerManager").GetComponent <PlayerManager>();
        SoulVisionEffect.SetActive(false);                 //開始時靈視關閉
        PossessEffect.SetActive(false);                    //開始時附身鏡頭關閉
        SoulPower.SetActive(false);                        //開始時靈視特效關閉
        Crosshairs.SetActive(false);                       //開始時準心關閉
        CameraState          = "NormalState";              //初始狀態為正常狀態
        AttachedBodyChildren = new Transform[3];           //只抓前四個物件(包含本身)
        PlayerView           = GameObject.Find("FirstPersonCamPoint");
        MoveEnd      = GameObject.Find("CamMoveEndPoint"); //一開始取正確腳色位置
        NowCharacter = GameObject.Find("Pine");
    }
예제 #4
0
 public void SoulVisionOver()//鏡頭後退為正常狀態
 {
     SoulPower.SetActive(false);
     SoulVisionEffect.SetActive(false);
     Crosshairs.SetActive(false);
     CanPossess = false;
     if (FowardAndBackTime > 0)//從移動到的位置退回正常位置
     {
         FowardAndBackTime -= Time.deltaTime;
         VectorMoveDistance = NormalPosition - CameraNowPosition;//距離為正常位置減當前位置
         Move = VectorMoveDistance * Time.deltaTime * 5;
         transform.position += Move;
     }
     else if (FowardAndBackTime <= 0)
     {
         CameraState = "NormalState";
     }
 }