Example #1
0
    private int i;// for문 돌림용

    private void Awake()
    {
        instance         = this;
        _weaponSelectors = GetComponentsInChildren <WeaponSelector>();
        selectWeapon     = WeaponName.pistol;
        SetCommand();
    }
Example #2
0
    private int[] _numEnemies = new int[(int)Enemy.Type.NUM_ENEMIES]; //!< Each int is number of enemies of each type to pool for this scene

    #endregion Fields

    #region Methods

    public Enemy SpawnEnemy(Enemy.Type type, WeaponName weapon, Vector2 pos)
    {
        for (int i = 0; i < _instances[(int)type].Count; i++)
        {
            GameObject go = _instances[(int)type][i];
            if(go.activeSelf == false)
            {
                Enemy returnEnemy = go.GetComponent<Enemy>();

                // Init enemy
                go.SetActive(true);
                if ((int)(weapon) != (int)WeaponName.NUMBER_OF_WEAPONS) returnEnemy.startingWeapon = weapon;
                returnEnemy.Spawn(pos);

                // Tell yo boss
                //EnemyBehaviour behave = _enemies[n].GetComponentInChildren<EnemyBehaviour>();
                //if (behave == null) Debug.Log("But mom...");
                //else _enemyManager.EnemySpawned(behave);

                // Return so doesn't bother trawling through other enemies in array
                return returnEnemy;
            }
        }

        return null;
    }
Example #3
0
    void SetBulletDamage(WeaponName weaponName, GameObject bullet)
    {
        switch (weaponName)
        {
        case WeaponName.Pistol:
            bullet.GetComponent <BulletController>().damage = 2;
            break;

        case WeaponName.MP5:
            bullet.GetComponent <BulletController>().damage = 3;
            break;

        case WeaponName.M3:
            bullet.GetComponent <BulletController>().damage = 4;
            break;

        case WeaponName.AWP:
            bullet.GetComponent <BulletController>().damage = 10;
            break;

        case WeaponName.AK:
            bullet.GetComponent <BulletController>().damage = 5;
            break;

        case WeaponName.Rocket:
            bullet.GetComponent <BulletController>().damage = 10;
            break;
        }
    }
Example #4
0
    public void ChangeWeapon(WeaponName newWeapon, int amountOfAmmo)
    {
        //find weaopn
        foreach (WeaponComponent weapon in weapons)
        {
            if (weapon.name == newWeapon)
            {
                if (weapon.grade == WeaponGrade.Primary)
                {
                    if (primaryWeapon)
                    {
                        primaryWeapon.gameObject.SetActive(false);
                    }
                    primaryWeapon = weapon;
                    primaryWeapon.gameObject.SetActive(true);
                }

                if (weapon.grade == WeaponGrade.Secondary)
                {
                    if (secondaryWeapon)
                    {
                        secondaryWeapon.gameObject.SetActive(false);
                    }
                    secondaryWeapon = weapon;
                    secondaryWeapon.gameObject.SetActive(true);

                    weaponsBar.SetShots(amountOfAmmo);
                }

                return;
            }
        }
    }
Example #5
0
    public void ChangeWeapon(WeaponName newWeapon)
    {
        //find weapon
        foreach (WeaponComponent weapon in weapons)
        {
            //find the weapon name
            if (weapon.name == newWeapon)
            {
                //check for primary or secondary
                if (weapon.grade == WeaponGrade.Primary)
                {
                    if (primaryWeapon)
                    {
                        primaryWeapon.gameObject.SetActive(false);
                    }
                    primaryWeapon = weapon;
                    primaryWeapon.gameObject.SetActive(true);
                }

                if (weapon.grade == WeaponGrade.Secondary)
                {
                    if (secondaryWeapon)
                    {
                        secondaryWeapon.gameObject.SetActive(false);
                    }
                    secondaryWeapon = weapon;
                    secondaryWeapon.gameObject.SetActive(true);
                }
                return;
            }
        }
    }
