Ejemplo n.º 1
0
    IEnumerator OnScoped()
    {
        scopeSound.Play();
        yield return(new WaitForSeconds(0.15f));

        WeaponSwitching w = gameObject.GetComponent <WeaponSwitching>();

        for (int i = 0; i < 3; i++)
        {
            if (w.currWeapon == i)
            {
                scopes[i].SetActive(true);
            }
            else
            {
                scopes[i].SetActive(false);
            }
        }

        weaponCam.SetActive(false);

        if (w.currWeapon == 5) //AR
        {
            mainCam.fieldOfView = scopedFOV + 20;
        }
        else
        {
            mainCam.fieldOfView = scopedFOV;
        }

        MouseLook ml = mainCamera.GetComponent <MouseLook>();

        ml.mouseSensitivity = 80.0f;
    }
Ejemplo n.º 2
0
    // Update is called once per frame
    void Update()
    {
        if (Input.GetMouseButtonDown(1))
        {
            if (animator.GetBool("Reloading"))
            {
                return;
            }

            WeaponSwitching w = gameObject.GetComponent <WeaponSwitching>();

            if (w.currWeapon == 3 || w.currWeapon == 4 || w.currWeapon == 6 || w.currWeapon == 7) //laser weapon, knife, grenade or portal gun
            {
                return;
            }

            isScoped = !isScoped;
            animator.SetBool("Scoped", isScoped);

            if (isScoped)
            {
                crosshair.enabled = false;
                StartCoroutine(OnScoped());
            }
            else
            {
                //The crosshair bug could be fixed if I add a check for
                //weapon reload state
                crosshair.enabled = true;
                OnUnScoped();
            }
        }
    }
Ejemplo n.º 3
0
    void OnTriggerEnter(Collider collider)
    {
        if (collider.gameObject.tag == "Player")
        {
            if (gameObject.tag == "col_gun0")
            {
                WeaponSwitching.HAS_MACHINE_GUN = true;

                WeaponSwitching.index          = 0;
                WeaponSwitching.selectedWeapon = 0;
                WeaponSwitching.SwitchWeapons(trans_wep_0, trans_wep_1, trans_wep_2);
            }
            else if (gameObject.tag == "col_gun1")
            {
                WeaponSwitching.HAS_SNIPER_RIFLE = true;

                WeaponSwitching.index          = 1;
                WeaponSwitching.selectedWeapon = 1;
                WeaponSwitching.SwitchWeapons(trans_wep_0, trans_wep_1, trans_wep_2);
            }
            else if (gameObject.tag == "col_gun2")
            {
                WeaponSwitching.HAS_GRANADE_LAUNCHER = true;

                WeaponSwitching.index          = 2;
                WeaponSwitching.selectedWeapon = 2;
                WeaponSwitching.SwitchWeapons(trans_wep_0, trans_wep_1, trans_wep_2);
            }
            Destroy(gameObject);
        }
    }
Ejemplo n.º 4
0
 private void Start()
 {
     fakeWeapon      = gameObject;
     pickupSound     = audioFX[transform.tag];
     weaponHolder    = GameObject.FindGameObjectWithTag("WeaponHolder");
     switchingScript = weaponHolder.GetComponent <WeaponSwitching>();
 }
Ejemplo n.º 5
0
 void Awake()
 {
     anim         = GetComponent <Animator>();
     player       = GameObject.FindGameObjectWithTag("Player");
     playerHealth = player.GetComponent <PlayerHealth>();
     playerWeapon = player.GetComponent <Player>().weaponSwitching;
 }
Ejemplo n.º 6
0
    // Start is called before the first frame update
    void Start()
    {
        isComplete = false;
        isGameOver = false;
        killCount  = 0;

        if (PlayerPrefs.HasKey("CurrentGems"))
        {
            gemCount = PlayerPrefs.GetInt("CurrentGems");
        }
        else
        {
            gemCount = 0;
        }

        gemText.text = gemCount.ToString();

        if (PlayerPrefs.HasKey("CurrentLevel"))
        {
            currentLevel = PlayerPrefs.GetInt("CurrentLevel");
        }
        else
        {
            currentLevel = 1;
        }
        playerController = FindObjectOfType <PlayerController>();
        levelPortal      = FindObjectOfType <LevelPortal>();
        waveSpawner      = FindObjectOfType <WaveSpawner2>();
        weaponSwitching  = FindObjectOfType <WeaponSwitching>();
        crosshair        = FindObjectOfType <Crosshair>();

        updateKillGoal();
        killText.text  = killCount.ToString() + "/" + killGoal.ToString();
        killText.color = Color.white;
    }
Ejemplo n.º 7
0
    private void Awake()
    {
        playerCamera   = GetComponentInChildren <PlayerCamera> ();
        weaponSwitcher = GetComponentInChildren <WeaponSwitching> ();
        player         = GetComponent <Player> ();

        weapon = weaponSwitcher?.SelectWeapon();
    }
