Beispiel #1
0
        private void StartPlaying()
        {
            if (m_FadeInData != null)
            {
                float val = m_FadeInData.Fade.Evaluate(0);
                if (m_FadeInData.Type == AudioFadeInFilterData.EFadeType.VOLUME)
                {
                    AudioSource.volume = val;
                }
                else if (m_FadeInData.Type == AudioFadeInFilterData.EFadeType.PITCH)
                {
                    AudioSource.pitch = val;
                }
            }

            AudioSource.Play();

            _signalBus?.Fire(new AudioBeganPlayingSignal()
            {
                clipID = ClipID
            });

            for (int i = 0; i < m_WaitUntilStartedInstructions.Count; i++)
            {
                m_WaitUntilStartedInstructions[i].StopWaiting();
            }
            m_WaitUntilStartedInstructions.Clear();

            if (m_FadeInData != null)
            {
                float duration = m_FadeInData.Fade.keys[m_FadeInData.Fade.length - 1].time;

                StartCoroutine(StartFadeCR(m_FadeInData.Fade, 0, duration, false, m_FadeInData.Type == AudioFadeInFilterData.EFadeType.PITCH));
            }
            if (m_FadeOutData != null)
            {
                float duration     = m_FadeOutData.Fade.keys[m_FadeOutData.Fade.length - 1].time;
                float clipDuration = AudioSource.clip.length;

                StartCoroutine(StartFadeCR(m_FadeOutData.Fade, clipDuration - duration, duration, false, m_FadeOutData.Type == AudioFadeOutFilterData.EFadeType.PITCH));
            }
        }
Beispiel #2
0
        private void Init(SignalBus signalBus)
        {
            _signalBus             = signalBus;
            _toggleInventoryButton = GameObject.Find("InventoryToggleButton").GetComponent <Button>();
            _toggleInventoryButton.onClick.AddListener(() =>
            {
                _signalBus.Fire(new UIToggleSignal(UIPanelType.Inventory));
            });


            _getOutCarButton = GameObject.Find("GetOutCarButton").GetComponent <Button>();
            _getOutCarButton.onClick.AddListener(() =>
            {
                _getOutCarButton.gameObject.SetActive(false);
                Debug.Log("Get Out signal fired");
                _signalBus.Fire(new GetOutCarSignal());
            });

            _signalBus.Subscribe <GetInCarSignal>((signal) =>
            {
                _getOutCarButton.gameObject.SetActive(true);
            });
        }
        protected virtual void StartReader()
        {
            SceneInfoSelector.CurrentValue.SceneInfo.Encounter.Content.NonImageContent.SetCurrentSection(SectionSelector.CurrentValue.SelectedSection);
            SectionSelector.CurrentValue.SelectedSection.SetCurrentTab(TabSelector.CurrentValue.SelectedTab);

            SignalBus.Fire <SerializeEncounterSignal>();
            var sceneInfo       = SceneInfoSelector.CurrentValue.SceneInfo;
            var encounterStatus = new EncounterStatus(new EncounterBasicStatus(), new EncounterContentStatus());
            var encounter       = new UserEncounter(sceneInfo.User, sceneInfo.Encounter, encounterStatus);
            var encounterResult = new WaitableTask <UserEncounter>(encounter);
            var loadingInfo     = new LoadingReaderSceneInfo(sceneInfo.User, sceneInfo.LoadingScreen, encounterResult);

            ReaderSceneStarter.StartScene(loadingInfo);
        }
Beispiel #4
0
    private void CheckFieldPart(Collider collisionCollider)
    {
        if (collisionCollider.GetComponent <FieldPart>() == null)
        {
            return;
        }

        var positionOnPlatform = collisionCollider.transform.position + _spherePosShift;

        _lastStablePosition = positionOnPlatform;
        _signalBus.Fire(new PositionChangedSignal {
            Position = positionOnPlatform
        });
    }
        public void AddNewHighScore(string name)
        {
            Assert.IsTrue(pendingHighScore.HasValue);
            var newEntry = new HighScoreEntry(name, pendingHighScore.Value);

            pendingHighScore = null;

            var newEntryIndex = FindIndexOfNewEntry(newEntry.score);

            entries.Insert(newEntryIndex, newEntry);
            SaveEntries(entries);

            signalBus.Fire <NewHighScoreInsertedSignal>();
        }
