コード例 #1
0
ファイル: WallRideTrigger.cs プロジェクト: Stibbins/hover
 // Update is called once per frame
 void Update()
 {
     if (Wallactive)
     {
         if (detectState.m_getRailPermission)
         {
             detectState.transform.position += transform.right;
             detectState.updateKeyState("Wall").setVector      = direction;
             detectState.updateKeyState("Wall").m_RightjumpVec = -transform.right;
             detectState.updateKeyState("Wall").m_UpjumpVec    = transform.up;
             detectState.changeKeyState("Wall");
             detectState.m_getRailPermission = false;
             detectState.m_getRayCastState   = false;
         }
     }
 }
コード例 #2
0
 // Update is called once per frame
 void Update()
 {
     if (Grindactive)
     {
         if (detectState.m_getRailPermission && GlobalFuncVari.getNum() > 0)
         {
             player.transform.eulerAngles  = push;
             detectState.m_getRayCastState = false;
             detectState.changeKeyState("Rail");
             detectState.m_getRailPermission = false;
         }
     }
 }
コード例 #3
0
ファイル: Pause_menu.cs プロジェクト: Stibbins/hover
    // Update is called once per frame
    void Update()
    {
        pDeltaTime        = Time.realtimeSinceStartup - realtimeSinceLast;
        realtimeSinceLast = Time.realtimeSinceStartup;
        if (Input.GetKeyDown(KeyCode.P))
        {
            keyState = detectState.getKeyState;

            Meny_Active = !Meny_Active;
            MasterPanel.SetActive(Meny_Active);

            if (Meny_Active)
            {
                Time.timeScale = 0;
                detectState.changeKeyState("MenuState");
            }
            if (!Meny_Active)
            {
                Time.timeScale = 1;
                detectState.changeKeyState(keyState);
            }
        }
    }
コード例 #4
0
ファイル: Grindable.cs プロジェクト: Raful/Hoverboard
    void OnTriggerEnter(Collider col)
    {
        player = col.gameObject;
        detectState = player.gameObject.GetComponent<DetectState> ();

        if(player.transform.localScale.x != 2)
        {
            GlobalFuncVari.setRailBounds(col.transform.localScale);
            player.transform.localScale = new Vector3 (2, player.transform.localScale.y, 2) ;
        }

        if(GlobalFuncVari.getNum() == 0)
        {
            if(Vector3.Angle(transform.forward, player.transform.right) <= 90)
            {
                GlobalFuncVari.railFalse();
                detectState.updateKeyState ("Rail").setVector = -transform.right;
            }
            else
            {
                GlobalFuncVari.railTrue();
                detectState.updateKeyState ("Rail").setVector = transform.right;
            }
        }
        else if(GlobalFuncVari.getallowRail())
        {
            detectState.m_getRayCastState = false;
            detectState.changeKeyState("Rail");
            detectState.m_getRailPermission = false;

            if(GlobalFuncVari.getRailbool())
            {
                push = new Vector3(-transform.eulerAngles.z, transform.eulerAngles.y+90, player.transform.eulerAngles.z);
                player.transform.position = transform.position + (player.transform.position-transform.position).magnitude*-transform.right;
                player.transform.eulerAngles = new Vector3(-transform.eulerAngles.z, transform.eulerAngles.y+90, player.transform.eulerAngles.z);
                detectState.updateKeyState ("Rail").setVector = transform.right;
            }
            else
            {
                push = new Vector3(transform.eulerAngles.z, transform.eulerAngles.y-90, player.transform.eulerAngles.z);
                player.transform.position = transform.position + (player.transform.position-transform.position).magnitude*transform.right;
                player.transform.eulerAngles = new Vector3(transform.eulerAngles.z, transform.eulerAngles.y-90, player.transform.eulerAngles.z);
                detectState.updateKeyState ("Rail").setVector = -transform.right;
            }
        }
        Grindactive = true;
        GlobalFuncVari.incNum();

        if(detectState.m_getRailPermission)
        {
            detectState.m_getRayCastState = false;
            detectState.changeKeyState("Rail");
            detectState.m_getRailPermission = false;
            GlobalFuncVari.allowRailTrue();

            if(GlobalFuncVari.getRailbool())
            {
                player.transform.position = transform.position + (player.transform.position-transform.position).magnitude*-transform.right;
                player.transform.eulerAngles = new Vector3(-transform.eulerAngles.z, transform.eulerAngles.y+90, player.transform.eulerAngles.z);
                push = new Vector3(-transform.eulerAngles.z, transform.eulerAngles.y+90, player.transform.eulerAngles.z);
            }
            else
            {
                player.transform.position = transform.position + (player.transform.position-transform.position).magnitude*transform.right;
                player.transform.eulerAngles = new Vector3(transform.eulerAngles.z, transform.eulerAngles.y-90, player.transform.eulerAngles.z);
                push = new Vector3(transform.eulerAngles.z, transform.eulerAngles.y-90, player.transform.eulerAngles.z);
            }
        }
    }
