切换主武器
This commit is contained in:
@@ -15,14 +15,14 @@ namespace Cielonos.MainGame.Inventory
|
||||
public Player player => MainGameManager.Instance.player;
|
||||
protected PlayerAnimationSubcontroller animationSc => player.animationSc;
|
||||
protected FunctionalAnimationSubmodule fullBodyFuncAnimSm => animationSc.fullBodyFuncAnimSm;
|
||||
|
||||
public ItemViewObject viewObject;
|
||||
|
||||
[Title("Data")]
|
||||
public List<FuncAnimData> fullBodyFuncAnims = new List<FuncAnimData>();
|
||||
[HideInInspector]
|
||||
private List<string> registeredFunctionNames = new List<string>();
|
||||
|
||||
[FormerlySerializedAs("objectData")]
|
||||
public ViewObjectData viewObjectData;
|
||||
public VFXData vfxData;
|
||||
public ComboData comboData;
|
||||
public AttackData attackData;
|
||||
@@ -41,10 +41,12 @@ namespace Cielonos.MainGame.Inventory
|
||||
[Title("Subcontrollers")]
|
||||
public FeedbackSubcontroller feedbackSc;
|
||||
|
||||
|
||||
[Title("View Objects")]
|
||||
public Dictionary<string, ItemViewObject> viewObjects = new Dictionary<string, ItemViewObject>();
|
||||
|
||||
protected virtual void Update()
|
||||
{
|
||||
functionSm.Update(player.selfTimeSm.DeltaTime);
|
||||
functionSm?.Update(player.selfTimeSm.DeltaTime);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -7,7 +7,6 @@ namespace Cielonos.MainGame.Inventory
|
||||
{
|
||||
public partial class ItemViewObject : SerializedMonoBehaviour
|
||||
{
|
||||
public GameObject item;
|
||||
public Dictionary<string, GameObject> functionalParts;
|
||||
|
||||
public GameObject Part(string partName)
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
using System.Collections.Generic;
|
||||
using Cielonos.MainGame.Characters;
|
||||
using MoreMountains.Feedbacks;
|
||||
using MoreMountains.FeedbacksForThirdParty;
|
||||
@@ -7,7 +8,6 @@ namespace Cielonos.MainGame.Inventory
|
||||
{
|
||||
public abstract partial class MainWeaponBase : ItemBase
|
||||
{
|
||||
|
||||
public BaseAnimationGroup baseAnimationGroup;
|
||||
}
|
||||
|
||||
@@ -16,17 +16,45 @@ namespace Cielonos.MainGame.Inventory
|
||||
public virtual void OnEquipped()
|
||||
{
|
||||
baseAnimationGroup.SetUp(animationSc);
|
||||
foreach (ViewObjectData.ViewObjectDataUnit unit in viewObjectData.viewObjectUnits)
|
||||
{
|
||||
Transform attachPoint = !unit.isCustomAttachPoint ?
|
||||
player.bodyPartsSc.GetPart(unit.normalAttachBodyPart) :
|
||||
player.bodyPartsSc.GetPart(unit.customAttachPartName);
|
||||
if (attachPoint != null)
|
||||
{
|
||||
ItemViewObject view = Instantiate(unit.objectPrefab, attachPoint).GetComponent<ItemViewObject>();
|
||||
if (unit.applyOffset)
|
||||
{
|
||||
view.transform.localPosition = unit.positionOffset;
|
||||
view.transform.localEulerAngles = unit.rotationOffset;
|
||||
}
|
||||
viewObjects[unit.objectName] = view;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public virtual void OnUnequipped()
|
||||
{
|
||||
RemoveAllRegisteredFunctions();
|
||||
|
||||
foreach (ItemViewObject view in viewObjects.Values)
|
||||
{
|
||||
Destroy(view.gameObject);
|
||||
}
|
||||
viewObjects.Clear();
|
||||
}
|
||||
}
|
||||
|
||||
public partial class MainWeaponBase
|
||||
{
|
||||
protected Transform muzzle => viewObject.functionalParts["Muzzle"].transform;
|
||||
protected override void Update()
|
||||
{
|
||||
if (player.inventorySc.equipmentSm.currentMainWeapon == this)
|
||||
{
|
||||
functionSm?.Update(player.selfTimeSm.DeltaTime);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public partial class MainWeaponBase
|
||||
|
||||
16
Assets/Scripts/MainGame/Items/Data/ContentData.cs
Normal file
16
Assets/Scripts/MainGame/Items/Data/ContentData.cs
Normal file
@@ -0,0 +1,16 @@
|
||||
using UnityEngine;
|
||||
|
||||
public class ContentData : MonoBehaviour
|
||||
{
|
||||
// Start is called once before the first execution of Update after the MonoBehaviour is created
|
||||
void Start()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
void Update()
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
2
Assets/Scripts/MainGame/Items/Data/ContentData.cs.meta
Normal file
2
Assets/Scripts/MainGame/Items/Data/ContentData.cs.meta
Normal file
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: fd6893a98c17a0e47af8bd555a67190b
|
||||
@@ -8,11 +8,11 @@ using UnityEngine;
|
||||
namespace Cielonos.MainGame.Inventory
|
||||
{
|
||||
[CreateAssetMenu(fileName = "FunctionData", menuName = "Cielonos/Items/FunctionData")]
|
||||
public class FunctionData : SerializedScriptableObject
|
||||
public partial class FunctionData : SerializedScriptableObject
|
||||
{
|
||||
[DictionaryDrawerSettings(KeyLabel = "Attack Unit", DisplayMode = DictionaryDisplayOptions.ExpandedFoldout)]
|
||||
[Searchable]
|
||||
public Dictionary<string, ItemFunctionUnit> functionUnits;
|
||||
public Dictionary<string, FunctionUnit> functionUnits = new Dictionary<string, FunctionUnit>();
|
||||
|
||||
[OnInspectorGUI("UpdateUnits")]
|
||||
public void UpdateUnits()
|
||||
@@ -23,9 +23,8 @@ namespace Cielonos.MainGame.Inventory
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
[Serializable]
|
||||
public class ItemFunctionUnit
|
||||
|
||||
public partial class FunctionData
|
||||
{
|
||||
public enum IntervalReductionType
|
||||
{
|
||||
@@ -34,26 +33,30 @@ namespace Cielonos.MainGame.Inventory
|
||||
AttackSpeed = 10
|
||||
}
|
||||
|
||||
[ReadOnly]
|
||||
public FunctionData parentData;
|
||||
[Serializable]
|
||||
public class FunctionUnit
|
||||
{
|
||||
[ReadOnly]
|
||||
public FunctionData parentData;
|
||||
|
||||
[TitleGroup("Information")]
|
||||
public bool shownInUI;
|
||||
[TitleGroup("Information")]
|
||||
public Sprite icon;
|
||||
[TitleGroup("Information")]
|
||||
public List<string> operation;
|
||||
[TitleGroup("Information")]
|
||||
public bool shownInUI;
|
||||
[TitleGroup("Information")]
|
||||
public Sprite icon;
|
||||
[TitleGroup("Information")]
|
||||
public List<string> operation;
|
||||
|
||||
[TitleGroup("Costs")]
|
||||
public float energyCost;
|
||||
[TitleGroup("Costs")]
|
||||
public int ammoCost;
|
||||
[TitleGroup("Costs")]
|
||||
public float energyCost;
|
||||
[TitleGroup("Costs")]
|
||||
public int ammoCost;
|
||||
|
||||
[TitleGroup("Interval")]
|
||||
public float interval;
|
||||
[TitleGroup("Interval")]
|
||||
public float intervalLowerLimit;
|
||||
[TitleGroup("Interval")]
|
||||
public IntervalReductionType intervalReductionType;
|
||||
[TitleGroup("Interval")]
|
||||
public float interval;
|
||||
[TitleGroup("Interval")]
|
||||
public float intervalLowerLimit;
|
||||
[TitleGroup("Interval")]
|
||||
public IntervalReductionType intervalReductionType;
|
||||
}
|
||||
}
|
||||
}
|
||||
48
Assets/Scripts/MainGame/Items/Data/ViewObjectData.cs
Normal file
48
Assets/Scripts/MainGame/Items/Data/ViewObjectData.cs
Normal file
@@ -0,0 +1,48 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Sirenix.OdinInspector;
|
||||
using UnityEngine;
|
||||
using UnityEngine.Serialization;
|
||||
|
||||
namespace Cielonos.MainGame.Inventory
|
||||
{
|
||||
[CreateAssetMenu(fileName = "ViewObjectData", menuName = "Cielonos/Items/ViewObjectData")]
|
||||
public partial class ViewObjectData : SerializedScriptableObject
|
||||
{
|
||||
[ListDrawerSettings(ShowFoldout = true)]
|
||||
public List<ViewObjectDataUnit> viewObjectUnits = new List<ViewObjectDataUnit>();
|
||||
}
|
||||
|
||||
public partial class ViewObjectData
|
||||
{
|
||||
public enum AttachBodyPartType
|
||||
{
|
||||
RightHand,
|
||||
LeftHand,
|
||||
Head,
|
||||
FlexibleCenterPoint,
|
||||
Back,
|
||||
Hips,
|
||||
RightFoot,
|
||||
LeftFoot,
|
||||
}
|
||||
|
||||
[Serializable]
|
||||
public class ViewObjectDataUnit
|
||||
{
|
||||
public string objectName;
|
||||
public GameObject objectPrefab;
|
||||
public bool isCustomAttachPoint;
|
||||
[HideIf("isCustomAttachPoint")]
|
||||
public AttachBodyPartType normalAttachBodyPart;
|
||||
[ShowIf("isCustomAttachPoint")]
|
||||
public string customAttachPartName;
|
||||
|
||||
public bool applyOffset;
|
||||
[ShowIf("applyOffset")]
|
||||
public Vector3 positionOffset;
|
||||
[ShowIf("applyOffset")]
|
||||
public Vector3 rotationOffset;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 1bfbd542596c9aa4887562352b6768c7
|
||||
@@ -23,6 +23,10 @@ namespace Cielonos.MainGame.Inventory
|
||||
{
|
||||
PlayTargetedAnimation("LightAttack" + comboSm.GetCurrentNodeName(), currentTarget, 5f);
|
||||
}
|
||||
else
|
||||
{
|
||||
PlayTargetedAnimation("LightAttack" + comboSm.GetCurrentNodeName(), null, 5f);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -37,6 +41,10 @@ namespace Cielonos.MainGame.Inventory
|
||||
{
|
||||
PlayTargetedAnimation("HeavyAttack", currentTarget, 3f);
|
||||
}
|
||||
else
|
||||
{
|
||||
PlayTargetedAnimation("HeavyAttack", null, 3f);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -50,6 +58,11 @@ namespace Cielonos.MainGame.Inventory
|
||||
private void LightAttack3() => GenerateProjectile("HeavyProjectile", currentTarget, 10f);
|
||||
private void HeavyAttack() => GenerateGroundArea("GroundArea");
|
||||
}
|
||||
|
||||
public partial class FutureWand : MainWeaponBase
|
||||
{
|
||||
private Transform muzzle => viewObjects["Wand"].functionalParts["Muzzle"].transform;
|
||||
}
|
||||
|
||||
public partial class FutureWand
|
||||
{
|
||||
|
||||
@@ -12,12 +12,16 @@ namespace Cielonos.MainGame.Inventory
|
||||
|
||||
protected override void Update()
|
||||
{
|
||||
base.Update();
|
||||
perfectBlockedTimer -= player.selfTimeSm.DeltaTime;
|
||||
if (player.inventorySc.equipmentSm.currentMainWeapon == this)
|
||||
{
|
||||
functionSm?.Update(player.selfTimeSm.DeltaTime);
|
||||
perfectBlockedTimer -= player.selfTimeSm.DeltaTime;
|
||||
}
|
||||
}
|
||||
|
||||
public override void OnEquipped()
|
||||
{
|
||||
base.OnEquipped();
|
||||
RegisterFunctionsToAnimSc(
|
||||
LightAttack0, LightAttack1, LightAttack2, LightAttack3,
|
||||
TripleAttack_0, TripleAttack_1, TripleAttack_2,
|
||||
|
||||
@@ -36,11 +36,11 @@ namespace Cielonos.MainGame.Inventory
|
||||
{
|
||||
private CharacterBase character => owner.owner.player;
|
||||
|
||||
public ItemFunctionUnit data;
|
||||
public FunctionData.FunctionUnit data;
|
||||
public float currentCooldown;
|
||||
public float maxCooldown;
|
||||
|
||||
public RuntimeFunctionUnit(FunctionSubmodule owner, ItemFunctionUnit data) : base(owner)
|
||||
public RuntimeFunctionUnit(FunctionSubmodule owner, FunctionData.FunctionUnit data) : base(owner)
|
||||
{
|
||||
this.data = data;
|
||||
maxCooldown = data.interval;
|
||||
|
||||
Reference in New Issue
Block a user