架构重新设计
基本重做了所有物体和次级模块代码
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using Ichni.RhythmGame.Beatmap;
|
||||
using Lean.Pool;
|
||||
using UnityEngine;
|
||||
using UnityEngine.Serialization;
|
||||
@@ -13,41 +14,35 @@ namespace Ichni.RhythmGame
|
||||
public partial class LookAt : AnimationBase
|
||||
{
|
||||
public TransformSubmodule targetTransformSubmodule;
|
||||
public BaseElement lookAtObject;
|
||||
public GameElement lookAtObject;
|
||||
public FlexibleBool enabling;
|
||||
|
||||
public static LookAt GenerateElement(string elementName, Guid id,
|
||||
List<string> tags, BaseElement targetObject,
|
||||
BaseElement lookAtTarget, FlexibleBool enabling)
|
||||
List<string> tags, bool isFirstGenerated, GameElement animatedObject,
|
||||
GameElement lookAtTarget, FlexibleBool enabling)
|
||||
{
|
||||
LookAt look = Instantiate(EditorManager.instance.basePrefabs.emptyObject).AddComponent<LookAt>();
|
||||
|
||||
look.Initialize(elementName, id, tags);
|
||||
look.Initialize(elementName, id, tags, isFirstGenerated);
|
||||
|
||||
look.targetObject = targetObject;
|
||||
look.animatedObject = animatedObject;
|
||||
look.lookAtObject = lookAtTarget;
|
||||
look.enabling = enabling;
|
||||
look.animationReturnType = FlexibleReturnType.Before;
|
||||
|
||||
if (targetObject.transformSubmodule != null)
|
||||
{
|
||||
look.targetTransformSubmodule = targetObject.transformSubmodule;
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new System.Exception("Target object does not have a TransformSubmodule");
|
||||
}
|
||||
look.targetTransformSubmodule = (animatedObject as IHaveTransformSubmodule).transformSubmodule;
|
||||
|
||||
look.SetParent(targetObject);
|
||||
look.SetParent(animatedObject);
|
||||
|
||||
look.timeDurationSubmodule.SetDuration(-999f, 999f); //TODO: 换为(-delay, songLength)
|
||||
//look.timeDurationSubmodule.SetDuration(-999f, 999f); //TODO: 换为(-delay, songLength)
|
||||
|
||||
return look;
|
||||
}
|
||||
|
||||
private void Start()
|
||||
|
||||
protected override void SetDefaultSubmodules()
|
||||
{
|
||||
targetTransformSubmodule = targetObject.transformSubmodule;
|
||||
timeDurationSubmodule = new TimeDurationSubmodule(this);
|
||||
submoduleList.Add(timeDurationSubmodule);
|
||||
}
|
||||
|
||||
protected override void UpdateAnimation(float songTime)
|
||||
@@ -57,7 +52,7 @@ namespace Ichni.RhythmGame
|
||||
{
|
||||
animationReturnType = FlexibleReturnType.MiddleExecuting;
|
||||
Vector3 lookingDirection =
|
||||
(lookAtObject.transform.position - targetObject.transform.position).normalized;
|
||||
(lookAtObject.transform.position - animatedObject.transform.position).normalized;
|
||||
|
||||
Vector3 eulerAnglesOffset = Quaternion.LookRotation(lookingDirection).eulerAngles;
|
||||
|
||||
@@ -74,14 +69,14 @@ namespace Ichni.RhythmGame
|
||||
|
||||
public override void SaveBM()
|
||||
{
|
||||
matchedBM = new Beatmap.LookAt_BM(elementName, elementGuid, tags, parentElement.matchedBM,
|
||||
matchedBM = new LookAt_BM(elementName, elementGuid, tags, parentElement.matchedBM as GameElement_BM,
|
||||
enabling.ConvertToBM(), lookAtObject.elementGuid);
|
||||
}
|
||||
}
|
||||
|
||||
namespace Beatmap
|
||||
{
|
||||
public class LookAt_BM : BaseElement_BM
|
||||
public class LookAt_BM : GameElement_BM
|
||||
{
|
||||
public FlexibleBool_BM enabling;
|
||||
public Guid lookAtObjectGuid;
|
||||
@@ -91,8 +86,8 @@ namespace Ichni.RhythmGame
|
||||
}
|
||||
|
||||
public LookAt_BM(string elementName, Guid elementGuid, List<string> tags,
|
||||
BaseElement_BM attachedElement, FlexibleBool_BM enabling, Guid lookAtObjectGuid) : base(elementName,
|
||||
elementGuid, tags, attachedElement)
|
||||
GameElement_BM attachedElement, FlexibleBool_BM enabling, Guid lookAtObjectGuid)
|
||||
: base(elementName, elementGuid, tags, attachedElement)
|
||||
{
|
||||
this.enabling = enabling;
|
||||
this.lookAtObjectGuid = lookAtObjectGuid;
|
||||
@@ -100,13 +95,13 @@ namespace Ichni.RhythmGame
|
||||
|
||||
public override void ExecuteBM()
|
||||
{
|
||||
matchedElement = LookAt.GenerateElement(elementName, elementGuid, tags,
|
||||
matchedElement = LookAt.GenerateElement(elementName, elementGuid, tags, false,
|
||||
GetElement(attachedElementGuid), GetElement(lookAtObjectGuid), enabling.ConvertToGameType());
|
||||
}
|
||||
|
||||
public override BaseElement DuplicateBM(BaseElement parent)
|
||||
public override GameElement DuplicateBM(GameElement parent)
|
||||
{
|
||||
return LookAt.GenerateElement(elementName, elementGuid, tags, parent,
|
||||
return LookAt.GenerateElement(elementName, elementGuid, tags, false, parent,
|
||||
GetElement(lookAtObjectGuid), enabling.ConvertToGameType());
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user