Inheritance: MonoBehaviour, item
Example #1
0
    private void loadScene()
    {
        SaveData data = SaveSystem.loadPlayer();

        if (data.level == SceneManager.GetActiveScene().buildIndex)
        {
            Vector3 position = new Vector3(data.playerPosition[0], data.playerPosition[1], data.playerPosition[2]);
            Player.transform.position = position;
            HealthAndShield healthAndShield = Player.GetComponent <HealthAndShield>();
            healthAndShield.health = data.health;
            healthAndShield.Shield = data.shield;
            GunPlaceHolderPlayer gunHolder = player.GetComponentInChildren <GunPlaceHolderPlayer>();
            gunHolder.activePrimary = data.primaryGunID;
            gun Primary = gunHolder.findWeaponByID(data.primaryGunID).GetComponent <gun>();
            Primary.ammoInBag         = data.PrimaryAmmoInBag;
            Primary.ammoInMag         = data.PrimaryAmmoInMag;
            gunHolder.activeSecondary = data.secondaryGunID;
            gun Secondary = gunHolder.findWeaponByID(data.secondaryGunID).GetComponent <gun>();
            Secondary.ammoInBag       = data.SecondaryAmmoInBag;
            Secondary.ammoInMag       = data.SecondaryAmmoInMag;
            gunHolder.grenadeCount[0] = data.GrenadeCount[0];
            gunHolder.grenadeCount[1] = data.GrenadeCount[1];
            gunHolder.grenadeCount[2] = data.GrenadeCount[2];
            gunHolder.switchWeapon();
            gunHolder.switchWeapon();
        }
    }
Example #2
0
    void reloadingAndNoAmmo()  /*
                                * gun g= gunPlaceHolderReference.ActiveGun.GetComponent<gun>();
                                * if (g.reloading) {
                                * float reloadPercent = (g.ReloadCount / g.reloadTime) * 100;
                                * ammo.text = ammo.text + "   reloading:" + reloadPercent.ToString("F0") + "%";
                                * }
                                * if (g.noAmmo) {
                                * ammo.text = ammo.text + "NoAmmo";
                                * }
                                */
    {
        gun g = gunPlaceHolderReference.ActiveGun.GetComponent <gun>();

        if (g.reloading)
        {
            float reloadPercent = (g.ReloadCount / g.reloadTime);
            reloadBar.fillAmount = 1 - reloadPercent;
            reloading.SetActive(true);
        }
        else
        {
            reloading.SetActive(false);
        }
        if (g.noAmmo)
        {
            noAmmo.SetActive(true);
        }
        else
        {
            noAmmo.SetActive(false);
        }
    }
Example #3
0
    // Use this for initialization
    void Start()
    {
        m_transform = this.transform;
        if (bossMake)
        {
            m_point = 0;
        }
        GameObject obj = GameObject.FindGameObjectWithTag("GameManager");

        if (obj != null)
        {
            m_GameManager = obj.GetComponent <GameManager>();
        }
        GameObject obj2 = GameObject.FindGameObjectWithTag("Player");

        if (obj2 != null)
        {
            m_gun = obj2.GetComponent <gun>();
        }

        if (m_GameManager.Stop)
        {
            getPlayerXY = new Vector3(m_gun.transform.position.x, m_gun.transform.position.y, 0);
        }
    }
Example #4
0
    void Shoot(gun gun)
    {
        if (currentGun.fireMode == "auto" || currentGun.fireMode == "semi" && !wasMouse1Pressed)
        {
            if (Input.GetMouseButton(0) && newGunFlicker <= gunFlickerDuration - newGunDisableDuration && !tooCloseToShoot && timeTilNextShot <= 0 && reloading <= 0)
            {
                if (ammoInClip > 0)
                {
                    SpawnBullet();
                    SpawnMuzzleFlash(muzzle.transform.position, this.transform.rotation, muzzleFlashDuration, playerScript.direction);
                    SpawnSoundEffect(currentGun.fireSoundClip, muzzle.transform.position, soundEffectDuration, soundEffectVolume, soundEffectPitch);

                    ammoInClip       -= 1;
                    timeTilNextShot   = currentGun.timeBetweenShots;
                    spreadFromRecoil += currentGun.recoilRate;
                    if (spreadFromRecoil > currentGun.recoilRate * 10)
                    {
                        spreadFromRecoil = currentGun.recoilRate * 10;
                    }
                }
                else if (ammoInClip == 0 || (ammoInClip < 0 && !wasMouse1Pressed))
                {
                    SpawnSoundEffect(emptyclip_fire, muzzle.transform.position, soundEffectDuration, soundEffectVolume, soundEffectPitch);
                    ammoInClip = -1;
                }
            }
        }
    }
