예제 #1
0
        // Use this for initialization
        void Start()
        {
            PlayerState.Do(ps => {
                PlayerStateClear.Dispose();
                PlayerStateClear = new CompositeDisposable();
                PlayerStateClear.AddTo(this);
            }).Where(ps => ps != null).Subscribe(ps => {
                AvatarRight.onClick.AsObservable().Select(p => 1)
                .Merge(AvatarLeft.onClick.AsObservable().Select(p => - 1))
                .Subscribe(pos => {
                    var list         = GameManager.GameConfig.CampaignConfig.PlayerAvatarList;
                    var currentIndex = list.IndexOf(GameManager.GameConfig.CampaignConfig.PlayerAvatars[PlayerState.Value.Avatar]);
                    var nextIndex    = currentIndex + pos;

                    if (nextIndex < 0)
                    {
                        nextIndex = list.Count - 1;
                    }
                    if (nextIndex >= list.Count)
                    {
                        nextIndex = 0;
                    }

                    PlayerState.Value.Avatar = list[nextIndex].Name;
                }).AddTo(PlayerStateClear);
            }).AddTo(this);
        }
 public AsyncKinectManager()
 {
     SensorDisconnected = _Sensor
                          .Select(s => _sensorCache)
                          .Where(s => s != null)
                          .ToReadOnlyReactiveProperty(null, ReactivePropertyMode.None);
     SensorConnected = _Sensor
                       .Do(s => _sensorCache = s)
                       .Where(s => s != null)
                       .ToReadOnlyReactiveProperty(null, ReactivePropertyMode.None);
 }
예제 #3
0
 // Use this for initialization
 void Start()
 {
     PlayerState.Do(ps =>
     {
         PlayerStateClear.Dispose();
         PlayerStateClear = new CompositeDisposable();
         PlayerStateClear.AddTo(this);
     }).Where(ps => ps != null).Subscribe(ps =>
     {
         ps.AvatarProperty.StartWith(ps.Avatar).Subscribe(a =>
         {
             Icon.sprite = GameManager.GameConfig.CampaignConfig.PlayerAvatars[a].Avatar;
         }).AddTo(PlayerStateClear);
     }).AddTo(this);
 }
예제 #4
0
        private void Awake()
        {
            if (Debug.isDebugBuild)
            {
                this.UpdateAsObservable()
                .Select(_ => Input.GetKeyDown(KeyCode.R))
                .Where(x => x)
                .Subscribe(_ => SceneManager.LoadScene(SceneManager.GetActiveScene().name));
            }

            _inputProvider = GetComponent <InputProvider>();
            powerGauge     = GetComponent <PowerGauge>();

            _gameState
            .Do(state =>
            {
                _isPlayable.Value =
                    state == GameState.Title ||
                    state == GameState.InGame ||
                    state == GameState.Result;
            })
            .Subscribe(state =>
            {
                switch (state)
                {
                case GameState.Initialize:
                    OnInitialize();
                    break;

                case GameState.Title:
                    if (Debug.isDebugBuild)
                    {
                        Debug.Log("<color=yellow>Title</color>");
                    }
                    OnStart();
                    break;

                case GameState.Introduction:
                    if (Debug.isDebugBuild)
                    {
                        Debug.Log("<color=yellow>Introduction</color>");
                    }
                    OnIntroduction();
                    break;

                case GameState.InGame:
                    if (Debug.isDebugBuild)
                    {
                        Debug.Log("<color=yellow>InGame</color>");
                    }
                    OnGameStart();
                    break;

                case GameState.Ending:
                    if (Debug.isDebugBuild)
                    {
                        Debug.Log("<color=yellow>Ending</color>");
                    }
                    OnLaunch();
                    break;

                case GameState.Result:
                    if (Debug.isDebugBuild)
                    {
                        Debug.Log("<color=yellow>Result</color>");
                    }
                    rocket.PlayAnimation("Finish");
                    break;
                }
            }).AddTo(gameObject);

            _onInitialized
            .Subscribe(complete =>
            {
                if (Debug.isDebugBuild)
                {
                    Debug.Log("Initialized");
                }
            });

            rocket.Goaled.Where(x => x)
            .Subscribe(_ => _gameState.Value = GameState.Result);

            //narrative.ExecutingBlock
            //    .DelayFrame(30)
            //    .Subscribe(block =>
            //    {
            //        // Fungusのナレーションが終わったらGameStateを更新
            //        Observable.Return(Unit.Default)
            //            .SkipWhile(_ => block.IsExecuting())
            //            .Subscribe(_ =>
            //            {
            //                switch (block.BlockName)
            //                {
            //                    case "Intro":
            //                        _gameState.Value = GameState.InGame;
            //                        break;
            //                    case "InGame":
            //                        _gameState.Value = GameState.Ending;
            //                        break;
            //                    case "Ending":
            //                        _gameState.Value = GameState.Result;
            //                        break;
            //                    default:
            //                        Debug.LogError("Unknown Block");
            //                        break;
            //                }
            //            });
            //    });
        }
