public void GoToRoom(int x, int y)
        {
            if (x >= RoomMapWidth)
            {
                x = RoomMapWidth - 1;
            }
            if (y >= RoomMapHeight)
            {
                y = RoomMapHeight - 1;
            }
            if (x < 0)
            {
                x = 0;
            }
            if (y < 0)
            {
                y = 0;
            }
            BossObject bossObject = ((BossObject)Engine.CurrentRoom.FindObject("obj_boss"));

            if (bossObject != null)
            {
                bossObject.Position += new Vector2((CurrentRoomX - x) * 1024, (CurrentRoomY - y) * 768);
            }
            CurrentRoomX = x;
            CurrentRoomY = y;
            ConsoleManager.WriteLine("room position x: " + CurrentRoomX + ", y: " + CurrentRoomY);
            Engine.ChangeRoom(RoomMap[x, y]);
            MaxTimerLength -= 60;
            Timer           = MaxTimerLength;
        }
Example #2
0
    /// <summary>
    /// Helper method for creating and spawning a boss.
    /// </summary>
    /// <param name="bossObject">The scriptable object describing the boss.</param>
    /// <param name="roomBorder">The border of the room to where the boss should be spawned in.</param>
    /// <param name="position">The position to where the enemy should be spawned to.</param>
    /// <param name="quaternion">The rotation of the enemy.</param>
    /// <returns>The spawned boss.</returns>
    public static Enemy InstantiateAndSpawn(BossObject bossObject, Rect roomBorder, Vector3 position, Quaternion quaternion)
    {
        GameObject gameObject = Instantiate(bossObject.EnemyObject.Prefab, position, quaternion);
        Enemy      enemy      = gameObject.GetComponent <Enemy>();

        enemy.IsBoss = true;
        enemy.Set(bossObject.EnemyObject, roomBorder);
        NetworkServer.Spawn(gameObject);
        return(enemy);
    }