Example #1
0
        public void WriteScriptMap()
        {
            _loader.EnsureDataLoaded();
            _loader.EnsureScriptsLoaded();
            EnsureCodeMapBuild();
            var map = new Dictionary <int, ScriptSystem>();


            foreach (var entry in _loader.GetCodePoints(0, ushort.MaxValue))
            {
                if (entry.Script != 0)
                {
                    ScriptSystem sys = GetScriptSystem(entry.Script);
                    map.Add(entry.CodeValue, sys);
                }
            }

#if true1
            using (var w = File.CreateText(@"f:\_tests\Del\ScriptMap.txt")) {
                for (int i = 0; i <= ushort.MaxValue; i++)
                {
                    if (map.TryGetValue(i, out ScriptSystem value))
                    {
                    }

                    string text = $"{i:X4} ";
                    if (_loader.TryGetEntry(i, out UnicodeEntry entry))
                    {
                        if (IsPrintable(entry.Category))
                        {
                            text += entry + " ";
                        }

                        if (entry.Script != 0)
                        {
                            text += "[" + entry.Script + "] ";
                        }
                        text += entry.Name + " ";
                    }

                    w.WriteLine(text + value);
                }
            }
#else
            InterleaveMap imap = new InterleaveMap();
            for (int i = 0; i <= ushort.MaxValue; i++)
            {
                if (map.TryGetValue(i, out ScriptSystem value))
                {
                    imap.Add((char)i, (int)value);
                }
            }


            using (var w = File.Create(@"f:\_tests\Del\ScriptMap.bin"))
                using (var b = new BinaryWriter(w)){
                    imap.SaveByte(b);
                }
#endif
        }
Example #2
0
        /// <summary>
        /// Initializes a new instance of the <see cref="Game"/> class.
        /// </summary>
        public Game()
        {
            // Register the logger backend before anything else
            logListener = GetLogListener();

            if (logListener != null)
            {
                GlobalLogger.GlobalMessageLogged += logListener;
            }

            // Create all core services, except Input which is created during `Initialize'.
            // Registration takes place in `Initialize'.
            Script             = new ScriptSystem(Services);
            SceneSystem        = new SceneSystem(Services);
            Audio              = new AudioSystem(Services);
            gameFontSystem     = new GameFontSystem(Services);
            SpriteAnimation    = new SpriteAnimationSystem(Services);
            DebugConsoleSystem = new DebugConsoleSystem(Services);
            ProfilerSystem     = new GameProfilingSystem(Services);

            Content.Serializer.LowLevelSerializerSelector = ParameterContainerExtensions.DefaultSceneSerializerSelector;

            // Creates the graphics device manager
            GraphicsDeviceManager = new GraphicsDeviceManager(this);

            AutoLoadDefaultSettings = true;
        }
        /// <summary>
        /// Adds a micro thread function to the <paramref name="scriptSystem"/> that executes after waiting specified delay.
        /// </summary>
        /// <param name="scriptSystem">The <see cref="ScriptSystem"/>.</param>
        /// <param name="action">The micro thread function to execute.</param>
        /// <param name="delay">The amount of time to wait for.</param>
        /// <param name="priority">The priority of the micro thread action being added.</param>
        /// <returns>The <see cref="MicroThread"/>.</returns>
        /// <exception cref="ArgumentNullException"> If <paramref name="scriptSystem"/> or <paramref name="action"/> is <see langword="null"/>.</exception>
        /// <exception cref="ArgumentOutOfRangeException">If <paramref name="delay"/> is less than zero.</exception>
        /// <remarks>
        /// If the <paramref name="action"/> is a <see cref="ScriptComponent"/> instance method the micro thread will be automatically stopped if the <see cref="ScriptComponent"/> or <see cref="Entity"/> is removed.
        /// </remarks>
        public static MicroThread AddTask(
            this ScriptSystem scriptSystem,
            Func <Task> action,
            TimeSpan delay,
            long priority = 0L)
        {
            if (scriptSystem == null)
            {
                throw new ArgumentNullException(nameof(scriptSystem));
            }

            if (action == null)
            {
                throw new ArgumentNullException(nameof(action));
            }

            return(scriptSystem.AddTask(DoTask, priority));

            //C# 7 Local function could also use a variable Func<Task> DoEvent = async () => { ... };
            async Task DoTask()
            {
                var scriptDelegateWatcher = new ScriptDelegateWatcher(action);

                await scriptSystem.WaitFor(delay, scriptDelegateWatcher);

                if (scriptSystem.Game.IsRunning && scriptDelegateWatcher.IsActive)
                {
                    await action();
                }
            }
        }