Example #6
0
	void SwitchWeapon()
	{
		switch (m_NowWeapon)
		{
			case WeaponName.Gun:
				// 剣に変わる瞬間に雷を発生させる
				GameObject effect = Instantiate(m_LightningPrefab);
				effect.transform.position = m_GunObj.transform.position;
				Destroy(effect, 1.9f);

				m_GunObj.SetActive(false);
				m_SwordObj.SetActive(true);
				m_Player.Proximity(MainPlayer.HandData.Right);
				m_NowWeapon = WeaponName.Sword;
				break;
			case WeaponName.Sword:
				// ガンに切り替わる瞬間に炎を発生させる
				GameObject fire = Instantiate(m_FirePrefab);
				fire.transform.position = m_SwordObj.transform.position;
				Destroy(fire, 3.0f);
				m_GunObj.SetActive(true);
				m_SwordObj.SetActive(false);
				m_Player.LongDistance();
				m_NowWeapon = WeaponName.Gun;
				break;
		}
	}
Example #7
0
 void onWeaponChanged(Weapon weapon)
 {
     this.WeaponName = weapon.Config.WeaponName;
     //skeletonAnimation.AnimationState.SetEmptyAnimations(0);
     // TODO: Aca hay que arreglar que cuando llegue el evento se seteen las animaciones correctamente.
     ChanginWeapon = true;
 }
Example #8
0
 public void MakeIntoCopyOfWeapon(Weapon weaponToCopy)
 {
     this.weaponName = weaponToCopy.weaponName;
     //this.owner = weaponToCopy.owner;
     //this.float timeSinceLastShot;
     //this.reloadTime = weaponToCopy.reloadTime;
     //this.fireRate = weaponToCopy.fireRate;
     //this.magazines = weaponToCopy.magazines; //list of magazines with number of bullets in them.
     this.magNum        = weaponToCopy.magNum;      //Which mag is currently being used.
     this.stateOfWeapon = weaponToCopy.stateOfWeapon;
     this.fireModes     = new FireMode[weaponToCopy.fireModes.Length];
     for (int i = 0; i < fireModes.Length; i++)
     {
         fireModes[i] = weaponToCopy.fireModes[i].Copy();
     }
     for (int j = 0; j < weaponToCopy.magazines.Count; j++)
     {
         magazines.Add(weaponToCopy.magazines[j]);
     }
     this.currentFireMode = weaponToCopy.currentFireMode;
     //this.DictionaryOfFireModeAndGameObject projectileDictionary; //used to fire a different projectile based on the fire mode.
     this.barrelEnd           = weaponToCopy.barrelEnd;
     this.barrelStart         = weaponToCopy.barrelStart;
     this.prefabToSpawnOnDrop = weaponToCopy.prefabToSpawnOnDrop;
     this.discardOnFire       = weaponToCopy.discardOnFire;
     this.reloadable          = weaponToCopy.reloadable;
 }
Example #9
0
        public void swichWeapon()
        {
            var currentWp = weapon.wName;

            if (weapon is Gun)
            {
                var gun = weapon as Gun;
                if (gun != null)
                {
                    _deagleMag = gun.magNum * gun.magSize + gun.mag;
                }
            }

            setWeapon(_lastWeapon);
            var gun2 = weapon as Gun;

            if (gun2 != null)
            {
                gun2.magNum = _deagleMag / gun2.magSize;
                gun2.mag    = _deagleMag % gun2.magSize;

                if (gun2.magNum > 0 && gun2.mag == 0 && Time.time - gun2.lastReloadTime > gun2.reloadTime)
                {
                    gun2.magNum -= 1;
                    gun2.mag     = gun2.magSize;
                }
            }

            _lastWeapon = currentWp;
        }
Example #10
0
    //Call this when changing weapons
    public void UpdateWeapon(WeaponName wn)
    {
        switch (wn)
        {
        case WeaponName.WEAPON0:
        default:
            weaponId = 0;
            break;

        case WeaponName.WEAPON1:
            weaponId = 1;
            break;

        case WeaponName.WEAPON2:
            weaponId = 2;
            break;
        }
        SpriteRenderer sprite    = GetComponent <SpriteRenderer>();
        SpriteRenderer retSprite = reticle.GetComponent <SpriteRenderer>();

        sprite.sprite    = wdata[weaponId].weaponsprite;
        sprite.color     = wdata[weaponId].bullettype.element.primary;
        retSprite.sprite = wdata[weaponId].bullettype.element.reticleSprite;
        retSprite.color  = wdata[weaponId].bullettype.element.primary;

        //Attempt to turn on glow animation on reticle
        GlowAnimation g = reticle.GetComponent <GlowAnimation>();

        if (g)
        {
            g.c0 = wdata[weaponId].bullettype.element.primary;
        }
    }
