public EquipWeapon ( PlayerWeapon, _weapon ) : void | ||
_weapon | PlayerWeapon, | |
Résultat | void |
private void PrevWeapon() { m_weaponNum--; if (m_weaponNum < 0) { m_weaponNum = (int)WeaponTypes.NUM - 1; } m_weaponManager.EquipWeapon(m_weaponPath[m_weaponNum]); }
private void UseItem(Items item) { switch (item.itemType) { case Items.ItemType.SMG: weaponManager.PickUpWeapon(go_SMGPrefab); weaponManager.EquipWeapon(go_SMGPrefab); go_CurrentWeapon = go_SMGPrefab; foreach (AnimatorControllerParameter parameter in playerAnimator.parameters) { playerAnimator.SetBool(parameter.name, false); } playerAnimator.SetBool("SMG", true); playerAnimator.SetBool("Crouching", bIsCrouching); for (int i = 0; i < go_aOverHeatBars.Length; i++) { go_aOverHeatBars[i].SetActive(true); } //GameObject currentEquippedWeapon = go_SMGPrefab; //go_WeaponManger.GetComponent<WeaponManager>().go_CurrentWeapon = currentEquippedWeapon; break; case Items.ItemType.Shotgun: weaponManager.PickUpWeapon(go_ShotgunPrefab); weaponManager.EquipWeapon(go_ShotgunPrefab); go_CurrentWeapon = go_ShotgunPrefab; foreach (AnimatorControllerParameter parameter in playerAnimator.parameters) { playerAnimator.SetBool(parameter.name, false); } playerAnimator.SetBool("Shotgun", true); playerAnimator.SetBool("Crouching", bIsCrouching); for (int i = 0; i < go_aOverHeatBars.Length; i++) { go_aOverHeatBars[i].SetActive(true); } //GameObject currentEquippedWeapon = go_SMGPrefab; //go_WeaponManger.GetComponent<WeaponManager>().go_CurrentWeapon = currentEquippedWeapon; break; case Items.ItemType.Health: PlayerHealing(); inventory.RemoveItem(new Items { itemType = Items.ItemType.Health, iItemAmmount = 1 }); break; } }
void Awake() { //Set up UI canvas = FindObjectOfType <Canvas>(); controllersUI = canvas.GetComponent <ControllersUI>(); gameUI = canvas.GetComponent <GameUI>(); //Find map, player, and equip weapon mapGen = FindObjectOfType <MapGenerator>().GetComponent <MapGenerator>(); Map map = mapGen.map; currentPlayer = (Player)Instantiate(startPlayer, mapGen.CoordToPosition(map.mapSize.x / 2, 2), Quaternion.identity); weaponManager = currentPlayer.transform.GetComponent <WeaponManager>(); playerCurrentWeapon = weaponManager.EquipWeapon(weaponManager.startingWeaponIndex); //playerCurrentWeapon = weaponManager.allWeapons[weaponManager.startingWeaponIndex]; //Setup audio Transform audioManager = FindObjectOfType <AudioManager>().transform; audioManager.position = currentPlayer.transform.position; audioManager.rotation = currentPlayer.transform.rotation; audioManager.parent = currentPlayer.transform; //Set up controllers SwipeDetector swipeDetect = currentPlayer.GetComponent <SwipeDetector>(); swipeDetect.aimJoystickArea = controllersUI.AimJoystickArea; swipeDetect.aimJoystickRect = controllersUI.AimJoystickRect; swipeDetect.attackJoystickRect = controllersUI.AttackJoystickRect; swipeDetect.changeWeaponJoystickRect = controllersUI.ChangeWeaponRect; //Camera.main.GetComponent<CameraController>().SetTarget(currentPlayer.transform); Camera.main.GetComponent <CameraFollow>().SetTarget(currentPlayer.transform); }
void InitWeapon() { //有初始武器就生成 if (weaponName != "") { WeaponManager.EquipWeapon(this, weaponName); } }
void OnTriggerEnter(Collider _collider) { if (_collider.gameObject.tag == "Player") { //create playerweapon from gameobject then pass playerweapon object to equip weapon WeaponManager weaponManager = GetComponent <WeaponManager>(); PlayerWeapons weapon = new Submachine(); weapon.initializeSubmachine(); weaponManager.EquipWeapon(weapon); } }
private void ShowWeaponList(int index) { SerializedProperty weapon = m_WeaponList.GetArrayElementAtIndex(index); using (new EditorGUILayout.HorizontalScope()) { EditorGUILayout.PropertyField(weapon, new GUIContent("Weapon " + (index + 1))); if (weapon.objectReferenceValue != null) { if (!m_Target.IsEquipped((IWeapon)weapon.objectReferenceValue) && m_Target.HasFreeSlot) { EditorGUI.BeginChangeCheck(); if (GUILayout.Button("Equip", Styling.button)) { if (EditorGUI.EndChangeCheck()) { Undo.RecordObject(m_Target, "Undo Inspector"); m_Target.EquipWeapon(index); EditorUtility.SetDirty(m_Target); return; } } } } EditorGUI.BeginChangeCheck(); if (GUILayout.Button("+", Styling.leftButton, GUILayout.Width(24))) { if (EditorGUI.EndChangeCheck()) { Undo.RecordObject(m_Target, "Undo Inspector"); m_Target.AddWeapon(); EditorUtility.SetDirty(m_Target); return; } } EditorGUI.BeginChangeCheck(); if (GUILayout.Button("-", Styling.rightButton, GUILayout.Width(24))) { if (EditorGUI.EndChangeCheck()) { Undo.RecordObject(m_Target, "Undo Inspector"); m_Target.RemoveWeapon(index); EditorUtility.SetDirty(m_Target); } } } }
override protected void Start() { base.Start(); controller = GetComponent <PlayerController>(); weaponManager = GetComponent <WeaponManager>(); swipeControl = GetComponent <SwipeDetector>(); anim = GetComponentInChildren <Animator>(); viewCamera = Camera.main; spawnRect.SetOwner(transform); anim.SetInteger("weaponNum", weaponManager.EquipWeapon(weaponManager.startingWeaponIndex).weaponNum); }
void SelectedWeapon() { int i = 0; foreach (PlayerWeapon playerWeapon in playerWeapons) { if (i == selectedWeapon) { weaponManager.EquipWeapon(playerWeapon); } i++; } }
public void Equip(Equipment newItem) { int slotIndex = (int)newItem.equipmentSlot; Equipment oldItem = null; if (currentEquipment[slotIndex] != null) { oldItem = currentEquipment[slotIndex]; inventory.Add(oldItem); } if (onEquipmentChangedCallback != null) { onEquipmentChangedCallback.Invoke(newItem, oldItem, newItem.equipmentSlot); } currentEquipment[slotIndex] = newItem; if (newItem.equipmentSlot == EquipmentSlot.Primary) { weaponManager.EquipWeapon(newItem.name); } }
public void EquipWeapon(ItemClass item) { // Equip item passed weaponManager.EquipWeapon(item); }
void Start() { wm.LoadWeapons(); wm.EquipWeapon(0); }