Exemplo n.º 1
0
        /// <summary>
        /// Helper function to handle spawn tasks
        ///
        ///
        /// </summary>
        private void HandleSpawnPlayerTasks()
        {
            SpawnPlayerTask[] tasks = _mailbox.GetSubscribedTasksForType <SpawnPlayerTask>(this);

            for (int i = 0; i < tasks.Length; i++)
            {
                SpawnPlayerTask task = tasks[i];
                task.IsFinished = true;
                _mailbox.RemoveTask(task);

                GameObject player = _charactersManager.CreatePlayer(
                    task.Position,
                    task.EntityName);

                var hub = player.GetComponent <Hub>();

                hub.Level      = task.Level;
                hub.Health     = task.Health;
                hub.Experience = task.Experience;
            }
        }
Exemplo n.º 2
0
        protected override void OnUpdate()
        {
            _tasks.Clear();

            Tasks.UpdateInventoryTask[] tasks = _mailbox.GetSubscribedTasksForType <Tasks.UpdateInventoryTask>(this);

            for (int i = 0; i < tasks.Length; i++)
            {
                Tasks.UpdateInventoryTask updateInventoryTask = tasks[i];
                _tasks[updateInventoryTask.EntityName] = updateInventoryTask;
                _mailbox.RemoveTask(updateInventoryTask);
            }

            this.Entities
            .WithoutBurst()
            .ForEach((Character character, Inventory inventory) =>
            {
                if (_tasks.TryGetValue(character.name, out Tasks.UpdateInventoryTask task))
                {
                    if (task.shoes_changed)
                    {
                        inventory.Bottom = _spriteDatabase.GetWearable(task.Bottom);
                    }

                    if (task.clothes_changed)
                    {
                        inventory.Top = _spriteDatabase.GetWearable(task.Top);
                    }

                    if (task.hat_changed)
                    {
                        inventory.Head = _spriteDatabase.GetWearable(task.Head);
                    }

                    if (task.accesory_changed)
                    {
                        inventory.Accessory = _spriteDatabase.GetWearable(task.Accessory);
                    }

                    if (task.weapon_changed)
                    {
                        inventory.Weapon = _spriteDatabase.GetWearable(task.Weapon);
                    }

                    task.IsFinished = true;
                }
            })
            .Run();
        }
        protected override void OnUpdate()
        {
            Tasks.FollowPathTask[] tasks = _mailbox.GetSubscribedTasksForType <Tasks.FollowPathTask>(this);


            for (int i = 0; i < tasks.Length; i++)
            {
                Tasks.FollowPathTask movementTask = tasks[i];
                _tasksToBeScheduled[movementTask.EntityName] = movementTask;
                _mailbox.RemoveTask(movementTask);
            }

            if (_tasksToBeScheduled.Count > 0)
            {
                this.Dispatch();
            }

            _tasksToBeScheduled.Clear();
            _ecbSystem.AddJobHandleForProducer(this.Dependency);
        }
Exemplo n.º 4
0
        protected override void OnUpdate()
        {
            _tasks.Clear();

            Tasks.UpdateHubTask[] tasks = _mailbox.GetSubscribedTasksForType <Tasks.UpdateHubTask>(this);

            for (int i = 0; i < tasks.Length; i++)
            {
                Tasks.UpdateHubTask updateHubTask = tasks[i];
                _tasks[updateHubTask.EntityName] = updateHubTask;
                _mailbox.RemoveTask(updateHubTask);
            }

            this.Entities
            .WithoutBurst()
            .ForEach((Character character, Hub hub) =>
            {
                if (_tasks.TryGetValue(character.name, out Tasks.UpdateHubTask task))
                {
                    if (task.Health.HasValue)
                    {
                        hub.Health = task.Health.Value;
                    }

                    if (task.Level.HasValue)
                    {
                        hub.Level = task.Level.Value;
                    }

                    if (task.Experience.HasValue)
                    {
                        hub.Experience = task.Experience.Value;
                    }

                    task.IsFinished = true;
                }
            })
            .Run();
        }