Example #11
0
    IBullet CreateBullet(WeaponName bulletType)
    {
        GameObject aux;

        switch (bulletType)
        {
        case WeaponName.Spray:
            aux = Instantiate(SprayBulletPrefab, Vector3.zero, Quaternion.identity, this.transform);
            break;

        case WeaponName.Club:
            aux = Instantiate(clubBulletPrefab, Vector3.zero, Quaternion.identity, this.transform);
            break;

        case WeaponName.WaterGun:
            aux = Instantiate(WaterPistolBulletPrefab, Vector3.zero, Quaternion.identity, this.transform);
            break;

        default:
            Debug.LogError("Se esta instanciando un prefab que no existe");
            aux = Instantiate(SprayBulletPrefab, Vector3.zero, Quaternion.identity, this.transform);
            break;
        }
        return(aux.GetComponent <IBullet>());
    }
Example #12
0
 public Weapon GetWeapon(WeaponName weaponName)
 {
     int i = (int)weaponName;
     GameObject weaponInst = (GameObject)Instantiate(weaponPrefabs[i].gameObject);
     Weapon newWeapon = weaponInst.GetComponent<Weapon>();
     _weaponInstances.Add(newWeapon);
     return newWeapon;
 }
Example #13
0
    public Weapon GetWeaponNamed(WeaponName name, string qualifer = "")
    {
        Weapon the_weapon = qualifer == ""
            ? weapons.First(weapon => weapon.weapon_name == name)
            : weapons.First(weapon => weapon.weapon_name == name && weapon.qualifier == qualifer);

        return(the_weapon);
    }
Example #14
0
    //change the weapon on hand
    //1=left;2=right
    public void ChangeWeapon(int leftOrRight, WeaponName weaponName)
    {
        //Find face right or left
        Movement_New playerMovement = gameObject.GetComponent <Movement_New>();
        bool         isFaceRight    = playerMovement.IsFaceRight;
        float        eulerAngel;

        if (isFaceRight)
        {
            eulerAngel = 0;
        }
        else
        {
            eulerAngel = 180;
        }
        GameObject weaponObj    = gameManager.GetWeaponObj(weaponName);
        Vector3    tempPosition = new Vector3(0, 0, 0);

        weaponObj = Instantiate(weaponObj, tempPosition, Quaternion.Euler(0, eulerAngel, 0));
        weaponObj.transform.localScale = WeaponSizeUp * weaponObj.transform.localScale;
        shoot.CombineOn = false;

        if (leftOrRight == 1)
        {
            // clear objects on hand

            foreach (Transform child in LeftHand)
            {
                Destroy(child.gameObject);
            }
            weaponObj.transform.parent        = LeftHand;
            weaponObj.transform.localPosition = tempPosition;
            weaponObj.transform.eulerAngles   = LeftHand.eulerAngles + new Vector3(0, 0, -player.fixLeftAngle);
            if (weaponObj.GetComponent <WeaponColor>())
            {
                weaponObj.GetComponent <WeaponColor>().leftorright = 1;
            }
            player.CombineWeapon();
        }
        else if (leftOrRight == 2)
        {
            // clear objects on hand

            foreach (Transform child in RightHand)
            {
                Destroy(child.gameObject);
            }

            weaponObj.transform.parent        = RightHand;
            weaponObj.transform.localPosition = tempPosition;
            weaponObj.transform.eulerAngles   = RightHand.eulerAngles + new Vector3(0, 0, -player.fixRightAngle);
            if (weaponObj.GetComponent <WeaponColor>())
            {
                weaponObj.GetComponent <WeaponColor>().leftorright = 2;
            }
            player.CombineWeapon();
        }
    }