Beispiel #6
0
        public override void Interact()
        {
            StopAnimation();

            IsCollected = true;

            transform.DOMove(_ui_context.CoinPanelPosition, 0.3f)
            .SetEase(Ease.OutCirc)
            .OnComplete(() => {
                SignalBus.Fire(new CollectCoinSignal {
                    coin_view = this
                });
            }).SetLink(gameObject, LinkBehaviour.KillOnDestroy);
        }
        protected override void OnUpdate()
        {
            int currentCount = query.CalculateEntityCount();

            if (currentCount == previousCount)
            {
                return;
            }

            signalBus.Fire(new AliveEnemiesSignal {
                AliveEnemiesCount = currentCount
            });
            previousCount = currentCount;
        }
Beispiel #8
0
        private void Initialize()
        {
            _signalBus.Subscribe <PhotoTakenSignal>(s => SerializePhotoFromByteArray(s.PhotoData, s.PhotoName));
            _signalBus.Subscribe <PhotoAnalyzedSignal>(s => AppendAnalyticsData(s.PhotoName, s.IsAnybodySmiling));
            _signalBus.Subscribe <MiniaturesPreparedSignal>(() =>
            {
                foreach (PhotoData data in _photoData)
                {
                    _signalBus.Fire(new UpdateMiniatureSignal(data.Smile, data.Name));
                }
            });
            _signalBus.Subscribe <ClearAllDataSignal>(ClearAllData);

            if (!PlayerPrefs.HasKey("PhotoCounter"))
            {
                PlayerPrefs.SetInt("PhotoCounter", 0);
                PlayerPrefs.Save();
            }

            _counter = PlayerPrefs.GetInt("PhotoCounter");

            _photoData = GetSerializedPhotoData();
        }
Beispiel #9
0
    void EnterStartState(Vector2 vp1)
    {
        _ustate  = UnitState.UNIT_START;
        _vorigin = vp1;
        UnitOriginPointEvt evt = new UnitOriginPointEvt();

        evt.vorigin = vp1;
        _signalBus.Fire(evt);
    }
Beispiel #10
0
        private IEnumerator AddInfoFromQueue(float waitTime)
        {
            yield return(new WaitForSeconds(waitTime));

            if (_notificationQueue.Count > 0)
            {
                var info = _notificationQueue.Dequeue() as UINotificationContentInfo;
                _signalBus.Fire(new UIAddContentSignal {
                    ContainerInfo = new UIContainerInfo()
                    {
                        ContainerId = container.ContainerId
                    }, Info = info
                });
            }
        }
            public override void OnStateEnter()
            {
                base.OnStateEnter();

                LoadStaticDataSignal signal = new LoadStaticDataSignal()
                {
                    Promise = new Promise()
                };

                signal.Promise.Then(
                    () => { StartupModel.LoadingProgress.Value = StartupModel.ELoadingProgress.LoadUserData; }
                    ).Catch(e => { Debug.LogError("Exception seeding static data 2: " + e.ToString()); });

                SignalBus.Fire(signal);
            }
Beispiel #12
0
    void LateUpdate()
    {
        Vector3 toCar = _steering.transform.position - transform.position;

        transform.rotation = Quaternion.LookRotation(toCar);

        transform.position = Vector3.Lerp(transform.position, _targetPosition, smoothingPos);

        bool canSteer, canDrive;

        if (_steering.IsGrounded(out canSteer, out canDrive))
        {
            _signalBus.Fire <DisableTrackingCamSignal>();
        }
    }
    public bool TryChangePlayerMoney(int team, int deltaMoney)
    {
        if (playersData[team].money + deltaMoney >= 0)
        {
            playersData[team].money += deltaMoney;

            _signalBus.Fire(new MoneyChangedSignal()
            {
                teamId = team, newAmount = playersData[team].money
            });

            return(true);
        }
        return(false);
    }
Beispiel #14
0
        public void SetMainScreen(MainScreenEnum mainScreen)
        {
            if (mainScreen != CurrentScreen)
            {
                CurrentScreen = mainScreen;

                mapCanvas.enabled       = CurrentScreen == MainScreenEnum.Map;
                inboxCanvas.enabled     = CurrentScreen == MainScreenEnum.Inbox;
                tasksCanvas.enabled     = CurrentScreen == MainScreenEnum.Tasks;
                buildingsCanvas.enabled = CurrentScreen == MainScreenEnum.Buildings;
                builderCanvas.enabled   = CurrentScreen == MainScreenEnum.Builder;

                signalBus.Fire <MainScreenChangedSignal>();
            }
        }
