public void Die() { PlayerWeapons.HideWeapon(); PlayerWeapons.playerActive = false; this.GetComponent <CharacterMotorDB>().canControl = false; BroadcastMessage("Death"); BroadcastMessage("Freeze"); LockCursor.HardUnlock(); dead = true; }
void Start() { singleton = this; dead = false; cam = PlayerWeapons.weaponCam; hitEffectTime = 0; mainCam = PlayerWeapons.mainCam; pWeapons = this.GetComponentInChildren <PlayerWeapons>(); health = maxHealth; }
//Reactivates player to normal function public void ReleasePlayer() { player.GetComponent <MouseLookDBJS>().UnlockIt(); PlayerWeapons.weaponCam.GetComponent <MouseLookDBJS>().UnlockIt(); ladder = false; SmartCrosshair.draw = true; DBStoreController.canActivate = true; PlayerWeapons.playerActive = true; CharacterMotorDB.paused = false; if (temp) { PlayerWeapons.ShowWeapon(); } }
public void activateStore() { PlayerWeapons.HideWeaponInstant(); Time.timeScale = 0; // GUIController.state = GUIStates.store; inStore = true; //BroadcastMessage("Unlock"); storeActive = true; Screen.lockCursor = false; LockCursor.canLock = false; //playerW.BroadcastMessage("DeselectWeapon"); //turn off graphics/weapons on entering store GameObject player = GameObject.FindWithTag("Player"); player.BroadcastMessage("Freeze", SendMessageOptions.DontRequireReceiver); }
public void Initialize() { singleton = this; playerW = FindObjectOfType(typeof(PlayerWeapons)) as PlayerWeapons; slotInfo = FindObjectOfType(typeof(SlotInfo)) as SlotInfo; WeaponInfoArray = FindObjectsOfType(typeof(WeaponInfo)) as WeaponInfo[]; foreach (WeaponInfo w in WeaponInfoArray) { if (w.weaponClass == WeaponInfo.weaponClasses.Null) { nullWeapon = w.gameObject; } } setupWeaponClassNames(); setupWeaponInfoByClass(); }
void Awake() { if (PW) { Debug.LogError("Too many instances of PlayerWeapons! There should only be one per scene"); } PW = this; weaponCam = GameObject.FindWithTag("WeaponCamera"); mainCam = GameObject.FindWithTag("MainCamera"); player = GameObject.FindWithTag("Player"); CM = player.GetComponent <CharacterMotorDB>(); controller = player.GetComponent <CharacterController>(); hidden = false; SetSensitivity(); }
public void deActivateStore() { if (PlayerWeapons.HasEquipped() <= 0 && !canExitWhileEmpty) { return; } storeActive = false; inStore = false; //GUIController.state = GUIStates.playing; //BroadcastMessage("Lock"); Time.timeScale = 1; Screen.lockCursor = true; LockCursor.canLock = true; PlayerWeapons.ShowWeapon(); //playerW.SelectWeapon(playerW.selectedWeapon); // activate graphics on selected weapon GameObject player = GameObject.FindWithTag("Player"); player.BroadcastMessage("UnFreeze", SendMessageOptions.DontRequireReceiver); }
//Locks player to ladder public IEnumerator LockPlayer() { if (GunScript.takingOut || GunScript.puttingAway || ladder) { yield break; } if (PlayerWeapons.PW.weapons[PlayerWeapons.PW.selectedWeapon]) { temp = PlayerWeapons.PW.weapons[PlayerWeapons.PW.selectedWeapon].GetComponent <GunScript>().gunActive; } else { temp = true; } player.SendMessage("StandUp"); belowHeight = true; CharacterMotorDB.paused = true; SmartCrosshair.draw = false; PlayerWeapons.playerActive = false; DBStoreController.canActivate = false; PlayerWeapons.HideWeapon(); val = (player.position.y - transform.position.y) / (exitPos.position.y - transform.position.y); RotateTo(player, enterPos.eulerAngles, moveSpeed, false); RotateTo(PlayerWeapons.weaponCam.transform, Vector3.zero, moveSpeed, true); player.GetComponent <MouseLookDBJS>().individualFreeze = true; PlayerWeapons.weaponCam.GetComponent <MouseLookDBJS>().individualFreeze = true; yield return(MoveToStart(player, enterPos.position, moveSpeed)); player.GetComponent <MouseLookDBJS>().LockIt(60, 60); PlayerWeapons.weaponCam.GetComponent <MouseLookDBJS>().LockItSpecific(-40, 80); player.GetComponent <MouseLookDBJS>().individualFreeze = false; PlayerWeapons.weaponCam.GetComponent <MouseLookDBJS>().individualFreeze = false; PlayerWeapons.canLook = true; ladder = true; soundAmt = soundInterval; }
void Start() { playerWeapons = PlayerWeapons.PW; store = FindObjectOfType <DBStoreController>(); singleton = this; }
// This function draws the popup window to buy or equip a weapon. public void WeaponBuyWindow(int windowID) { WeaponInfo g; string msg; Rect rLeft = new Rect(5, 20, popupRect.width / 2 - 7, popupRect.height - 25); Rect rRight = new Rect(popupRect.width / 2 + 2, 20, popupRect.width / 2 - 7, popupRect.height - 25); int slot = lsEquip.selection; // only used for equiping if (header.selection == (int)HeaderModes.Buy) { g = mdBuy.wi[mdBuy.selection]; } else { g = mdEquip.wi[mdEquip.selection]; } Upgrade[] upgrades = g.getUpgrades(); //bool[ ] upgradeToggles = new bool[ upgrades.Length]; GUI.Box(rLeft, ""); GUILayout.BeginArea(rLeft); GUILayout.BeginHorizontal(); GUILayout.Space(5); GUILayout.BeginVertical(); GUILayout.Space(5); if (header.selection == (int)HeaderModes.Buy) { msg = getBuyMsg(g); } else { msg = getEquipMsg(g, slot); } GUILayout.Label(msg); GUILayout.Label("Available Balance = $" + store.getBalance()); GUILayout.FlexibleSpace(); GUILayout.BeginHorizontal(); GUILayout.FlexibleSpace(); if (header.selection == (int)HeaderModes.Equip) { if (store.playerW.weapons[slot] != g.gameObject) { if (GUILayout.Button("Equip", GUILayout.Width(65))) { store.equipWeapon(g, slot); } } else { if (GUILayout.Button("Un-Equip", GUILayout.Width(65))) { store.unEquipWeapon(g, slot); } } if (!g.gun.infiniteAmmo) { if (g.gun.clips < g.gun.maxClips) { if (store.getBalance() >= g.ammoPrice) { if (GUILayout.Button(new GUIContent("Ammo ($" + g.ammoPrice + ")", "Current Ammo: " + g.gun.clips), GUILayout.Width(85))) { store.BuyAmmo(g); } } else { GUILayout.Button(new GUIContent("Ammo ($" + g.ammoPrice + ")", "Can't Afford"), GUILayout.Width(85)); } } else { GUILayout.Button(new GUIContent("Ammo ($" + g.ammoPrice + ")", "Ammo Full: " + g.gun.clips), GUILayout.Width(85)); } } } else { if (g.owned) { if (g.canBeSold) { if (GUILayout.Button("Sell", GUILayout.Width(70))) { store.sellWeapon(g); } } else { GUILayout.Button("Can't Sell", GUILayout.Width(70)); } if (!g.gun.infiniteAmmo) { if (g.gun.clips < g.gun.maxClips) { if (store.getBalance() >= g.ammoPrice) { if (GUILayout.Button(new GUIContent("Ammo ($" + g.ammoPrice + ")", "Current Ammo: " + g.gun.clips), GUILayout.Width(85))) { store.BuyAmmo(g); } } else { GUILayout.Button(new GUIContent("Ammo ($" + g.ammoPrice + ")", "Can't Afford"), GUILayout.Width(85)); } } else { GUILayout.Button(new GUIContent("Ammo ($" + g.ammoPrice + ")", "Ammo Full: " + g.gun.clips), GUILayout.Width(85)); } } } else { if (store.getBalance() >= g.buyPrice) { if (GUILayout.Button("Buy", GUILayout.Width(70))) { store.buyWeapon(g); } } else { GUILayout.Button(new GUIContent("Buy", "Insufficient Funds"), GUILayout.Width(70)); } } } if (GUILayout.Button("Close", GUILayout.Width(70))) { MDSelection = -1; popupActive = false; popupBuyActive = false; } GUILayout.FlexibleSpace(); GUILayout.EndHorizontal(); GUILayout.Label(GUI.tooltip); GUILayout.EndVertical(); GUILayout.Space(5); GUILayout.EndHorizontal(); GUILayout.EndArea(); // Display for upgrades in the right side of the window // The display changes for buying upgrades or equipping upgrades. GUI.Box(rRight, ""); GUILayout.BeginArea(rRight); GUILayout.BeginHorizontal(); GUILayout.Space(5); GUILayout.BeginVertical(); GUILayout.Space(5); if (upgrades == null) { GUILayout.Label("No Upgrades Available for this Weapon"); } else if (upgrades.Length < 0) { GUILayout.Label("No Upgrades Available for this Weapon"); } else { GUILayout.BeginHorizontal(); GUILayout.FlexibleSpace(); upgradeDisplayBuy = GUILayout.Toggle(upgradeDisplayBuy, "Buy Upgrades"); if (upgradeDisplayBuy) { upgradeDisplayEquip = false; } upgradeDisplayEquip = GUILayout.Toggle(upgradeDisplayEquip, "Equip Upgrades"); if (upgradeDisplayEquip) { upgradeDisplayBuy = false; } GUILayout.FlexibleSpace(); GUILayout.EndHorizontal(); if (upgradeDisplayBuy) { GUILayout.Space(5); string upgradeMsg; if (g.owned) { upgradeMsg = "View or Buy Upgrades"; } else { upgradeMsg = "You must Purchase the Weapon before buying Upgrades"; } GUILayout.Label(upgradeMsg); popupBuyScroll1 = GUILayout.BeginScrollView(popupBuyScroll1); if (upgrades != null) { for (int i = 0; i < upgrades.Length; i++) { if (!upgrades[i].owned) { GUILayout.BeginHorizontal(); GUILayout.Label(upgrades[i].upgradeName); GUILayout.Space(5); if (GUILayout.Button(setGUIContent(upgradeInfoIcon, "View", ""), GUILayout.Width(40), GUILayout.Height(20))) { if (upgradeSelected[i]) { upgradeSelected[i] = false; } else { upgradeSelected[i] = true; } } GUILayout.Space(5); GUIContent gc; if (upgrades[i].locked) { GUILayout.Label("(Locked)"); upgradeMsg = upgrades[i].lockedDescription; } else { if (g.owned) { float balance = store.getBalance(); if (balance > upgrades[i].buyPrice) { gc = setGUIContent(upgradeBuyIcon, "Buy", ""); } else { gc = new GUIContent(upgradeBuyIcon, "Insufficient Funds"); } if (GUILayout.Button(gc, GUILayout.Width(40), GUILayout.Height(20))) { if (balance > upgrades[i].buyPrice) { store.buyUpgrade(g, upgrades[i]); } } } } upgradeMsg = "Price :\t$" + upgrades[i].buyPrice + "\n"; upgradeMsg += "Description:\t" + upgrades[i].description; GUILayout.FlexibleSpace(); GUILayout.EndHorizontal(); if (upgradeSelected[i]) { closeOtherSelections(i); GUILayout.BeginHorizontal(); GUILayout.Space(10); GUILayout.BeginVertical(); GUILayout.Label(upgradeMsg); GUILayout.EndVertical(); GUILayout.EndHorizontal(); } } // upgrade not owned } // loop over upgrades } GUILayout.EndScrollView(); GUILayout.Label(GUI.tooltip); } else { // Displaying Equip Window GUILayout.Space(5); GUILayout.Label("Select Upgrades To Apply - Note: Some upgrades disable others"); bool before; // bool[ ] upgradesApplied = g.getUpgradesApplied(); popupBuyScroll1 = GUILayout.BeginScrollView(popupBuyScroll1); for (int j = 0; j < upgrades.Length; j++) { if (upgrades[j].owned) { before = g.upgradesApplied[j]; // keep track of current state g.upgradesApplied[j] = GUILayout.Toggle(g.upgradesApplied[j], upgrades[j].upgradeName); if (before != g.upgradesApplied[j]) { if (before) { upgrades[j].RemoveUpgrade(); } else { upgrades[j].ApplyUpgrade(); PlayerWeapons.HideWeaponInstant(); //turn off graphics for applied upgrade } g.updateApplied(); } } } GUILayout.EndScrollView(); GUILayout.Space(8); } // Displaying Equip Window } //upgrades.Length !=0 GUILayout.EndVertical(); GUILayout.Space(5); GUILayout.EndHorizontal(); GUILayout.EndArea(); }
public override void OnInspectorGUI() { //If our allowed array is the wrong Length, we must correct it if (player.weapons.Length != Instance.allowed.Length) { //Create an array of the proper Length tmpAllowed = new int[player.weapons.Length]; //Now iterate through and copy values int upperBound = Mathf.Min(Instance.allowed.Length, player.weapons.Length); for (int j = 0; j < upperBound; j++) { tmpAllowed[j] = Instance.allowed[j]; } Instance.allowed = tmpAllowed; } //If our slotName array is the wrong Length, we must correct it if (player.weapons.Length != Instance.slotName.Length) { //Create an array of the proper Length string[] tmpAllowedS = new string[player.weapons.Length]; //Now iterate through and copy values int upperBound = Mathf.Min(Instance.slotName.Length, player.weapons.Length); for (int j = 0; j < upperBound; j++) { tmpAllowedS[j] = Instance.slotName[j]; } Instance.slotName = tmpAllowedS; } player = FindObjectOfType(typeof(PlayerWeapons)) as PlayerWeapons; EditorGUIUtility.LookLikeInspector(); for (int i = 0; i < player.weapons.Length; i++) { if (string.IsNullOrEmpty(Instance.slotName[i])) { Instance.slotName[i] = "Slot " + (i + 1); } Instance.slotName[i] = EditorGUILayout.TextField("Slot Name:", Instance.slotName[i]); foldoutState[i] = EditorGUILayout.Foldout(foldoutState[i], "Allowed Weapon Classes"); if (foldoutState[i]) { foreach (WeaponInfo.weaponClasses w in WeaponInfo.weaponClasses.GetValues(typeof(WeaponInfo.weaponClasses))) { if (w == WeaponInfo.weaponClasses.Null) { break; } string className = w.ToString().Replace("_", " "); bool allowed = Instance.isWCAllowed(i, w); bool toggleState; toggleState = GUILayout.Toggle(allowed, className); if (toggleState != allowed) { Instance.setAllowed(i, w, toggleState); toggleState = allowed; } } } } if (GUI.changed) { EditorUtility.SetDirty(Instance); } }
void Awake() { player = FindObjectOfType(typeof(PlayerWeapons)) as PlayerWeapons; foldoutState = new bool[player.weapons.Length]; }