Example #15
0
 void SwitchWeapon(WeaponName weaponName)
 {
     if (weaponName != previousWeapon)
     {
         moveSpeed = maxSpeed;
         if (weapon != null)
         {
             weapon.Disable();
         }
         if (weaponName > 0)
         {
             if (hero == Hero.Neo)
             {
                 weapon = weapons[(int)weaponName - 1];
                 weapons[(int)weaponName - 1].Enable();
                 if (weapon.Settings.fireRate * 1.25f <= 20)
                 {
                     weapon.Settings.fireRate = weapon.Settings.fireRate * 1.25f;
                 }
                 else
                 {
                     weapon.Settings.fireRate = 20;
                 }
             }
             else
             {
                 weapon = weapons[(int)weaponName - 1];
                 weapons[(int)weaponName - 1].Enable();
                 moveSpeed = (maxSpeed / weapon.Settings.speedDecrease);
             }
         }
         else
         {
             weapon = null;
         }
         if (weapon != null)
         {
             if (!weapon.Settings.two_Handed)
             {
                 bodyState = 1;
             }
             else
             {
                 bodyState = 2;
             }
         }
         else
         {
             bodyState = 0;
         }
         if (weapon != null)
         {
             weapon.AudioPlay();
         }
         previousWeapon = weaponName;
     }
 }
Example #16
0
 public void Init(Weapon weaponToBuy)
 {
     this.weaponName = weaponToBuy.WeaponName;
     this.weapon     = weaponToBuy;
     SetImage();
     SetName();
     SetPrice();
     SetBuyButton();
     buyButton.onClick.AddListener(BuyItem);
     UserInfo.Instance.UserInfoUpdate += SetBuyButton;
 }
Example #17
0
 public float GetElapseCooltime(WeaponName _weaponName)
 {
     if (_weapons[(int)_weaponName].GetIsShot()) // 총알을 발사할 수 있는 상태일 경우
     {
         return(0);
     }
     else // 아닐 경우
     {
         return(_weapons[(int)_weaponName].GetElapseCooltime());
     }
 }
Example #18
0
    // Start is called before the first frame update

    public WeaponConfig GetWeapon(WeaponName wep)
    {
        WeaponConfig aux = Weapons.FirstOrDefault(w => w.WeaponName.Equals(wep));

        if (!aux)
        {
            aux = Weapons[0];
            Debug.LogError("NO SE ENCONTRO EL ARMA " + wep.ToString());
        }
        return(aux);
    }
    public void PlayRandomSound(WeaponName weaponName)
    {
        AudioClip source = null;

        if (WeaponClipDic.TryGetValue(weaponName, out source))
        {
            if (randomizePitch)
            {
                m_Source.pitch = Random.Range(1.0f - pitchRange, 1.0f + pitchRange);
            }
            m_Source.PlayOneShot(source);
        }
    }
Example #20
0
    //change the weapon on hand
    //1=left;2=right
    void ChangeWeapon(int leftOrRight, WeaponName weaponName)
    {
        //Find face right or left
        Movement playerMovement = gameObject.GetComponent <Movement>();
        bool     isFaceRight    = playerMovement.IsFaceRight;
        float    eulerAngel;

        if (isFaceRight)
        {
            eulerAngel = 0;
        }
        else
        {
            eulerAngel = 180;
        }

        GameObject weaponObj    = gameManager.GetWeaponObj(weaponName);
        Vector3    tempPosition = new Vector3(0, 0, 0);

        weaponObj = Instantiate(weaponObj, tempPosition, Quaternion.Euler(0, eulerAngel, 0));
        weaponObj.transform.localScale = WeaponSizeUp * weaponObj.transform.localScale;


        if (leftOrRight == 1)
        {
            // clear objects on hand

            foreach (Transform child in LeftHand)
            {
                Destroy(child.gameObject);
            }
            weaponObj.transform.parent        = LeftHand;
            weaponObj.transform.localPosition = tempPosition;
            weaponObj.transform.rotation      = LeftHand.rotation;
            player.CombineWeapon();
        }
        else if (leftOrRight == 2)
        {
            // clear objects on hand

            foreach (Transform child in RightHand)
            {
                Destroy(child.gameObject);
            }

            weaponObj.transform.parent        = RightHand;
            weaponObj.transform.localPosition = tempPosition;
            weaponObj.transform.rotation      = RightHand.rotation;
            player.CombineWeapon();
        }
    }
