private void ChangeValue(string msg) { //Debug.Log("ChangeValue:" + msg); GameObject one = null; if (LastWeapon != null) { LastWeapon.SetActive(false); if (!weaponList.ContainsKey(MsgCenter.Instance.DefaultWeapon)) { weaponList.Add(MsgCenter.Instance.DefaultWeapon, LastWeapon); } } if (weaponList.ContainsKey(msg)) { one = weaponList[msg]; WeaponControll weapon = one.GetComponent <WeaponControll>(); if (msg != MsgCenter.Instance.DefaultWeapon && weapon != null) { weapon.LifeTime = MsgCenter.Instance.player.useWeapon.LifeTime; weapon._time = 0; } one.SetActive(true); } else { GameObject go; if (IsRight) { go = MsgCenter.Instance.RightWeapons[msg]; if (msg != MsgCenter.Instance.DefaultWeapon) { WeaponControll weapon = go.AddComponent <WeaponControll>(); weapon.LifeTime = MsgCenter.Instance.player.useWeapon.LifeTime; //weapon.enabled = true; } } else { go = MsgCenter.Instance.LeftWeapons[msg]; } one = Instantiate(go); weaponList.Add(msg, one); one.SetActive(true); one.transform.SetParent(this.transform, false); one.transform.localPosition = Vector3.zero; one.transform.localEulerAngles = Vector3.zero; one.transform.localScale = Vector3.one; } currWeapon = one; LastWeapon = one; }
//-------------------- // WEAPON //-------------- // public void OnChengWeapon(int newWeaponId) { if (currentWeapon != newWeaponId) { if (currentWeapon >= 0) { weaponC.DestroyW(); } // GameObject _w = Instantiate(rpcc.weapons[newWeaponId].gom, tr_veapon) as GameObject; _w.transform.localPosition = Vector3.zero; _w.transform.localRotation = Quaternion.identity; weaponC = _w.GetComponent <WeaponControll>(); haveWeapon = (rpcc.weapons[newWeaponId].isWeapon); tr_shoot = weaponC.shootPos; currentWeapon = newWeaponId; weaponC.rpcc = rpcc; } }