Example #4
0
        public static MicroThread AddOnEventTask <T>(
            this ScriptSystem scriptSystem,
            EventReceiver <T> receiver,
            Func <T, Task> action,
            long priority = 0L)
        {
            if (scriptSystem == null)
            {
                throw new ArgumentNullException(nameof(scriptSystem));
            }

            if (receiver == null)
            {
                throw new ArgumentNullException(nameof(receiver));
            }

            if (action == null)
            {
                throw new ArgumentNullException(nameof(action));
            }

            return(scriptSystem.AddTask(DoEvent, priority));

            //C# 7 Local function could also use a variable Func<Task> DoEvent = async () => { ... };
            async Task DoEvent()
            {
                while (scriptSystem.Game.IsRunning)
                {
                    await action(await receiver.ReceiveAsync());
                }
            }
        }
Example #5
0
        public static MicroThread AddAction(
            this ScriptSystem scriptSystem,
            Action action,
            TimeSpan delay,
            long priority = 0L)
        {
            if (scriptSystem == null)
            {
                throw new ArgumentNullException(nameof(scriptSystem));
            }

            if (action == null)
            {
                throw new ArgumentNullException(nameof(action));
            }

            if (delay <= TimeSpan.Zero)
            {
                throw new ArgumentOutOfRangeException(nameof(delay), "Must be greater than zero.");
            }

            return(scriptSystem.AddTask(DoTask, priority));

            //C# 7 Local function could also use a variable Func<Task> DoEvent = async () => { ... };
            async Task DoTask()
            {
                while (scriptSystem.Game.IsRunning && delay >= TimeSpan.Zero)
                {
                    delay -= scriptSystem.Game.UpdateTime.Elapsed;
                    await scriptSystem.NextFrame();
                }

                action();
            }
        }
 public void Start(ScriptSystem script, string initialStateName)
 {
     exited       = false;
     scriptSystem = script;
     scriptSystem.AddTask(Run);
     nextState = states[initialStateName];
 }
    void Update()
    {
        if (!bDressingClothes && PlayerInventory.GetPlayerInventory().IsItem("ArmoredJacket") && PlayerInventory.GetPlayerInventory().IsItem("ArmoredTrousers"))
        {
            bDressingClothes = true;
            ScriptSystem.GetInstance().SetScriptCommand(GameObject.Find("DialogWindow"), "ShowDialog", new string[1] {
                "DIALOG_2"
            });
            inHouseDoor.SetActive(true);
        }

        if (bDressingClothes && !bHaveAxe && PlayerInventory.GetPlayerInventory().IsItem("Axe"))
        {
            bHaveAxe = true;
            ScriptSystem.GetInstance().SetScriptCommand(GameObject.Find("DialogWindow"), "ShowDialog", new string[1] {
                "DIALOG_3"
            });
        }

        if (bDressingClothes && bHaveAxe && !bNextLevel)
        {
            bNextLevel = true;
            nextLevel.gameObject.SetActive(true);
            GameObject.Find("NextLevel").SetActive(true);
        }
    }
