public void AddNewWeapon(GameObject weapon) { if (currentWeapon) { Destroy(currentWeapon); } currentWeapon = GetChildedWeapon(this.gameObject); if (currentWeapon) { PhotonNetwork.Destroy(currentWeapon.gameObject); } GameObject newWeapon = PhotonNetwork.Instantiate(weapon.name, this.transform.position, Quaternion.identity); currentWeaponObject = newWeapon; photonView.RPC("SetParent", RpcTarget.AllBuffered, currentWeaponObject.GetComponent <PhotonView>().ViewID); //newWeapon.transform.parent = this.transform; currentWeapon = newWeapon.GetComponent <WeaponAbstract>(); currentWeaponType = currentWeapon.weaponType; if (currentWeaponType == WeaponAbstract.WeaponTypes.MeleeWeapon) { newWeapon.transform.localScale = new Vector3(0.3f, 0.3f, 0.3f); } else { newWeapon.transform.localScale = new Vector3(-0.2f, 0.2f, 0.2f); } }
public void UpdateWeapon(WeaponAbstract thisWeap = null) { if (thisWeap != null) { autoShoot = thisWeap.AutoShoot; SpeedReduce = thisWeap.SpeedReduce; thisWeapon = thisWeap; } else { thisWeapon = null; } }
// Use this for initialization void Start() { initedWeapons = new WeaponAbstract[weaponsPrefabs.Length]; for(int i = 0; i < weaponsPrefabs.Length; i++) { weapon = Instantiate(weaponsPrefabs[i]); weapon.InitGunHead(gameObject); weapon.transform.parent = transform; initedWeapons[i] = weapon; } weapon = initedWeapons[0]; }
public WeaponAbstract GetChildedWeapon(GameObject player) { for (int i = 0; i < player.transform.childCount; i++) { Transform currentChild = player.transform.GetChild(i); var foundWeapon = currentChild.GetComponent <WeaponAbstract>(); if (foundWeapon) { currentWeapon = foundWeapon; currentWeaponType = foundWeapon.weaponType; return(currentWeapon); } } currentWeapon = null; return(null); }
public override void OnInspectorGUI() { EditorGUILayout.LabelField("Weapon Inspector", EditorStyles.boldLabel); WeaponAbstract myTarget = (WeaponAbstract)target; var oldColor = GUI.backgroundColor; var buttonStyle = new GUIStyle(EditorStyles.miniButton); //buttonStyle.normal.textColor = Color.green; //buttonStyle.normal.textColor = Color.red; serializedObject.Update( ); EditorGUILayout.PropertyField(WeightRandom); EditorGUILayout.Space(); EditorGUILayout.BeginVertical(); EditorGUILayout.BeginHorizontal(); EditorGUILayout.LabelField("Bullet Object"); EditorGUILayout.LabelField("Spawn Pos Bullet"); EditorGUILayout.EndHorizontal(); EditorGUILayout.BeginHorizontal(); EditorGUILayout.PropertyField(Bullet, Empty); EditorGUILayout.PropertyField(SpawnBullet, Empty); EditorGUILayout.EndHorizontal(); EditorGUILayout.EndVertical(); EditorGUILayout.Space(); // -- bool EditorGUILayout.BeginHorizontal(); if (myTarget.AutoShoot) { GUI.backgroundColor = Color.green; } else { GUI.backgroundColor = Color.red; } if (GUILayout.Button("AutoShoot", buttonStyle)) { myTarget.AutoShoot = !myTarget.AutoShoot; } //EditorGUILayout.PropertyField ( AutoShoot ); if (myTarget.Projectile) { GUI.backgroundColor = Color.green; } else { GUI.backgroundColor = Color.red; } if (GUILayout.Button("It's a Projectile", buttonStyle)) { myTarget.Projectile = !myTarget.Projectile; } EditorGUILayout.EndHorizontal(); //EditorGUILayout.PropertyField ( Projectile ); EditorGUILayout.BeginHorizontal(); if (myTarget.Through) { GUI.backgroundColor = Color.green; } else { GUI.backgroundColor = Color.red; } if (GUILayout.Button("Can Through", buttonStyle)) { myTarget.Through = !myTarget.Through; } //EditorGUILayout.PropertyField ( AutoShoot ); if (myTarget.Explosion) { GUI.backgroundColor = Color.green; } else { GUI.backgroundColor = Color.red; } if (GUILayout.Button("Can Explose", buttonStyle)) { myTarget.Explosion = !myTarget.Explosion; } EditorGUILayout.EndHorizontal(); EditorGUILayout.Space(); //EditorGUILayout.PropertyField ( Through ); //EditorGUILayout.PropertyField ( Explosion ); // -- GUI.backgroundColor = oldColor; EditorGUILayout.PropertyField(BulletCapacity); EditorGUILayout.PropertyField(Damage); EditorGUILayout.PropertyField(BackPush); EditorGUILayout.PropertyField(SpeedReduce); EditorGUILayout.PropertyField(Range); EditorGUILayout.Space(); EditorGUILayout.LabelField("WeaponCustom -------", EditorStyles.boldLabel); EditorGUI.indentLevel = 1; // si auto if (myTarget.AutoShoot) { EditorGUILayout.LabelField("AutoShoot -------", EditorStyles.boldLabel); EditorGUILayout.PropertyField(FireRate); EditorGUILayout.LabelField("-------", EditorStyles.boldLabel); } // fin auto else // si manuel { EditorGUILayout.LabelField("ManualShoot -------", EditorStyles.boldLabel); EditorGUILayout.PropertyField(CoolDown); EditorGUILayout.LabelField("-------", EditorStyles.boldLabel); } // fin manuel // -- si Projectile if (myTarget.Projectile) { EditorGUILayout.LabelField("Projectile -------", EditorStyles.boldLabel); EditorGUILayout.PropertyField(NbrBullet); EditorGUILayout.PropertyField(ScaleBullet); EditorGUILayout.PropertyField(SpeedBullet); if (myTarget.Gust) { GUI.backgroundColor = Color.green; } else { GUI.backgroundColor = Color.red; } if (GUILayout.Button("Gust", buttonStyle)) { myTarget.Gust = !myTarget.Gust; } GUI.backgroundColor = oldColor; //EditorGUILayout.PropertyField ( Gust ); EditorGUI.indentLevel = 2; // -- si Gust if (myTarget.Gust) { EditorGUILayout.LabelField("Gust -------", EditorStyles.boldLabel); EditorGUILayout.PropertyField(SpaceBulletTime); EditorGUILayout.LabelField("-------", EditorStyles.boldLabel); } // -- fin Gust else // -- si spread { EditorGUILayout.LabelField("Spread -------", EditorStyles.boldLabel); EditorGUILayout.PropertyField(Angle); EditorGUILayout.LabelField("-------", EditorStyles.boldLabel); } // -- fin spread EditorGUI.indentLevel = 1; EditorGUILayout.LabelField("-------", EditorStyles.boldLabel); } else // -- fin projectile { // -- si zone EditorGUILayout.PropertyField(FarEffect); EditorGUILayout.PropertyField(TimeFarEffect); EditorGUILayout.PropertyField(WidthRange); EditorGUILayout.PropertyField(SpeedZone); EditorGUILayout.PropertyField(TimeDest); // -- fin zone } EditorGUI.indentLevel = 2; if (myTarget.Explosion) { // -- si explosion EditorGUILayout.LabelField("Explosion -------", EditorStyles.boldLabel); EditorGUILayout.PropertyField(Diameter); EditorGUILayout.LabelField("-------", EditorStyles.boldLabel); // -- fin explostion } EditorGUI.indentLevel = 0; EditorGUILayout.LabelField("-------", EditorStyles.boldLabel); serializedObject.ApplyModifiedProperties( ); }
IEnumerator DoubleDamageResetCountDown(float doubleDamageLength, WeaponAbstract weapon) { yield return(new WaitForSeconds(doubleDamageLength)); weapon.Damage /= 2; }
public void ChangeWeapons(int weaponIndex) { weapon = initedWeapons[weaponIndex]; }