IEnumerator CountCoroutine() { _readyTimer.SetValueAndForceNotify(_readyTimer.Value); yield return(new WaitForSecondsRealtime(1)); while (_readyTimer.Value >= 0) { _readyTimer.SetValueAndForceNotify(_readyTimer.Value - 1); yield return(new WaitForSecondsRealtime(1)); } while (_mainTimer.Value > 0) { _mainTimer.Value--; yield return(new WaitForSecondsRealtime(1)); } while (_finishTimer.Value > 0) { _finishTimer.Value--; yield return(new WaitForSecondsRealtime(1)); } while (_resultTimer.Value > 0) { _resultTimer.Value--; yield return(new WaitForSecondsRealtime(1)); } }
IEnumerator ReadyGameCoroutine() { _readyTimer.SetValueAndForceNotify(Mathf.Max(1, _readyTimer.Value)); yield return(new WaitForSecondsRealtime(1)); while (_readyTimer.Value > 0) { _readyTimer.SetValueAndForceNotify(_readyTimer.Value - 1); yield return(new WaitForSecondsRealtime(1)); } }
IEnumerator StartNormalTetrisModeCoroutine() { _normalTetrisModeTimer.SetValueAndForceNotify(initialNormalTetrisModeTime); yield return(new WaitForSecondsRealtime(1)); while (_normalTetrisModeTimer.Value > 0) { _normalTetrisModeTimer.SetValueAndForceNotify(_normalTetrisModeTimer.Value - 1); yield return(new WaitForSecondsRealtime(1)); } }
public void LoadDrumLevel(DrumGameLevel level) { //TODO: this doesn't address the List nature of the level storage at the Switcher, //but this method is a temporary stand-in for switching to a particle-firing mode //for the call and response section levels = new List <DrumGameLevel>(); levels.Add(level); globalLevelIndex.SetValueAndForceNotify(0); }
public override void Initialize() { var allChildrenToRun = from x in Children select x as BehaviorTreeElement; foreach (var ch in allChildrenToRun) { //TODO: will be changed to an actual debugger instead of just unity logs. Issue #3 ch.ObserveEveryValueChanged(x => x.CurrentState) .Do(x => { //BehaviorLogger.Warning(ElementType + " state changed: " + x); if (x == BehaviorState.Fail) { NumberOfFailures.SetValueAndForceNotify(NumberOfFailures.Value + 1); } else if (x == BehaviorState.Success) { NumberOfSuccesses.SetValueAndForceNotify(NumberOfSuccesses.Value + 1); } }) .Subscribe() .AddTo(Disposables); } Initialized = true; }
void Start() { var player = _manager.Player; // 選択中スキル番号の更新 player.ObserveEveryValueChanged(x => x.CurrentSelectedSkill()) .Subscribe(x => _selectedSkillNumber.SetValueAndForceNotify(x)); // スロットの初期化 for (int i = 0; i < SLOT_SIZE; i++) { _slot.Add(null); } // Update毎にスキルスロット内の情報を更新する this.UpdateAsObservable() .Subscribe(_ => { var skills = player.GetSkillsInSlot(); for (int i = 0; i < SLOT_SIZE; i++) { _slot[i] = i >= skills.Count ? null : skills[i]; } }); }
public void LoadSequence(DrumSequence next) { //NOTE: ForceNotify is very useful here, in case [next] is the same as the current sequence! //We may need to add many more ForceNotify calls around these managers //Bruce says making the sequence an Observable instead of a ReactiveProperty would also work reactiveSequence.SetValueAndForceNotify(next); sequenceIndex.SetValueAndForceNotify(0); }
// ------------------------------------------------------------------------------------------------- public void Awake() { _SnakeAcademy = FindObjectOfType(typeof(SnakeAcademy)) as SnakeAcademy; SetStateObject(); Observable.EveryUpdate().Where(_ => _IsPlay && !_State.GameOver).Subscribe ( _ => { _Timer += Time.deltaTime; } ).AddTo(this); Observable.EveryUpdate().Where(_ => _Timer > _SnakeAcademy.resetParameters["Speed"]).Subscribe ( _ => { _Timer = 0f; _State.Next(_Direction); if (_State.GameOver) { SetReward(-1f); Done(); } else if (_State.Eat) { SetReward(1f); _score.SetValueAndForceNotify(_score.Value + 1); } RenderState(); } ).AddTo(this); _score.Subscribe ( _value => { m_ScoreText.text = _value + ""; } ).AddTo(this); RenderState(); _IsPlay = true; }
// --------------------------------------------------------------------------------------------------- // Public Function public void ResetArena() { // Arena scoreA.SetValueAndForceNotify(0); scoreB.SetValueAndForceNotify(0); AgentATransform.Transfer(AgentA.transform); AgentBTransform.Transfer(AgentB.transform); MaxScore = (int)academy.resetParameters["MaxScore"]; focusTeam = RandomTeamOn ? focusTeam.RandomTeam() : TeamType.A; time = 0f; winTeam = TeamType.None; // Agent AgentA.Done(); AgentB.Done(); // Restart Game isPlaying = true; }
IEnumerator FinishGameCoroutine() { _loadTitleTimer.SetValueAndForceNotify(Mathf.Max(1, _loadTitleTimer.Value)); yield return(new WaitForSecondsRealtime(1)); while (_loadTitleTimer.Value > 0) { _loadTitleTimer.Value--; yield return(new WaitForSecondsRealtime(1)); } }
public void RefreshChildren() { _children.Clear(); foreach (Transform child in _transform) { _children.Add(child); } _childrenCount.Value = _children.Count; _currentIndex.SetValueAndForceNotify(0); }
Dictionary <int, int> GenerateDeliveries() { int count = UnityEngine.Random.Range(3, 6); // we are only doing northeastern hemisphere int maxNavUnit = 90 * AstroManager.Instance.navUnitsPerDeg; Dictionary <int, int> destinations = new Dictionary <int, int>(); while (destinations.Count < count) { int navUnit = UnityEngine.Random.Range(1, maxNavUnit + 1); int nearestBox = Mathf.RoundToInt(navUnit / 5f) + 1; if (!destinations.ContainsValue(nearestBox)) { destinations.Add(nearestBox, 1); } } deliveriesRemaining.SetValueAndForceNotify(count); return(destinations); }
IEnumerator ReadyCountCoroutine() { yield return(new WaitForSeconds(0.5f)); _readyCountDownTime.SetValueAndForceNotify(_readyCountDownTime.Value); yield return(new WaitForSeconds(1)); while (_readyCountDownTime.Value > 0) { _readyCountDownTime.Value -= 1; yield return(new WaitForSeconds(1)); } }
private IEnumerator CountDown() { yield return(new WaitForSeconds(.5f)); m_countDownTime.SetValueAndForceNotify(m_countDownTime.Value); yield return(new WaitForSeconds(1f)); while (m_countDownTime.Value > 0) { m_countDownTime.Value -= 1; yield return(new WaitForSeconds(1f)); } }
private async UniTask CountRemainingTimeAsync(CancellationToken token) { await UniTask.Delay(1000, cancellationToken : token); _remainingTime.SetValueAndForceNotify(_remainingTime.Value); while (!token.IsCancellationRequested) { await UniTask.Delay(1000, cancellationToken : token); _remainingTime.Value--; if (_remainingTime.Value == 0) { return; } } }
void Update() { if (PausableTime.Instance.IsPaused) { return; } if (isRotating) { var t = (PausableTime.Instance.Time - rotationStartTime) / (direction > 0 ? unitDurationUp : unitDurationDown); for (int i = 0; i < cylinders.Length; i++) { var isDigitChanging = GetDigit(i, currentValue.Value) != GetDigit(i, currentValue.Value + direction); if (isDigitChanging) { float angleDelta = -unitAngle * direction; if (t < 1.0) { var newAngles = new Vector3( Mathf.Lerp(angles[i].x, angles[i].x + angleDelta, t), Mathf.Lerp(angles[i].y, angles[i].y + angleDelta, t), Mathf.Lerp(angles[i].z, angles[i].z + angleDelta, t) ).FilterCombine(angles[i], rotationAxes); cylinders[i].localRotation = Quaternion.Euler(newAngles); } else { var newAngles = new Vector3( angles[i].x + angleDelta, angles[i].y + angleDelta, angles[i].z + angleDelta ).FilterCombine(angles[i], rotationAxes); cylinders[i].localRotation = Quaternion.Euler(newAngles); angles[i] = newAngles; } } } if (t >= 1.0) { isRotating = false; currentValue.SetValueAndForceNotify(currentValue.Value + direction); BroadcastMessage(CounterMessages.ValueChanged, currentValue.Value, SendMessageOptions.DontRequireReceiver); StartRotating(); } } }
public void UpdateFuel(int newFuel) { fuelAvailable.SetValueAndForceNotify(newFuel); }
private void RefreshCurrentLevel() { activeManagerIndex.SetValueAndForceNotify(activeManagerIndex.Value); globalLevelIndex.SetValueAndForceNotify(globalLevelIndex.Value); }
void OnEnable() { currentPage.SetValueAndForceNotify(0); }
void Start() { // 項目数 _itemNum = GetComponentsInChildren <IPauseItem>().Length; // 移動前のカメラ座標を記録 _startPos = Camera.main.transform.position; // アニメーション情報 _tweener = Camera.main.transform.DOMove(Pausable.Instance.pausing ? _goalPos : _startPos, _duration); // カメラを規定の座標に移動させる this.ObserveEveryValueChanged(x => Pausable.Instance.pausing) .Where(_ => GucchiCS.StageManager.Instance.IsPlay) .Subscribe(x => { // 停止中で再生中でないなら基点の更新 if (x && !_tweener.IsPlaying()) { _startPos = Camera.main.transform.position; _startRot = Camera.main.transform.rotation.eulerAngles; } _tweener = Camera.main.transform.DOMove(x ? _goalPos : _startPos, _duration); Camera.main.transform.DORotate(x ? _goalRot : _startRot, _duration); }); // マウスカーソル移動を取得 this.UpdateAsObservable() .Select(_ => Input.mousePosition) .Subscribe(x => _mousePosition.SetValueAndForceNotify(x)); // 垂直方向の入力をIntに変換する this.UpdateAsObservable() .Where(_ => Pausable.Instance.pausing) .Where(_ => !GucchiCS.ControlState.Instance.IsStateMouse) .Select(_ => { int result = 0; result += Input.GetKeyDown(KeyCode.W) ? 1 : 0; result += Input.GetKeyDown(KeyCode.S) ? -1 : 0; return(-result); }) .Subscribe(x => _inputDirection.SetValueAndForceNotify(x)); // 入力方向が変更されたら選択項目を移動する _inputDirection .Subscribe(x => { SelectNum += x; }); // 決定された時の処理 this.UpdateAsObservable() .Where(_ => Input.GetKeyDown(KeyCode.Space)) .Where(_ => _item != null) .Where(_ => Pausable.Instance.pausing) .Subscribe(_ => { // 対象のアイテムのアクションを実行 _item.OnClick(); }); this.UpdateAsObservable() .Where(_ => Input.GetMouseButtonDown(0)) .Where(_ => _item != null) .Where(_ => Pausable.Instance.pausing) .Subscribe(_ => { Ray ray = Camera.main.ScreenPointToRay(_mousePosition.Value); // 衝突したオブジェクトを全て取得 // TODO: レイの長さを制限する RaycastHit[] hits = Physics.RaycastAll(ray, Mathf.Infinity); foreach (var obj in hits) { // 対象のコンポーネントを特定 var component = obj.transform.GetComponent <IPauseItem>(); if (component != null) { component.OnClick(); break; } } }); // マウス座標が変更された時にレイを飛ばす _mousePosition // ポーズされている .Where(_ => Pausable.Instance.pausing) .Where(_ => GucchiCS.ControlState.Instance.IsStateMouse) .Subscribe(x => { // スクリーン上のマウス座標からのレイ Ray ray = Camera.main.ScreenPointToRay(x); // 衝突したオブジェクトを全て取得 // TODO: レイの長さを制限する RaycastHit[] hits = Physics.RaycastAll(ray, Mathf.Infinity); foreach (var obj in hits) { // 対象のコンポーネントを特定 var component = obj.transform.GetComponent <IPauseItem>(); if (component != null && component != _item) { component.OnEnter(); // ポーズメニューを持ったオブジェクトの番号を選択中にする var trans = transform.GetComponentsInChildren <Transform>() .FirstOrDefault(t => t.GetComponent <IPauseItem>() == component); SelectNum = trans.GetSiblingIndex(); if (_item != null) { _item.OnExit(); } _item = component; } } }); // 選択項目が変更されたら this.ObserveEveryValueChanged(x => _selectNum) .Subscribe(x => { if (_item != null) { _item.OnExit(); } _item = GetComponentsInChildren <IPauseItem>()[x]; _item.OnEnter(); }); }
public void MoveByOne(int direction) { currentNavUnit.SetValueAndForceNotify(currentNavUnit.Value + (1 * direction)); }