Ejemplo n.º 8
0
 void Start()
 {
     weaponSwitching = GameObject.FindObjectOfType <WeaponSwitching>();
     //revolverFire = GameObject.FindObjectOfType<RevolverFire>();
     //repeaterFire = GameObject.FindObjectOfType<RepeaterFire>();
     //shotgunFire = GameObject.FindObjectOfType<ShotgunFire>();
     //bowFire = GameObject.FindObjectOfType<BowFire>();
 }
Ejemplo n.º 9
0
 void Start()
 {
     currentAmmo     = maxAmmo;
     source          = GetComponent <AudioSource>();
     player          = GameObject.FindGameObjectWithTag("Player").GetComponent <Player>();
     weaponSwitching = GameObject.FindGameObjectWithTag("WeaponHolder").GetComponent <WeaponSwitching>();
     ammoTextMesh.SetText(maxAmmo.ToString());
 }
Ejemplo n.º 10
0
 // Start is called before the first frame update
 void Start()
 {
     networkAnimator = GetComponent <NetworkAnimator>();
     weaponSwitcher  = weaponHolder.GetComponent <WeaponSwitching>();
     EquipWeapon(defaultWeapon);
     GetComponent <EquipmentManager>().EquipDefault(weaponHolder);
     GetComponent <Player>().zombifyPlayer += Disarm;
 }
Ejemplo n.º 11
0
    /*
     * private void OnTriggerStay(Collider other)
     * {
     *
     *  if (other.gameObject.CompareTag("Player") && Input.GetKeyDown(input))
     *  {
     *
     *      if (isLocked && needKey)
     *      {
     *
     *          Inventory inv = other.transform.GetComponent<Inventory>();
     *          if (inv != null)
     *          {
     *
     *              if (inv.key)
     *              {
     *
     *                  doorTextObj.SetActive(false);
     *                  UnlockDoor();
     *              }
     *
     *              else
     *              {
     *
     *                  doorText.text = "You need a key.";
     *                  doorTextObj.SetActive(true);
     *                  DoorLocked();
     *
     *              }
     *
     *          }
     *
     *          return;
     *
     *      }
     *      else if (isLocked)
     *      {
     *
     *          WeaponSwitching wpSwitch = other.GetComponentInChildren<WeaponSwitching>();
     *          if (wpSwitch != null)
     *          {
     *
     *              if (wpSwitch.selectedWeapon == 0)
     *              {
     *
     *                  doorTextObj.SetActive(false);
     *                  UnlockDoor();
     *              }
     *
     *              else
     *              {
     *
     *                  doorText.text = "Door is locked or jammed. Try using a crowbar.";
     *                  doorTextObj.SetActive(true);
     *                  DoorLocked();
     *
     *              }
     *
     *          }
     *
     *          return;
     *
     *      }
     *
     *      if (isOpen)
     *      {
     *
     *          CloseDoor();
     *
     *      }
     *      else OpenDoor();
     *
     *  }
     *
     * }
     */

    private void OnTriggerStay(Collider other)
    {
        if (other.gameObject.CompareTag("Player") && Input.GetKeyDown(input))
        {
            if (isLocked)
            {
                if (needKey)
                {
                    Inventory inv = other.transform.GetComponent <Inventory>();
                    if (inv != null)
                    {
                        if (inv.key)
                        {
                            doorTextObj.SetActive(false);
                            UnlockDoor();
                        }

                        else
                        {
                            doorText.text = "You need a key.";
                            doorTextObj.SetActive(true);
                            DoorLocked();
                        }
                    }
                    return;
                }
                else
                {
                    WeaponSwitching wpSwitch = other.GetComponentInChildren <WeaponSwitching>();
                    if (wpSwitch != null)
                    {
                        if (wpSwitch.selectedWeapon == 0)
                        {
                            doorTextObj.SetActive(false);
                            UnlockDoor();
                        }

                        else
                        {
                            doorText.text = "Door is locked or jammed. Try using a crowbar.";
                            doorTextObj.SetActive(true);
                            DoorLocked();
                        }
                    }

                    return;
                }
            }
            else if (isOpen)
            {
                CloseDoor();
            }
            else
            {
                OpenDoor();
            }
        }
    }
Ejemplo n.º 12
0
 void Awake()
 {
     weaponSwitching = GetComponentInParent <WeaponSwitching>();
     currentAmmo     = maxAmmo;
     shootableMask   = LayerMask.GetMask("Shootable");
     gunParticles    = GetComponent <ParticleSystem>();
     gunLine         = GetComponent <LineRenderer>();
     gunLight        = GetComponent <Light>();
 }
