private void OnEnable() { script = (bl_GunPickUp)target; info = bl_GameData.Instance.GetWeapon(script.GunID); if (script.m_DetectMode == bl_GunPickUp.DetectMode.Trigger) { if (script.gameObject.layer != LayerMask.NameToLayer("Ignore Raycast")) { script.gameObject.layer = LayerMask.NameToLayer("Ignore Raycast"); } } else { if (script.gameObject.layer == LayerMask.NameToLayer("Ignore Raycast")) { script.gameObject.layer = 0; } SphereCollider sc = script.GetComponent <SphereCollider>(); Rigidbody rb = script.GetComponent <Rigidbody>(); BoxCollider bc = script.GetComponent <BoxCollider>(); if (sc != null && sc.radius < 0.5f) { sc.radius += 0.2f; } if (sc == null || rb == null || bc == null) { isSetUp = false; } } }
void TrowGunRPC(int id, Vector3 point, string prefix, int[] info) { GameObject trow = null; bl_GunInfo ginfo = GameData.GetWeapon(id); if (ginfo.PickUpPrefab == null) { Debug.LogError(string.Format("The weapon: '{0}' not have a pick up prefab in Gun info", ginfo.Name)); return; } trow = ginfo.PickUpPrefab.gameObject; GameObject p = FindPlayerRoot(info[2]); GameObject gun = Instantiate(trow, point, Quaternion.identity) as GameObject; Collider[] c = p.GetComponentsInChildren <Collider>(); for (int i = 0; i < c.Length; i++) { Physics.IgnoreCollision(c[i], gun.GetComponent <Collider>()); } gun.GetComponent <Rigidbody>().AddForce(p.transform.forward * ForceImpulse); gun.GetComponent <bl_GunPickUp>().Info.Clips = info[0]; gun.GetComponent <bl_GunPickUp>().Info.Bullets = info[1]; gun.name = gun.name.Replace("(Clone)", ""); gun.name += prefix; gun.transform.parent = transform; }
/// <summary> /// /// </summary> protected override void Awake() { if (!PhotonNetwork.IsConnected) { return; } base.Awake(); PUM = FindObjectOfType <bl_PickGunManager>(); UIReferences = bl_UIReferences.Instance; CacheGun = bl_GameData.Instance.GetWeapon(GunID); uniqueLocal = (byte)Random.Range(0, 9998); }
/// <summary> /// /// </summary> public void Setup(bool initial = false) { bulletsLeft = bulletsPerClip; // load gun on startup DefaultPos = transform.localPosition; WeaponCamera = Camera.main.transform.GetChild(0).GetComponent <Camera>(); DefaultFog = Camera.main.fieldOfView; if (!initial) { DefaultSway = GunBob.bobbingAmount; DefaultAmountSway = SwayGun.amount; DeafultSmoothSway_ = SwayGun.smooth; } CanAim = true; Info = bl_GameData.Instance.GetWeapon(GunID); }
void DrawCreateInfo() { if (subStep == 0) { DrawText("The first step to add a new weapon is create the weapon info,\n for it you need go to the 'GameData' and add a new field in\n the 'AllWeapons' list."); GUILayout.Space(10); if (DrawButton("Open GameData")) { bl_GameData gm = bl_GameData.Instance; Selection.activeObject = gm; EditorGUIUtility.PingObject(gm); subStep++; } } else if (subStep == 1) { DrawText("Now the GameData should be open in the inspector window,\n-There in the inspector of GameData in the bottom you will see a 'Weapon' section with a 'AllWeapons' list, open it and <b>Add</b> a new field to the list. \n<i>(use the button bellow)</i>"); if (DrawButton("Add Field Automatically")) { bl_GameData gm = bl_GameData.Instance; Selection.activeObject = gm; EditorGUIUtility.PingObject(gm); bl_GunInfo info = new bl_GunInfo(); info.Name = "New Weapon"; gm.AllWeapons.Add(info); subStep++; } } else if (subStep == 2) { DrawText("Now in the 'AllWeapons' list you should see a new field called <b>'New Weapon'</b>, open it and fill the information as required by the type of weapon you are adding."); DownArrow(); DrawPropertieInfo("Name", "string", "The name of this weapon, use a Unique name for each weapon so you can easily identified they."); DrawPropertieInfo("Type", "enum", "The type of this weapon, is a sniper, rifle, knife, etc..."); DrawPropertieInfo("Damage", "int", "The amount of damage that will cause this weapon with every hit."); DrawPropertieInfo("Fire Rate", "float", "Minimum time between shots."); DrawPropertieInfo("Reload Time", "float", "Time that take reload the weapon."); DrawPropertieInfo("Range", "int", "The maximum distance that the bullet of this weapon can travel (and hit something) before get destroyed."); DrawPropertieInfo("Accuracy", "int", "The spread of the bullet."); DrawPropertieInfo("Weight", "int", "The 'weight' of this weapon, the weight affect the player speed when this gun is enabled"); DrawPropertieInfo("Pick Up Prefab", "bl_GunPickUp", "The pick up prefab of this weapon, leave empty at the moment, you will set up later in this tutorial."); DrawPropertieInfo("Gun Icon", "Sprite", "an sprite icon that represent this weapon."); DownArrow(); DrawImage(GetServerImage(4)); GUILayout.Label("With this you have setup the weapon info, you're ready for the next step."); } }
public void Init(bl_Customizer weapon) { lockedStatus = 0; customizerWeapon = weapon; bl_GunInfo info = customizerWeapon.GetWeaponInfo(); m_Text.text = customizerWeapon.WeaponName; weaponIcon.sprite = info.GunIcon; #if SHOP && ULSP if (info.Price > 0 && bl_DataBase.Instance != null) { if (bl_DataBase.Instance.LocalUser.ShopData.isItemPurchase(ShopItemType.Weapon, customizerWeapon.GunID())) { lockedStatus = bl_ShopData.Instance.purchaseOverrideLevelLock ? 3 : 0; } else { lockedStatus = 1; lockedText.text = "PRICE: $" + info.Price; button.interactable = false; } } #endif #if LM if (bl_GameData.Instance.LockWeaponsByLevel && (lockedStatus == 0 || lockedStatus == 3)) { int al = bl_LevelManager.Instance.GetLevelID(); bool UnLock = (al >= info.LevelUnlock); lockedStatus = UnLock ? lockedStatus : 2; if (!UnLock) { lockedText.text = "REQUIRES LEVEL: " + info.LevelUnlock; button.interactable = false; } } #endif lockedUI.SetActive(lockedStatus != 0 && lockedStatus != 3); }
public void Show(string killer, int gunID) { bl_GunInfo info = bl_GameData.Instance.GetWeapon(gunID); GunImage.sprite = info.GunIcon; GunNameText.text = info.Name.ToUpper(); KillerNameText.text = killer; #if LOCALIZATION KillCamSpectatingText.text = string.Format("<size=8>{0}:</size>\n{1}", bl_Localization.Instance.GetText(26).ToUpper(), killer); #else KillCamSpectatingText.text = string.Format("<size=8>{0}:</size>\n{1}", bl_GameTexts.Spectating.ToUpper(), killer); #endif bl_GameManager.SceneActors actor = bl_GameManager.Instance.FindActor(killer); if (actor != null) { if (actor.isRealPlayer) { bl_PlayerDamageManager pdm = actor.Actor.GetComponent <bl_PlayerDamageManager>(); int health = Mathf.FloorToInt(pdm.health); if (pdm != null) { KillerHealthText.text = string.Format("HEALTH: {0}", health); } } else { bl_AIShooterHealth pdm = actor.Actor.GetComponent <bl_AIShooterHealth>(); int health = Mathf.FloorToInt(pdm.Health); if (pdm != null) { KillerHealthText.text = string.Format("HEALTH: {0}", health); } } } else { KillerHealthText.text = string.Empty; } }
/// <summary> /// /// </summary> private bool isAllowedWeapon(bl_GunInfo info, int slot) { ClassAllowedWeaponsType rules = PrimaryAllowedWeapons; if (slot == 1) { rules = SecondaryAllowedWeapons; } else if (slot == 2) { rules = KnifeAllowedWeapons; } else if (slot == 3) { rules = GrenadesAllowedWeapons; } if ((rules.AllowMachineGuns && (info.Type == GunType.Machinegun || info.Type == GunType.Burst)) || (rules.AllowPistols && info.Type == GunType.Pistol) || (rules.AllowShotguns && info.Type == GunType.Shotgun) || (rules.AllowKnifes && info.Type == GunType.Knife) || (rules.AllowGrenades && (info.Type == GunType.Grenade || info.Type == GunType.Grenade)) || (rules.AllowSnipers && info.Type == GunType.Sniper)) { return(true); } return(false); }
public void SetPickUp(bool show, int id = 0, bl_GunPickUp gun = null, bool equiped = false) { if (show) { bl_GunInfo info = bl_GameData.Instance.GetWeapon(id); #if LOCALIZATION string t = (equiped) ? string.Format(LocaleStrings[7], info.Name) : string.Format(LocaleStrings[8], bl_GameData.Instance.GetWeapon(id).Name); #else string t = (equiped) ? string.Format(bl_GameTexts.PickUpWeaponEquipped, info.Name) : string.Format(bl_GameTexts.PickUpWeapon, bl_GameData.Instance.GetWeapon(id).Name); #endif PlayerUI.PickUpText.text = t.ToUpper(); PlayerUI.PickUpUI.SetActive(true); if (PlayerUI.PickUpIconUI != null) { PlayerUI.PickUpIconUI.transform.GetChild(0).GetComponent <Image>().sprite = info.GunIcon; PlayerUI.PickUpIconUI.SetActive(info.GunIcon != null); } } else { PlayerUI.PickUpUI.SetActive(false); } CacheGunPickUp = gun; }
public void Export() { if (FPWeapon == null || Player == null) { return; } bl_GunInfo info = bl_GameData.Instance.GetWeapon(FPWeapon.GunID); GameObject root = new GameObject(info.Name + " [Export]"); root.transform.SetAsLastSibling(); bl_WeaponExported export = root.AddComponent <bl_WeaponExported>(); export.WeaponInfo = info; GameObject fpwCopy = Instantiate(FPWeapon.gameObject); fpwCopy.SetActive(true); fpwCopy.name = info.Name + " [FP]"; fpwCopy.transform.parent = root.transform; fpwCopy.transform.localPosition = Vector3.zero; export.FPWeapon = fpwCopy.GetComponent <bl_Gun>(); export.FPWPosition = FPWeapon.transform.localPosition; export.FPWRotation = FPWeapon.transform.localRotation; if (NetworkGun != null) { GameObject tpwCopy = Instantiate(NetworkGun.gameObject); tpwCopy.SetActive(true); tpwCopy.name = info.Name + " [TP]"; tpwCopy.transform.parent = root.transform; tpwCopy.transform.localPosition = Vector3.zero; export.TPWeapon = tpwCopy.GetComponent <bl_NetworkGun>(); export.TPWPosition = NetworkGun.transform.localPosition; export.TPWRotation = NetworkGun.transform.localRotation; } string lastPath = EditorPrefs.GetString(LAST_PATH, ""); Debug.Log(lastPath); string path = EditorUtility.OpenFolderPanel("Select Folder to save prefab", lastPath, ""); if (!string.IsNullOrEmpty(path)) { string relativepath = "Assets" + path.Substring(Application.dataPath.Length); relativepath += "/" + root.name + ".prefab"; #if UNITY_2018_3_OR_NEWER GameObject newPrefab = PrefabUtility.SaveAsPrefabAsset(root, relativepath); #else GameObject newPrefab = PrefabUtility.CreatePrefab(relativepath, root); #endif Selection.activeGameObject = newPrefab; EditorGUIUtility.PingObject(newPrefab); DestroyImmediate(root); EditorPrefs.SetString(LAST_PATH, path); } else { Debug.LogWarning("Could not create a prefab automatically."); Selection.activeGameObject = root; EditorGUIUtility.PingObject(root); } Close(); }
public override void OnInspectorGUI() { EditorGUI.BeginChangeCheck(); EditorGUILayout.BeginVertical("box"); EditorGUILayout.BeginVertical("box"); script.GunID = EditorGUILayout.Popup("Gun ID ", script.GunID, bl_GameData.Instance.AllWeaponStringList(), EditorStyles.toolbarDropDown); if (info != null && info.GunIcon != null) { GUILayout.Space(5); GUILayout.BeginHorizontal(); GUILayout.FlexibleSpace(); Texture2D t = info.GunIcon.texture; GUILayout.Label(t, GUILayout.Width(t.width * 0.5f), GUILayout.Height(t.height * 0.5f)); GUILayout.FlexibleSpace(); EditorGUILayout.EndHorizontal(); } EditorGUILayout.EndVertical(); if (info.Type != GunType.Knife && info.Type != GunType.Grenade) { EditorGUILayout.BeginHorizontal("box"); float dw = EditorGUIUtility.labelWidth; EditorGUIUtility.labelWidth = 90; script.Info.Bullets = EditorGUILayout.IntField("Bullets", script.Info.Bullets); script.Info.Clips = EditorGUILayout.IntField("Clips", script.Info.Clips); int bullets = script.Info.Bullets * script.Info.Clips; EditorGUILayout.LabelField(" = " + bullets + " Bullets"); EditorGUIUtility.labelWidth = dw; EditorGUILayout.EndHorizontal(); } else if (info.Type == GunType.Grenade) { } EditorGUILayout.BeginVertical("box"); script.m_DetectMode = (bl_GunPickUp.DetectMode)EditorGUILayout.EnumPopup("Detect Mode", script.m_DetectMode, EditorStyles.toolbarDropDown); script.AutoDestroy = EditorGUILayout.ToggleLeft("Destroy After Time", script.AutoDestroy, EditorStyles.toolbarButton); if (script.AutoDestroy) { script.DestroyIn = EditorGUILayout.Slider("Destroy In", script.DestroyIn, 0.1f, 30); } EditorGUILayout.EndVertical(); if (!isSetUp) { GUILayout.BeginHorizontal("box"); if (GUILayout.Button("Add require components", EditorStyles.toolbarButton)) { if (script.GetComponent <SphereCollider>() == null) { SphereCollider sc = script.gameObject.AddComponent <SphereCollider>(); sc.radius = 0.62f; sc.isTrigger = true; } if (script.GetComponent <BoxCollider>() == null) { script.gameObject.AddComponent <BoxCollider>(); } if (script.GetComponent <Rigidbody>() == null) { script.gameObject.AddComponent <Rigidbody>(); } isSetUp = false; } GUILayout.EndHorizontal(); } EditorGUILayout.EndVertical(); if (EditorGUI.EndChangeCheck()) { serializedObject.ApplyModifiedProperties(); EditorUtility.SetDirty(target); info = bl_GameData.Instance.GetWeapon(script.GunID); } }