Beispiel #15
0
            public override void OnStateEnter()
            {
                base.OnStateEnter();

                LoadUserDataSignal signal = new LoadUserDataSignal()
                {
                    Promise = new Promise()
                };

                signal.Promise.Then(
                    () => { StartupModel.LoadingProgress.Value = StartupModel.ELoadingProgress.LoadHud; }
                    ).Catch(e => { StartupModel.LoadingProgress.Value = StartupModel.ELoadingProgress.CreateUserData; });

                SignalBus.Fire(signal);
            }
Beispiel #16
0
        public IEnumerable Subscribe_WhenSignalFired_ExecutesSeveralCallbacks()
        {
            SignalBus bus = new SignalBus();
            int       firstCallbackCount  = 0;
            int       secondCallbackCount = 0;

            bus.Subscribe((TestSignal signal) => { firstCallbackCount++; });
            bus.Subscribe((TestSignal signal) => { secondCallbackCount++; });

            bus.Fire(new TestSignal());

            Assert.IsTrue(firstCallbackCount == 1 && secondCallbackCount == 1);

            yield return(null);
        }
Beispiel #17
0
 public void OnPointerClick(PointerEventData eventData)
 {
     if (WorkerCoin.dragging)
     {
         return;
     }
     _signalBus.Fire(new TileClickedSignal()
     {
         position = transform.position
     });
     clicked = true;
     editBox.transform.position = new Vector3(transform.position.x, 15, transform.position.z);
     tile.SetActive(false);
     editBox.SetActive(true);
 }
        private IEnumerator ChangeState()
        {
            //it need to wait until the camera have arrived to the end position
            while (isArrive == false)
            {
                yield return(null);
            }

            // when the camera have arrived to the end position
            //than set the runTime State to the BuildingInfo
            runtimeStateController.CurrentState = RunTimeState.BUILDING_INFO;
            // the signal bus is to early instantiate as the ShowBuildingData in Game scene new declarated
            signalBus.Fire(new ShowBuildingData {
            });
        }
        private void BulletViewOnOnCollide(BulletView bulletView, Collider other)
        {
            if (bulletView.CompareTag("Bullet") && other.CompareTag("EnemyBullet"))
            {
                return;
            }

            if (bulletView.CompareTag("EnemyBullet") && other.CompareTag("Bullet"))
            {
                return;
            }

            if (bulletView.CompareTag("EnemyBullet") && other.CompareTag("Player"))
            {
                signalBus.Fire(new PlayerHitSignal());
                RemoveBullet(bulletView);
            }

            if (bulletView.CompareTag("Bullet") && other.CompareTag("Enemy"))
            {
                signalBus.Fire(new EnemyHitSignal(other.GetComponent <EnemyView>().EnemyData));
                RemoveBullet(bulletView);
            }
        }
Beispiel #20
0
        private void HandleEnemyShipDestroyed(EnemyShipDestroyedSignal signal)
        {
            EnemyAgent next = GetFirstAliveAgentInColumn(signal.FleetCoordinate.ColumnIndex);

            if (next != null)
            {
                next.FireAtWill();
                return;
            }

            _destroyedColumns++;
            if (_destroyedColumns == _fleetModel.Length)
            {
                _signalBus.Fire <FleetDestroyedSignal>();
            }
        }
        public void Create(LevelConfig levelConfig)
        {
            Reset();
            foreach (var configEnemyInfo in levelConfig.enemyInfos)
            {
                var enemyData        = new EnemyData(configEnemyInfo.enemyConfig);
                var spawnCoordinates = new Vector3(configEnemyInfo.startPosition.x, 0, configEnemyInfo.startPosition.y);

                signalBus.Fire(new SpawnEnemiesSignal(enemyData, spawnCoordinates));

                enemyData.IsDead.Where(isDead => isDead == true)
                .Subscribe(_ => { OnDestroyEnemy(enemyData); });

                enemies.Add(enemyData);
            }
        }
 public ProgressService(SignalBus signalBus)
 {
     signalBus.Subscribe <PlayerActionSignal>(signal =>
     {
         if (signal.Data.progress != null)
         {
             var newProgress   = signal.Data.progress;
             var expLvlChanged = Progress != null && newProgress.expeditionLevel != Progress.expeditionLevel;
             Progress          = newProgress;
             if (expLvlChanged)
             {
                 signalBus.Fire <ExpeditionLevelSignal>();
             }
         }
     });
 }
