예제 #1
0
 void Awake()
 {
     if (_instance == null)
     {
         _instance = this;
     }
     else
     {
         Destroy(gameObject);
     }
 }
예제 #2
0
        // Use this for initialization
        void Start()
        {
            gm       = MRPM_GeneralManager._instance;
            Energy   = new ReactiveProperty <int>(100);
            HitPoint = new ReactiveProperty <int>(100);
            IsDead   = new ReactiveProperty <int>(0);

            HitPoint.ObserveEveryValueChanged(x => x.Value).Buffer(2)
            .Subscribe(x =>
            {
                if (x[0] - x[1] > 0)
                {
                    // regenerating
                    if (isMine)
                    {
                    }
                }
                else
                {
                    // damaged
                    if (isMine)
                    {
                    }
                }
                //update health bar
                _healthBar.value = x[0];
            });

            var isDeadStream = IsDead.ObserveEveryValueChanged(x => x.Value);

            isDeadStream.Subscribe(
                x =>
            {
                if (x > 0)
                {
                    if (isMine)
                    {
                        // show death timer
                        _hudController.ShowDeathTimer(IsDead.Value);
                    }
                    _deathEffect.Play();
                }
                else
                {
                    // revive
                    if (isMine)
                    {
                        // remove death screen
                        _hudController.ShowDeathTimer(IsDead.Value);
                    }
                    // show revive effect
                    //
                }
            });

            /*MRPM_SceneSyncManager._instance.SceneVariables
             * .ObserveEveryValueChanged(x => x)
             * .Subscribe(x =>
             * {
             *      Sync(x);
             * })
             * .AddTo(this);*/

            Observable.EveryUpdate()
            .Subscribe(_ =>
            {
                Sync(MRPM_SceneSyncManager._instance.SceneVariables);
            })
            .AddTo(this);

            if (isMine)
            {
                _hudController = MRPM_HUDController._instance;
            }
        }