示例#1
0
        void Update()
        {
            if (GameManager_Main.instance.startGame)
            {
                if (PhotonNetwork.IsMasterClient)
                {
                    if (!startedGameCounter)
                    {
                        //Debug.Log("Counter Called");
                        StartCoroutine(GameTimerCountDown());
                        startedGameCounter = true;
                    }
                }

                if (!_playerStatus.IsPlayerAlive() && _photonView.IsMine)
                {
                    if (!startedRevivedCounter)
                    {
                        startedRevivedCounter = true;
                        StartCoroutine(ReviveCountDown());
                    }
                }
            }
        }
示例#2
0
        // Update is called once per frame
        void Update()
        {
            if (GameManager_Main.instance.startGame && _playerStatus.IsPlayerAlive())
            {
                if (_debugFlag)
                {
                    if (Input.GetKeyDown(KeyCode.Alpha1))
                    {
                        CastingSkill(0, (playerCamera.position), playerCamera.forward);
                    }
                    else if (Input.GetKeyDown(KeyCode.Alpha2))
                    {
                        CastingSkill(1, (playerCamera.position), playerCamera.forward);
                    }
                    else if (Input.GetKeyDown(KeyCode.Alpha3))
                    {
                        CastingSkill(2, (playerCamera.position), playerCamera.forward);
                    }
                    else if (Input.GetKeyDown(KeyCode.Alpha4))
                    {
                        CastingSkill(3, (playerCamera.position), playerCamera.forward);
                    }
                    else if (Input.GetKeyDown(KeyCode.Alpha5))
                    {
                        CastingSkill(4, (playerCamera.position), playerCamera.forward);
                    }
                }
                else
                {
                    //--Relase and Cast a spell--//
                    if (Input.GetKeyUp(KeyCode.Space) || (_received))
                    {
                        _received = false;
                        Sound_Manager.instance.StopLoopSound(SoundIndex.Casting);
                        if (castingGround.isPlaying)
                        {
                            castingGround.Stop();
                            castingGround.Clear();
                        }
                        if (castingTrail.isPlaying)
                        {
                            castingTrail.Stop();
                            castingTrail.Clear();
                        }

                        if ((chosenSpell <= 4) && (canCastSkill[chosenSpell]))
                        {
                            CastingSkill(chosenSpell, (playerCamera.position), playerCamera.forward);
                        }
                        else
                        {
                            Debug.Log("Skill Failed");
                            Sound_Manager.instance.PlayShortSound(SoundIndex.CastFail);
                            if (!failedSpell.isPlaying)
                            {
                                failedSpell.Play();
                            }
                        }
                    }
                    //--Pressed spacebar or trigger--//
                    else if (Input.GetKeyDown(KeyCode.Space) || _isCasting)
                    {
                        chosenSpell = 5;
                        if (!castingGround.isPlaying)
                        {
                            castingGround.Play();
                        }
                        if (!castingTrail.isPlaying)
                        {
                            Debug.Log("Playing Particle");
                            castingTrail.Play();
                        }

                        Sound_Manager.instance.PlayLoopSound(SoundIndex.Casting);
                        _isCasting = false;
                    }
                    //--Holding spacebar or trigger--//
                    else if (Input.GetKey(KeyCode.Space) /*|| Trigger is pressing*/)
                    {
                        if (Input.GetKeyDown(KeyCode.Alpha1))
                        {
                            chosenSpell = 0;
                        }
                        else if (Input.GetKeyDown(KeyCode.Alpha2))
                        {
                            chosenSpell = 1;
                        }
                        else if (Input.GetKeyDown(KeyCode.Alpha3))
                        {
                            chosenSpell = 2;
                        }
                        else if (Input.GetKeyDown(KeyCode.Alpha4))
                        {
                            chosenSpell = 3;
                        }
                        else if (Input.GetKeyDown(KeyCode.Alpha5))
                        {
                            chosenSpell = 4;
                        }
                    }
                }


                if (GameManager_Main.instance.debugFlag && Input.GetKeyDown(KeyCode.F))
                {
                    GetComponent <PlayerStatus>().Damage(10, Photon_Room.instance.GetMyPlayerID());
                }
            }
            else if (GameManager_Main.instance.endGame)
            {
                Sound_Manager.instance.StopLoopSound(SoundIndex.Casting);
                if (castingGround.isPlaying)
                {
                    castingGround.Stop();
                    castingGround.Clear();
                }
                if (castingTrail.isPlaying)
                {
                    castingTrail.Stop();
                    castingTrail.Clear();
                }

                if (PhotonNetwork.IsMasterClient)
                {
                    if (Input.GetKeyDown(KeyCode.Return))
                    {
                        //PhotonNetwork.LoadLevel(Photon_GameSetting.instance.scenesIndex.firstScene);
                    }
                    else if (Input.GetKeyDown(KeyCode.Escape))
                    {
                        Photon_Room.instance.BackToMainMenu();
                    }
                }
            }
        }
示例#3
0
 void Update()
 {
     if (!GameManager_Main.instance.debugFlag)
     {
         if (GameManager_Main.instance.hasVREnvironment && (leftController != null))
         {
             UICanvas.gameObject.SetActive(leftController.triggerPressed && GameManager_Main.instance.startGame && _playerStatus.IsPlayerAlive());
         }
         else
         {
             UICanvas.gameObject.SetActive(Input.GetKey(KeyCode.Q) && GameManager_Main.instance.startGame && _playerStatus.IsPlayerAlive());
         }
     }
     else
     {
         UICanvas.gameObject.SetActive(Input.GetKey(KeyCode.Q) && GameManager_Main.instance.startGame && _playerStatus.IsPlayerAlive());
     }
 }