Beispiel #23
0
    void OnTriggerEnter(Collider other)
    {
        Vector3 targetPos = transform.parent.position;

        Camera child = transform.parent.GetComponentInChildren <Camera>(true);

        if (child)
        {
            targetPos = child.transform.position;
        }

        _signalBus.Fire(new EnableTrackingCamSignal()
        {
            trackingPosition = targetPos
        });
    }
    private UnitFacade ProcessHit(UnitFacade hitUnit, UnitFacade striker, int damage)
    {
        if (hitUnit != null)
        {
            if (hitUnit.UnitModel.hp > 0)
            {
                hitUnit.UnitModel.DoDamage(damage);
                if (hitUnit.UnitModel.hp <= 0)
                {
                    _signalBus.Fire(new UnitDestroyedBySignal(hitUnit, striker));
                }
            }
        }

        return(hitUnit);
    }
Beispiel #25
0
 public void AddPoints(int value)
 {
     if (value == 0)
     {
         return;
     }
     LocationPoints.Value += value;
     if (LocationPoints.Value > config.TargetLocationPointsValue)
     {
         LocationPoints.Value = config.TargetLocationPointsValue;
     }
     if (LocationPoints.Value == config.TargetLocationPointsValue)
     {
         signalBus.Fire <LocationMissionComplete>();
     }
 }
    private void TryToReduceCooldown()
    {
        var currentChance = Random.Range(0f, 1f);

        if (currentChance <= chance)
        {
            signalBus.Fire(new BrokenClockTriggered {
                reducedTime = reduceValue
            });
            anim.SetTrigger("brokenClockTriggered");
            for (int i = 0; i < skills.Length; i++)
            {
                skills[i].ReduceCoolDown(reduceValue);
            }
        }
    }
        public void SendStatsRequest(int id, Action <string> callback)
        {
            _loadingPanel.SetActive(true);
            callback += s =>
            {
                _signalBus.Fire <UpdatePlayerLabelsSignal>();
                _loadingPanel.SetActive(false);
            };
            var restRequest = new RestRequest("stats/get", HttpMethod.Get);
            var wrapper     = new RequestWrapper(restRequest, new CallbackWrapper(callback), new CallbackWrapper(_logError));
            var headers     = new Dictionary <string, string>();

            headers.Add("id", id.ToString());

            _restClient.SendRequest(wrapper, headers);
        }
 public void OnCLoseEditor()
 {
     // Нажата кнопка выхода из редактора (для standalone сборок редактора).
     _signalBus.Fire(new ShowMessageSignal
     {
         Message  = "Are you really want to exit the Editor?",
         Buttons  = MessageBoxButton.Yes | MessageBoxButton.No,
         Callback = result =>
         {
             if (result == MessageBoxButton.Yes)
             {
                 Application.Quit();
             }
         }
     });
 }
Beispiel #29
0
 public void AddToMoney(int amount)
 {
     _signalBus.Fire(new AddMoneySignal()
     {
         amount = amount
     });
     _signalBus.Fire(new NotificationSignal()
     {
         rewardType = 1, rewardCount = amount
     });
 }
Beispiel #30
0
        protected virtual void RetrievedLocks(TaskResult <Dictionary <int, EncounterEditLock> > result)
        {
            if (!result.HasValue())
            {
                return;
            }

            var locks     = result.Value;
            var sceneInfo = SceneSelectedListener.CurrentValue.SceneInfo;

            foreach (var encounter in sceneInfo.MenuEncountersInfo.GetEncounters())
            {
                var recordNumber = encounter.GetLatestMetadata().RecordNumber;
                encounter.Lock = locks.ContainsKey(recordNumber) ? locks[recordNumber] : null;
            }
            SignalBus.Fire <EncounterLocksUpdatedSignal>();
        }