Exemple #1
0
    // Start is called before the first frame update
    void Start()
    {
        Debug.Log("This is level: " + level);

        //rb = GetComponent<Rigidbody>();
        currentWeapon       = laserGun;
        characterController = GetComponent <CharacterController>();

        Cursor.lockState = CursorLockMode.Locked;
        Cursor.visible   = false;
    }
    IEnumerator RapidFire()
    {
        print("TEST");
        GameObject   gun     = GameObject.Find("FPSController/FirstPersonCharacter/PM-40_Variant1/");
        RayCastShoot raycast = gun.GetComponent <RayCastShoot>();


        raycast.fireRate    = 0.14f;
        raycast.currentAmmo = 30;
        raycast.maxAmmo     = 30;
        raycast.SetAmmoText();

        GameObject textUI    = GameObject.Find("HUD/PowerType/");
        Text       powerType = textUI.GetComponent <Text>();

        powerType.text = "Rapid Fire!";

        //print("PowerupGiven");

        yield return(new WaitForSeconds(30f));

        raycast.fireRate = 0.25f;
        if (raycast.currentAmmo > 15)
        {
            raycast.currentAmmo = 15;
        }

        raycast.maxAmmo = 15;
        raycast.SetAmmoText();
        powerType.text = "Powerup Removed";
        print("Powerup Removed");

        yield return(new WaitForSeconds(5f));

        powerType.text = "";

        GameObject    anotherPowerup = GameObject.Find("PowerupLocations/");
        DeployPowerup deploy         = anotherPowerup.GetComponent <DeployPowerup>();

        yield return(new WaitForSeconds(5f));

        deploy.ChooseSpawners(2);
        print("ANOTHER POWERUP SPAWNED");

        // Remove Powerup
        Destroy(gameObject);
        //print("GameObject removed");
    }
Exemple #3
0
    IEnumerator DoubleDamage()
    {
        GameObject   gun     = GameObject.Find("FPSController/FirstPersonCharacter/PM-40_Variant1/");
        RayCastShoot raycast = gun.GetComponent <RayCastShoot>();

        raycast.gunDamage = 2;
        //print("PowerupGiven");

        yield return(new WaitForSeconds(10f));

        raycast.gunDamage = 1;
        print("Powerup Removed");

        // Remove Powerup
        Destroy(gameObject);
        //print("GameObject removed");
    }
Exemple #4
0
        private void GetCurrentWeaponType()
        {
            rayCastShoot    = currentWep.GetComponent <RayCastShoot>();
            projectileShoot = currentWep.GetComponent <ProjectileShoot>();

            if (rayCastShoot != null)
            {
                wepType = WeaponType.raycast;
            }
            else if (projectileShoot != null)
            {
                wepType = WeaponType.projectile;
            }
            else
            {
                wepType = WeaponType.noncombat;
            }
        }
    IEnumerator DoubleDamage()
    {
        GameObject   gun     = GameObject.Find("FPSController/FirstPersonCharacter/PM-40_Variant1/");
        RayCastShoot raycast = gun.GetComponent <RayCastShoot>();

        raycast.gunDamage = 2;

        GameObject textUI    = GameObject.Find("HUD/PowerType/");
        Text       powerType = textUI.GetComponent <Text>();

        powerType.text = "Double Damage!";

        //print("PowerupGiven");

        yield return(new WaitForSeconds(30f));

        raycast.gunDamage = 1;
        //print("Powerup Removed");
        powerType.text = "Powerup Removed";

        yield return(new WaitForSeconds(5f));

        powerType.text = "";


        GameObject    anotherPowerup = GameObject.Find("PowerupLocations/");
        DeployPowerup deploy         = anotherPowerup.GetComponent <DeployPowerup>();

        yield return(new WaitForSeconds(5f));

        deploy.ChooseSpawners(3);
        print("ANOTHER POWERUP SPAWNED");

        // Remove Powerup
        Destroy(gameObject);
        //print("GameObject removed");
    }
Exemple #6
0
    IEnumerator RapidFire()
    {
        GameObject   gun     = GameObject.Find("FPSController/FirstPersonCharacter/PM-40_Variant1/");
        RayCastShoot raycast = gun.GetComponent <RayCastShoot>();

        print("TEST");
        raycast.fireRate    = 0.1f;
        raycast.currentAmmo = 30;
        raycast.maxAmmo     = 30;
        raycast.SetAmmoText();
        //print("PowerupGiven");

        yield return(new WaitForSeconds(10f));

        raycast.fireRate    = 0.25f;
        raycast.currentAmmo = 15;
        raycast.maxAmmo     = 15;
        raycast.SetAmmoText();
        print("Powerup Removed");

        // Remove Powerup
        Destroy(gameObject);
        //print("GameObject removed");
    }
Exemple #7
0
    // Update is called once per frame
    void Update()
    {
        if (Input.GetKeyDown("i"))
        {
            LookSentitivity += 0.2f;
        }

        if (Input.GetKeyDown("k"))
        {
            LookSentitivity -= 0.2f;
        }

        // Movement
        transform.Rotate(Vector3.up, Input.GetAxis("Mouse X") * LookSentitivity);
        // head rotation
        rotationY += Input.GetAxis("Mouse Y") * LookSentitivity;
        rotationY  = Mathf.Clamp(rotationY, -90, 90);
        head.transform.localEulerAngles = new Vector3(-rotationY, head.transform.localEulerAngles.y, 0); //head.transform.Rotate(Vector3.right, -Input.GetAxis("Mouse Y") * LookSentitivity);
        // rb.MovePosition(transform.position + transform.forward * Input.GetAxis("Vertical") * MovementSpeed * Time.deltaTime + transform.right * Input.GetAxis("Horizontal") * MovementSpeed * Time.deltaTime);

        if (characterController.isGrounded)
        {
            // We are grounded, so recalculate
            // move direction directly from axes

            moveDirection  = Input.GetAxis("Horizontal") * transform.right + transform.forward * Input.GetAxis("Vertical");
            moveDirection *= MovementSpeed;

            if (Input.GetButton("Jump"))
            {
                moveDirection.y = JumpPower;
            }
            else
            {
                if (NextStep < Time.time && (Mathf.Abs(Input.GetAxis("Horizontal")) > 0.1 || Mathf.Abs(Input.GetAxis("Vertical")) > 0.1))
                {
                    NextStep = Time.time + StepSoundColddown;
                    AudioManeger.main.Play(AudioManeger.main.StepSound, feetPosition.position);
                }
            }
        }

        // Apply gravity. Gravity is multiplied by deltaTime twice (once here, and once below
        // when the moveDirection is multiplied by deltaTime). This is because gravity should be applied
        // as an acceleration (ms^-2)
        moveDirection.y -= Gravity * Time.deltaTime;

        // Move the controller
        characterController.Move(moveDirection * Time.deltaTime);

        if (currentWeapon.reloading == false)
        {
            if (Input.GetButton("Weapon1"))
            {
                currentWeapon = laserGun;
                sniper.gameObject.SetActive(false);
                currentWeapon.gameObject.SetActive(true);
            }
            if (Input.GetButton("Weapon2"))
            {
                currentWeapon = sniper;
                laserGun.gameObject.SetActive(false);
                currentWeapon.gameObject.SetActive(true);
            }
        }

        healthText.text = "HP: " + currentHealth.ToString();
    }