Example #8
0
        public EffectNodeFactory()
        {
            mainContext = VLServiceRegistry.Default.GetService <SynchronizationContext>();
            var game = VLServiceRegistry.Default.GetService <Game>();

            ServiceRegistry  = game?.Services;
            ContentManger    = game?.Content;
            EffectSystem     = game?.EffectSystem;
            DeviceManager    = game?.GraphicsDeviceManager;
            ScriptSystem     = game?.Script;
            nodeDescriptions = new ObservableCollection <IVLNodeDescription>(GetNodeDescriptions());
            NodeDescriptions = new ReadOnlyObservableCollection <IVLNodeDescription>(nodeDescriptions);

            if (EffectSystem != null)
            {
                // Ensure the effect system tracks the same files as we do
                var fieldInfo = typeof(EffectSystem).GetField("directoryWatcher", BindingFlags.NonPublic | BindingFlags.Instance);
                directoryWatcher = fieldInfo.GetValue(EffectSystem) as DirectoryWatcher;
            }
            else
            {
                directoryWatcher = new DirectoryWatcher(xkslFileFilter);
            }
            directoryWatcher.Modified += DirectoryWatcher_Modified;
        }
Example #9
0
 public static ScriptSystem GetInstance()
 {
     if (instance != null)
     {
         return(instance);
     }
     return(instance = new ScriptSystem());
 }
 public static ScriptSystem GetInstance()
 {
     if (instance != null)
     {
         return instance;
     }
     return instance = new ScriptSystem();
 }
Example #11
0
        /// <summary>
        /// Initializes a new instance of the <see cref="Game"/> class.
        /// </summary>
        public Game()
        {
            // Register the logger backend before anything else
            logListener = GetLogListener();

            if (logListener != null)
            {
                GlobalLogger.GlobalMessageLogged += logListener;
            }

            // Create and register all core services
            Input           = new InputManager(Services);
            Script          = new ScriptSystem(Services);
            SceneSystem     = new SceneSystem(Services);
            Audio           = new AudioSystem(Services);
            UI              = new UISystem(Services);
            gameFontSystem  = new GameFontSystem(Services);
            SpriteAnimation = new SpriteAnimationSystem(Services);
            ProfilerSystem  = new GameProfilingSystem(Services);

            // ---------------------------------------------------------
            // Add common GameSystems - Adding order is important
            // (Unless overriden by gameSystem.UpdateOrder)
            // ---------------------------------------------------------

            // Add the input manager
            GameSystems.Add(Input);

            // Add the scheduler system
            // - Must be after Input, so that scripts are able to get latest input
            // - Must be before Entities/Camera/Audio/UI, so that scripts can apply
            // changes in the same frame they will be applied
            GameSystems.Add(Script);

            // Add the UI System
            GameSystems.Add(UI);

            // Add the Audio System
            GameSystems.Add(Audio);

            // Add the Font system
            GameSystems.Add(gameFontSystem);

            //Add the sprite animation System
            GameSystems.Add(SpriteAnimation);

            Asset.Serializer.LowLevelSerializerSelector = ParameterContainerExtensions.DefaultSceneSerializerSelector;

            // Creates the graphics device manager
            GraphicsDeviceManager = new GraphicsDeviceManager(this);

            GameSystems.Add(ProfilerSystem);

            AutoLoadDefaultSettings = true;
        }
