85 lines
3.0 KiB
C#
85 lines
3.0 KiB
C#
using System;
|
|
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using Ichni.RhythmGame.Beatmap;
|
|
|
|
namespace Ichni.RhythmGame
|
|
{
|
|
public partial class VariablesContainer : GameElement
|
|
{
|
|
public Dictionary<string, int> originalVariables;
|
|
public Dictionary<string, int> currentVariables;
|
|
|
|
public static VariablesContainer GenerateElement(string elementName, Guid id, List<string> tags, bool isFirstGenerated,
|
|
GameElement parentElement, Dictionary<string, int> variables)
|
|
{
|
|
VariablesContainer variablesContainer =
|
|
Instantiate(GameManager.instance.basePrefabs.emptyObject).AddComponent<VariablesContainer>();
|
|
|
|
GameManager.instance.variablesContainer = variablesContainer;
|
|
variablesContainer.Initialize(elementName, id, tags, isFirstGenerated, parentElement);
|
|
variablesContainer.originalVariables = new Dictionary<string, int>(variables);
|
|
variablesContainer.currentVariables = new Dictionary<string, int>(variables);
|
|
|
|
return variablesContainer;
|
|
}
|
|
|
|
public void SetVariable(string variableName, int value)
|
|
{
|
|
currentVariables[variableName] = value;
|
|
}
|
|
|
|
public int GetVariable(string variableName)
|
|
{
|
|
return currentVariables[variableName];
|
|
}
|
|
|
|
public void RevertVariable(string variableName)
|
|
{
|
|
currentVariables[variableName] = originalVariables[variableName];
|
|
}
|
|
|
|
public void RevertAllVariables()
|
|
{
|
|
currentVariables = new Dictionary<string, int>(originalVariables);
|
|
}
|
|
}
|
|
|
|
public partial class VariablesContainer
|
|
{
|
|
public override void SaveBM()
|
|
{
|
|
matchedBM = new VariablesContainer_BM(elementName, elementGuid, tags, null, originalVariables);
|
|
}
|
|
}
|
|
|
|
namespace Beatmap
|
|
{
|
|
public class VariablesContainer_BM : GameElement_BM
|
|
{
|
|
public Dictionary<string, int> originalVariables;
|
|
|
|
public VariablesContainer_BM()
|
|
{
|
|
|
|
}
|
|
|
|
public VariablesContainer_BM(string elementName, Guid elementGuid, List<string> tags, GameElement_BM parentElement,
|
|
Dictionary<string, int> originalVariables) : base(elementName, elementGuid, tags, parentElement)
|
|
{
|
|
this.originalVariables = new Dictionary<string, int>(originalVariables);
|
|
}
|
|
|
|
public override void ExecuteBM()
|
|
{
|
|
matchedElement = VariablesContainer.GenerateElement(elementName, elementGuid, tags, false,
|
|
GetElement(attachedElementGuid), originalVariables);
|
|
}
|
|
|
|
public override GameElement DuplicateBM(GameElement attached)
|
|
{
|
|
return VariablesContainer.GenerateElement(elementName, Guid.NewGuid(), tags, false, attached, originalVariables);
|
|
}
|
|
}
|
|
}
|
|
} |