示例#1
0
    void Update()
    {
        if (instance == null)
        {
            GameModeManagerBase.SetManagerInstance(ref instance);
        }

        if (instance.mState == GameModeManagerBase.State.Paused)
        {
            return;
        }

        string fireButton = "";

        if (player.name == "Player 1")
        {
            fireButton = "Fire1";
        }

        if (player.name == "Player 2")
        {
            fireButton = "Fire2";
        }

        if (Input.GetButton(fireButton) && Time.time > nextFire)
        {
            nextFire = Time.time + fireRate;
            GameObject clone = instance.GetBulletSpawner()
                               .Spawn(shotSpawn.position, shotSpawn.rotation, player);
            rb          = clone.GetComponent <Rigidbody>();
            rb.velocity = clone.transform.forward * bulletSpeed;
        }
    }
示例#2
0
    void FixedUpdate()
    {
        float horizontalInput = 0.0f;
        float forwardVelocity = 0.0f;

        if (instance == null)
        {
            GameModeManagerBase.SetManagerInstance(ref instance);
        }

        if (instance.mState == GameModeManagerBase.State.Paused)
        {
            return;
        }

        if (name == "Player 1")
        {
            horizontalInput = Input.GetAxis("Horizontal_p1");
            forwardVelocity = Input.GetAxisRaw("Vertical_p1");
        }

        if (name == "Player 2")
        {
            horizontalInput = Input.GetAxis("Horizontal_p2");
            forwardVelocity = Input.GetAxisRaw("Vertical_p2");
        }

        transform.RotateAround(transform.position, transform.up, horizontalInput * TurnSpeed);
        mBody.velocity += (transform.forward * Mathf.Clamp(forwardVelocity, 0.0f, 1.0f) * Speed);
        mBody.velocity  = new Vector3(
            Mathf.Clamp(mBody.velocity.x, -maxVelocity, maxVelocity),
            0.0f,
            Mathf.Clamp(mBody.velocity.z, -maxVelocity, maxVelocity));
    }
示例#3
0
    void FixedUpdate()
    {
        if (instance == null)
        {
            GameModeManagerBase.SetManagerInstance(ref instance);
        }

        if (instance.mState != GameModeManagerBase.State.Paused)
        {
            rb.MoveRotation(rb.rotation * deltaRotation);
        }
    }
示例#4
0
    void Update()
    {
        if (instance == null)
        {
            GameModeManagerBase.SetManagerInstance(ref instance);
            PlayerOne = instance.GetPlayerOne();
            PlayerTwo = instance.GetPlayerTwo();
        }

        if (instance.mState == GameModeManagerBase.State.Playing)
        {
            AimAndFire();
        }
    }
示例#5
0
    void Update()
    {
        if (instance == null)
        {
            GameModeManagerBase.SetManagerInstance(ref instance);
        }

        //Needs to be changed to the base class
        if (instance.mState == GameModeManagerBase.State.Paused)
        {
            return;
        }
        ApplyThrustEffect();
    }
示例#6
0
    public static void SetManagerInstance(ref GameModeManagerBase instance)
    {
        switch (GameMaster.instance.activeScene)
        {
        case GameMaster.ActiveScene.ClassicGame:
            instance = ClassicManager.instance;
            break;

        case GameMaster.ActiveScene.SurvivalGame:
            instance = SurvivalManager.instance;
            break;

        case GameMaster.ActiveScene.DodgeGame:
            instance = DodgeManager.instance;
            break;
        }
    }
示例#7
0
    public void HandlePause(GameModeManagerBase instance)
    {
        //clear the preexisting data for overwrite if saving and not loading.
        if (instance.mState == GameModeManagerBase.State.Paused)
        {
            rotations.Clear();
            velocities.Clear();
            rootObjects.Clear();
            rootObjectsWithRB.Clear();

            //Get root objects in scene
            scene = SceneManager.GetActiveScene();
            scene.GetRootGameObjects(rootObjects);

            //Iterate root objects, save their rotations & velocities, then freeze them
            for (int i = 0; i < rootObjects.Count; i++)
            {
                GameObject gameObject = rootObjects[i];
                Rigidbody  objectRb   = gameObject.GetComponent <Rigidbody>();

                if (objectRb != null)
                {
                    rootObjectsWithRB.Add(rootObjects[i]);
                    velocities.Add(objectRb.velocity);
                    rotations.Add(objectRb.rotation);
                    objectRb.isKinematic = true;
                }
            }
        }

        //Read the preexisting data for resetting rigidbodies when loading.
        if (instance.mState == GameModeManagerBase.State.Playing)
        {
            for (int i = 0; i < rootObjectsWithRB.Count; i++)
            {
                rootObjectsWithRB[i].GetComponent <Rigidbody>().isKinematic = false;
                rootObjectsWithRB[i].GetComponent <Rigidbody>().velocity    = velocities[i];
                rootObjectsWithRB[i].GetComponent <Rigidbody>().rotation    = rotations[i];
            }
        }
    }
示例#8
0
 void Awake()
 {
     GameModeManagerBase.SetManagerInstance(ref instance);
     player = transform.root.gameObject;
 }