//-----------------------------------------------------------------------------
        // Switching
        //-----------------------------------------------------------------------------

        public void BeginSwitch(object hookedObject)
        {
            this.hookedObject  = hookedObject;
            this.isSwitching   = true;
            this.isSwitched    = false;
            this.liftZPosition = 0;

            if (hookedObject is Entity)
            {
                hookedEntity = (Entity)hookedObject;
            }
            else if (hookedObject is Tile)
            {
                Tile        hookedTile  = (Tile)hookedObject;
                CarriedTile carriedTile = new CarriedTile(hookedTile);
                carriedTile.SetPositionByCenter(hookedTile.Center);
                carriedTile.Initialize(player.RoomControl);
                hookedEntity = carriedTile;
                player.RoomControl.RemoveTile(hookedTile);

                // Find location for tile to land at.
                tileSwitchLocation = player.RoomControl.GetTileLocation(player.Center);
                int syncAxis = Axes.GetOpposite(Directions.ToAxis(direction));
                tileSwitchLocation[syncAxis] = hookedTile.Location[syncAxis];

                // Check if there is a hazard tile.
                if (hookedTile.StaysOnSwitch && !CanTileLandAtLocation(tileSwitchLocation))
                {
                    // Attempt to move landing location one tile further to avoid hazard.
                    int     checkDir          = Directions.Reverse(direction);
                    Point2I newSwitchLocation = tileSwitchLocation + Directions.ToPoint(checkDir);
                    if (CanTileLandAtLocation(newSwitchLocation))
                    {
                        tileSwitchLocation = newSwitchLocation;
                    }
                }

                // Spawn drops as the tile is picked up.
                hookedTile.SpawnDrop();
            }

            hookedEntity.RemoveFromRoom();

            hookProjectile.Position = hookedEntity.Center;

            player.IsPassable = true;
            player.Physics.CollideWithWorld    = false;
            player.Physics.CollideWithEntities = false;
            player.Physics.HasGravity          = false;
            player.IsStateControlled           = true;

            hookedEntityPosition   = hookedEntity.Position;
            playerPosition         = player.Position;
            hookProjectilePosition = hookProjectile.Position;

            AudioSystem.PlaySound(GameData.SOUND_SWITCH_HOOK_SWITCH);
        }
        //-----------------------------------------------------------------------------
        // Switching
        //-----------------------------------------------------------------------------
        public void BeginSwitch(object hookedObject)
        {
            this.hookedObject	= hookedObject;
            this.isSwitching	= true;
            this.isSwitched		= false;
            this.liftZPosition	= 0;

            if (hookedObject is Entity) {
                hookedEntity = (Entity) hookedObject;
            }
            else if (hookedObject is Tile) {
                Tile hookedTile = (Tile) hookedObject;
                CarriedTile carriedTile = new CarriedTile(hookedTile);
                carriedTile.SetPositionByCenter(hookedTile.Center);
                carriedTile.Initialize(player.RoomControl);
                hookedEntity = carriedTile;
                player.RoomControl.RemoveTile(hookedTile);

                // Find location for tile to land at.
                tileSwitchLocation = player.RoomControl.GetTileLocation(player.Center);
                int syncAxis = Axes.GetOpposite(Directions.ToAxis(direction));
                tileSwitchLocation[syncAxis] = hookedTile.Location[syncAxis];

                // Check if there is a hazard tile.
                if (hookedTile.StaysOnSwitch && !CanTileLandAtLocation(tileSwitchLocation)) {
                    // Attempt to move landing location one tile further to avoid hazard.
                    int checkDir = Directions.Reverse(direction);
                    Point2I newSwitchLocation = tileSwitchLocation + Directions.ToPoint(checkDir);
                    if (CanTileLandAtLocation(newSwitchLocation))
                        tileSwitchLocation = newSwitchLocation;
                }

                // Spawn drops as the tile is picked up.
                hookedTile.SpawnDrop();
            }

            hookedEntity.RemoveFromRoom();

            hookProjectile.Position = hookedEntity.Center;

            player.IsPassable					= true;
            player.Physics.CollideWithWorld		= false;
            player.Physics.CollideWithEntities	= false;
            player.Physics.HasGravity	= false;
            player.IsStateControlled	= true;

            hookedEntityPosition	= hookedEntity.Position;
            playerPosition			= player.Position;
            hookProjectilePosition	= hookProjectile.Position;

            AudioSystem.PlaySound(GameData.SOUND_SWITCH_HOOK_SWITCH);
        }
Example #3
0
 public override void OnHitByThrownObject(CarriedTile thrownObject)
 {
     Toggle();
 }
 public override void OnHitByThrownObject(CarriedTile thrownObject)
 {
     Toggle();
 }
Example #5
0
 // Called when a thrown object crashes onto this tile.
 public virtual void OnHitByThrownObject(CarriedTile thrownObject)
 {
 }
Example #6
0
 // Called when a thrown object crashes onto this tile.
 public virtual void OnHitByThrownObject(CarriedTile thrownObject)
 {
 }