public override void addOpperand(Calc calc, Complex c) { //just replace current w/ this calc.setDisplay(c.ToString()); calc.CurrentState = OpperandEnteredState.Singleton; }
private static void Main(string[] args) { Console.WriteLine("Enter an arithmatic expression (using only integers)."); Console.Write("Enter to quit"); string input; do { Console.Write(": "); input = Console.ReadLine(); if (!string.IsNullOrEmpty(input)) { var matcher = new Calc(); var result = matcher.GetMatch(input, matcher.Expression); if (result.Success) Console.WriteLine("Result: " + result.Result); else Console.WriteLine("Error: " + result.Error); } } while (!string.IsNullOrEmpty(input)); }
public void testTratt5() { var c = new Calc(); var match = c.GetMatch("1-2-3", c.Expression); Assert.True(match.Success); Assert.That(match.Result, Is.EqualTo("(1-(2-3))")); }
public void Initialize(Calc.Regression.Nonlinear.FitEnsemble ensemble, object[] fitEleControls) { _itemsHost.Children.Clear(); foreach (UIElement ele in fitEleControls) _itemsHost.Children.Add(ele); }
public override void addOpperand(Calc calc,Complex c) { //calc.Opperand1=calc.Total; //calc.Opperand2=c; calc.Total=c; calc.CurrentState=OpperandEnteredState.Singleton; }
public override void addOpperator(Calc calc, IBinOp op) { calc.pending_op = op; calc.setDisplay(""); calc.CurrentState = OpperatorEntredState.Singleton; //calc.CurrentState=ErrorState.Singleton; //throw new Exception("cant add opperator in opperator entered state"); }
public override void enterDigit(Calc calc, char c) { Console.WriteLine("Error State: enter character " + c); calc.setDisplay("" + c); if ('0' != c) { calc.CurrentState = AccumState.Singleton; } }
public static void Main(string[] args) { Calc calc = new Calc(); calc.X = 100; calc.Y = 50; Console.WriteLine("{0} + {1} = {2}", calc.X, calc.Y, calc.Add()); }
public override void Calculate(Calc calc) { Complex total = calc.pending_op.compute(calc.Total, Complex.Parse(calc.getDisplay())); calc.setDisplay(total.ToString()); calc.Total = total; calc.CurrentState = CompState.Singleton; //calc.CurrentState=ErrorState.Singleton; //throw new Exception("you cant do a calculation right after you add an opperator, need another opperand"); }
public static int RedirectOutput(string file, Calc c, int arg1, int arg2) { // Redirect output to file: // 1. Get the original IO streams TextWriter standardWriter = Console.Out; // 2. Create new output stream StreamWriter writer = new StreamWriter(file); Console.SetOut(writer); // 3. Write to file int outputLines = c(arg1, arg2); writer.Close(); Console.SetOut(standardWriter); // Get back to standard output stream return outputLines; }
public override void addOpperand(Calc calc, Complex c) { //calc.Opperand1=calc.Total; //calc.Opperand2=c; calc.setDisplay(c.ToString()); // Complex result = calc.pending_op.compute(calc.Total, calc.Opperand2); // calc.Total=result; // calc.Opperand1=result; //why did I do this??? //calc.pending_op=null; calc.CurrentState=OpperandEnteredState.Singleton; //calc.CurrentState=CompState.Singleton; }
/// <summary>Initializes a new instance of the <see cref="FastHadamardTransformation"/> class.</summary> /// <param name="mls">The maximum length sequence that is used to generate the input signal for the device under test (DUT).</param> public FastHadamardTransformation(Calc.Probability.MaximumLengthSequence mls) { _responsePermutation = new int[mls.Length]; _signalPermutation = new int[mls.Length]; _permutedSignal = new double[mls.Length + 1]; _numberOfBits = 1 + BinaryMath.Ld(mls.Length); bool[] seq = new bool[mls.Length]; int i = 0; foreach (var e in mls.GetSequence(false, true)) seq[i++] = e; GenerateResponsePermutationTable(seq, _responsePermutation, _numberOfBits); GenerateSignalPermutationTable(seq, _signalPermutation, _numberOfBits); }
public override void Calculate(Calc calc) { if (calc.pending_op != null) { Complex opperand = Complex.Parse(calc.getDisplay()); Complex total = calc.pending_op.compute(calc.Total, opperand); //calc.Opperand1=total; calc.Total = total; calc.setDisplay(total.ToString()); calc.CurrentState = CompState.Singleton; } else { calc.CurrentState=ErrorState.Singleton; // throw new Exception("cannot do calculation w/o pending opperator"); } }
public static void Main(string[] args) { // using ensures call of diposable in any cases using (Calc c = new Calc()) { c.Add(5); c.Add(10); c.Add(15); c.Add(20); Console.WriteLine("Sum {0:f2}", c.GetSum()); } // only is no using but not ensured that always called c.Dispose(); }
static void Main(string[] args) { const int ilosc = 100; int wylosowanaLiczba, licznik = 0; int[] tablicaLiczb = new int[ilosc];//deklaracja tablicy liczb for (int i = 0; i < ilosc; i++) { int seed = Guid.NewGuid().GetHashCode();//losowanie liczb Random random = new Random(seed); wylosowanaLiczba = random.Next(0, 100); tablicaLiczb[i] = wylosowanaLiczba;//wypelnienie tablicy liczbami // Console.WriteLine(tablicaLiczb[i]); } // Console.ReadKey(); Calc calc = new Calc(); calc.CheckNumberParity1(3);//wywolanie metody niestatycznej z instancji klasy Calc.CheckNumberParity(3);//wywolanie metody statycznej bezpośrednio z klasy //za pomoca metody CheckNumberParity dostepnej w solucji wypisz na konsoli wszystkie parzyste liczby z tablicy tablicaLiczb[] //wskazowki - mozna uzyc for lub foreach oraz Console.Write() Console.WriteLine() //w jednym wierszu niech bedzie wypisane 10 liczb jak na skanie jpg //powyzej dostepna jest tablica tablicaLiczb[] wypelniona przypadkowymi liczbami z zakresu 0-100 foreach (var item in tablicaLiczb) { if (Calc.CheckNumberParity(item)) { Console.Write(item.ToString() + ", "); licznik++; if (licznik % 10 == 0) Console.WriteLine(); //if (item % 2 == 0) //{ // Console.Write("{0}, ", item); //} } } Console.ReadKey(); }
static void Main(string[] args) { Calculator calculator = new Calculator(); Calc calc1 = new Calc(calculator.Add); Calc calc2 = new Calc(calculator.Sub); Calc calc3 = new Calc(calculator.Mul); Calc calc4 = new Calc(calculator.Div); double a = 100; double b = 200; Console.WriteLine(calc1(a,b)); Console.WriteLine(calc2(a,b)); Console.WriteLine(calc3.Invoke(a,b)); Console.WriteLine(calc4.Invoke(a,b)); Func<double, double, double> func = new Func<double, double, double>(calculator.Add); Console.WriteLine(func(1,2)); }
public InfixCalcTests() { calc = new Calc<double>( new UnaryOperation<double>[] { Calc<double>.CreateUnaryOperation("+", a => a), Calc<double>.CreateUnaryOperation("-", a => -a), Calc<double>.CreateUnaryOperation("sqrt", a => Math.Sqrt(a)), Calc<double>.CreateUnaryOperation("!:", a => { int res = 1; for (int i = 2; i <= a; i++) { res += i; } return res; }, true), Calc<double>.CreateUnaryOperation("!", a => { int res = 1; for (int i = 2; i <= a; i++) { res *= i; } return res; }, true), Calc<double>.CreateUnaryOperation("plusOne", a => a+1, true), Calc<double>.CreateUnaryOperation("x2", a => a*2), Calc<double>.CreateUnaryOperation("p3", a => a+3), }, new BinaryOperation<double>[][] { new BinaryOperation<double> [] { Calc<double>.CreateBinaryOperation("**", (a,b) => Math.Pow(a,b), true), }, new BinaryOperation<double> [] { Calc<double>.CreateBinaryOperation("*", (a,b) => a*b), Calc<double>.CreateBinaryOperation("/", (a,b) => a/b), }, new BinaryOperation<double> [] { Calc<double>.CreateBinaryOperation("+", (a,b) => a+b), Calc<double>.CreateBinaryOperation("-", (a,b) => a-b), }, new BinaryOperation<double> [] { Calc<double>.CreateBinaryOperation("lowPriorPower", (a,b) => Math.Pow(a,b), true), }, }, new Func<CharEnum, Tuple<double>>[] { DoubleParser.Parse }); }
public GamePadTriggers(float left, float right) { Left = Calc.Clamp(left, 0f, 1f); Right = Calc.Clamp(right, 0f, 1f); }
public void CalcIncidentEnergyDistanceAC([ValueSource(typeof(CalcNoCAC), "GetCalculationInputSimples")] CalculationInputSimple inputSimple, [ValueSource(typeof(CalcNoCAC), "GetCalculationOutputs")] CalculationOutput output) { CalculationInput input = Container.Resolve <ICalculationInput>() as CalculationInput; MapCalculationInputSimpleToCalculationInput(ref input, ref inputSimple); decimal IE = Calc.CalcIncidentEnergyAC(input.WorkingDistance.Value, Calc.CalculateArcFaultCurrentAC(input)).Value; var expected = RoundValue(output.IncidentEnergy); var real = RoundValue(IE); Assert.AreEqual(expected, real); }
public static void Interpolation(Altaxo.Data.DataColumn xCol, Altaxo.Data.DataColumn yCol, Calc.Interpolation.IInterpolationFunction interpolInstance, IROVector samplePoints, Altaxo.Data.DataColumn xRes, Altaxo.Data.DataColumn yRes) { int rows = Math.Min(xCol.Count, yCol.Count); IROVector yVec = DataColumnWrapper.ToROVector((INumericColumn)yCol, rows); IROVector xVec = DataColumnWrapper.ToROVector((INumericColumn)xCol, rows); interpolInstance.Interpolate(xVec, yVec); using (var suspendToken_xRes = xRes.SuspendGetToken()) { using (var suspendToken_yRes = yRes.SuspendGetToken()) { for (int i = 0; i < samplePoints.Length; i++) { //double r = i / (double)(parameters.NumberOfPoints - 1); //double x = parameters.XOrg * (1 - r) + parameters.XEnd * (r); double x = samplePoints[i]; double y = interpolInstance.GetYOfX(x); xRes[i] = x; yRes[i] = y; } suspendToken_yRes.Resume(); } suspendToken_xRes.Resume(); } }
public void TestInitialize() { calc = new Calc(); }
public void IABSTest() { Calc calc = new Calc(); Assert.AreEqual(-5, calc.IABS(5)); }
public abstract void addOpperand(Calc calc, Complex c);
public void MultTest() { Calc calc = new Calc(); Assert.AreEqual(4, calc.Mult(2, 2)); }
public void ModTest() { Calc calc = new Calc(); Assert.AreEqual(0, calc.Mod(4, 2)); }
public void SubTest() { Calc calc = new Calc(); Assert.AreEqual(-1, calc.Sub(1, 2)); }
public void AddTest() { Calc calc = new Calc(); Assert.AreEqual(3, calc.Add(1, 2)); }
public static new void Load() { orig_Load(); foreach (AreaData area in Areas) { area.SetSID("Celeste/" + area.Mode[0].Path); } // Separate array as we sort it afterwards. List <AreaData> modAreas = new List <AreaData>(); foreach (ModAsset asset in Everest.Content.Map.Values.Where(asset => asset.Type == typeof(AssetTypeMap))) { string path = asset.PathVirtual.Substring(5); AreaData area = new AreaData(); // Default values. area.SetSID(path); area.Name = path; area.Icon = "areas/" + path.ToLowerInvariant(); if (!GFX.Gui.Has(area.Icon)) { area.Icon = "areas/null"; } area.Interlude = false; area.TitleBaseColor = Calc.HexToColor("6c7c81"); area.TitleAccentColor = Calc.HexToColor("2f344b"); area.TitleTextColor = Color.White; area.IntroType = Player.IntroTypes.WakeUp; area.Dreaming = false; area.ColorGrade = null; area.Mode = new ModeProperties[] { new ModeProperties { Inventory = PlayerInventory.Default, AudioState = new AudioState(Sfxs.music_city, Sfxs.env_amb_00_main) } }; area.Wipe = (Scene scene, bool wipeIn, Action onComplete) => new AngledWipe(scene, wipeIn, onComplete); area.DarknessAlpha = 0.05f; area.BloomBase = 0f; area.BloomStrength = 1f; area.Jumpthru = "wood"; area.CassseteNoteColor = Calc.HexToColor("33a9ee"); area.CassetteSong = Sfxs.cas_01_forsaken_city; // Custom values can be set via the MapMeta. MapMeta meta = new MapMeta(); meta.ApplyTo(area); MapMeta metaLoaded = asset.GetMeta <MapMeta>(); if (metaLoaded != null) { area.SetMeta(null); metaLoaded.ApplyTo(area); meta = metaLoaded; } if (string.IsNullOrEmpty(area.Mode[0].Path)) { area.Mode[0].Path = asset.PathVirtual.Substring(5); } // Some of the game's code checks for [1] / [2] explicitly. // Let's just provide null modes to fill any gaps. meta.Modes = meta.Modes ?? new MapMetaModeProperties[3]; if (meta.Modes.Length < 3) { MapMetaModeProperties[] larger = new MapMetaModeProperties[3]; for (int i = 0; i < meta.Modes.Length; i++) { larger[i] = meta.Modes[i]; } meta.Modes = larger; } if (area.Mode.Length < 3) { ModeProperties[] larger = new ModeProperties[3]; for (int i = 0; i < area.Mode.Length; i++) { larger[i] = area.Mode[i]; } area.Mode = larger; } // Celeste levelset always appears first. if (area.GetLevelSet() == "Celeste") { Areas.Add(area); } else { modAreas.Add(area); } // Some special handling. area.OnLevelBegin = (level) => { MapMeta levelMeta = AreaData.Get(level.Session).GetMeta(); MapMetaModeProperties levelMetaMode = level.Session.MapData.GetMeta(); if (levelMetaMode?.SeekerSlowdown ?? false) { level.Add(new SeekerEffectsController()); } }; } // Merge modAreas into Areas. Areas.AddRange(modAreas); // Find duplicates and remove any earlier copies. for (int i = 0; i < Areas.Count; i++) { AreaData area = Areas[i]; int otherIndex = Areas.FindIndex(other => other.GetSID() == area.GetSID()); if (otherIndex < i) { Areas[otherIndex] = area; Areas.RemoveAt(i); i--; } } // Sort areas. Areas.Sort(AreaComparison); // Remove AreaDatas which are now a mode of another AreaData. // This can happen late as the map data (.bin) can contain additional metadata. for (int i = 0; i < Areas.Count; i++) { AreaData area = Areas[i]; string path = area.Mode[0].Path; int otherIndex = Areas.FindIndex(other => other.Mode.Any(otherMode => otherMode?.Path == path)); if (otherIndex != -1 && otherIndex != i) { Areas.RemoveAt(i); i--; continue; } int? order; AreaMode side; string name; ParseName(path, out order, out side, out name); // Also check for .bins possibly belonging to A side .bins by their path and lack of existing modes. for (int ii = 0; ii < Areas.Count; ii++) { AreaData other = Areas[ii]; int? otherOrder; AreaMode otherSide; string otherName; ParseName(other.Mode[0].Path, out otherOrder, out otherSide, out otherName); if (order == otherOrder && name == otherName && side != otherSide && !other.HasMode(side)) { if (other.Mode[(int)side] == null) { other.Mode[(int)side] = new ModeProperties { Inventory = PlayerInventory.Default, AudioState = new AudioState(Sfxs.music_city, Sfxs.env_amb_00_main) } } ; other.Mode[(int)side].Path = path; Areas.RemoveAt(i); i--; break; } } } // Update old MapData areas and load any new areas. for (int i = 0; i < Areas.Count; i++) { AreaData area = Areas[i]; area.ID = i; // Add the A side MapData or update its area key. if (area.Mode[0].MapData != null) { area.Mode[0].MapData.Area = area.ToKey(); } else { area.Mode[0].MapData = new MapData(area.ToKey()); } if (area.Interlude) { continue; } // A and (some) B sides have PoemIDs. Can be overridden via empty PoemID. if (area.Mode[0].PoemID == null) { area.Mode[0].PoemID = area.GetSID().DialogKeyify() + "_A"; } if (area.Mode[1] != null && area.Mode[1].PoemID == null) { area.Mode[1].PoemID = area.GetSID().DialogKeyify() + "_B"; } // Update all other existing mode's area keys. for (int mode = 1; mode < area.Mode.Length; mode++) { if (area.Mode[mode] == null) { continue; } if (area.Mode[mode].MapData != null) { area.Mode[mode].MapData.Area = area.ToKey((AreaMode)mode); } else { area.Mode[mode].MapData = new MapData(area.ToKey((AreaMode)mode)); } } } }
public override void enterDigit(Calc calc, char c) { throw new NotImplementedException(); }
public void AddExcepTest() { Calc calc = new Calc(); calc.Add(2147483648, 1); }
public void Setup() { c = new Calc(); }
public void SubExcepTest() { Calc calc = new Calc(); calc.Sub(-2147483648, 1); }
public abstract void Calculate(Calc calc);
public void MultExcepTest() { Calc calc = new Calc(); calc.Mult(214748, 83648); }
public void GetCoordForYearTests(int x, int y, int firstYear, int lastYear, int width, int year) { var coord = Calc.GetCoordForYear(firstYear, lastYear, width, year); Assert.AreEqual(x, coord.X); }
public void DivExcepTest() { Calc calc = new Calc(); Assert.AreEqual(1, calc.Div(2, 0)); }
public void divideTest() { var obj = new Calc(); Assert.AreEqual(2, obj.divide(2, 0)); }
public void Extend(int left, int right, int up, int down) { Position -= new Vector2(left * TileWidth, up * TileHeight); int newWidth = TilesX + left + right; int newHeight = TilesY + up + down; if (newWidth <= 0 || newHeight <= 0) { Tiles = new VirtualMap <MTexture>(0, 0); return; } var newTiles = new VirtualMap <MTexture>(newWidth, newHeight); //Center for (int x = 0; x < TilesX; x++) { for (int y = 0; y < TilesY; y++) { int atX = x + left; int atY = y + up; if (atX >= 0 && atX < newWidth && atY >= 0 && atY < newHeight) { newTiles[atX, atY] = Tiles[x, y]; } } } //Left for (int x = 0; x < left; x++) { for (int y = 0; y < newHeight; y++) { newTiles[x, y] = Tiles[0, Calc.Clamp(y - up, 0, TilesY - 1)]; } } //Right for (int x = newWidth - right; x < newWidth; x++) { for (int y = 0; y < newHeight; y++) { newTiles[x, y] = Tiles[TilesX - 1, Calc.Clamp(y - up, 0, TilesY - 1)]; } } //Top for (int y = 0; y < up; y++) { for (int x = 0; x < newWidth; x++) { newTiles[x, y] = Tiles[Calc.Clamp(x - left, 0, TilesX - 1), 0]; } } //Bottom for (int y = newHeight - down; y < newHeight; y++) { for (int x = 0; x < newWidth; x++) { newTiles[x, y] = Tiles[Calc.Clamp(x - left, 0, TilesX - 1), TilesY - 1]; } } Tiles = newTiles; }
public void SumIsCorrect(int a, int b, int c, int expected) { Calc.TripleCalc(a, b, c, out int sum); Assert.AreEqual(expected, sum); }
public void ApplyTo(AreaData area) { if (!string.IsNullOrEmpty(Icon) && GFX.Gui.Has(Icon)) { area.Icon = Icon; } if (Interlude != null) { area.Interlude = Interlude.Value; } if (CassetteCheckpointIndex != null) { area.CassetteCheckpointIndex = CassetteCheckpointIndex.Value; } if (!string.IsNullOrEmpty(TitleBaseColor)) { area.TitleBaseColor = Calc.HexToColor(TitleBaseColor); } if (!string.IsNullOrEmpty(TitleAccentColor)) { area.TitleAccentColor = Calc.HexToColor(TitleAccentColor); } if (!string.IsNullOrEmpty(TitleTextColor)) { area.TitleTextColor = Calc.HexToColor(TitleTextColor); } if (IntroType != null) { area.IntroType = IntroType.Value; } if (Dreaming != null) { area.Dreaming = Dreaming.Value; } if (!string.IsNullOrEmpty(ColorGrade)) { area.ColorGrade = ColorGrade; } if (!string.IsNullOrEmpty(Wipe)) { Type type = Assembly.GetEntryAssembly().GetType(Wipe); ConstructorInfo ctor = type?.GetConstructor(new Type[] { typeof(Scene), typeof(bool), typeof(Action) }); if (type != null && ctor != null) { area.Wipe = (scene, wipeIn, onComplete) => ctor.Invoke(new object[] { scene, wipeIn, onComplete }); } } if (DarknessAlpha != null) { area.DarknessAlpha = DarknessAlpha.Value; } if (BloomBase != null) { area.BloomBase = BloomBase.Value; } if (BloomStrength != null) { area.BloomStrength = BloomStrength.Value; } if (!string.IsNullOrEmpty(Jumpthru)) { area.Jumpthru = Jumpthru; } if (CoreMode != null) { area.CoreMode = CoreMode.Value; } if (!string.IsNullOrEmpty(CassetteNoteColor)) { area.CassseteNoteColor = Calc.HexToColor(CassetteNoteColor); } if (!string.IsNullOrEmpty(CassetteSong)) { area.CassetteSong = CassetteSong; } area.MountainIdle = Mountain?.Idle?.Convert() ?? area.MountainIdle; area.MountainSelect = Mountain?.Select?.Convert() ?? area.MountainSelect; area.MountainZoom = Mountain?.Zoom?.Convert() ?? area.MountainZoom; area.MountainCursor = Mountain?.Cursor?.ToVector3() ?? area.MountainCursor; area.MountainState = Mountain?.State ?? area.MountainState; ModeProperties[] modes = area.Mode; area.Mode = Convert(Modes) ?? modes; if (modes != null) { for (int i = 0; i < area.Mode.Length && i < modes.Length; i++) { if (area.Mode[i] == null) { area.Mode[i] = modes[i]; } } } MapMeta meta = area.GetMeta(); if (meta == null) { area.SetMeta(this); } else { if (!string.IsNullOrEmpty(Parent)) { meta.Parent = Parent; } if (!string.IsNullOrEmpty(PostcardSoundID)) { meta.PostcardSoundID = PostcardSoundID; } if (!string.IsNullOrEmpty(ForegroundTiles)) { meta.ForegroundTiles = ForegroundTiles; } if (!string.IsNullOrEmpty(BackgroundTiles)) { meta.BackgroundTiles = BackgroundTiles; } if (!string.IsNullOrEmpty(AnimatedTiles)) { meta.AnimatedTiles = AnimatedTiles; } if (!string.IsNullOrEmpty(Sprites)) { meta.Sprites = Sprites; } if (!string.IsNullOrEmpty(Portraits)) { meta.Portraits = Portraits; } if (OverrideASideMeta != null) { meta.OverrideASideMeta = OverrideASideMeta; } if ((Modes?.Length ?? 0) != 0 && Modes.Any(mode => mode != null)) { meta.Modes = Modes; } if (Mountain != null) { meta.Mountain = Mountain; } if (CompleteScreen != null) { meta.CompleteScreen = CompleteScreen; } if (LoadingVignetteScreen != null) { meta.LoadingVignetteScreen = LoadingVignetteScreen; } if (LoadingVignetteText != null) { meta.LoadingVignetteText = LoadingVignetteText; } if (CassetteModifier != null) { meta.CassetteModifier = CassetteModifier; } } }
static void Print(int a, int b, bool ab, string str, Calc func) { Console.WriteLine("Параметры: a = " + a.ToString() + ", b = " + b.ToString()); Console.WriteLine("\nРезультат:" + (func(str, a, b, ab)).ToString()); }
public override void Calculate(Calc calc) { }
public int Sub(int a, int b) { return(Calc.sub(a, b)); }
public Particle Create(ref Particle particle, Entity entity, Vector2 position, float direction, Color color) { particle.Track = entity; particle.Type = this; particle.Active = true; particle.Position = position; // source texture if (SourceChooser != null) { particle.Source = SourceChooser.Choose(); } else if (Source != null) { particle.Source = Source; } else { particle.Source = Draw.Particle; } // size if (SizeRange != 0) { particle.StartSize = particle.Size = Size - SizeRange * .5f + Calc.Random.NextFloat(SizeRange); } else { particle.StartSize = particle.Size = Size; } // color if (ColorMode == ColorModes.Choose) { particle.StartColor = particle.Color = Calc.Random.Choose(color, Color2); } else { particle.StartColor = particle.Color = color; } // speed / direction var moveDirection = direction - DirectionRange / 2 + Calc.Random.NextFloat() * DirectionRange; particle.Speed = Calc.AngleToVector(moveDirection, Calc.Random.Range(SpeedMin, SpeedMax)); // life particle.StartLife = particle.Life = Calc.Random.Range(LifeMin, LifeMax); // rotation if (RotationMode == RotationModes.Random) { particle.Rotation = Calc.Random.NextAngle(); } else if (RotationMode == RotationModes.SameAsDirection) { particle.Rotation = moveDirection; } else { particle.Rotation = 0; } // spin particle.Spin = Calc.Random.Range(SpinMin, SpinMax); if (SpinFlippedChance) { particle.Spin *= Calc.Random.Choose(1, -1); } return(particle); }
public void Initialize(Calc.Regression.Nonlinear.FitElement fitElement) { _fitElement = fitElement; _numberOfX = _fitElement.NumberOfIndependentVariables; _numberOfY = _fitElement.NumberOfDependentVariables; _numberOfParameter = _fitElement.NumberOfParameters; _totalSlots = Math.Max(_numberOfParameter, _numberOfX + _numberOfY + 4); SetupElements(); }
public void TestMethod2() { double rad = Calc.RadQ(-1); Assert.AreEqual(rad, double.NaN); }
public override void enterDigit(Calc calc, char c) { Console.WriteLine("OpperatorEntredS State: enter character " + c); calc.setDisplay( c.ToString()); calc.CurrentState = AccumState.Singleton; }
public void TestMethod1() { double rad = Calc.RadQ(4); Assert.AreEqual(rad, 2); }
public override void addOpperator(Calc calc, IBinOp op) { calc.Total = Complex.Parse(calc.getDisplay()); calc.pending_op=op; calc.CurrentState=OpperatorEntredState.Singleton; }
public void TestMethod1() { double num = 4; double risposta = Calc.RadQ(); }
public abstract void addOpperator(Calc calc, IBinOp op);
private static void ReadAtlasData(Atlas _atlas, string path, AtlasDataFormat format) { patch_Atlas atlas = (patch_Atlas)_atlas; string pathFull = Path.Combine(Engine.ContentDirectory, path); XmlDocument xmlDoc; VirtualTexture texV; MTexture texM; switch (format) { case AtlasDataFormat.TexturePacker_Sparrow: xmlDoc = Calc.LoadContentXML(path); XmlElement xmlTextureAtlas = xmlDoc["TextureAtlas"]; if (xmlTextureAtlas == null) { break; } texV = VirtualContent.CreateTexture(Path.Combine(Path.GetDirectoryName(path), xmlTextureAtlas.Attr("imagePath", ""))); texM = new MTexture(texV); texM.SetAtlas(atlas); atlas.Sources.Add(texV); XmlNodeList xmlSubs = xmlTextureAtlas.GetElementsByTagName("SubTexture"); foreach (XmlElement xmlSub in xmlSubs) { string name = xmlSub.Attr("name"); Rectangle clipRect = xmlSub.Rect(); if (xmlSub.HasAttr("frameX")) { atlas.textures[name] = new MTexture( texM, name, clipRect, new Vector2(-xmlSub.AttrInt("frameX"), -xmlSub.AttrInt("frameY")), xmlSub.AttrInt("frameWidth"), xmlSub.AttrInt("frameHeight") ); } else { atlas.textures[name] = new MTexture(texM, name, clipRect); } } break; case AtlasDataFormat.CrunchXml: if (!File.Exists(pathFull)) { break; } xmlDoc = Calc.LoadContentXML(path); XmlElement xmlAtlas = xmlDoc["atlas"]; foreach (XmlElement xmlAtlasSource in xmlAtlas) { texV = VirtualContent.CreateTexture(Path.Combine(Path.GetDirectoryName(path), xmlAtlasSource.Attr("n", "") + ".png")); texM = new MTexture(texV); texM.SetAtlas(atlas); atlas.Sources.Add(texV); foreach (XmlElement xmlSub in xmlAtlasSource) { string name = xmlSub.Attr("n"); Rectangle clipRect = new Rectangle(xmlSub.AttrInt("x"), xmlSub.AttrInt("y"), xmlSub.AttrInt("w"), xmlSub.AttrInt("h")); if (xmlSub.HasAttr("fx")) { atlas.textures[name] = new MTexture( texM, name, clipRect, new Vector2(-xmlSub.AttrInt("fx"), -xmlSub.AttrInt("fy")), xmlSub.AttrInt("fw"), xmlSub.AttrInt("fh") ); } else { atlas.textures[name] = new MTexture(texM, name, clipRect); } } } break; case AtlasDataFormat.CrunchBinary: if (!File.Exists(pathFull)) { break; } using (FileStream stream = File.OpenRead(pathFull)) using (BinaryReader reader = new BinaryReader(stream)) { short sources = reader.ReadInt16(); for (int i = 0; i < sources; i++) { texV = VirtualContent.CreateTexture(Path.Combine(Path.GetDirectoryName(path), reader.ReadNullTerminatedString() + ".png")); texM = new MTexture(texV); texM.SetAtlas(atlas); atlas.Sources.Add(texV); short subs = reader.ReadInt16(); for (int j = 0; j < subs; j++) { string name = reader.ReadNullTerminatedString(); short clipX = reader.ReadInt16(); short clipY = reader.ReadInt16(); short clipWidth = reader.ReadInt16(); short clipHeight = reader.ReadInt16(); short offsX = reader.ReadInt16(); short offsY = reader.ReadInt16(); short width = reader.ReadInt16(); short height = reader.ReadInt16(); atlas.textures[name] = new MTexture( texM, name, new Rectangle(clipX, clipY, clipWidth, clipHeight), new Vector2(-offsX, -offsY), width, height ); } } } break; case AtlasDataFormat.CrunchXmlOrBinary: if (File.Exists(pathFull + ".bin")) { ReadAtlasData(atlas, path + ".bin", AtlasDataFormat.CrunchBinary); } else if (File.Exists(pathFull + ".xml")) { ReadAtlasData(atlas, path + ".xml", AtlasDataFormat.CrunchXml); } return; case AtlasDataFormat.CrunchBinaryNoAtlas: if (!File.Exists(pathFull + ".bin")) { break; } using (FileStream stream = File.OpenRead(pathFull + ".bin")) using (BinaryReader reader = new BinaryReader(stream)) { short sources = reader.ReadInt16(); for (int i = 0; i < sources; i++) { string sourcePath = Path.Combine(Path.GetDirectoryName(path), reader.ReadNullTerminatedString()); short subs = reader.ReadInt16(); for (int j = 0; j < subs; j++) { string name = reader.ReadNullTerminatedString(); short unknownA = reader.ReadInt16(); short unknownB = reader.ReadInt16(); short unknownC = reader.ReadInt16(); short unknownD = reader.ReadInt16(); short offsX = reader.ReadInt16(); short offsY = reader.ReadInt16(); short width = reader.ReadInt16(); short height = reader.ReadInt16(); texV = VirtualContent.CreateTexture(Path.Combine(sourcePath, name + ".png")); texM = atlas.textures[name] = new MTexture(texV, new Vector2(-offsX, -offsY), width, height); texM.SetAtlas(atlas); atlas.Sources.Add(texV); } } } break; case AtlasDataFormat.Packer: if (!File.Exists(pathFull + ".meta")) { break; } using (FileStream stream = File.OpenRead(pathFull + ".meta")) using (BinaryReader reader = new BinaryReader(stream)) { reader.ReadInt32(); // ??? reader.ReadString(); // ??? reader.ReadInt32(); // ??? short sources = reader.ReadInt16(); for (int i = 0; i < sources; i++) { texV = VirtualContent.CreateTexture(Path.Combine(Path.GetDirectoryName(path), reader.ReadString() + ".data")); texM = new MTexture(texV); texM.SetAtlas(atlas); atlas.Sources.Add(texV); short subs = reader.ReadInt16(); for (int j = 0; j < subs; j++) { string name = reader.ReadString().Replace('\\', '/'); short clipX = reader.ReadInt16(); short clipY = reader.ReadInt16(); short clipWidth = reader.ReadInt16(); short clipHeight = reader.ReadInt16(); short offsX = reader.ReadInt16(); short offsY = reader.ReadInt16(); short width = reader.ReadInt16(); short height = reader.ReadInt16(); atlas.textures[name] = new MTexture( texM, name, new Rectangle(clipX, clipY, clipWidth, clipHeight), new Vector2(-offsX, -offsY), width, height ); } } if (stream.Position < stream.Length && reader.ReadString() == "LINKS") { short count = reader.ReadInt16(); for (int i = 0; i < count; i++) { string key = reader.ReadString(); string value = reader.ReadString(); atlas.links.Add(key, value); } } } break; case AtlasDataFormat.PackerNoAtlas: if (!File.Exists(pathFull + ".meta")) { break; } using (FileStream stream = File.OpenRead(pathFull + ".meta")) using (BinaryReader reader = new BinaryReader(stream)) { reader.ReadInt32(); reader.ReadString(); reader.ReadInt32(); short sources = reader.ReadInt16(); for (int i = 0; i < sources; i++) { string sourcePath = Path.Combine(Path.GetDirectoryName(path), reader.ReadString()); short subs = reader.ReadInt16(); for (int j = 0; j < subs; j++) { string name = reader.ReadString().Replace('\\', '/'); short unknownA = reader.ReadInt16(); short unknownB = reader.ReadInt16(); short unknownC = reader.ReadInt16(); short unknownD = reader.ReadInt16(); short offsX = reader.ReadInt16(); short offsY = reader.ReadInt16(); short width = reader.ReadInt16(); short height = reader.ReadInt16(); texV = VirtualContent.CreateTexture(Path.Combine(sourcePath, name + ".data")); texM = atlas.textures[name] = new MTexture(texV, new Vector2(-offsX, -offsY), width, height); texM.SetAtlas(atlas); texM.AtlasPath = name; atlas.Sources.Add(texV); } } if (stream.Position < stream.Length && reader.ReadString() == "LINKS") { short count = reader.ReadInt16(); for (int i = 0; i < count; i++) { string key = reader.ReadString(); string value = reader.ReadString(); atlas.links.Add(key, value); } } } break; default: break; } }
public abstract void enterDigit(Calc calc, char c);
public override AgentActivityData[] Answer() { var result = new AgentActivityData[2]; //一人目のエージェントがどの方向に行くかを保存する var agent1dir = Arrow.Up; //二人目のエージェントがどの方向に行くかを保存する var agent2dir = Arrow.Up; //エージェント1が理想的にとれる最高値 var agent1pmax = int.MinValue; //エージェント2が理想的にとれる最高値 var agent2pmax = int.MinValue; Coordinate coodinate; var sum = 0; var count = 0; var nowpoint = 0; Coordinate pastposition; var enowpoint = 0; Calc calc; int[,] prob = new int[, ] { { 3, 2, 2, 4, 8, 4, 2, 2 }, { 2, 1, 2, 3, 4, 8, 4, 3 }, { 2, 2, 3, 2, 2, 4, 8, 4 }, { 4, 3, 2, 1, 2, 3, 4, 8 }, { 8, 4, 2, 2, 3, 2, 2, 4 }, { 4, 8, 4, 3, 2, 1, 2, 3 }, { 2, 4, 8, 4, 2, 2, 3, 2 }, { 2, 3, 4, 8, 4, 3, 2, 1 } }; coodinate = Calc.Agents[OurTeam, AgentNumber.One].Position; pastposition = null; foreach (Arrow arrow in Enum.GetValues(typeof(Arrow))) { sum = 0; count = 0; nowpoint = Calc.TotalPoint(OurTeam); calc = Simulate(OurTeam, AgentNumber.One, new AgentActivityData(AgentStatusCode.RequestMovement, coodinate + arrow)); foreach (Arrow arrow2 in Enum.GetValues(typeof(Arrow))) { try { calc = calc.Simulate(OurTeam, AgentNumber.One, new AgentActivityData(AgentStatusCode.RequestMovement, coodinate + arrow + arrow2)); if (Calc.Field[coodinate + arrow].IsTileOn[OurTeam.Opponent()]) { sum += Calc.Field[coodinate + arrow].Point + 27 * (enowpoint - calc.TotalPoint(OurTeam.Opponent())); } if (Calc.Field[coodinate + arrow].IsTileOn[OurTeam.Opponent()]) { sum += 0; } else { sum += prob[(int)arrow, (int)arrow2] * (calc.TotalPoint(OurTeam) - nowpoint); } } catch (Exception e) { count++; continue; } } if ((agent1pmax < sum) && (count != 8)) { agent1pmax = sum; agent1dir = arrow; } if (pastposition == coodinate) { agent1dir++; } pastposition = coodinate; } if (Calc.Field[Calc.Agents[OurTeam, AgentNumber.One].Position + agent1dir].IsTileOn[OurTeam.Opponent()]) { result[(int)AgentNumber.One] = new AgentActivityData(AgentStatusCode.RequestRemovementOpponentTile, Calc.Agents[OurTeam, AgentNumber.One].Position + agent1dir); } result[(int)AgentNumber.One] = new AgentActivityData(AgentStatusCode.RequestMovement, Calc.Agents[OurTeam, AgentNumber.One].Position + agent1dir); coodinate = Calc.Agents[OurTeam, AgentNumber.Two].Position; pastposition = null; foreach (Arrow arrow in Enum.GetValues(typeof(Arrow))) { sum = 0; count = 0; nowpoint = Calc.TotalPoint(OurTeam); calc = Simulate(OurTeam, AgentNumber.Two, new AgentActivityData(AgentStatusCode.RequestMovement, coodinate + arrow)); foreach (Arrow arrow2 in Enum.GetValues(typeof(Arrow))) { try { calc = calc.Simulate(OurTeam, AgentNumber.Two, new AgentActivityData(AgentStatusCode.RequestMovement, coodinate + arrow + arrow2)); if (Calc.Field[coodinate + arrow].IsTileOn[OurTeam.Opponent()]) { sum += Calc.Field[coodinate + arrow].Point + 27 * (enowpoint - calc.TotalPoint(OurTeam.Opponent())); } if (Calc.Field[coodinate + arrow].IsTileOn[OurTeam.Opponent()]) { sum += 0; } else { sum += prob[(int)arrow, (int)arrow2] * (calc.TotalPoint(OurTeam) - nowpoint); } } catch (Exception e) { count++; continue; } } if ((agent2pmax < sum) && (count != 8)) { agent2pmax = sum; agent2dir = arrow; } if (pastposition == coodinate) { agent1dir++; } pastposition = coodinate; } if (Calc.Field[Calc.Agents[OurTeam, AgentNumber.Two].Position + agent2dir].IsTileOn[OurTeam.Opponent()]) { result[(int)AgentNumber.Two] = new AgentActivityData(AgentStatusCode.RequestRemovementOpponentTile, Calc.Agents[OurTeam, AgentNumber.Two].Position + agent2dir); } result[(int)AgentNumber.Two] = new AgentActivityData(AgentStatusCode.RequestMovement, Calc.Agents[OurTeam, AgentNumber.Two].Position + agent2dir); return(result); }
private IEnumerator moveSequence(Vector2 node, bool goingBack) { Vector2 start = Position; Color fromColor, toColor; if (!goingBack) { fromColor = inactiveColor; toColor = finishColor; while ((!Triggered || allowReturn) && !SceneAs <Level>().Session.GetFlag(Flag)) { yield return(null); } } else { fromColor = finishColor; toColor = inactiveColor; while (SceneAs <Level>().Session.GetFlag(Flag)) { yield return(null); } } yield return(0.1f); if (shouldCancelMove(goingBack)) { yield break; } // animate the icon openSfx.Play(moveSound); if (shakeTime > 0f) { StartShaking(shakeTime); while (icon.Rate < 1f) { icon.Color = Color.Lerp(fromColor, activeColor, icon.Rate); icon.Rate += Engine.DeltaTime / shakeTime; yield return(null); if (shouldCancelMove(goingBack)) { yield break; } } } else { icon.Rate = 1f; } yield return(0.1f); if (shouldCancelMove(goingBack)) { yield break; } // move the switch gate, emitting particles along the way int particleAt = 0; Tween tween = Tween.Create(Tween.TweenMode.Oneshot, moveEased ? Ease.CubeOut : null, moveTime + (moveEased ? 0.2f : 0f), start: true); tween.OnUpdate = tweenArg => { MoveTo(Vector2.Lerp(start, node, tweenArg.Eased)); if (Scene.OnInterval(0.1f)) { particleAt++; particleAt %= 2; for (int tileX = 0; tileX < Width / 8f; tileX++) { for (int tileY = 0; tileY < Height / 8f; tileY++) { if ((tileX + tileY) % 2 == particleAt) { SceneAs <Level>().ParticlesBG.Emit(SwitchGate.P_Behind, Position + new Vector2(tileX * 8, tileY * 8) + Calc.Random.Range(Vector2.One * 2f, Vector2.One * 6f)); } } } } }; Add(tween); float moveTimeLeft = moveTime; while (moveTimeLeft > 0f) { yield return(null); moveTimeLeft -= Engine.DeltaTime; if (shouldCancelMove(goingBack, tween)) { yield break; } } bool collidableBackup = Collidable; Collidable = false; // collide dust particles on the left if (node.X <= start.X) { Vector2 add = new Vector2(0f, 2f); for (int tileY = 0; tileY < Height / 8f; tileY++) { Vector2 collideAt = new Vector2(Left - 1f, Top + 4f + (tileY * 8)); Vector2 noCollideAt = collideAt + Vector2.UnitX; if (Scene.CollideCheck <Solid>(collideAt) && !Scene.CollideCheck <Solid>(noCollideAt)) { SceneAs <Level>().ParticlesFG.Emit(SwitchGate.P_Dust, collideAt + add, (float)Math.PI); SceneAs <Level>().ParticlesFG.Emit(SwitchGate.P_Dust, collideAt - add, (float)Math.PI); } } } // collide dust particles on the rigth if (node.X >= start.X) { Vector2 add = new Vector2(0f, 2f); for (int tileY = 0; tileY < Height / 8f; tileY++) { Vector2 collideAt = new Vector2(Right + 1f, Top + 4f + (tileY * 8)); Vector2 noCollideAt = collideAt - Vector2.UnitX * 2f; if (Scene.CollideCheck <Solid>(collideAt) && !Scene.CollideCheck <Solid>(noCollideAt)) { SceneAs <Level>().ParticlesFG.Emit(SwitchGate.P_Dust, collideAt + add, 0f); SceneAs <Level>().ParticlesFG.Emit(SwitchGate.P_Dust, collideAt - add, 0f); } } } // collide dust particles on the top if (node.Y <= start.Y) { Vector2 add = new Vector2(2f, 0f); for (int tileX = 0; tileX < Width / 8f; tileX++) { Vector2 collideAt = new Vector2(Left + 4f + (tileX * 8), Top - 1f); Vector2 noCollideAt = collideAt + Vector2.UnitY; if (Scene.CollideCheck <Solid>(collideAt) && !Scene.CollideCheck <Solid>(noCollideAt)) { SceneAs <Level>().ParticlesFG.Emit(SwitchGate.P_Dust, collideAt + add, -(float)Math.PI / 2f); SceneAs <Level>().ParticlesFG.Emit(SwitchGate.P_Dust, collideAt - add, -(float)Math.PI / 2f); } } } // collide dust particles on the bottom if (node.Y >= start.Y) { Vector2 add = new Vector2(2f, 0f); for (int tileX = 0; tileX < Width / 8f; tileX++) { Vector2 collideAt = new Vector2(Left + 4f + (tileX * 8), Bottom + 1f); Vector2 noCollideAt = collideAt - Vector2.UnitY * 2f; if (Scene.CollideCheck <Solid>(collideAt) && !Scene.CollideCheck <Solid>(noCollideAt)) { SceneAs <Level>().ParticlesFG.Emit(SwitchGate.P_Dust, collideAt + add, (float)Math.PI / 2f); SceneAs <Level>().ParticlesFG.Emit(SwitchGate.P_Dust, collideAt - add, (float)Math.PI / 2f); } } } Collidable = collidableBackup; // moving is over Audio.Play(finishedSound, Position); StartShaking(0.2f); while (icon.Rate > 0f) { icon.Color = Color.Lerp(activeColor, toColor, 1f - icon.Rate); icon.Rate -= Engine.DeltaTime * 4f; yield return(null); if (shouldCancelMove(goingBack)) { yield break; } } icon.Rate = 0f; icon.SetAnimationFrame(0); wiggler.Start(); // emit fire particles if the block is not behind a solid. collidableBackup = Collidable; Collidable = false; if (!Scene.CollideCheck <Solid>(Center)) { for (int i = 0; i < 32; i++) { float angle = Calc.Random.NextFloat((float)Math.PI * 2f); SceneAs <Level>().ParticlesFG.Emit(goingBack ? P_RecoloredFireBack : P_RecoloredFire, Position + iconOffset + Calc.AngleToVector(angle, 4f), angle); } } Collidable = collidableBackup; }
public void CalcLinesNumFromYearsAndWidthTests(int res, int firstYear, int lastYear, int width) { Assert.AreEqual(res, Calc.LinesNumFromYearsAndWidth(firstYear, lastYear, width)); }
public override void addOpperator(Calc calc, IBinOp op) { //calc.Opperand1=calc.Total; calc.pending_op=op; calc.CurrentState=OpperatorEntredState.Singleton; }
// this is heavily inspired by Vortex Helper by catapillie, and also requires Vortex Helper to fully work. private IEnumerator shatterSequence() { if (!Everest.Loader.DependencyLoaded(new EverestModuleMetadata { Name = "VortexHelper", Version = new Version(1, 1, 0) })) { // error postcards are nicer than crashes! LevelEnter.ErrorMessage = "{big}Oops!{/big}{n}To use {# F94A4A}Shatter Flag Switch Gates{#}, you need to have {# d678db}Vortex Helper{#} installed!"; LevelEnter.Go(new Session(SceneAs <Level>().Session.Area), fromSaveData: false); yield break; } Level level = SceneAs <Level>(); while ((!Triggered || allowReturn) && !SceneAs <Level>().Session.GetFlag(Flag)) { yield return(null); } openSfx.Play("event:/game/general/fallblock_shake"); yield return(0.1f); if (shakeTime > 0f) { StartShaking(shakeTime); while (icon.Rate < 1f) { icon.Color = Color.Lerp(inactiveColor, finishColor, icon.Rate); icon.Rate += Engine.DeltaTime / shakeTime; yield return(null); } } else { icon.Rate = 1f; } yield return(0.1f); for (int k = 0; k < 32; k++) { float num = Calc.Random.NextFloat((float)Math.PI * 2f); SceneAs <Level>().ParticlesFG.Emit(TouchSwitch.P_Fire, Position + iconOffset + Calc.AngleToVector(num, 4f), num); } openSfx.Stop(); Audio.Play("event:/game/general/wall_break_stone", Center); Audio.Play(finishedSound, Center); level.Shake(); string debrisPath; switch (blockSpriteName) { default: debrisPath = "debris/VortexHelper/disintegate/1"; break; case "mirror": debrisPath = "debris/VortexHelper/disintegate/2"; break; case "temple": debrisPath = "debris/VortexHelper/disintegate/3"; break; case "stars": debrisPath = "debris/VortexHelper/disintegate/4"; break; } for (int i = 0; i < Width / 8f; i++) { for (int j = 0; j < Height / 8f; j++) { Debris debris = new Debris().orig_Init(Position + new Vector2(4 + i * 8, 4 + j * 8), '1').BlastFrom(Center); DynData <Debris> debrisData = new DynData <Debris>(debris); debrisData.Get <Image>("image").Texture = GFX.Game[debrisPath]; Scene.Add(debris); } } DestroyStaticMovers(); RemoveSelf(); }
public override void enterDigit(Calc calc, char c) { //Complex c=Complex.Parse(calc.getDisplay()); throw new NotImplementedException(); }
public FlagSwitchGate(EntityData data, Vector2 offset) : base(data.Position + offset, data.Width, data.Height, safe: false) { isShatter = data.Bool("isShatter", defaultValue: false); if (data.Nodes.Length > 0) { node = data.Nodes[0] + offset; } ID = data.ID; Flag = data.Attr("flag"); inactiveColor = Calc.HexToColor(data.Attr("inactiveColor", "5FCDE4")); activeColor = Calc.HexToColor(data.Attr("activeColor", "FFFFFF")); finishColor = Calc.HexToColor(data.Attr("finishColor", "F141DF")); shakeTime = data.Float("shakeTime", 0.5f); moveTime = data.Float("moveTime", 1.8f); moveEased = data.Bool("moveEased", true); moveSound = data.Attr("moveSound", "event:/game/general/touchswitch_gate_open"); finishedSound = data.Attr("finishedSound", "event:/game/general/touchswitch_gate_finish"); allowReturn = data.Bool("allowReturn", false); P_RecoloredFire = new ParticleType(TouchSwitch.P_Fire) { Color = finishColor }; P_RecoloredFireBack = new ParticleType(TouchSwitch.P_Fire) { Color = inactiveColor }; string iconAttribute = data.Attr("icon", "vanilla"); icon = new Sprite(GFX.Game, iconAttribute == "vanilla" ? "objects/switchgate/icon" : $"objects/MaxHelpingHand/flagSwitchGate/{iconAttribute}/icon"); Add(icon); icon.Add("spin", "", 0.1f, "spin"); icon.Play("spin"); icon.Rate = 0f; icon.Color = inactiveColor; icon.Position = (iconOffset = new Vector2(data.Width / 2f, data.Height / 2f)); icon.CenterOrigin(); Add(wiggler = Wiggler.Create(0.5f, 4f, f => { icon.Scale = Vector2.One * (1f + f); })); blockSpriteName = data.Attr("sprite", "block"); MTexture nineSliceTexture = GFX.Game["objects/switchgate/" + blockSpriteName]; nineSlice = new MTexture[3, 3]; for (int i = 0; i < 3; i++) { for (int j = 0; j < 3; j++) { nineSlice[i, j] = nineSliceTexture.GetSubtexture(new Rectangle(i * 8, j * 8, 8, 8)); } } Add(openSfx = new SoundSource()); Add(new LightOcclude(0.5f)); }