public bool Check(Sonic character) { bool none = false; foreach (var i in Sensors) { SensorResults[i.Key] = i.Value.Check(character); none = none || ( SensorResults[i.Key] != null ); } return none; }
public bool Tick(LevelObjectInfo @object, SonicLevel level, Sonic.Sonic sonic) { if (@object.lastDrawTick != SonicManager.Instance.tickCount - 1) Init(@object, level, sonic); @object.lastDrawTick = SonicManager.Instance.tickCount; evalMe("tickScript").Me().apply(@object, new object[] {@object, level, sonic}); if (@object.State.Truthy()) { @object.Xsp = @object.State.Xsp; @object.Ysp = @object.State.Ysp; } @object.X += @object.Xsp; @object.Y += @object.Ysp; return true; }
public SensorM Check(Sonic character) { var _y2 = character.InAir ? Y2 : Y2; SensorM m = null; var x = Help.Floor(character.X); var y = Help.Floor(character.Y); switch (character.Mode) { case RotationMode.Floor: m = checkCollisionLineWrap(x + X1, x + X2, y + Y1, y + _y2, IgnoreSolid); break; case RotationMode.LeftWall: m = checkCollisionLineWrap(x - Y1, x - _y2, y + X1, y + X2, IgnoreSolid); break; case RotationMode.Ceiling: m = checkCollisionLineWrap(x - X1, x - X2, y - Y1, y - _y2, IgnoreSolid); break; case RotationMode.RightWall: m = checkCollisionLineWrap(x + Y1, x + _y2, y - X1, y - X2, IgnoreSolid); break; } if (m != null) { m.Letter = Letter; if (m.Angle == 255 || m.Angle == 0 || m.Angle == 1) { if (character.Mode == RotationMode.Floor) m.Angle = 255; if (character.Mode == RotationMode.LeftWall) m.Angle = 64; if (character.Mode == RotationMode.Ceiling) m.Angle = 128; if (character.Mode == RotationMode.RightWall) m.Angle = 192; } } return m; }
public void Draw(CanvasRenderingContext2D canvas, Sonic character, SensorM sensorResult) { var x = Help.Floor(character.X) - SonicManager.Instance.WindowLocation.X; var y = Help.Floor(character.Y) - SonicManager.Instance.WindowLocation.Y; canvas.BeginPath(); if (sensorResult.Truthy() && sensorResult.Chosen) { canvas.StrokeStyle = "#FFF76D"; canvas.LineWidth = 4; } else { canvas.StrokeStyle = Color; canvas.LineWidth = 2; } switch (character.Mode) { case RotationMode.Floor: canvas.MoveTo(( x + X1 ), ( y + Y1 )); canvas.LineTo(( x + X2 ), ( y + Y2 )); break; case RotationMode.LeftWall: canvas.MoveTo(( x - Y1 ), ( y + X1 )); canvas.LineTo(( x - Y2 ), ( y + X2 )); break; case RotationMode.Ceiling: canvas.MoveTo(( x - X1 ), ( y - Y1 )); canvas.LineTo(( x - X2 ), ( y - Y2 )); break; case RotationMode.RightWall: canvas.MoveTo(( x + Y1 ), ( y - X1 )); canvas.LineTo(( x + Y2 ), ( y - X2 )); break; } canvas.ClosePath(); canvas.Stroke(); }
public void Draw(CanvasRenderingContext2D canvas, Sonic sonic) { foreach (var sensor in Sensors) { sensor.Value.Draw(canvas, sonic, SensorResults[sensor.Key]); } }
public bool OnHurtSonic(LevelObjectInfo @object, SonicLevel level, Sonic.Sonic sonic, string sensor, dynamic piece) { return Script.Reinterpret<bool>(evalMe("hurtScript").Me().apply(@object, new object[] {@object, level, sonic, sensor, piece})); }
public void Init(LevelObjectInfo @object, SonicLevel level, Sonic.Sonic sonic) { @object.Reset(); evalMe("initScript").Me().apply(@object, new object[] {@object, level, sonic}); }