特效范例

This commit is contained in:
SoulliesOfficial
2025-02-19 09:15:51 -05:00
parent b36f0469d0
commit 5349cde381
26 changed files with 531 additions and 216 deletions

View File

@@ -4,6 +4,7 @@ using Ichni.Editor;
using Ichni.RhythmGame.Beatmap;
using Sirenix.Utilities;
using UnityEngine;
using UnityEngine.Events;
namespace Ichni.RhythmGame
{
@@ -83,6 +84,12 @@ namespace Ichni.RhythmGame
public interface IHaveEffectSubmodule
{
public EffectSubmodule effectSubmodule { get; set; }
public static Dictionary<string, EffectBase> EffectCollection { get; } =
new Dictionary<string, EffectBase>()
{
{"BloomShake", new BloomShake(1, 2)}
};
}
namespace Beatmap

View File

@@ -17,6 +17,7 @@ namespace Ichni.RhythmGame
isOverridingDuration = false;
startTime = -32767;//TODO: 换为-delay
endTime = 32767;//TODO: 换为songLength
}
public TimeDurationSubmodule(GameElement attachedGameElement, bool isOverridingDuration, float startTime, float endTime) : base(attachedGameElement)

View File

@@ -29,8 +29,7 @@ namespace Ichni.RhythmGame
public bool scaleDirtyMark;
public bool eulerAnglesOffsetLock;
public TransformSubmodule(GameElement attachedGameElement) : base(attachedGameElement)
{
this.originalPosition = Vector3.zero;
@@ -51,7 +50,8 @@ namespace Ichni.RhythmGame
eulerAnglesOffsetLock = false;
// (attachedGameElement as IHaveTransformSubmodule).SetTransformObserver();
(attachedGameElement as IHaveTransformSubmodule).transformSubmodule = this;
(attachedGameElement as IHaveTransformSubmodule).SetTransformObserver();
}
public TransformSubmodule(GameElement attachedGameElement,
@@ -75,7 +75,8 @@ namespace Ichni.RhythmGame
eulerAnglesOffsetLock = false;
// (attachedGameElement as IHaveTransformSubmodule).SetTransformObserver();
(attachedGameElement as IHaveTransformSubmodule).transformSubmodule = this;
(attachedGameElement as IHaveTransformSubmodule).SetTransformObserver();
}
public override void SaveBM()
@@ -98,6 +99,10 @@ namespace Ichni.RhythmGame
inspector.GenerateParameterText(this, container, "Current Rotation", nameof(currentEulerAngles), true);
var currentScaleText =
inspector.GenerateParameterText(this, container, "Current Scale", nameof(currentScale), true);
originalPosInputField.AddListenerFunction(Refresh);
originalRotInputField.AddListenerFunction(Refresh);
originalScaleInputField.AddListenerFunction(Refresh);
}
public override void Refresh()
@@ -119,7 +124,7 @@ namespace Ichni.RhythmGame
public void SetTransformObserver()
{
GameElement attachedGameElement = transformSubmodule.attachedGameElement;
Observable.EveryUpdate().Subscribe(_ =>
{
if (transformSubmodule == null)
@@ -197,6 +202,7 @@ namespace Ichni.RhythmGame
public override void ExecuteBM()
{
attachedElement = GameElement_BM.GetElement(attachedElementGuid);
Debug.Log(attachedElementGuid);
(attachedElement as IHaveTransformSubmodule).transformSubmodule = new TransformSubmodule(attachedElement, originalPosition, originalEulerAngles, originalScale);
attachedElement.submoduleList.Add((attachedElement as IHaveTransformSubmodule).transformSubmodule);
}

View File

@@ -73,6 +73,9 @@ namespace Ichni.RhythmGame
var swirlButton = inspector.GenerateButton(this, container, "Swirl",
() => Swirl.GenerateElement("New Swirl", Guid.NewGuid(), new List<string>(), true, this,
new FlexibleFloat(), new FlexibleFloat(), new FlexibleFloat()));
var timeEffectsCollectionButton = inspector.GenerateButton(this, container, "Time Effects Collection",
() => TimeEffectsCollection.GenerateElement("New Time Effects Collection", Guid.NewGuid(),
new List<string>(), true, this, 0f));
}
}

View File

@@ -2,10 +2,12 @@ using System;
using System.Collections;
using System.Collections.Generic;
using Dreamteck.Splines;
using Ichni.Editor;
using Ichni.RhythmGame.Beatmap;
using Lean.Pool;
using UniRx;
using UnityEngine;
using UnityEngine.Rendering.Universal;
using UnityEngine.Serialization;
namespace Ichni.RhythmGame
@@ -23,15 +25,28 @@ namespace Ichni.RhythmGame
public TransformSubmodule transformSubmodule { get; set; }
public TimeDurationSubmodule timeDurationSubmodule { get; set; }
private static CameraManager cameraManager => EditorManager.instance.cameraManager;
public static GameCamera GenerateElement(string elementName, Guid id,
List<string> tags, bool isFirstGenerated, GameElement parentElement,
CameraViewType cameraViewType, float perspectiveAngle, float orthographicSize)
{
if (EditorManager.instance.cameraManager.haveGameCamera)
{
LogWindow.Log("Only one GameCamera can be created", Color.red);
return null;
}
GameCamera gameCamera =
Instantiate(EditorManager.instance.basePrefabs.gameCamera).GetComponent<GameCamera>();
gameCamera.Initialize(elementName, id, tags, isFirstGenerated, parentElement);
cameraManager.gameCamera = gameCamera;
cameraManager.backgroundCamera.GetComponent<UniversalAdditionalCameraData>().cameraStack.Add(gameCamera.camera);
if (cameraManager.isSceneCameraActive) gameCamera.camera.enabled = false;
gameCamera.parentElement = parentElement;
gameCamera.cameraViewType = cameraViewType;
gameCamera.camera.orthographic = cameraViewType == CameraViewType.Orthographic;
@@ -132,7 +147,7 @@ namespace Ichni.RhythmGame
public override void ExecuteBM()
{
GameCamera.GenerateElement(elementName, elementGuid, tags, false,
matchedElement = GameCamera.GenerateElement(elementName, elementGuid, tags, false,
GetElement(attachedElementGuid), cameraViewType, perspectiveAngle, orthographicSize);
}

View File

@@ -57,6 +57,7 @@ namespace Ichni.RhythmGame
if (isFirstGenerated) SetDefaultSubmodules();
SetParent(parentElement);
EditorManager.instance.uiManager.hierarchy.GenerateTab(this, parentElement);
//GameManager.beatMapContainer.beatMapElementList.Add(this);
//serialNumber = totalSerialNumber++;
//SetTransformObserver();

View File

@@ -14,8 +14,14 @@ namespace Ichni.RhythmGame
{
public float bloomTime;
public float bloomPeak;
[Button("Test Bloom Shake")]
public BloomShake(float bloomTime, float bloomPeak)
{
this.effectTime = 0;
this.bloomTime = bloomTime;
this.bloomPeak = bloomPeak;
}
public override void Adjust()
{
MMF_Player effect = LeanPool.Spawn(EditorManager.instance.basePrefabs.bloomShake).GetComponent<MMF_Player>();
@@ -27,12 +33,40 @@ namespace Ichni.RhythmGame
public override EffectBase_BM ConvertToBM()
{
throw new NotImplementedException();
return new BloomShake_BM(bloomTime, bloomPeak);
}
public override void SetUpInspector()
{
throw new NotImplementedException();
var container = inspector.GenerateContainer("Bloom Shake");
var effectTimeField = inspector.GenerateInputField(this, container, "Bloom Time", nameof(bloomTime));
var bloomPeakField = inspector.GenerateInputField(this, container, "Bloom Peak", nameof(bloomPeak));
}
}
namespace Beatmap
{
public class BloomShake_BM : EffectBase_BM
{
public float bloomTime;
public float bloomPeak;
public BloomShake_BM()
{
}
public BloomShake_BM(float bloomTime, float bloomPeak)
{
this.effectTime = 0;
this.bloomTime = bloomTime;
this.bloomPeak = bloomPeak;
}
public override EffectBase ConvertToGameType()
{
return new BloomShake(bloomTime, bloomPeak);
}
}
}
}

View File

@@ -1,6 +1,7 @@
using System;
using System.Collections;
using System.Collections.Generic;
using Ichni.RhythmGame.Beatmap;
using Sirenix.OdinInspector;
using UnityEngine;
@@ -11,10 +12,12 @@ namespace Ichni.RhythmGame
public EffectSubmodule effectSubmodule { get; set; }
public float time;
public static TimeEffectsCollection CreateTimeEffectsCollection(float time)
public static TimeEffectsCollection GenerateElement(string name, Guid guid, List<string> tags,
bool isFirstGenerated, GameElement parentElement, float time)
{
TimeEffectsCollection timeEffectsCollection = Instantiate(EditorManager.instance.basePrefabs.emptyObject)
.AddComponent<TimeEffectsCollection>();
timeEffectsCollection.Initialize(name, guid, tags, isFirstGenerated, parentElement);
timeEffectsCollection.time = time;
return timeEffectsCollection;
}
@@ -34,18 +37,53 @@ namespace Ichni.RhythmGame
{
public override void SaveBM()
{
matchedBM = new TimeEffectsCollection_BM(this);
}
public override void SetUpInspector()
{
var container = inspector.GenerateContainer("Time Effects Collection");
var timeInputField = inspector.GenerateInputField(this, container, "Time", nameof(time));
var addEffectButton = inspector.GenerateButton(this, container, "Add Effect", () =>
{
IHaveEffectSubmodule.EffectCollection.TryGetValue("BloomShake", out var effect);
effectSubmodule.effectCollection["Default"].Add(effect);
});
foreach (var effect in effectSubmodule.effectCollection["Default"])
{
effect.SetUpInspector();
}
}
}
namespace Beatmap
{
public class TimeEffectsCollection_BM : GameElement_BM
{
public float time;
public TimeEffectsCollection_BM()
{
}
public TimeEffectsCollection_BM(TimeEffectsCollection timeEffectsCollection)
{
time = timeEffectsCollection.time;
}
public override void ExecuteBM()
{
matchedElement = TimeEffectsCollection.GenerateElement("Time Effects Collection", elementGuid,
tags, false, GetElement(attachedElementGuid), time);
}
public override GameElement DuplicateBM(GameElement attached)
{
return TimeEffectsCollection.GenerateElement("Time Effects Collection", elementGuid,
tags, false, attached, time);
}
}
}
}

View File

@@ -63,6 +63,21 @@ namespace Ichni.RhythmGame
trackPositioner.SetPercent(trackPercent.value);
}
private void PasteTrackList()
{
List<Track> trackList = (parentElement as ElementFolder).trackList;
trackSwitch = new FlexibleInt();
trackPercent = new FlexibleFloat();
foreach (Track track in trackList)
{
TrackTimeSubmoduleMovable trackTimeSubmodule = track.trackTimeSubmodule as TrackTimeSubmoduleMovable;
trackSwitch.animations.Add(new AnimatedInt(trackTimeSubmodule.trackStartTime,
trackList.IndexOf(track)));
trackPercent.animations.Add(new AnimatedFloat(trackTimeSubmodule.trackStartTime,
trackTimeSubmodule.trackEndTime, 0, 1, trackTimeSubmodule.animationCurveType));
}
}
}
public partial class CrossTrackPoint
@@ -72,6 +87,28 @@ namespace Ichni.RhythmGame
matchedBM = new CrossTrackPoint_BM(elementName, elementGuid, tags,
parentElement.matchedBM as GameElement_BM, trackSwitch, trackPercent);
}
public override void SetUpInspector()
{
base.SetUpInspector();
var container = inspector.GenerateContainer("Cross Track Point");
var trackSwitchButton = inspector.GenerateButton(this, container, "Track Switch",
() =>
{
inspector.GenerateCompositeParameterWindow(this, "Track Switch", nameof(trackSwitch)).SetAsFlexibleInt();
});
var trackPercentButton = inspector.GenerateButton(this, container, "Track Percent",
() =>
{
inspector.GenerateCompositeParameterWindow(this, "Track Percent", nameof(trackPercent)).SetAsFlexibleFloat();
});
var pasteTrackListButton = inspector.GenerateButton(this, container, "Paste Track List", PasteTrackList);
var generateContainer = inspector.GenerateContainer("Generate");
var generateCameraButton = inspector.GenerateButton(this, generateContainer, "Game Camera",
() => GameCamera.GenerateElement("New Game Camera", Guid.NewGuid(), new List<string>(),
true, this, GameCamera.CameraViewType.Perspective, 60, 10));
}
}
namespace Beatmap