Example #21
0
	// Use this for initialization
	void Start () {
		m_TimeCnt = 0.0f;
		m_NowWeapon = WeaponName.Gun;

		m_GunObj = transform.Find("Handgun_Body").gameObject;
		if (m_GunObj == null)
			Debug.Log("ガンオブジェクトがおらんぞ");

		m_SwordObj = transform.Find("greatsword_of_fn").gameObject;
		if (m_SwordObj == null)
			Debug.Log("Swordオブジェクトがおらんぞ");
		m_SwordObj.SetActive(false);

		m_Player = GameObject.Find("[CameraRig]").GetComponent<MainPlayer>();
	}
Example #22
0
    public GameObject GetWeaponObj(WeaponName weaponName)
    {
        // Debug.Log("a");
        GameObject weaponFound = new GameObject();

        foreach (WeaponObject currentWeaponObj in WeaponObjectList)
        {
            //Debug.Log(itemName);
            if (currentWeaponObj.WeaponName == weaponName)
            {
                weaponFound = currentWeaponObj.weaponObj;
            }
        }

        return(weaponFound);
    }
Example #23
0
 public bool ContainsWeapon(WeaponName n)
 {
     if (Slot1 != null)
     {
         if (Slot1.Name == n)
         {
             return(true);
         }
     }
     if (Slot2 != null)
     {
         if (Slot2.Name == n)
         {
             return(true);
         }
     }
     return(false);
 }
        public override Weapon CreateWeapon(WeaponName heavyWeapon)
        {
            switch (heavyWeapon)
            {
            case WeaponName.Bazooka:
                return(new Bazooka
                {
                    Name = "Bazooka"
                });

            case WeaponName.Shotgun:
                return(new Shotgun
                {
                    Name = "Shotgun"
                });

            default:
                return(null);
            }
        }
        public override Weapon CreateWeapon(WeaponName lightWeapon)
        {
            switch (lightWeapon)
            {
            case WeaponName.Pistol:
                return(new Pistol
                {
                    Name = "Pistol"
                });

            case WeaponName.SMG:
                return(new SMG
                {
                    Name = "SMG"
                });

            default:
                return(null);
            }
        }
Example #26
0
    public IBullet GetBullet(WeaponName wep)
    {
        IBullet aux = null;

        foreach (IBullet a in bulletListEnabled)
        {
            if (a.GetWeapon() == wep)
            {
                aux = a;
            }
        }

        if (aux == null)
        {
            aux = CreateBullet(wep);
        }

        aux.Reset();
        return(aux);
    }
Example #27
0
    public override void OnInspectorGUI()
    {
        int weaponCount = (int)WeaponName.NUMBER_OF_WEAPONS;

        // Ensure weapon array is not null and is equal in size to weaponCount
        if (_weaponMan.weaponPrefabs == null)
        {
            _weaponMan.weaponPrefabs = new Weapon[weaponCount];
        }
        else if (_weaponMan.weaponPrefabs.Length < weaponCount)
        {
            Weapon[] newWeapons = new Weapon[weaponCount];
            _weaponMan.weaponPrefabs.CopyTo(newWeapons, 0);
            _weaponMan.weaponPrefabs = newWeapons;
        }
        else if (_weaponMan.weaponPrefabs.Length > weaponCount)
        {
            List <Weapon> newWeapons = new List <Weapon>(_weaponMan.weaponPrefabs);
            newWeapons.RemoveRange(weaponCount, newWeapons.Count - weaponCount);
            _weaponMan.weaponPrefabs = newWeapons.ToArray();
        }


        // For each weapon in enum weapon names, provide a space to assign a prefab
        for (int i = 0; i < weaponCount; i++)
        {
            WeaponName name = (WeaponName)i;
            EditorGUILayout.PrefixLabel(name.ToString());
            _weaponMan.weaponPrefabs[i] = (Weapon)EditorGUILayout.ObjectField(_weaponMan.weaponPrefabs[i], typeof(Weapon), false);
        }



        // Ensure target changes if any changes in GUI
        if (GUI.changed)
        {
            EditorUtility.SetDirty(target);
        }
    }