Example #5
0
        public ActionResult CommitGunEdit(gun g)
        {
            string query = "update shooters.gun" + " set gDesc = '" + g.gDesc + "'" + " where gName = '" + g.gName + "'";

            setSuccess(QueryUtils.query(query));
            return(RedirectToAction("EditGun", "Guns", new { gName = g.gName }));
        }
Example #6
0
 void MakeInstance()
 {
     if (instance == null)
     {
         instance = this;
     }
 }
Example #7
0
 void Start()
 {
     g    = gun.GetComponent <gun>();
     ammo = g.getAmmo();
     //healthBar = GameObject.Find("Ammunition").GetComponent<HealthBarController>();
     t = GetComponent <Text>();
 }
Example #8
0
    public IEnumerator UpdateUserBullets()
    {
        User user     = Data.Usuario;
        gun  gunClass = Data.UserGun;

        int     bullets = Convert.ToInt32(gunClass.bulletsLeft + gunClass.currentBullets);
        WWWForm form    = new WWWForm();

        form.AddField("slotid", gunClass.idSlot);
        form.AddField("quantity", bullets);

        UnityWebRequest www = UnityWebRequest.Post("http://alienated.eastus2.cloudapp.azure.com:8080/inventory/update", form);

        yield return(www.SendWebRequest());

        status = www.downloadHandler.text;

        if (status.Equals("Updated"))
        {
            print("Updated");
        }
        else
        {
            print("Not Updated");
        }
    }
Example #9
0
 public void EquipGun(gun gunToEquip)
 {
     if (equippedGun != null)
     {
         Destroy(equippedGun.gameObject);
     }
     equippedGun = Instantiate(gunToEquip, weaponhold.position, weaponhold.rotation) as gun;
     equippedGun.transform.parent = weaponhold;
 }
Example #10
0
 // Use this for initialization
 void Awake()
 {
     Gun = this.gameObject.GetComponent <gun>();
     Gun.ChooseRocket  += doChooseRocket;
     Gun2               = this.gameObject.GetComponent <AndroidTouch>();
     Gun2.ChooseRocket += doChooseRocket;
     m_sprite2          = (SpriteRenderer)GetComponent("SpriteRenderer");
     m_transform        = this.transform;
 }
Example #11
0
    // Update is called once per frame
    void Update()
    {
        gun game_script = game.GetComponent <gun>();

        //Debug.Log(game_script.points);

        myScore.text = "Score: " + Static.points;
        //myScore.text = "testing";
    }
Example #12
0
 void RunToMap()
 {
     rifleClass = Data.UserRifle;
     gunClass   = Data.UserGun;
     StartCoroutine(UpdateUserBulletsAK());
     StartCoroutine(UpdateUserBulletsRifle());
     StartCoroutine(UpdateUserConsumable());
     Invoke("GoToMap", 1);
     audioSource.PlayOneShot(chickenSound);
 }
 // Use this for initialization
 void Start()
 {
     line = GetComponent <LineRenderer>();
     if (a)
     {
         guns = GetComponentInParent <gun>();
     }
     else
     {
     }
 }
