public void DestroyCurrentWeapon()
        {
            // Destroy the weapon
            if (playerRightArm.transform.GetChild(0).childCount > 0)
            {
                GameObject first = playerRightArm.transform.GetChild(0).transform.GetChild(0).gameObject;
                if (first.CompareTag("Key"))
                {
                    hasKey = false;
                    GMController.instance.canSpawnKey = true;
                    GMController.instance.SlowdownSpawns();
                }

                if (first == baseWeapon.gameObject)
                {
                    //hide the base weapon instead of destroying it
                    baseWeapon.transform.parent = null;
                    baseWeapon.mesh.enabled     = false;
                }
                else
                {
                    Destroy(first);
                    currentWeapon = null;
                }
            }
        }
        public void CallShoot(GameObject arm, Weapon3D weapon)
        {
            // decide if it has to shoot from base weapon or not
            weapon.Shoot(arm.transform.GetChild(1).gameObject);

            //CameraShake shake = GameObject.Find("Main Camera").GetComponent<CameraShake>();
            //shake.ShakeCamera(1.2f, .2f);
        }
Esempio n. 3
0
    //------------------------------------------------------------------
    private void SetStartingWeapon(int playerNumber)
    {
        Weapon3D rewardWeapon = Instantiate(weaponRewardFromLastLevel[playerNumber]);

        rewardWeapon.isReward        = true;
        rewardWeapon.bullets         = rewardWeapon.bulletsIfReward;
        rewardWeapon.hand            = playerInfo[playerNumber].PlayerController.playerRightArm.transform.GetChild(0).gameObject;
        rewardWeapon.weaponOwnership = playerNumber;
        rewardWeapon.GrabAndDestroy(playerInfo[playerNumber].PlayerController);
    }
Esempio n. 4
0
    private IEnumerator SpawnWeaponFromList(List <Weapon3D> weapons)
    {
        spawnDone = false;
        anim.SetInteger("State", 1);
        yield return(new WaitForSeconds(0.2f));

        GameObject newWeapon = Instantiate(weapons[Random.Range(0, weapons.Count)].gameObject, transform.position, Quaternion.identity);

        currentWeapon = newWeapon.GetComponent <Weapon3D>();
        currentWeapon.currentSpawn = this;
        anim.SetInteger("State", 2);

        yield return(new WaitForSeconds(0.2f));

        anim.SetInteger("State", 0);
        spawnDone = true;
        yield return(null);
    }
Esempio n. 5
0
    protected virtual void Update()
    {
        if (GMController.instance.gameStart && magazineReady)
        {
            if (GMController.instance.playerInfo[playerNumber].PlayerController.currentWeapon != null &&
                GMController.instance.playerInfo[playerNumber].PlayerController.currentWeapon.perfBullet == type &&
                playerWeapon == null)
            {
                playerWeapon = GMController.instance.playerInfo[playerNumber].PlayerController.currentWeapon;
            }

            if (playerWeapon != null)
            {
                CopyStats();
            }

            for (int i = 0; i < perfPool.Length; i++)
            {
                if (perfPool[i].isActive)
                {
                    // Movement
                    perfPool[i].velocity = (perfPool[i].dir * bulletSpeed);
                    perfPool[i].bullet.transform.Translate(perfPool[i].velocity * Time.deltaTime, Space.World);

                    // timer CD
                    perfPool[i].lifeTime -= Time.deltaTime;

                    // Raycast check for Collision
                    EnvoiromentRaycastCheck(i);

                    if (perfPool[i].numberOfHits <= 0 || perfPool[i].lifeTime <= 0)
                    {
                        Collector(i);
                    }
                }
            }
        }
    }
        //---------------------------------------------------------------------------------------
        private void OnTriggerStay2D(Collider2D collision)
        {
            if (isAlive)
            {
                if (collision.CompareTag("EnergyDispenser") && canHeal && Input.GetButtonDown(inputMapping.interactInput))
                {
                    collision.GetComponent <HealStation>().UseStation(GetComponent <_CharacterController>());
                }
                if (collision.CompareTag("Weapon") && Input.GetButtonDown(inputMapping.interactInput))
                {
                    Weapon3D weapon = collision.GetComponent <Weapon3D>();
                    if (!weapon.isGrabbed)
                    {
                        weapon.hand = playerRightArm.transform.GetChild(0).gameObject;

                        weapon.weaponOwnership = playerNumber;
                        weapon.GrabAndDestroy(this);
                        GMController.instance.TensionThresholdCheck(GMController.instance.tensionStats.actionsPoints); // add tension points for action
                    }
                }
                if (collision.CompareTag("Key") && Input.GetButtonDown(inputMapping.interactInput))
                {
                    Weapon3D key = collision.GetComponent <Weapon3D>();
                    if (!key.isGrabbed)
                    {
                        key.hand = playerRightArm.transform.GetChild(0).gameObject;

                        key.weaponOwnership = playerNumber;
                        key.GrabAndDestroy(this);
                        hasKey = true;
                    }
                }
                if (collision.CompareTag("Exit") && hasKey)
                {
                    canExit = true;
                }
            }
        }
Esempio n. 7
0
    private void Update()
    {
        if (GMController.instance.gameStart && poolReady)
        {
            // get the player weapon if needed
            if (GMController.instance.playerInfo[playerNumber].PlayerController.currentWeapon != null &&
                GMController.instance.playerInfo[playerNumber].PlayerController.currentWeapon.decalType == type &&
                playerWeapon == null)
            {
                playerWeapon = GMController.instance.playerInfo[playerNumber].PlayerController.currentWeapon;
            }

            // assign this depot to the weapon
            if (playerWeapon != null)
            {
                if (playerWeapon.currentDecal != this)
                {
                    playerWeapon.currentDecal = this;
                }
            }

            for (int i = 0; i < decalList.Length; i++)
            {
                if (decalList[i].isActive)
                {
                    decalList[i].lifeTime -= Time.deltaTime;

                    if ((decalList[i].enemyHit != null && decalList[i].enemyHit.currentLife <= 0) ||
                        decalList[i].lifeTime <= 0)
                    {
                        Collector(i);
                    }
                }
            }
        }
    }
Esempio n. 8
0
 public void SetCurrentWeaponToNull()
 {
     currentWeapon = null;
 }
Esempio n. 9
0
 public void AddWeaponReward(int playerNumber, Weapon3D weapon)
 {
     weaponRewardFromLastLevel[playerNumber] = weapon;
 }