Example #28
0
    public void SpawnBullet(Vector3 pos, Vector3 dir, Quaternion rot, WeaponName wpName)
    {
        if (wpName != WeaponName.Rocket)
        {
            for (int i = 0; i < bulletPrefabs.Count; i++)
            {
                if (!bulletPrefabs[i].activeInHierarchy)
                {
                    bulletPrefabs[i].SetActive(true);
                    bulletPrefabs[i].transform.position = pos;
                    bulletPrefabs[i].transform.rotation = rot;

                    bulletPrefabs[i].GetComponent <BulletController>().SetDirection(dir);

                    SetBulletDamage(wpName, bulletPrefabs[i]);

                    break;
                }
            }
        }
        else
        {
            for (int i = 0; i < rocketMissilePrefabs.Count; i++)
            {
                if (!rocketMissilePrefabs[i].activeInHierarchy)
                {
                    rocketMissilePrefabs[i].SetActive(true);
                    rocketMissilePrefabs[i].transform.position = pos;
                    rocketMissilePrefabs[i].transform.rotation = rot;

                    rocketMissilePrefabs[i].GetComponent <BulletController>().SetDirection(dir);

                    SetBulletDamage(wpName, rocketMissilePrefabs[i]);

                    break;
                }
            }
        }
    }
Example #29
0
        int GetPriceForItem(WeaponName weaponName)
        {
            int cost = 0;

            switch (weaponName)
            {
            case WeaponName.Carrot:
                cost = 0;
                break;

            case WeaponName.Gyoza:
                cost = 10;
                break;

            case WeaponName.Karaage:
                cost = 25;
                break;

            default:
                break;
            }
            return(cost);
        }
Example #30
0
        public void setWeapon(WeaponName weaponName)
        {
            switch (weaponName)
            {
            case WeaponName.Deagle:
                setWeapon <Deagle>();
                break;

            case WeaponName.AssaultRifle:
                setWeapon <AssaultRifle>();
                break;

            case WeaponName.Shoty:
                setWeapon <Shoty>();
                break;

            case WeaponName.Sniper:
                setWeapon <Sniper>();
                break;

            case WeaponName.Hand:
                setWeapon <Hand>();
                break;

            case WeaponName.Knife:
                setWeapon <Knife>();
                break;

            case WeaponName.Pencil:
                setWeapon <Pencil>();
                break;

            default:
                throw new ArgumentOutOfRangeException("weaponName", weaponName, null);
            }
        }
Example #31
0
 public void SwitchWeapon(WeaponName weaponName)
 {
     ActiveWeapon = _ownedWeapons.Where(weapon => weapon.Name == weaponName).First();
     InvokeActiveWeaponChanged();
 }
Example #32
0
 public virtual Weapon CreateWeapon(WeaponName weapon)
 {
     return(null);
 }
Example #33
0
 public bool CheckPlayerInventory(WeaponName weapon)
 {
     return fPlayer.InventoryWeaponNames.Contains(weapon);
 }
Example #34
0
 public void Equip(WeaponName weapon)
 {
     fPlayer.Equip(weapon);
 }
 public IWeapon getWeapon(WeaponName name)
 {
     return (IWeapon)this.weapons [name];
 }
Example #36
0
	public void ChangeWeapon(WeaponName newWeapon, int amountOfAmmo) {

		//find weaopn
		foreach (WeaponComponent weapon in weapons) {
			if (weapon.name == newWeapon) {

				if (weapon.grade == WeaponGrade.Primary) {
					if (primaryWeapon) primaryWeapon.gameObject.SetActive(false);
					primaryWeapon = weapon;
					primaryWeapon.gameObject.SetActive(true);
				}

				if (weapon.grade == WeaponGrade.Secondary) {
					if (secondaryWeapon) secondaryWeapon.gameObject.SetActive(false);
					secondaryWeapon = weapon;
					secondaryWeapon.gameObject.SetActive(true);

					weaponsBar.SetShots (amountOfAmmo);
				}

				return;
			}
		}
	}
Example #37
0
	public void ChangeWeapon(WeaponName newWeapon) {
		//find weapon
		foreach (WeaponComponent weapon in weapons) {
			//find the weapon name
			if (weapon.name == newWeapon) {

				//check for primary or secondary
				if (weapon.grade == WeaponGrade.Primary) {
					if (primaryWeapon) primaryWeapon.gameObject.SetActive(false);
					primaryWeapon = weapon;
					primaryWeapon.gameObject.SetActive(true);
				}

				if (weapon.grade == WeaponGrade.Secondary) {
					if (secondaryWeapon) secondaryWeapon.gameObject.SetActive(false);
					secondaryWeapon = weapon;
					secondaryWeapon.gameObject.SetActive(true);
				}
				return;
			}
		}
	}