Example #14
0
 void PopulateGuns()
 {
     m4a4 = new gun(
         "m4a4",          //weapon name
         "auto",          //fireMode
         25,              //damage
         30,              //clipSize
         2.5f,            //reloadTime
         0.1f,            //timeBetweenShots - in seconds
         0.3f,            //bulletSpeed
         15f,             //maxRng - maximum range before bullet dissapears
         3f,              //falloffRng - range that damage starts falling off
         1f,              //falloffAmt - after falloffRng, amount that damage decreases per unit travelled
         0.05f,           //accuracy - subtracted from spread
         0.25f,           //recoilRate - amount of recoil per shot
         1.0f,            //recoilRecoveryRate - amount recoil recovers per second
         m4a4_fire,       //fireSoundClip
         null             //m4a4_reload //reloadSoundClip
         );
     ak47 = new gun(
         "ak47",          //weapon name
         "auto",          //fireMode
         30,              //damage
         30,              //clipSize
         2.5f,            //reloadTime
         0.125f,          //timeBetweenShots - in seconds
         0.35f,           //bulletSpeed
         15f,             //maxRng - maximum range before bullet dissapears
         5f,              //falloffRng - range that damage starts falling off
         1f,              //falloffAmt - after falloffRng, amount that damage decreases per unit travelled
         0.0f,            //accuracy - subtracted from spread
         0.3f,            //recoilRate - amount of recoil per shot
         0.8f,            //recoilRecoveryRate - amount recoil recovers per second
         ak47_fire,       //fireSoundClip
         null             //ak47_reload //reloadSoundClip
         );
     deagle = new gun(
         "deagle",        //weapon name
         "semi",          //fireMode
         50,              //damage
         7,               //clipSize
         2f,              //reloadTime
         0.5f,            //timeBetweenShots - in seconds
         0.5f,            //bulletSpeed
         20f,             //maxRng - maximum range before bullet dissapears
         0f,              //falloffRng - range that damage starts falling off
         1.0f,            //falloffAmt - after falloffRng, amount that damage decreases per unit travelled
         0.0f,            //accuracy - subtracted from spread
         0.7f,            //recoilRate - amount of recoil per shot
         0.3f,            //recoilRecoveryRate - amount recoil recovers per second
         deagle_fire,     //fireSoundClip
         null             //deagle_reload //reloadSoundClip
         );
 }
Example #15
0
    void YouWin()
    {
        rifleClass = Data.UserRifle;
        gunClass   = Data.UserGun;
        StartCoroutine(UpdateUserBulletsAK());
        StartCoroutine(UpdateUserBulletsRifle());
        StartCoroutine(UpdateUserConsumable());
        StartCoroutine(UpdateUserExp());

        Invoke("GotoYouWin", time);
    }
Example #16
0
        public ActionResult GunTypeAdd(string gName)
        {
            List <gunType> _curTypes = TableUtils.queryToTable <gunType>("SELECT * FROM shooters.gunType natural join shooters.gunTypeRel where gName = '" + gName + "'");
            List <gunType> _newTypes = TableUtils.queryToTable <gunType>("SELECT * FROM shooters.gunType");
            gun            _gun      = TableUtils.queryToObject <gun>("SELECT * FROM shooters.gun where gName = '" + gName + "'");
            GunTypeAdder   _tAdder   = new GunTypeAdder();

            _tAdder._currTypes = _curTypes;
            _tAdder._newTypes  = _newTypes;
            _tAdder._gun       = _gun;
            return(View(_tAdder));
        }
Example #17
0
        public ActionResult EditGun(string gName)
        {
            gun     _gun = TableUtils.queryToObject <gun>("SELECT * FROM shooters.gun where gName= '" + gName + "'");
            GunSpec gs   = new GunSpec();

            gs._gun = _gun;
            List <gunType> _types = TableUtils.queryToTable <gunType>("SELECT * FROM shooters.gunTypeRel natural join shooters.gunType where gName= '" + gName + "'");

            gs._specs     = _types;
            ViewBag.gName = gName;
            return(View(gs));
        }
Example #18
0
        public ActionResult CommitGun(gun g)
        {
            NpgsqlConnection connection = new NpgsqlConnection(RouteConfig.connectString);

            connection.Open();
            NpgsqlCommand command = new NpgsqlCommand("insert into shooters.gun (gDesc, gName) values (@gDesc,'" + g.gName + "')", connection);

            command.Parameters.AddWithValue("@gDesc", g.gDesc);
            int num = command.ExecuteNonQuery();

            connection.Close();
            return(RedirectToAction("Guns"));
        }
Example #19
0
 public void PickupNewGun(gun gun, int slot)
 {
     if (slot == 1)
     {
         primaryGun     = gun;
         primaryGunAmmo = gun.clipSize;
     }
     else if (slot == 2)
     {
         secondaryGun     = gun;
         secondaryGunAmmo = gun.clipSize;
     }
     EquipNewGun(slot);
 }
 // Use this for initialization
 void Start()
 {
     weather = Random.Range (0,3);
     thisgun = gameObject.GetComponent<gun> ();
     switch (weather) {
     case 0:
         thisgun.projectileGameObject = m;
         break;
     case 1:
         thisgun.projectileGameObject = r;
         break;
     case 2:
         thisgun.projectileGameObject = l;
         break;
     }
 }
    public GameObject findWeaponByID(int id)
    {
        int        type   = id / 100;
        GameObject weapon = null;

        switch (type)
        {
        case 01:
            for (int i = 0; i < secondaryGuns.Length; i++)
            {
                gun testGun = secondaryGuns[i].GetComponent <gun>();
                if (testGun.id == id)
                {
                    weapon = testGun.gameObject;
                    break;
                }
            }
            break;

        case 02:
            for (int i = 0; i < primaryGuns.Length; i++)
            {
                gun testGun = primaryGuns[i].GetComponent <gun>();
                if (testGun.id == id)
                {
                    weapon = testGun.gameObject;
                    break;
                }
            }
            break;

        case 03:
            for (int i = 0; i < Grenades.Length; i++)
            {
                Grenades testGun = Grenades[i].GetComponent <Grenades>();
                if (testGun.grenadeID == id)
                {
                    weapon = testGun.gameObject;
                    break;
                }
            }
            break;
        }

        return(weapon);
    }