示例#4
0
        // Update is called once per frame
        void Update()
        {
            if (GameManager_Main.instance.startGame && _playerStatus.IsPlayerAlive())
            {
                movement = Vector3.zero;

                if (GameManager_Main.instance.allowKeyboardInput)
                {
                    //--KeyBoard Mode--//
                    if (Input.GetKey(KeyCode.W))
                    {
                        movement = playerCamera.forward;
                    }
                    else if (Input.GetKey(KeyCode.S))
                    {
                        movement = -1 * playerCamera.forward;
                    }

                    if (Input.GetKey(KeyCode.D))
                    {
                        movement += playerCamera.right;
                        //transform.Rotate(Vector3.up, Time.deltaTime * keyboardRotationSpeed);
                    }
                    else if (Input.GetKey(KeyCode.A))
                    {
                        movement += -1 * playerCamera.right;
                        //transform.Rotate(Vector3.up, Time.deltaTime * -keyboardRotationSpeed);
                    }

                    CameraRotation();
                    Movement(movement, _playerStatus.CurrentMovementSpeed());
                }

                if (_hasVREnvironment)
                {
                    if (leftController != null)
                    {
                        VRControllerState_t controllerState = leftController.controllerState;
                        ulong pad = controllerState.ulButtonTouched & (1UL << ((int)EVRButtonId.k_EButton_SteamVR_Touchpad));

                        if (pad > 0L)
                        {
                            movement = Vector3.zero;
                            bool singleDirection = false;
                            if (controllerState.rAxis0.x > touchpadThreshold)
                            {
                                movement        = playerCamera.right;
                                singleDirection = !singleDirection;
                                //Debug.Log("right");
                            }
                            else if (controllerState.rAxis0.x < -touchpadThreshold)
                            {
                                movement        = -1 * playerCamera.right;
                                singleDirection = !singleDirection;
                                //Debug.Log("left");
                            }

                            if (controllerState.rAxis0.y > touchpadThreshold)
                            {
                                movement       += playerCamera.forward;
                                singleDirection = !singleDirection;
                                //Debug.Log("forward");
                            }
                            else if (controllerState.rAxis0.y < -touchpadThreshold)
                            {
                                movement       -= playerCamera.forward;
                                singleDirection = !singleDirection;
                                //Debug.Log("down");
                            }

                            if (!singleDirection)
                            {
                                movement /= 2;
                            }

                            Movement(movement, _playerStatus.CurrentMovementSpeed());
                        }
                    }
                }



                // keep the collider follow the HMD
                _collider.center = new Vector3(playerCamera.localPosition.x, _collider.size.y / 2, playerCamera.localPosition.z);
            }
        }
示例#5
0
        // Update is called once per frame
        void Update()
        {
            if (GameManager_Main.instance.startGame && _playerStatus.IsPlayerAlive() && _photonView.IsMine)
            {
                // Not pressed yet, and detected pressed
                if (!PressedFlag && controller.triggerPressed)
                {
                    PressedFlag = true;
                    _playerSkill.IsCasting();
                    if (collecting)
                    {
                        string[] initial_List = new string[] { "Index", "X", "Y", "Z" };
                        sb.AppendLine(string.Join(",", initial_List));
                    }
                }

                // If the controller is pressed, record the location of tracker
                if (controller.triggerPressed)
                {
                    Vector3  img_coord = currentObjectTransform.transform.InverseTransformPoint(controller.transform.position.x, controller.transform.position.y, controller.transform.position.z);
                    string[] posList   = new string[] { DataIdx.ToString(), img_coord.x.ToString(), img_coord.y.ToString(), img_coord.z.ToString() };
                    if (!_isInDebugMode)
                    {
                        //Debug.Log(posList);
                        //Debug.Log(socket);
                        socket.SocketSend(posList[1] + "," + posList[2]);
                    }

                    if (collecting)
                    {
                        sb.AppendLine(string.Join(",", posList));
                        DataIdx += 1;
                    }
                }
                // If the triggered is not pressed
                if (PressedFlag && !controller.triggerPressed)
                {
                    PressedFlag = false;
                    if (!_isInDebugMode)
                    {
                        socket.SocketSend("MessageSent");
                        canCall = true;
                    }


                    if (collecting)
                    {
                        DirectoryInfo di = Directory.CreateDirectory("Assets\\Gesture\\Data\\csv\\" + DataType + "\\" + user);

                        Debug.Log("csv num " + csvNum + " Done");
                        string       filename  = csvNum + ".csv";
                        string       filePath  = "Assets\\Gesture\\Data\\csv\\" + DataType + "\\" + user + "\\" + filename;
                        StreamWriter outStream = new StreamWriter(filePath);
                        outStream.WriteLine(sb);
                        outStream.Close();


                        sb      = new StringBuilder();
                        DataIdx = 0;
                        csvNum += 1;
                    }
                }

                if (canCall && (socket.recvStr != ""))
                {
                    //Debug.Log(socket.recvStr);
                    _playerSkill.CastingSpell(int.Parse(socket.recvStr));
                    socket.recvStr = "";
                    canCall        = false;
                }
            }
        }