Example #12
0
        /// <summary>
        /// Initializes a new instance of the <see cref="Game"/> class.
        /// </summary>
        public Game()
        {
            // Register the logger backend before anything else
            logListener = GetLogListener();

            if (logListener != null)
            {
                GlobalLogger.GlobalMessageLogged += logListener;
            }

            // Create all core services, except Input which is created during `Initialize'.
            // Registration takes place in `Initialize'.
            Script = new ScriptSystem(Services);
            Services.AddService(Script);

            SceneSystem = new SceneSystem(Services);
            Services.AddService(SceneSystem);

            Streaming = new StreamingManager(Services);

            Audio = new AudioSystem(Services);
            Services.AddService(Audio);
            Services.AddService <IAudioEngineProvider>(Audio);

            gameFontSystem = new GameFontSystem(Services);
            Services.AddService(gameFontSystem.FontSystem);
            Services.AddService <IFontFactory>(gameFontSystem.FontSystem);

            SpriteAnimation = new SpriteAnimationSystem(Services);
            Services.AddService(SpriteAnimation);

            DebugTextSystem = new DebugTextSystem(Services);
            Services.AddService(DebugTextSystem);

            DebugRenderSystem = new DebugRenderSystem(Services);
            Services.AddService(DebugRenderSystem);

            ProfilingSystem = new GameProfilingSystem(Services);
            Services.AddService(ProfilingSystem);

            VRDeviceSystem = new VRDeviceSystem(Services);
            Services.AddService(VRDeviceSystem);

            // Creates the graphics device manager
            GraphicsDeviceManager = new GraphicsDeviceManager(this);
            Services.AddService <IGraphicsDeviceManager>(GraphicsDeviceManager);
            Services.AddService <IGraphicsDeviceService>(GraphicsDeviceManager);

            AutoLoadDefaultSettings = true;
        }
        /// <summary>
        /// Adds a micro thread function to the <paramref name="scriptSystem"/> that executes after waiting specified delay and repeats execution.
        /// </summary>
        /// <param name="scriptSystem">The <see cref="ScriptSystem"/>.</param>
        /// <param name="action">The micro thread function to execute.</param>
        /// <param name="delay">The amount of time to wait for.</param>
        /// <param name="repeatEvery">The amount of time to wait for between repetition.</param>
        /// <param name="priority">The priority of the micro thread action being added.</param>
        /// <returns>The <see cref="MicroThread"/>.</returns>
        /// <exception cref="ArgumentNullException"> If <paramref name="scriptSystem"/> or <paramref name="action"/> is <see langword="null"/>.</exception>
        /// <exception cref="ArgumentOutOfRangeException">If <paramref name="delay"/> or <paramref name="repeatEvery"/> is less than zero.</exception>
        /// <remarks>
        /// If the <paramref name="action"/> is a <see cref="ScriptComponent"/> instance method the micro thread will be automatically stopped if the <see cref="ScriptComponent"/> or <see cref="Entity"/> is removed.
        /// </remarks>
        public static MicroThread AddAction(
            this ScriptSystem scriptSystem,
            Action action,
            TimeSpan delay,
            TimeSpan repeatEvery,
            long priority = 0L)
        {
            if (scriptSystem == null)
            {
                throw new ArgumentNullException(nameof(scriptSystem));
            }

            if (action == null)
            {
                throw new ArgumentNullException(nameof(action));
            }

            if (delay <= TimeSpan.Zero)
            {
                throw new ArgumentOutOfRangeException(nameof(delay), "Must be greater than zero.");
            }

            if (repeatEvery <= TimeSpan.Zero)
            {
                throw new ArgumentOutOfRangeException(nameof(repeatEvery), "Must be greater than zero.");
            }

            return(scriptSystem.AddTask(DoTask, priority));

            //C# 7 Local function could also use a variable Func<Task> DoEvent = async () => { ... };
            async Task DoTask()
            {
                var elapsedTime = new TimeSpan(0);

                var scriptDelegateWatcher = new ScriptDelegateWatcher(action);

                while (scriptSystem.Game.IsRunning && scriptDelegateWatcher.IsActive)
                {
                    elapsedTime += scriptSystem.Game.UpdateTime.Elapsed;

                    if (elapsedTime >= delay)
                    {
                        elapsedTime -= delay;
                        delay        = repeatEvery;
                        action();
                    }
                    await scriptSystem.NextFrame();
                }
            }
        }
        /// <summary>
        /// Adds a micro thread function to the <paramref name="scriptSystem"/> that executes after waiting specified delay and repeats execution.
        /// </summary>
        /// <param name="scriptSystem">The <see cref="ScriptSystem"/>.</param>
        /// <param name="action">The micro thread function to execute. The parameter is the progress over time from 0.0f to 1.0f.</param>
        /// <param name="duration">The duration of the time to execute the micro thread function for.</param>
        /// <param name="priority">The priority of the micro thread action being added.</param>
        /// <returns>The <see cref="MicroThread"/>.</returns>
        /// <exception cref="ArgumentNullException"> If <paramref name="scriptSystem"/> or <paramref name="action"/> is <see langword="null"/>.</exception>
        /// <exception cref="ArgumentOutOfRangeException">If <paramref name="duration"/> is less than zero.</exception>
        /// <remarks>
        /// If the <paramref name="action"/> is a <see cref="ScriptComponent"/> instance method the micro thread will be automatically stopped if the <see cref="ScriptComponent"/> or <see cref="Entity"/> is removed.
        /// </remarks>
        public static MicroThread AddOverTimeAction(
            this ScriptSystem scriptSystem,
            Action <float> action,
            TimeSpan duration,
            long priority = 0L)
        {
            if (scriptSystem == null)
            {
                throw new ArgumentNullException(nameof(scriptSystem));
            }

            if (action == null)
            {
                throw new ArgumentNullException(nameof(action));
            }

            if (duration <= TimeSpan.Zero)
            {
                throw new ArgumentOutOfRangeException(nameof(duration), "Must be greater than zero.");
            }

            return(scriptSystem.AddTask(DoTask, priority));

            //C# 7 Local function could also use a variable Func<Task> DoEvent = async () => { ... };
            async Task DoTask()
            {
                var elapsedTime = new TimeSpan(0);

                var scriptDelegateWatcher = new ScriptDelegateWatcher(action);

                while (scriptSystem.Game.IsRunning && scriptDelegateWatcher.IsActive)
                {
                    elapsedTime += scriptSystem.Game.UpdateTime.Elapsed;

                    if (elapsedTime >= duration)
                    {
                        action(1.0f);
                        break;
                    }
                    else
                    {
                        var progress = (float)(elapsedTime.TotalSeconds / duration.TotalSeconds);

                        action(progress);
                    }
                    await scriptSystem.NextFrame();
                }
            }
        }
    void OnTriggerEnter2D(Collider2D other)
    {
        if (flagScript)
        {
            return;
        }

        if (other.gameObject.tag == objectTag)
        {
            ScriptSystem scriptSystem = ScriptSystem.GetInstance();
            scriptSystem.SetScriptCommand(doingObject, scriptCommand, arrayOfParameter);
            flagScript = true;
            Destroy(gameObject);
        }
    }
