@@ -0,0 +1,179 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using Ichni.Editor;
|
||||
using Ichni.RhythmGame;
|
||||
using Ichni.RhythmGame.Beatmap;
|
||||
using UnityEngine;
|
||||
namespace Ichni.RhythmGame
|
||||
{
|
||||
public class TrackGlobalColorChange : AnimationBase
|
||||
{
|
||||
|
||||
|
||||
public FlexibleFloat colorR, colorG, colorB, colorA;
|
||||
public static TrackGlobalColorChange GenerateElement(string elementName, System.Guid id,
|
||||
List<string> tags, bool isFirstGenerated, GameElement animatedObject,
|
||||
FlexibleFloat colorR, FlexibleFloat colorG, FlexibleFloat colorB, FlexibleFloat colorA)
|
||||
{
|
||||
if (animatedObject is not Track)
|
||||
{
|
||||
Debug.LogError("Animated Object is Not Track");
|
||||
throw new System.ArgumentException("Animated Object is Not Track");
|
||||
}
|
||||
TrackGlobalColorChange trackGlobalColorChange = Instantiate(EditorManager.instance.basePrefabs.emptyObject)
|
||||
.AddComponent<TrackGlobalColorChange>();
|
||||
|
||||
trackGlobalColorChange.Initialize(elementName, id, tags, isFirstGenerated, animatedObject);
|
||||
trackGlobalColorChange.animatedObject = animatedObject;
|
||||
|
||||
trackGlobalColorChange.colorR = colorR;
|
||||
trackGlobalColorChange.colorG = colorG;
|
||||
trackGlobalColorChange.colorB = colorB;
|
||||
trackGlobalColorChange.colorA = colorA;
|
||||
trackGlobalColorChange.animationReturnType = FlexibleReturnType.Before;
|
||||
|
||||
//trackGlobalColorChange.timeDurationSubmodule.SetDuration(colorR, colorG, colorB, colorA);
|
||||
|
||||
return trackGlobalColorChange;
|
||||
}
|
||||
public override void SetDefaultSubmodules()
|
||||
{
|
||||
timeDurationSubmodule = new TimeDurationSubmodule(this);
|
||||
}
|
||||
protected override void UpdateAnimation(float songTime)
|
||||
{
|
||||
colorR.UpdateFlexibleFloat(songTime);
|
||||
colorG.UpdateFlexibleFloat(songTime);
|
||||
colorB.UpdateFlexibleFloat(songTime);
|
||||
colorA.UpdateFlexibleFloat(songTime);
|
||||
|
||||
if (colorR.returnType is FlexibleReturnType.MiddleExecuting ||
|
||||
colorG.returnType is FlexibleReturnType.MiddleExecuting ||
|
||||
colorB.returnType is FlexibleReturnType.MiddleExecuting ||
|
||||
colorA.returnType is FlexibleReturnType.MiddleExecuting)
|
||||
{
|
||||
animationReturnType = FlexibleReturnType.MiddleExecuting;
|
||||
Color color = new Color(colorR.value, colorG.value, colorB.value, colorA.value);
|
||||
((Track)animatedObject).trackRendererSubmodule.meshGenerator.color = color;
|
||||
}
|
||||
else if (colorR.isSwitchingReturnType || colorG.isSwitchingReturnType || colorB.isSwitchingReturnType || colorA.isSwitchingReturnType)
|
||||
{
|
||||
animationReturnType = FlexibleReturnType.MiddleExecuting;
|
||||
Color color = new Color(colorR.value, colorG.value, colorB.value, colorA.value);
|
||||
((Track)animatedObject).trackRendererSubmodule.meshGenerator.color = color;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!EditorManager.instance.musicPlayer.isPlaying && animationReturnType != FlexibleReturnType.MiddleInterval)
|
||||
{
|
||||
Color color = new Color(colorR.value, colorG.value, colorB.value, colorA.value);
|
||||
((Track)animatedObject).trackRendererSubmodule.meshGenerator.color = color;
|
||||
animationReturnType = FlexibleReturnType.After;
|
||||
}
|
||||
else
|
||||
{
|
||||
animationReturnType = FlexibleReturnType.Before;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
public override void ApplyTimeOffset(float offset)
|
||||
{
|
||||
base.ApplyTimeOffset(offset);
|
||||
foreach (var item in colorR.animations) item.ApplyTimeOffset(offset);
|
||||
foreach (var item in colorG.animations) item.ApplyTimeOffset(offset);
|
||||
foreach (var item in colorB.animations) item.ApplyTimeOffset(offset);
|
||||
foreach (var item in colorA.animations) item.ApplyTimeOffset(offset);
|
||||
|
||||
}
|
||||
|
||||
|
||||
public override Vector3 getValue(float time)
|
||||
{
|
||||
float r = colorR.GetValue(time);
|
||||
float g = colorG.GetValue(time);
|
||||
float b = colorB.GetValue(time);
|
||||
float a = colorA.GetValue(time);
|
||||
return new Vector3(r, g, b);
|
||||
}
|
||||
public override void Refresh()
|
||||
{
|
||||
base.Refresh();
|
||||
if (colorR.animations.Count == 0 && colorG.animations.Count == 0 && colorB.animations.Count == 0 && colorA.animations.Count == 0)
|
||||
{
|
||||
((Track)animatedObject).trackRendererSubmodule.meshGenerator.color = Color.white;
|
||||
}
|
||||
else
|
||||
{
|
||||
UpdateAnimation(EditorManager.instance.songInformation.songTime);
|
||||
}
|
||||
}
|
||||
public override void SetUpInspector()
|
||||
{
|
||||
IHaveInspection inspector = EditorManager.instance.uiManager.inspector;
|
||||
base.SetUpInspector();
|
||||
var container = inspector.GenerateContainer("Track Global Color Change");
|
||||
|
||||
var subcontainer = container.GenerateSubcontainer(3);
|
||||
var colorRButton = inspector.GenerateButton(this, subcontainer, "Color R", () =>
|
||||
{
|
||||
inspector.GenerateCompositeParameterWindow(this, "Color R", nameof(colorR)).SetAsFlexibleFloat();
|
||||
});
|
||||
var colorGButton = inspector.GenerateButton(this, subcontainer, "Color G", () =>
|
||||
{
|
||||
inspector.GenerateCompositeParameterWindow(this, "Color G", nameof(colorG)).SetAsFlexibleFloat();
|
||||
});
|
||||
var colorBButton = inspector.GenerateButton(this, subcontainer, "Color B", () =>
|
||||
{
|
||||
inspector.GenerateCompositeParameterWindow(this, "Color B", nameof(colorB)).SetAsFlexibleFloat();
|
||||
});
|
||||
var colorAButton = inspector.GenerateButton(this, subcontainer, "Color A", () =>
|
||||
{
|
||||
inspector.GenerateCompositeParameterWindow(this, "Color A", nameof(colorA)).SetAsFlexibleFloat();
|
||||
});
|
||||
var graphicEditor = inspector.GenerateButton(this, subcontainer, "GraphicEditor", () =>
|
||||
{
|
||||
inspector.GenerateGraphicalFlexibleFloatWindow(this, "Track Global Color Change",
|
||||
new FlexibleFloat[] { colorR, colorG, colorB, colorA }, new string[] { "ColorR", "ColorG", "ColorB", "ColorA" });
|
||||
});
|
||||
|
||||
}
|
||||
public override void SaveBM()
|
||||
{
|
||||
matchedBM = new Beatmap.TrackGlobalColorChange_BM(elementName, elementGuid, tags, parentElement.matchedBM as GameElement_BM,
|
||||
colorR.ConvertToBM(), colorG.ConvertToBM(), colorB.ConvertToBM(), colorA.ConvertToBM());
|
||||
}
|
||||
}
|
||||
}
|
||||
namespace Ichni.RhythmGame.Beatmap
|
||||
{
|
||||
public class TrackGlobalColorChange_BM : AnimationBase_BM
|
||||
{
|
||||
public FlexibleFloat_BM colorR, colorG, colorB, colorA;
|
||||
public TrackGlobalColorChange_BM()
|
||||
{
|
||||
|
||||
}
|
||||
public TrackGlobalColorChange_BM(string elementName, Guid elementGuid, List<string> tags,
|
||||
GameElement_BM attachedElement, FlexibleFloat_BM colorR, FlexibleFloat_BM colorG, FlexibleFloat_BM colorB, FlexibleFloat_BM colorA)
|
||||
: base(elementName, elementGuid, tags, attachedElement)
|
||||
{
|
||||
this.colorR = colorR;
|
||||
this.colorG = colorG;
|
||||
this.colorB = colorB;
|
||||
this.colorA = colorA;
|
||||
}
|
||||
public override GameElement DuplicateBM(GameElement attached)
|
||||
{
|
||||
return TrackGlobalColorChange.GenerateElement(elementName, Guid.NewGuid(), tags, true, attached,
|
||||
colorR.ConvertToGameType(), colorG.ConvertToGameType(), colorB.ConvertToGameType(), colorA.ConvertToGameType());
|
||||
}
|
||||
|
||||
public override void ExecuteBM()
|
||||
{
|
||||
matchedElement = TrackGlobalColorChange.GenerateElement(elementName, elementGuid, tags, false, GetElement(attachedElementGuid),
|
||||
colorR.ConvertToGameType(), colorG.ConvertToGameType(), colorB.ConvertToGameType(), colorA.ConvertToGameType());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: f6851ca77cda521469be038d4232a719
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Reference in New Issue
Block a user