예제 #5
0
    public void PostInit()
    {
        SceneLoader    root = SceneLoader.Instance;
        BindingManager bind = BindingManager.Instance;

        (from order in Singleton <PrestigeRunner> .Instance.PrestigeTriggered
         where order == PrestigeOrder.PrestigePost
         select order).Do(delegate
        {
        }).Subscribe(delegate
        {
            ResetChunks();
            SpawnBaseCamp();
        }).AddTo(root);
        BlocksClearTriggered.Do(delegate
        {
        }).Subscribe(delegate
        {
            if (!IsNextChunkBoss(Singleton <WorldRunner> .Instance.CurrentChunk.Value.Index))
            {
                SpawnChunkIncrease();
            }
            else if (PlayerData.Instance.BossFailedLastTime.Value)
            {
                SpawnChunkRetry();
            }
            else
            {
                SpawnBoss();
            }
        }).AddTo(root);
        (from _ in Singleton <BossSuccessRunner> .Instance.SequenceClosed
         where !ShouldGoToMap(Singleton <WorldRunner> .Instance.CurrentChunk.Value.Index, PlayerData.Instance.LifetimeChunk.Value)
         select _).Do(delegate
        {
        }).Subscribe(delegate
        {
            SpawnChunkIncrease();
        }).AddTo(root);
        (from _ in Singleton <BossSuccessRunner> .Instance.SequenceClosed
         where ShouldGoToMap(Singleton <WorldRunner> .Instance.CurrentChunk.Value.Index, PlayerData.Instance.LifetimeChunk.Value)
         select _).Do(delegate
        {
        }).Subscribe(delegate
        {
            root.StartCoroutine(MapSequenceRoutine());
        }).AddTo(root);
        (from win in Singleton <BossBattleRunner> .Instance.BossBattleResult.Skip(1)
         where !win
         select win).Delay(TimeSpan.FromSeconds(3.0)).Subscribe(delegate
        {
            if (PlayerData.Instance.BossFailedLastTime.Value)
            {
                SpawnChunkRetry();
            }
        }).AddTo(root);
        (from tuple in Singleton <BossBattleRunner> .Instance.BossBattleActive.CombineLatest(Singleton <BossBattleRunner> .Instance.BossCurrentHP, (bool active, BigDouble hp) => new
        {
            active,
            hp
        })
         where tuple.active
         select tuple).Subscribe(tuple =>
        {
            ChunkMaxHealth.Value     = Singleton <BossBattleRunner> .Instance.BossFullHP.Value;
            CurrentChunkHealth.Value = tuple.hp;
        }).AddTo(root);
        (from active in Singleton <BossBattleRunner> .Instance.BossBattleActive.Pairwise()
         where !active.Current && active.Previous
         select active).Subscribe(delegate
        {
            CurrentChunkHealth.Value = BigDouble.ZERO;
        }).AddTo(root);
        BlocksClearTriggered.Subscribe(delegate
        {
            CurrentChunkHealth.Value = BigDouble.ZERO;
        }).AddTo(root);
        (from _ in (from _ in TryBossAgainTriggered
                    select(from moving in Singleton <CameraMoveRunner> .Instance.IsCameraMoving
                           where !moving
                           select moving).Take(1)).Switch()
         where !Singleton <BossBattleRunner> .Instance.BossLevelActive.Value
         select _).Subscribe(delegate
        {
            SpawnBossRetry();
        }).AddTo(root);
        if (Singleton <WorldRunner> .Instance.CurrentChunk.Value.Index == 0)
        {
            SpawnBaseCamp();
        }
        else
        {
            SpawnGameLoaded();
        }
        if (PlayerData.Instance.LifetimeChunk.Value == 0 && PersistentSingleton <GameSettings> .Instance.IntroSequenceOn)
        {
            BindingManager.Instance.MapPanel.SetActive(value: true);
            BindingManager.Instance.MapCamera.IntroCameraDrive();
        }
        Singleton <TntRunner> .Instance.TntTriggered.Subscribe(delegate(BigDouble damage)
        {
            CauseDamageToRandomBlocks(damage, (128L * Singleton <CumulativeBonusRunner> .Instance.BonusMult[12].Value).ToInt());
            Vector3 position = bind.CameraCtrl.transform.position;
            CauseBlastWave(position.x0z(), 10f);
        }).AddTo(root);

        HeroDamageRunner mainHeroDamage = Singleton <HeroTeamRunner> .Instance.GetOrCreateHeroDamageRunner(0);

        Singleton <AutoMineRunner> .Instance.DamageTriggered.Subscribe(delegate
        {
            CauseDamageToClosestBlockOrBoss(mainHeroDamage.Damage.Value *PersistentSingleton <GameSettings> .Instance.AutoMineMultiplier, bind.TornadoDamageNode.position);
        }).AddTo(root);

        GoldBlockReward = BlocksInChunk.CombineLatest(Singleton <WorldRunner> .Instance.CurrentBiomeConfig, Singleton <GoldFingerRunner> .Instance.GoldFingerActive, GoldBlocks, (int blocks, BiomeConfig cnfg, bool goldFinger, int golds) => (!goldFinger) ? (new BigDouble(blocks) * cnfg.BlockReward / golds) : (cnfg.BlockReward * 13.5)).TakeUntilDestroy(root).ToReactiveProperty();
        (from gf in Singleton <GoldFingerRunner> .Instance.GoldFingerActive.Pairwise()
         where !gf.Current && gf.Previous
         select gf).Subscribe(delegate
        {
            GoldBlockReward.SetValueAndForceNotify(Singleton <WorldRunner> .Instance.CurrentBiomeConfig.Value.BlockReward * 13.5);
        }).AddTo(root);
        CanBeHurt = Singleton <BossBattleRunner> .Instance.BossBattlePaused.CombineLatest(Singleton <PrestigeRunner> .Instance.SequenceDone, Singleton <WorldRunner> .Instance.MapSequence, (bool bossPause, bool prestigeDone, bool map) => !bossPause && prestigeDone && !map).TakeUntilDestroy(root).ToReadOnlyReactiveProperty();

        TickerService.MasterTicksFast.Subscribe(delegate(long ticks)
        {
            m_timeSinceLastHitSound     += ticks;
            m_timeSinceLastDestroySound += ticks;
        }).AddTo(root);
        (from triggered in BlocksClearTriggered
         where triggered
         select triggered).Subscribe(delegate
        {
            overflowChunk = false;
        }).AddTo(root);
    }