Example #16
0
        /// <summary>
        /// Initializes a new instance of the <see cref="Game"/> class.
        /// </summary>
        public HeadlessGame()
        {
            // Internals
            Log                = GlobalLogger.GetLogger(GetType().GetTypeInfo().Name);
            UpdateTime         = new GameTime();
            autoTickTimer      = new TimerTick();
            IsFixedTimeStep    = true;
            maximumElapsedTime = TimeSpan.FromMilliseconds(500.0);
            TargetElapsedTime  = TimeSpan.FromTicks(TimeSpan.TicksPerSecond / 60); // target elapsed time is by default 60Hz

            // Externals
            Services = new ServiceRegistry();

            GraphicsDevice = GraphicsDevice.New(DeviceCreationFlags.VideoSupport, new GraphicsProfile[]
            {
                GraphicsProfile.Level_11_0,
                GraphicsProfile.Level_11_1,
                GraphicsProfile.Level_11_2
            });
            Services.AddService <IGraphicsDeviceService>(new GraphicsDeviceServiceLocal(GraphicsDevice));

            // Database file provider
            Services.AddService <IDatabaseFileProviderService>(new DatabaseFileProviderService(null));

            GameSystems = new GameSystemCollection(Services);
            Services.AddService <IGameSystemCollection>(GameSystems);

            // Setup registry
            Services.AddService <IGame>(this);

            // Register the logger backend before anything else
            logListener = GetLogListener();

            if (logListener != null)
            {
                GlobalLogger.GlobalMessageLogged += logListener;
            }

            // Create all core services, except Input which is created during `Initialize'.
            // Registration takes place in `Initialize'.
            Script = new ScriptSystem(Services);
            Services.AddService(Script);

            SceneSystem = new SceneSystem(Services);
            Services.AddService(SceneSystem);

            Streaming = new StreamingManager(Services);
        }
        /// <summary>
        /// Waits for the specified delay <paramref name="delay"/> .
        /// </summary>
        /// <param name="scriptSystem">The <see cref="ScriptSystem"/>.</param>
        /// <param name="delay">The amount of time to wait.</param>
        /// <param name="scriptDelegateWatcher">Allows to stop waiting if <see cref="ScriptComponent"/> is not active.</param>
        /// <returns>The <see cref="Task"/> to await.</returns>
        internal static async Task WaitFor(this ScriptSystem scriptSystem, TimeSpan delay, ScriptDelegateWatcher scriptDelegateWatcher)
        {
            if (scriptSystem == null)
            {
                throw new ArgumentNullException(nameof(scriptSystem));
            }

            if (delay <= TimeSpan.Zero)
            {
                throw new ArgumentOutOfRangeException(nameof(delay), "Must be greater than zero.");
            }

            while (scriptSystem.Game.IsRunning && scriptDelegateWatcher.IsActive && delay >= TimeSpan.Zero)
            {
                delay -= scriptSystem.Game.UpdateTime.Elapsed;
                await scriptSystem.NextFrame();
            }
        }
