切换主武器
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
using Cielonos.MainGame.Inventory;
|
||||
using Cielonos.MainGame.Inventory;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Cielonos.MainGame.Characters
|
||||
@@ -8,15 +8,14 @@ namespace Cielonos.MainGame.Characters
|
||||
public Player player => owner;
|
||||
private PlayerInputSubcontroller inputSc => player.inputSc;
|
||||
private PlayerOperationSubcontroller operationSc => player.operationSc;
|
||||
public MainWeaponBase testMainWeapon;
|
||||
public PlayerBackpack backpack;
|
||||
public PlayerEquipmentSubmodule equipmentSm;
|
||||
|
||||
public override void Initialize()
|
||||
{
|
||||
base.Initialize();
|
||||
RegisterOperations();
|
||||
equipmentSm = new PlayerEquipmentSubmodule(this);
|
||||
equipmentSm.EquipMainWeapon(testMainWeapon);
|
||||
equipmentSm ??= new PlayerEquipmentSubmodule(this);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -38,6 +37,8 @@ namespace Cielonos.MainGame.Characters
|
||||
operationSc.OnMainWeaponQuaternaryPress += MainWeaponSpecialBPress;
|
||||
operationSc.OnMainWeaponQuaternaryRelease += MainWeaponSpecialBRelease;
|
||||
|
||||
operationSc.OnSwitchMainWeapon += SwitchMainWeapon;
|
||||
|
||||
/*
|
||||
operationSc.OnSwitchMainWeapon += delegate(float dir) { SwitchMainWeapon(dir > 0 ? 1 : -1); };
|
||||
operationSc.OnUseSupportEquipment0Press += delegate { SupportEquipmentPress(0); };
|
||||
@@ -73,6 +74,15 @@ namespace Cielonos.MainGame.Characters
|
||||
|
||||
public partial class PlayerInventorySubcontroller
|
||||
{
|
||||
private void SwitchMainWeapon(int direction)
|
||||
{
|
||||
int currentIndex = equipmentSm.preparedMainWeapons.IndexOf(currentMainWeapon);
|
||||
equipmentSm.RemoveMainWeapon();
|
||||
int newIndex = (currentIndex + direction + equipmentSm.preparedMainWeapons.Count) % equipmentSm.preparedMainWeapons.Count;
|
||||
Debug.Log($"Switching main weapon from index {currentIndex} to {newIndex}");
|
||||
equipmentSm.EquipMainWeapon(equipmentSm.preparedMainWeapons[newIndex]);
|
||||
}
|
||||
|
||||
public void MainWeaponPrimaryPress()
|
||||
{
|
||||
if (currentMainWeapon != null)
|
||||
|
||||
Reference in New Issue
Block a user