Exemplo n.º 1
0
 /// <summary>
 /// Picks up a floating part.
 /// </summary>
 /// <param name="part"></param>
 public void PickUpFloatingPart(FloatingPart part)
 {
     part.PickUp(PlayerName);
 }
Exemplo n.º 2
0
    // FixedUpdate is called once per physics tick
    void FixedUpdate()
    {
        // Check if this code runs on the game object that represents my Player
        if (!isLocalPlayer)
        {
            return;
        }

        //Flight & Fight Mode
        if (!buildMode)
        {
            //- Flight -
            //Steer
            Vector3 steering = new Vector3((Camera.main.ScreenToViewportPoint(Input.mousePosition).y - 0.5f) * -1.0f, Camera.main.ScreenToViewportPoint(Input.mousePosition).x - 0.5f, 0.0f);
            GetComponent <Rigidbody>().angularVelocity = (transform.localToWorldMatrix.rotation * steering) * 2.0f;
            // Bank (roll due to steering)
            Ship.Roll(steering.y * -90f);
            //Roll
            if (Input.GetKey(KeyCode.Q))
            {
                Ship.Roll(60f);
            }
            if (Input.GetKey(KeyCode.E))
            {
                Ship.Roll(-60f);
            }
            //Thrust
            if (Input.GetKey(KeyCode.LeftShift))
            {
                Ship.Thrust(Vector3.forward);
            }
            if (Input.GetKeyDown(KeyCode.LeftShift))
            {
                audioManager.audioEvents[1].start();
            }
            if (Input.GetKeyUp(KeyCode.LeftShift))
            {
                audioManager.audioEvents[1].stop((FMOD.Studio.STOP_MODE.ALLOWFADEOUT));
            }
            //Reverse Thrust
            bool reversing = false;
            if (Input.GetKey(KeyCode.LeftControl))
            {
                Ship.Thrust(Vector3.back);
                reversing = true;
            }
            //Point velocity along ship direction (if not trying to reverse or currently going backwards)
            if (transform.InverseTransformDirection(GetComponent <Rigidbody>().velocity).z > 0 && !reversing)
            {
                GetComponent <Rigidbody>().velocity = transform.forward * GetComponent <Rigidbody>().velocity.magnitude;
            }

            //todo testing
            if (Input.GetKeyUp(KeyCode.R))
            {
                _testCounter++;
                switch (_testCounter)
                {
                case 1:
                    if (!isServer)
                    {
                        break;
                    }
                    GameObject floatingPart = Instantiate(GameController.Instance.FloatingPartGameObject, new Vector3(0f, 0f, 15f), new Quaternion());
                    NetworkServer.Spawn(floatingPart);
                    // Set FloatingPart ID
                    floatingPart.GetComponent <FloatingPart>().ID = 1;
                    _testPart = floatingPart.GetComponent <FloatingPart>();
                    Debug.Log("Created FloatingPart");
                    break;

                case 2:
                    Debug.Log("Picking up FloatingPart");
                    PickUpFloatingPart(_testPart);
                    break;

                case 3:
                    _testCounter = 0;
                    break;

                default:
                    _testCounter = 0;
                    break;
                }
            }
        }
    }