コード例 #5
0
    void PlayBack()
    {
        //Debug.Log ("Ghost position: " + transform.position.ToString ());
        //Debug.Log ("Position moving to: " + positionMovingTo.ToString ());

        int readInfo = 0;                                 // what kind of type the line in the textfile should be in

        if (positionList.Count == 0 && fetchFromTextFile) // if the lists are empty then get info for the ghost in a textfile and add the info to the lists
        {
            StreamReader readText = new StreamReader(filepath);
            while (!readText.EndOfStream)
            {
                string info = readText.ReadLine();

                if (info == "Rotation" || info == "State" || info == "Time")
                {
                    if (info == "Rotation")
                    {
                        readInfo = 2;
                    }
                    if (info == "State")
                    {
                        readInfo = 1;
                    }
                    if (info == "Time")
                    {
                        readInfo = 3;
                    }
                }
                else
                {
                    if (readInfo == 0)                          //if readInfo equals 0 convert the line to vector3 and add it to positionList
                    {
                        string[] xyz = info.Split(',');
                        if (xyz.Length == 3)
                        {
                            float   x    = float.Parse(xyz[0]);
                            float   y    = float.Parse(xyz[1]);
                            float   z    = float.Parse(xyz[2]);
                            Vector3 temp = new Vector3(x, y, z);

                            positionList.Add(temp);
                        }
                    }
                    else if (readInfo == 1)                      //if readInfo equals 1 add the line in the stateList
                    {
                        stateList.Add(info);
                    }
                    else if (readInfo == 2)                     //if readInfo equals 2 convert the line to the type Quaternion and add it to transformationList
                    {
                        string[] xyzw = info.Split(',');
                        if (xyzw.Length == 4)
                        {
                            float      x     = float.Parse(xyzw[0]);
                            float      y     = float.Parse(xyzw[1]);
                            float      z     = float.Parse(xyzw[2]);
                            float      w     = float.Parse(xyzw[3]);
                            Quaternion angle = new Quaternion(x, y, z, w);

                            transformationList.Add(angle);
                        }
                    }
                    else if (readInfo == 3)                      //if readInfo equals 3 convert the line to float and add it to timeBetweenUpdatesList
                    {
                        float temp = float.Parse(info);
                        timeBetweenUpdatesList.Add(temp);
                    }
                }
            }
            readText.Close();
        }
        int size = smallestSize(stateList.Count, positionList.Count, transformationList.Count, timeBetweenUpdatesList.Count);           //check which list that has the smallest size so

        //it can't be out of bound.
        if (i < size && Time.time > timeToChange) // if i < size and time is greater than timeToChange it's time to update what the ghost should do.
        {
            if (i == 0)                           // if i equals 0 then the ghost get the initialize values.
            {
                hoverboard.transform.position = positionMovingTo = positionList[i];
                if (canRecordThisHoverboard)
                {
                    movement.ResetPosition(positionMovingTo);
                    movement.isRecording = false;
                    currentState.changeKeyState(stateList[i]);
                }



                anglesMovingTo.Set(transformationList[i].x, transformationList[i].y, transformationList[i].z, transformationList[i].w);
                transform.rotation.Set(anglesMovingTo.x, anglesMovingTo.y, anglesMovingTo.z, anglesMovingTo.w);

                currentTimeBetweenTwoUpdates = timeBetweenUpdatesList[i];
                timeToLerp            = 1 / (m_howManyTimesPerSecond);
                timebetweenTwoUpdates = Time.time;
            }


            float x    = Mathf.Abs(positionMovingTo.x - hoverboard.transform.position.x);
            float z    = Mathf.Abs(positionMovingTo.z - hoverboard.transform.position.z);
            float temp = Time.time - timebetweenTwoUpdates;
            if (i != 0 && Time.time > timeToChange && temp > currentTimeBetweenTwoUpdates)           //if i < 0 and currentTimeBetweenTwoUpUpdates is smaller than the time it has taken
            {                                                                                        //to change the ghost's values then update the values that the ghost should change to.
                if (canRecordThisHoverboard)
                {
                    currentState.changeKeyState(stateList[i]);
                }

                positionMovingTo = positionList[i];
                anglesMovingTo.Set(transformationList[i].x, transformationList[i].y, transformationList[i].z, transformationList[i].w);
                currentTimeBetweenTwoUpdates = timeBetweenUpdatesList[i];
                timebetweenTwoUpdates        = Time.time;
                timeToLerp = 1 / (m_howManyTimesPerSecond);
            }
            i++;
            timeToChange = Time.time + (1f / m_howManyTimesPerSecond);
        }
        if (i == size && Time.time > timeToChange)
        {
            isRecording = true;
            if (canRecordThisHoverboard)
            {
                hoverboard.GetComponent <Movement>().isRecording = true;
            }
        }
    }