Example #18
0
 void OnTriggerStay2D(Collider2D other)
 {
     if (gameObject.activeSelf)
     {
         if (other.gameObject.tag == objectTag)
         {
             objectRenderer.enabled = true;
             if (Input.GetKeyUp(keyKode))
             {
                 ScriptSystem scriptSystem = ScriptSystem.GetInstance();
                 scriptSystem.SetScriptCommand(doingObject, scriptCommand, arrayOfParameter);
                 if (isLimited)
                 {
                     gameObject.SetActive(false);
                     Destroy(gameObject);
                     Debug.Log("KetCondition: OK!!!");
                 }
             }
         }
     }
 }
        /// <summary>
        /// Adds a micro thread function to the <paramref name="scriptSystem"/> that executes when the event is published.
        /// </summary>
        /// <typeparam name="T">The type of the event handler parameter.</typeparam>
        /// <param name="scriptSystem">The <see cref="ScriptSystem"/>.</param>
        /// <param name="receiver">The event reciever to listen to for.</param>
        /// <param name="action">The micro thread function to execute.</param>
        /// <param name="priority">The priority of the micro thread action being added.</param>
        /// <returns>The <see cref="MicroThread"/>.</returns>
        /// <exception cref="ArgumentNullException"> If <paramref name="scriptSystem"/>, <paramref name="receiver"/> or <paramref name="action"/> is <see langword="null"/>.</exception>
        /// <remarks>
        /// If the <paramref name="action"/> is a <see cref="ScriptComponent"/> instance method the micro thread will be automatically stopped if the <see cref="ScriptComponent"/> or <see cref="Entity"/> is removed.
        /// </remarks>
        public static MicroThread AddOnEventTask <T>(
            this ScriptSystem scriptSystem,
            EventReceiver <T> receiver,
            Func <T, Task> action,
            long priority = 0L)
        {
            if (scriptSystem == null)
            {
                throw new ArgumentNullException(nameof(scriptSystem));
            }

            if (receiver == null)
            {
                throw new ArgumentNullException(nameof(receiver));
            }

            if (action == null)
            {
                throw new ArgumentNullException(nameof(action));
            }


            return(scriptSystem.AddTask(DoEvent, priority));

            //C# 7 Local function could also use a variable Func<Task> DoEvent = async () => { ... };
            async Task DoEvent()
            {
                var scriptDelegateWatcher = new ScriptDelegateWatcher(action);

                while (scriptSystem.Game.IsRunning && scriptDelegateWatcher.IsActive)
                {
                    if (receiver.TryReceive(out var data))
                    {
                        await action(data);
                    }

                    await scriptSystem.NextFrame();
                }
            }
        }
        /// <summary>
        /// Adds a micro thread function to the <paramref name="scriptSystem"/> that executes when the event is published.
        /// </summary>
        /// <typeparam name="T">The type of the event handler parameter.</typeparam>
        /// <param name="scriptSystem">The <see cref="ScriptSystem"/>.</param>
        /// <param name="eventKey">The event to wait for.</param>
        /// <param name="action">The micro thread function to execute.</param>
        /// <param name="priority">The priority of the micro thread action being added.</param>
        /// <returns>The <see cref="MicroThread"/>.</returns>
        /// <exception cref="ArgumentNullException"> If <paramref name="scriptSystem"/>, <paramref name="eventKey"/> or <paramref name="action"/> is <see langword="null"/>.</exception>
        /// <remarks>
        /// If the <paramref name="action"/> is a <see cref="ScriptComponent"/> instance method the micro thread will be automatically stopped if the <see cref="ScriptComponent"/> or <see cref="Entity"/> is removed.
        /// </remarks>
        public static MicroThread AddOnEventAction <T>(
            this ScriptSystem scriptSystem,
            EventKey <T> eventKey, Action <T> action,
            long priority = 0L)
        {
            if (scriptSystem == null)
            {
                throw new ArgumentNullException(nameof(scriptSystem));
            }

            if (eventKey == null)
            {
                throw new ArgumentNullException(nameof(eventKey));
            }

            if (action == null)
            {
                throw new ArgumentNullException(nameof(action));
            }

            return(scriptSystem.AddOnEventAction(new EventReceiver <T>(eventKey), action, priority));
        }
