Пример #1
0
        /// <summary>
        /// Load level asset, build scene, setup dependencies.
        /// </summary>
        public void LoadLevel(int levelNumber)
        {
            // Read RawAsset by its URI
            using (var stream = Content.OpenAsStream($"LVL{levelNumber}", StreamFlags.None))
                level = LevelReader.Read(stream);

            var actionController = Entity.GetOrCreate <ActionController>();
            var builder          = new LevelBuilder(Environment, Robot, Items, SoundLibrary);

            var scene = builder.Build(level, out var robot);

            this.Entity.Scene.Children.Add(scene);

            actionController.Robot = robot.Get <RobotController>();

            var robotBrain = Entity.GetOrCreate <RobotBrain>();

            robotBrain.actions = level.ActionPattern;
            robotBrain.Reset();

            var inputController = Entity.GetOrCreate <InputController>();

            inputController.userActions  = level.UserActions;
            inputController.MistakeSound = SoundLibrary.MistakeSound;

            Camera.Entity.Get <RobotCameraFollower>().Robot = robot;

            TurnSystem.Reset();
            TurnSystem.Enable(Entity.Scene);
            TurnSystem.RemainingTime = level.ActionPattern.Length * TurnSystem.TurnLength * 5;

            UIScript.inputController = inputController;
            UIScript.robotBrain      = robotBrain;
        }