Ejemplo n.º 13
0
    protected override void Start()
    {
        controller           = GetComponent <CharacterController>();
        cam                  = Camera.main;
        weaponSwitching      = GetComponentInChildren <WeaponSwitching>();
        alertArrowController = GetComponentInChildren <AlertArrowController>();

        base.Start();
    }
Ejemplo n.º 14
0
 // Start is called before the first frame update
 void Start()
 {
     background.enabled = false;
     Xlogo.enabled      = false;
     text.enabled       = false;
     text1.enabled      = false;
     Player             = GameObject.FindGameObjectWithTag("Player");
     script             = gc.GetComponent <GameController>();
     activated          = false;
     script2            = FPC.GetComponent <WeaponSwitching>();
 }
Ejemplo n.º 15
0
    void Start()
    {
        animator = GetComponent <Animator>();
        clicks   = 0;
        canClick = true;

        movScript      = FindObjectOfType <Movimentacao>();
        weaponIdScript = FindObjectOfType <WeaponSwitching>();
        dashScript     = FindObjectOfType <dashMove>();
        jumpScript     = FindObjectOfType <PlayerJump>();
    }
Ejemplo n.º 16
0
    // adds the obtained Weapon to the weapons slot
    public void addWeapon(Weapon newWeapon, GameObject weaponButton, int Slot_i)
    {
        Weapon newGun = Instantiate(newWeapon, transform.position, Quaternion.identity, WeaponHolder.transform);

        newGun.currentWeaponSlot = Slot_i;
        newGun.ammoTextMesh      = weaponButton.GetComponentInChildren <TextMeshProUGUI>();
        newGun.weaponSlotPosUI   = Slot_i;
        WeaponSwitching weaponSwitching = WeaponHolder.GetComponent <WeaponSwitching>();

        weaponSwitching.currentAvailableWeapons++;
        weaponSwitching.SelectWeapon();
    }
Ejemplo n.º 17
0
    protected override void Pickup(Collider2D col)
    {
        //get component of the Weapon Switching script
        WeaponSwitching weaponSwitching = col.gameObject.GetComponentInChildren <WeaponSwitching>();

        //Change weapon index
        weaponSwitching.selectedWeapon = weaponIndex;
        //call the method to change weapon
        weaponSwitching.SelectWeapon();
        //Destroy powerup
        Destroy(gameObject);
    }
Ejemplo n.º 18
0
    void Start()
    {
        weaponManager = weaponHolder.GetComponent <WeaponSwitching>();

        int nowLoadingGame = PlayerPrefs.GetInt("Game_Starting_Loading", 0);

        if (nowLoadingGame == 1)   //game is loading from save
        {
            Debug.Log("Loading from save");
            LoadPlayerInfo();
        }
    }
Ejemplo n.º 19
0
 //When entering the state
 public override async Task Enter(GameObject player)
 {
     weaponSwitching = player.GetComponentInChildren <WeaponSwitching>();
     //var bob = PlayerStateController.FindState<MovingState>();
     //if (bob != null)
     //{
     //    bob.speed = 8;
     //    timeToSwitch = 2;
     //}
     await new WaitForEndOfFrame();
     Debug.Log("entered state " + nameof(BackgroundState));
 }
Ejemplo n.º 20
0
 private void Awake()
 {
     if (!instance)
     {
         instance = this;
         DontDestroyOnLoad(instance);
     }
     else
     {
         Destroy(this);
     }
 }
Ejemplo n.º 21
0
    // Start is called before the first frame update
    void Start()
    {
        rigidbody = GetComponent <Rigidbody>();
        anim      = GetComponent <Animator>();
        audio     = GetComponent <AudioSource>();


        weaponSwitching = GetComponentInChildren <WeaponSwitching>();

        dbConnection = FindObjectOfType <DBConnection>();
        swordAmmo    = dbConnection.IniAmmo("Sword");
        crossBowAmmo = dbConnection.IniAmmo("Arrow");
    }
Ejemplo n.º 22
0
    private void OnEnable()
    {
        if (shootJoystick == null)
        {
            shootJoystick = ShootJoystick.Instance;                       // FindObjectOfType<ShootJoystick>();
        }
        shootJoystick.OnUpEvent += Fire;

        if (wp == null)
        {
            wp = FindObjectOfType <WeaponSwitching>();
        }
    }
Ejemplo n.º 23
0
    //public GameObject cameraParent;



    private void Start()
    {
        //cameraParent.SetActive(photonView.IsMine);
        if (fpsCam == null)
        {
            fpsCam = FindObjectOfType <Camera>();
        }

        currentAmmo = maxAmmo;
        // anim = GetComponent<Animator>();
        movementScript = GetComponent <PlayerMovement>();
        weaponSwitch   = GetComponent <WeaponSwitching>();
    }