Example #21
0
        static void Main(string[] args)
        {
            ScriptSystem system = new ScriptSystem(0);
            AsynScript1  a;
            AsynScript2  b;
            AsynScript3  c;
            AsynScript4  d;

            system.Add(a = new ScriptDEMO.AsynScript1());
            system.Add(b = new ScriptDEMO.AsynScript2());
            system.Add(c = new ScriptDEMO.AsynScript3());
            system.Add(d = new ScriptDEMO.AsynScript4());
            system.Start();


            Console.ReadLine();
            system.Remove(a);
            Console.ReadLine();
            system.Remove(b);
            Console.ReadLine();
            system.Remove(c);
            Console.ReadLine();
        }
Example #22
0
        /// <inheritdoc />
        public override void Initialize()
        {
            base.Initialize();

            var gameSettings = Services.GetService <IGameSettingsService>()?.Settings;

            if (gameSettings != null)
            {
                InitializeSettingsFromGameSettings(gameSettings);
            }
            else
            {
                // Initial build settings
                BuildSettings           = ObjectFactoryRegistry.NewInstance <NavigationMeshBuildSettings>();
                IncludedCollisionGroups = CollisionFilterGroupFlags.AllFilter;
                Groups = new List <NavigationMeshGroup>
                {
                    ObjectFactoryRegistry.NewInstance <NavigationMeshGroup>(),
                };
            }

            sceneSystem  = Services.GetSafeServiceAs <SceneSystem>();
            scriptSystem = Services.GetSafeServiceAs <ScriptSystem>();
        }
Example #23
0
 public ScriptProcessor(ScriptSystem scriptSystem)
 {
     this.scriptSystem = scriptSystem;
 }
 protected override void OnSystemAdd()
 {
     gameEventSystem = GameEventSystem.GetFromServices(Services);
     scriptSystem    = Services.GetService <ScriptSystem>();
 }
