// Start is called before the first frame update void Start() { BlockComponent = GetComponent <DataBlockComponent>(); MovementScript = gameObject.AddComponent <TileMovingObjectScript>(); MovementScript.Target = gameObject; MovementScript.JumpToTile(BlockComponent.WorldTileX, BlockComponent.WorldTileY); MovementScript.TilePositionChanged += MovementScript_TilePositionChanged; TileMovingObjectScript.MoveableMoving += Jetstream_SpongebobPlayerPositionChanging; if (BlockComponent.DataBlock.GetParameterByName("CanFloat", out var parameter)) { CanFloat = bool.Parse(parameter.Value); } if (BlockComponent.DataBlock.GetParameterByName("ExclusiveMode", out parameter)) { ExclusivePushMode = (PlayerEnum)int.Parse(parameter.Value); } if (BlockComponent.DataBlock.GetParameterByName("CanDestory", out parameter)) { CanDestory = bool.Parse(parameter.Value); } if (!CanDestory) { MovementScript.CanMoveOverWorldReservedTiles = false; } }
bool MoveableEnteredTile(TileMovingObjectScript Moveable) { if (Moveable.Target.TryGetComponent <PushableScript>(out var box)) // is a box? { var animator = box.GetComponentInChildren <Animator>(); if ((box.CanFloat && !IsBoxFloating) || // if this box can float (wooden) and there isn't already one floating... (!box.CanFloat && IsBoxSunken && !IsBoxFloating)) // OR the box cannot float (steel) and there is already a sunken box in the water and there isn't already a box floating... { animator.Play("Floating"); IsBoxFloating = true; box.MovementAllowed = false; GetComponent <SoundLoader>().Play(0); } else if (!box.CanFloat && !IsBoxSunken && !IsBoxFloating) { IsBoxSunken = true; box.MovementAllowed = false; GetComponent <SoundLoader>().Play(0); animator.Play("Sunken"); } } else if (Moveable.Target.TryGetComponent <Player>(out var player) && IsCovered) { if (!isplayerfloating) { isplayerfloating = true; floating = Moveable; } }
private void Spongebob_PlayerPositionChanging(object sender, MoveEventArgs e) { TileMovingObjectScript otherObject = null; if (sender is TileMovingObjectScript) { if ((sender as TileMovingObjectScript).SpecialObjectIgnore) { return; } otherObject = sender as TileMovingObjectScript; } if (e.ToTile.x == BlockComponent.WorldTileX && e.ToTile.y == BlockComponent.WorldTileY) { if (!Pushed) { Press(sender, e); } e.SetRaisedTerrainFlag(.2f); } else if (Pushed && CanUnpush && pressingButton.Equals(sender)) { Unpress(sender, e); } }
// Start is called before the first frame update void Start() { PushableScript = GetComponent <PushableScript>(); PushableScript.OnPushing += OnPushing; TileMovingObjectScript.MoveableMoving += TileMovingObjectScript_MoveableMoving; MoveScript = GetComponent <TileMovingObjectScript>(); MoveScript.CanMoveOverWorldReservedTiles = true; soundEffects = GetComponent <SoundLoader>(); }
void PlayerEnteredTile(TileMovingObjectScript TileObject, StinkyFile.SRotation Direction) { if (TileObject.SpecialObjectIgnore) { return; } if (!TryMove(TileObject, Direction)) // try moving forward { if (!TryMove(TileObject, TileMovingObjectScript.GetBehindDirection(Direction))) // try flipping around { Player.KillAllPlayers(); } } }
bool TryMove(TileMovingObjectScript TileObject, StinkyFile.SRotation Direction) { bool motionResult = TileObject.MoveInDirection(Direction, 1, 7); if (motionResult) { soundEffects.Play(0); var rotator = TileObject.GetComponentInChildren <AngleRotator>(); if (rotator != null) { rotator.Rotate(Direction); } } return(motionResult); }
void PlayerEnteredTile(TileMovingObjectScript TileObject) { if (TileObject.SpecialObjectIgnore) { return; } var rotator = TileObject.GetComponentInChildren <AngleRotator>(); bool motionResult = false; float motionspeed = 7f; switch (BlockComponent.DataBlock.Rotation) { case StinkyFile.SRotation.NORTH: motionResult = TileObject.WalkToTile(TileObject.TileX, TileObject.TileY - 1, motionspeed); break; case StinkyFile.SRotation.SOUTH: motionResult = TileObject.WalkToTile(TileObject.TileX, TileObject.TileY + 1, motionspeed); break; case StinkyFile.SRotation.WEST: motionResult = TileObject.WalkToTile(TileObject.TileX - 1, TileObject.TileY, motionspeed); break; case StinkyFile.SRotation.EAST: motionResult = TileObject.WalkToTile(TileObject.TileX + 1, TileObject.TileY, motionspeed); break; } soundEffects.Play(0); if (!motionResult && TileObject.TryGetComponent <Player>(out _)) { Player.KillAllPlayers(); return; } if (rotator != null) { rotator.Rotate(BlockComponent.DataBlock.Rotation); } }
internal MoveEventArgs(TileMovingObjectScript creator) { parent = creator; }
private static SRotation GetBehind(SRotation rotation) => TileMovingObjectScript.GetBehindDirection(rotation);