Example #22
0
    void ammoUpdate()  /*
                        * gun g = gunPlaceHolderReference.ActiveGun.GetComponent<gun>();
                        * string text = "ammo:" + g.ammoInMag+"/" +g.ammoCapacityMag+"   ammoInBag:"+g.ammoInBag;
                        * ammo.text = text;
                        */
    {
        gun   g          = gunPlaceHolderReference.ActiveGun.GetComponent <gun>();
        float ammoAmount = g.ammoInMag * 1f / (g.ammoCapacityMag);

        ammo.fillAmount = ammoAmount;
        ammoInBag.text  = g.ammoInBag.ToString();
        int activeGrenadeIndex = gunPlaceHolderReference.ActiveGrenade;

        activeGrenadeIndex %= 10;
        int GrenadeNumber = gunPlaceHolderReference.grenadeCount[activeGrenadeIndex];

        grenadeCount.text = GrenadeNumber.ToString();
    }
Example #23
0
    public override void interact()
    {
        base.interact();
        GunPlaceHolderPlayer holder = gameManager.player.GetComponentInChildren <GunPlaceHolderPlayer>();
        GameObject           c      = Instantiate(creator, transform.position, transform.rotation);
        pupCreater           create = c.GetComponent <pupCreater>();
        bool replacing;

        if (holder.activePrimary == id)
        {
            replacing = false;
        }
        else
        {
            replacing = true;
            /////
            gun g = holder.findWeaponByID(holder.activePrimary).GetComponent <gun>();

            create.id   = g.id;
            create.ammo = g.ammoInBag + g.ammoInMag;
            g.ammoInMag = 0;
        }
        holder.activePrimary = id;
        if (holder.holdingPrimary)
        {
            holder.switchWeapon();
            holder.switchWeapon();
        }
        else
        {
            holder.switchWeapon();
        }
        if (replacing)
        {
            holder.ActiveGun.GetComponent <gun>().ammoInBag = ammo;
            create.Create();
        }
        else
        {
            holder.ActiveGun.GetComponent <gun>().ammoInBag += ammo;
        }
        Destroy(gameObject);
    }
 //    void Start () {
 //    }
 //    void Update () {
 //    }
 void OnParticleCollision(GameObject other)
 {
     if (shootingGun == null) {
         shootingGun = transform.parent.GetComponent<gun> ();
     }
     if (shootingGun == null) {
         shootingGun = transform.parent.parent.GetComponent<gun> ();
     }
         //		Debug.Log ("shootingGun = " + shootingGun);
     //		Debug.Log ("OnParticleCollisionIndependant: " + gameObject.name + " & other: " + other.name);
     hpManager alive = other.GetComponent<hpManager> ();
     //		Debug.Log ("alive = " + alive);
     if (shootingGun != null && alive != null) {
         alive.getHit (shootingGun.gunDamage);
     //		} else {
     //			Debug.Log ("parent or GrandParent has No GunDamage");
     }
     //		other.GetComponent<hpManager> ().getHit (gunDamage);
     //
     //		//pay damage audio clip
 }