Example #25
0
File: Game.cs Project: joewan/xenko
        /// <summary>
        /// Initializes a new instance of the <see cref="Game"/> class.
        /// </summary>
        public Game()
        {
            // Register the logger backend before anything else
            logListener = GetLogListener();

            if (logListener != null)
                GlobalLogger.GlobalMessageLogged += logListener;

            // Create and register all core services
            Input = new InputManager(Services);
            Script = new ScriptSystem(Services);
            SceneSystem = new SceneSystem(Services);
            Audio = new AudioSystem(Services);
            UI = new UISystem(Services);
            gameFontSystem = new GameFontSystem(Services);
            SpriteAnimation = new SpriteAnimationSystem(Services);
            ProfilerSystem = new GameProfilingSystem(Services);

            // ---------------------------------------------------------
            // Add common GameSystems - Adding order is important 
            // (Unless overriden by gameSystem.UpdateOrder)
            // ---------------------------------------------------------

            // Add the input manager
            GameSystems.Add(Input);

            // Add the scheduler system
            // - Must be after Input, so that scripts are able to get latest input
            // - Must be before Entities/Camera/Audio/UI, so that scripts can apply 
            // changes in the same frame they will be applied
            GameSystems.Add(Script);

            // Add the UI System
            GameSystems.Add(UI);

            // Add the Audio System
            GameSystems.Add(Audio);

            // Add the Font system
            GameSystems.Add(gameFontSystem);

            //Add the sprite animation System
            GameSystems.Add(SpriteAnimation);

            Asset.Serializer.LowLevelSerializerSelector = ParameterContainerExtensions.DefaultSceneSerializerSelector;

            // Creates the graphics device manager
            GraphicsDeviceManager = new GraphicsDeviceManager(this);

            GameSystems.Add(ProfilerSystem);

            AutoLoadDefaultSettings = true;
        }
 public void NextLevel()
 {
     ScriptSystem.GetInstance().SetScriptCommand(GameObject.Find("DialogWindow"), "ShowDialog", new string[1] {
         "DIALOG_5"
     });
 }
 public EntityScriptSystem(ScriptSystem scriptSystem)
 {
     this.scriptSystem = scriptSystem;
 }
Example #28
0
File: Game.cs Project: cg123/xenko
        /// <summary>
        /// Initializes a new instance of the <see cref="Game"/> class.
        /// </summary>
        public Game()
        {
            // Register the logger backend before anything else
            logListener = GetLogListener();

            if (logListener != null)
                GlobalLogger.GlobalMessageLogged += logListener;

            // Create all core services, except Input which is created during `Initialize'.
            // Registration takes place in `Initialize'.
            Script = new ScriptSystem(Services);
            SceneSystem = new SceneSystem(Services);
            Audio = new AudioSystem(Services);
            gameFontSystem = new GameFontSystem(Services);
            SpriteAnimation = new SpriteAnimationSystem(Services);
            ProfilerSystem = new GameProfilingSystem(Services);

            Content.Serializer.LowLevelSerializerSelector = ParameterContainerExtensions.DefaultSceneSerializerSelector;

            // Creates the graphics device manager
            GraphicsDeviceManager = new GraphicsDeviceManager(this);

            AutoLoadDefaultSettings = true;
        }
Example #29
0
        static void Main(string[] args)
        {
            Scheduler scehduler = new Scheduler();

            scehduler.Add(async() =>
            {
                await Task.Delay(1000);
                Console.WriteLine("AAAAAAAA");
            });


            scehduler.Run();
            System.Threading.Thread.Sleep(1100);
            scehduler.Run();

            Console.ReadLine();


            ScriptSystem tmp = new ScriptSystem(0);

            var a1 = new Test2()
            {
                Name = "1", Priority = 2, testcab = test
            };
            var a2 = new Test2()
            {
                Name = "2", Priority = 1, testcab = test
            };
            var a3 = new Test()
            {
                Name = "3", Priority = 0, testcab = test
            };
            var a4 = new Test3()
            {
                Name = "4", Priority = 0, testcab = test
            };

            tmp.Add(a1);
            tmp.Add(a2);
            tmp.Add(a3);
            tmp.Add(a4);



            tmp.Start();


            Console.ReadLine();

            tmp.Stop();

            Console.ReadLine();

            tmp.Start();

            Console.ReadLine();

            tmp.Remove(a1);
            tmp.Remove(a2);
            tmp.Remove(a3);
            tmp.Remove(a4);

            Console.ReadLine();
        }