using System.Collections; using System.Collections.Generic; using UnityEngine; public class MouldingCommand : ICommand { string[] _currentSC; string[] _previousSC; public MouldingCommand() { _currentSC = (string[])_G.SC.Clone(); _previousSC = (string[])_G.SC.Clone(); string cat = _currentSC[6][..1]; Debug.Log("command cat : " + cat); if (cat == "B") { _previousSC[6] = _G.WMK[0] != "ND" ? _G.WMK[0] : cat; // mould type? _previousSC[2] = _G.WMK[1]; // mesure _previousSC[5] = _G.WMK[2]; // color } else if (cat == "O") { _previousSC[6] = _G.WMO[0] != "ND" ? _G.WMO[0] : cat; _previousSC[2] = _G.WMO[1]; _previousSC[5] = _G.WMO[2]; } } public void Execute() { SetMould(_currentSC); } public string GetAction() { return "Mould"; } public void Undo() { SetMould(_previousSC); } public void UpdateCommand() { return; } private void SetMould(string[] SC) { string[] tmpSC = _G.SC; _G.SC = SC; if (_G.SC[6].Substring(0, 1) == "B") { _G.WMK[0] = _G.SC[6]; _G.WMK[1] = DOIT.CSs(_G.SC[2]); _G.WMK[2] = "ffffff"; _G.WMKs = _G.WMK[0] + "," + _G.WMK[1] + "," + _G.WMK[2]; ConstructMolding.AddMolding("B"); } if (_G.SC[6].Substring(0, 1) == "O") { _G.WMO[0] = _G.SC[6]; _G.WMO[1] = DOIT.CSs(_G.SC[2]); _G.WMO[2] = "ffffff"; _G.WMOs = _G.WMO[0] + "," + _G.WMO[1] + "," + _G.WMO[2]; ConstructMolding.AddMolding("O"); } _G.SC = tmpSC; } }