Пример #1
0
        public static SimpleCoroutineAwaiter <UnityEngine.Object> GetAwaiter(this ResourceRequest instruction)
        {
            var awaiter = new SimpleCoroutineAwaiter <UnityEngine.Object>();

            UnitySystem.RunOnUnityScheduler(() => UnitySystem.SystemBehavior.StartCoroutine(
                                                InstructionWrappers.ResourceRequest(awaiter, instruction)));
            return(awaiter);
        }
Пример #2
0
        static SimpleCoroutineAwaiter <T> GetAwaiterReturnSelf <T>(T instruction)
        {
            var awaiter = new SimpleCoroutineAwaiter <T>();

            UnitySystem.RunOnUnityScheduler(() => UnitySystem.SystemBehavior.StartCoroutine(
                                                InstructionWrappers.ReturnSelf(awaiter, instruction)));
            return(awaiter);
        }
Пример #3
0
        public static SimpleCoroutineAwaiter <AssetBundle> GetAwaiter(this AssetBundleCreateRequest instruction)
        {
            SystemBehavior behavior = UnitySystem.SystemBehavior;

            var awaiter = new SimpleCoroutineAwaiter <AssetBundle>();

            UnitySystem.RunOnUnityScheduler(() => UnitySystem.SystemBehavior.StartCoroutine(
                                                InstructionWrappers.AssetBundleCreateRequest(awaiter, instruction)));
            return(awaiter);
        }
Пример #4
0
            public void Complete(T result, Exception e)
            {
                Assert(!_isDone);

                _isDone    = true;
                _exception = e;
                _result    = result;

                // Always trigger the continuation on the unity thread when awaiting on unity yield
                // instructions
                if (_continuation != null)
                {
                    UnitySystem.RunOnUnityScheduler(_continuation);
                }
            }
Пример #5
0
    /// <summary> Initializes the views for the game. </summary>
    private void InitializeViews()
    {
        var pistolModel  = UnitySystem.RetrieveModel <IFireableWeaponModel>("Weapon/Pistol");
        var shotgunModel = UnitySystem.RetrieveModel <IFireableWeaponModel>("Weapon/Shotgun");

        _firableWeaponController = new FireableWeaponController(AllServices.RaycastService,
                                                                AllServices.RandomNumberGenerator);
        _playerController = new PlayerController(_player, _firableWeaponController);

        var weapons = from stat in GlobalResources.WeaponStats.Take(5)
                      let model = stat.AmmoType == AmmoType.Pistol ? pistolModel : shotgunModel
                                  let weapon = new FireableWeapon(new FireableWeaponTemplate(model, null, stat))
                                               select(IItemModel) weapon;

        var ammos = GlobalResources.Ammos.Cast <IItemModel>().Take(5);

        weapons.Concat(ammos)
        .Take(10)
        .Select(w => new InventoryStack(w, w.StackAmount))
        .ToList()
        .ForEach(itemStack => _player.Inventory.AddToStorage(itemStack));

        SwitchSlots(1);
    }