Example #25
0
    void EquipNewGun(int slot)
    {
        reloading = 0;
        if (currentWeaponSlot == 1)
        {
            primaryGunAmmo = ammoInClip;
        }
        else if (currentWeaponSlot == 2)
        {
            secondaryGunAmmo = ammoInClip;
        }
        if (slot == 1)
        {
            currentGun        = primaryGun;
            ammoInClip        = primaryGunAmmo;
            currentWeaponSlot = 1;
        }
        else if (slot == 2)
        {
            currentGun        = secondaryGun;
            ammoInClip        = secondaryGunAmmo;
            currentWeaponSlot = 2;
        }
        newGunFlicker = gunFlickerDuration;
        myAnimator.SetBool("changingGun", true);

        if (currentGun.weaponName == "m4a4")
        {
            myAnimator.SetInteger("currentGun", 1);
        }
        if (currentGun.weaponName == "ak47")
        {
            myAnimator.SetInteger("currentGun", 2);
        }
        if (currentGun.weaponName == "deagle")
        {
            myAnimator.SetInteger("currentGun", 3);
        }
    }
Example #26
0
    // Use this for initialization
    void Start()
    {
        Time.timeScale = 1;
        for (int i = 6; m_timer < i;)
        {
            m_timer = Random.value * 15;
        }
        m_score = change.NewScore;
        if (change.Hiscores[m_thisLevelNumber - 1] == 0)
        {
            change.Hiscores[m_thisLevelNumber - 1] = m_score;
        }
        m_hiscore = change.Hiscores[m_thisLevelNumber - 1];
        // 取得主角
        GameObject obj = GameObject.FindGameObjectWithTag("Player");

        if (obj != null)
        {
            m_gun = obj.GetComponent <gun>();
        }
        retran = change.GetRetarn();
    }
    void throwBullet(Vector2 direction)
    {
        GameObject shootedBullet = ammo [0];
        gun        g             = guns[0];
        float      s             = g.scale;

        Vector3 shootPlace     = transform.position + transform.rotation * new Vector3(g.deltaPos.x * direction.x.CompareTo(0), g.deltaPos.y, 0) + transform.right * shootDistance;
        Vector2 shootDirection = Quaternion.Euler(0, 0, s) * transform.right;

        shootedBullet.SetActive(true);
        shootedBullet.GetComponent <SpriteRenderer>().enabled = true;
        shootedBullet.GetComponent <bulletBehaviour>().applyDirection(shootDirection, angle, shootPlace);

        if (shotFire)
        {
            shotFire.enabled = true;
        }

        ammo.Remove(shootedBullet);
        ammo.Add(shootedBullet);
        guns.Remove(g);
        guns.Add(g);
    }
Example #28
0
    public SaveData(GameObject player, GunPlaceHolderPlayer guns, HealthAndShield healthAndShield, int levelThis)
    {
        level             = levelThis;
        playerPosition    = new float[3];
        playerPosition[0] = player.transform.position.x;
        playerPosition[1] = player.transform.position.y;
        playerPosition[2] = player.transform.position.z;
        primaryGunID      = guns.activePrimary;
        GrenadeCount      = new int[3];
        secondaryGunID    = guns.activeSecondary;
        GrenadeCount[0]   = guns.grenadeCount[0];
        GrenadeCount[1]   = guns.grenadeCount[1];
        GrenadeCount[2]   = guns.grenadeCount[2];
        health            = healthAndShield.health;
        shield            = healthAndShield.Shield;
        gun PrimaryGun = guns.findWeaponByID(guns.activePrimary).GetComponent <gun>();

        PrimaryAmmoInBag = PrimaryGun.ammoInBag;
        PrimaryAmmoInMag = PrimaryGun.ammoInMag;
        gun SecondaryGun = guns.findWeaponByID(guns.activeSecondary).GetComponent <gun>();

        SecondaryAmmoInBag = SecondaryGun.ammoInBag;
        SecondaryAmmoInMag = SecondaryGun.ammoInMag;
    }
Example #29
0
 private void doesChangeGun()
 {
     gunList [activeGunNb].SetActive (true);
     activeGun = gunList[activeGunNb].GetComponent<gun> ();
     activeGun.awake ();
 }
Example #30
0
 public void addweapon(gun newgun)
 {
     allGuns [numberofgun] = newgun;
     numberofgun++;
 }
Example #31
0
 void Start()
 {
     gunEquiped = gun.pistol;
 }
Example #32
0
 void Start()
 {
     scriptE = GameObject.Find("Player").GetComponentInChildren<gun>();
     scriptF = GameObject.Find("HpText").GetComponentInChildren<Hpscript>();
 }
Example #33
0
 public void addweapon(gun newgun)
 {
     gunController.addweapon(newgun);
 }
Example #34
0
 // Update is called once per frame
 void Update()
 {
     checkPlayerNearby();
     attachedGun     = gunScript.m4a4;
     attachedGunSlot = 1;
 }