コード例 #6
0
    void OnTriggerEnter(Collider col)
    {
        player      = col.gameObject;
        detectState = player.gameObject.GetComponent <DetectState> ();

        if (player.transform.localScale.x != 2)
        {
            GlobalFuncVari.setRailBounds(col.transform.localScale);
            player.transform.localScale = new Vector3(2, player.transform.localScale.y, 2);
        }

        if (GlobalFuncVari.getNum() == 0)
        {
            if (Vector3.Angle(transform.forward, player.transform.right) <= 90)
            {
                GlobalFuncVari.railFalse();
                detectState.updateKeyState("Rail").setVector = -transform.right;
            }
            else
            {
                GlobalFuncVari.railTrue();
                detectState.updateKeyState("Rail").setVector = transform.right;
            }
        }
        else if (GlobalFuncVari.getallowRail())
        {
            detectState.m_getRayCastState = false;
            detectState.changeKeyState("Rail");
            detectState.m_getRailPermission = false;

            if (GlobalFuncVari.getRailbool())
            {
                push = new Vector3(-transform.eulerAngles.z, transform.eulerAngles.y + 90, player.transform.eulerAngles.z);
                player.transform.position    = transform.position + (player.transform.position - transform.position).magnitude * -transform.right;
                player.transform.eulerAngles = new Vector3(-transform.eulerAngles.z, transform.eulerAngles.y + 90, player.transform.eulerAngles.z);
                detectState.updateKeyState("Rail").setVector = transform.right;
            }
            else
            {
                push = new Vector3(transform.eulerAngles.z, transform.eulerAngles.y - 90, player.transform.eulerAngles.z);
                player.transform.position    = transform.position + (player.transform.position - transform.position).magnitude * transform.right;
                player.transform.eulerAngles = new Vector3(transform.eulerAngles.z, transform.eulerAngles.y - 90, player.transform.eulerAngles.z);
                detectState.updateKeyState("Rail").setVector = -transform.right;
            }
        }
        Grindactive = true;
        GlobalFuncVari.incNum();

        if (detectState.m_getRailPermission)
        {
            detectState.m_getRayCastState = false;
            detectState.changeKeyState("Rail");
            detectState.m_getRailPermission = false;
            GlobalFuncVari.allowRailTrue();

            if (GlobalFuncVari.getRailbool())
            {
                player.transform.position    = transform.position + (player.transform.position - transform.position).magnitude * -transform.right;
                player.transform.eulerAngles = new Vector3(-transform.eulerAngles.z, transform.eulerAngles.y + 90, player.transform.eulerAngles.z);
                push = new Vector3(-transform.eulerAngles.z, transform.eulerAngles.y + 90, player.transform.eulerAngles.z);
            }
            else
            {
                player.transform.position    = transform.position + (player.transform.position - transform.position).magnitude * transform.right;
                player.transform.eulerAngles = new Vector3(transform.eulerAngles.z, transform.eulerAngles.y - 90, player.transform.eulerAngles.z);
                push = new Vector3(transform.eulerAngles.z, transform.eulerAngles.y - 90, player.transform.eulerAngles.z);
            }
        }
    }
コード例 #7
0
 public void changeState(string state)
 {
     currentState.changeKeyState(state);
 }