예제 #6
0
        public static void RequestFromPlayers <T>(PhotonRequest <T> request, Action <Action <int, T> > ValueReturnedCallback, Action <List <T> > FinishedCallback, params object[] args)
        {
            ReactiveProperty <List <T> > props = new ReactiveProperty <List <T> >();

            props.Value = new List <T>();

            // Give back a method that can be called to inform that a value has been received
            ValueReturnedCallback.Invoke((i, v) => {
                List <T> a = props.Value;
                a.Add(v); // Ignore the index for now
                props.SetValueAndForceNotify(a);
            });

            bool finished = false; // Safegaurd
            Action <List <T> > doMethod;

            doMethod = a => {
                if (finished)
                {
                    throw new Exception("Already finished");
                }

                if (!AreAllRequestsReceived(request.Players, (List <T>)props.Value))
                {
                    return;
                }

                // Old, to remove
                //for (int i = 0; i < a.Count; i++) {
                //    if (!request.DetermineHasReturned(data.Value[i])) {
                //        return;
                //    }
                //}

                // TODO Clean up disconnect callback
                // OnPlayerDisconnect -= doMethod;

                finished = true;
                FinishedCallback.Invoke(a);
            };

            // TODO Deal with disconnecting players by calling doMethod again when they do
            // OnPlayerDisconnect += doMethod;

            // TODO Some kind of check to see if it's taking too long, to pause the game

            // Sub to reactive properties
            props.Do(doMethod).Subscribe();

            if (args == null || args.Length == 0)
            {
                request.View.RPC(request.RPCName, request.Players);
            }
            else if (request.SerialiseArgsArray)
            {
                object[] serialisedArgs = new object[args.Length];
                for (int i = 0; i < args.Length; i++)
                {
                    serialisedArgs[i] = Serialisation.ToBinary(args[i]);
                }
                // Convert to object[] where each element is a byte[], then convert back to object[] on the other side
                // Serialise each array object individually and send object[] instead since RPC takes object[]
                request.View.RPC(request.RPCName, request.Players, serialisedArgs);
            }
            else
            {
                request.View.RPC(request.RPCName, request.Players, args);
            }
        }