Ejemplo n.º 24
0
    void Start()
    {
        weapon_switching = FindObjectOfType <WeaponSwitching>();

        player = FindObjectOfType <FirstPersonController>();

        gamePad                = InputManager.ActiveDevice;
        AmmoText.text          = "Ammo: " + ammoCount;
        AmmoInGunText.text     = "0";
        numberOfBulletsUsed    = 0;
        KeysCollectedText.text = "Keys Collected: 0";
        canFire                = false;
        Destroyed              = false;
    }
Ejemplo n.º 25
0
 // Use this for initialization
 void Start()
 {
     _camera          = GetComponent <Camera>();
     Cursor.lockState = CursorLockMode.Locked;
     Cursor.visible   = false;
     player           = GameObject.FindGameObjectWithTag("Player");
     playerAmmo       = player.GetComponent <PlayerCharacter>();
     //playerHealth = player.GetComponent<PlayerCharacter>();
     weaponHolder  = GameObject.FindGameObjectWithTag("Guns");
     currentWeapon = weaponHolder.GetComponent <WeaponSwitching>();
     pistolShot    = GetComponent <AudioSource>();
     akShot        = GetComponent <AudioSource>();
     //bulletHolePistol = GameObject.FindGameObjectWithTag("pistolHole");
 }
Ejemplo n.º 26
0
    void OnUpgradeMenuToggle(bool active)
    {
        Weapon _weapon = GetComponentInChildren <Weapon>();

        if (_weapon != null)
        {
            _weapon.enabled = !active;
        }

        WeaponSwitching _weaponSwitching = GetComponentInChildren <WeaponSwitching>();

        if (_weaponSwitching != null)
        {
            _weaponSwitching.enabled = !active;
        }
    }
Ejemplo n.º 27
0
    void Awake()
    {
        cam          = Camera.main;
        bulletLine   = GetComponent <LineRenderer>();
        magazineText = GameObject.Find("Canvas/MagazineText").GetComponent <Text>();
        ammoText     = GameObject.Find("Canvas/AmmoText").GetComponent <Text>();
        reloadText   = GameObject.Find("Canvas/ReloadText").GetComponent <Text>();
        weaponText   = GameObject.Find("Canvas/WeaponText").GetComponent <Text>();

        weaponHolder = GameObject.FindGameObjectWithTag("Weapon Holder");
        holder       = weaponHolder.GetComponent <WeaponSwitching>();

        startingMagazine = maxMagazine;
        startingAmmo     = maxAmmo;
        currentMagazine  = startingMagazine;
        currentAmmo      = startingAmmo;
    }
Ejemplo n.º 28
0
 // Start is called before the first frame update
 void Start()
 {
     background.enabled = false;
     Xlogo.enabled      = false;
     text.enabled       = false;
     text1.enabled      = false;
     Player             = GameObject.FindGameObjectWithTag("Player");
     script             = gc.GetComponent <GameController>();
     activated          = false;
     script2            = FPC.GetComponent <WeaponSwitching>();
     script3            = Player.GetComponent <Healing>();
     script4            = AR.GetComponent <Weapon>();
     script5            = Shotgun.GetComponent <Weapon>();
     audioSource        = GetComponent <AudioSource>();
     speedUpgrade       = 1;
     boughtShotgunAmmo  = false;
     boughtARAmmo       = false;
 }
Ejemplo n.º 29
0
    public void RpcChangeWeapon(int n)
    {
        if (isLocalPlayer)//script already works on local player
        {
            return;
        }

        //Debug.Log("changing weapon on clients");
        WeaponSwitching WS = GetComponentInChildren <WeaponSwitching>();

        if (!WS)
        {
            Debug.Log("cant find WS script");
            return;
        }
        WS.selectedWeapon = n;
        WS.selectWeapon();
    }
Ejemplo n.º 30
0
    // checks if there is an empty slot in the weapons slot in order to add a new weapon
    private void CheckAvailableWeaponSlot(Player player)
    {
        for (int i = 0; i < player.weaponsSlots.Length; i++)
        {
            bool            isEmpty         = player.weaponsSlots[i].GetComponent <WeaponSlot>().empty;
            WeaponSwitching weaponSwitching = GameObject.FindGameObjectWithTag("WeaponHolder").GetComponent <WeaponSwitching>();

            // checks for the status of the weaponSlot at index 'i' and if the max no. of weapons to carry has been reached
            if (isEmpty && weaponSwitching.currentAvailableWeapons < weaponSwitching.maxWeaponsToCarry)
            {
                Instantiate(pickUpSound, transform.position, Quaternion.identity);
                GameObject weaponButton = Instantiate(itemButton, player.weaponsSlots[i].transform, false);
                player.weaponsSlots[i].GetComponent <WeaponSlot>().empty = false;
                player.addWeapon(weaponToEquip, weaponButton, i);
                Destroy(gameObject);
                break;
            }
        }
    }