Exemplo n.º 1
0
 public Game()
 {
     _timeScale = new FloatReactiveProperty(1);
     _paused    = new BoolReactiveProperty();
 }
Exemplo n.º 2
0
 private void SubscribeSliderToContext(FloatReactiveProperty property, CustomSliderView view)
 {
     property.ObserveEveryValueChanged(x => x.Value)
     .Subscribe(x => view.SetValueWithoutNotify(x))
     .AddTo(_disposables);
 }
Exemplo n.º 3
0
        void InitializeUGUI()
        {
            life            = new FloatReactiveProperty();
            UpperLeftCanvas = GameObject.Find(nameof(UpperLeftCanvas)).transform;
            Transform 体力, 気温, 殺害数;

            体力       = UpperLeftCanvas.Find(nameof(体力)).transform;
            残ライフ     = 体力.Find(nameof(残ライフ)).GetComponent <TMP_Text>();
            残中島敦     = 体力.Find(nameof(残中島敦)).GetComponent <RectTransform>();
            気温       = UpperLeftCanvas.Find(nameof(気温)).transform;
            現在気温     = 気温.Find(nameof(現在気温)).GetComponent <TMP_Text>();
            機体温度     = 気温.Find(nameof(機体温度)).GetComponent <TMP_Text>();
            致死温度     = 気温.Find(nameof(致死温度)).GetComponent <TMP_Text>();
            殺害数      = UpperLeftCanvas.Find(nameof(殺害数)).transform;
            駆逐数説明    = 殺害数.Find(nameof(駆逐数説明)).GetComponent <TMP_Text>();
            駆逐数      = 殺害数.Find(nameof(駆逐数)).GetComponent <TMP_Text>();
            ノルマ      = 殺害数.Find(nameof(ノルマ)).GetComponent <TMP_Text>();
            ノルマ.text = "体/" + titleSettings.ClearKillScore + "体";
            deathCounter.Subscribe(deadCount =>
            {
                var color   = Color.Lerp(zeroColor, clearColor, deadCount / (float)titleSettings.ClearKillScore);
                駆逐数.text    = deadCount.ToString();
                駆逐数説明.color = color;
                駆逐数.color   = color;
                ノルマ.color   = color;
            });
            nearToRespawn.Skip(1).Subscribe((bool _) =>
            {
                if (_)
                {
                    注意 = GameObject.Instantiate(respawnDisplay, UpperLeftCanvas);
                }
                else
                {
                    GameObject.Destroy(注意);
                }
            });
            this.UpdateAsObservable().Select(_ => Input.GetKeyDown(KeyCode.Backspace)).ThrottleFirst(System.TimeSpan.FromMilliseconds(200)).Where(_ => _).Subscribe(_ =>
            {
                UICamera.enabled = !UICamera.enabled;
            });
            cameraMoveObserver = this.UpdateAsObservable().Subscribe(_ =>
            {
                var deltaY = Input.mouseScrollDelta.y;
                if (deltaY != 0)
                {
                    var @position = mainCamera.transform.position;
                    @position.y   = System.Math.Max(0.5f, @position.y - deltaY);
                    mainCamera.transform.position = @position;
                }
            });
            playerMoveObserver = this.UpdateAsObservable().Where(_ => UICamera.enabled).Subscribe(_ =>
            {
                var settings = manager.GetComponentData <PlayerSettings>(player);
                if (cached.Temperature != settings.Temperature)
                {
                    var temperatureColor = Color.Lerp(normalColor, deathColor, settings.Temperature / settings.ThermalDeathPoint);
                    現在気温.color           = temperatureColor;
                    現在気温.text            = settings.Temperature.ToString();
                    機体温度.color           = temperatureColor;
                    致死温度.color           = temperatureColor;
                }
                if (cached.Life != settings.Life)
                {
                    life.Value     = settings.Life;
                    float t        = (float)settings.Life / (float)settings.MaxLife;
                    残ライフ.color     = Color.Lerp(deathColor, normalColor, t);
                    var siz        = 残中島敦.sizeDelta;
                    siz.x          = 500f * t;
                    残中島敦.sizeDelta = siz;
                }
                cached = settings;
            });
        }
Exemplo n.º 4
0
        private static void ApplyValue(object component, JSONNode node, PropertyInfo property)
        {
            if (property.CanRead && property.CanWrite)
            {
                var propertyData = node[property.Name];
                if (propertyData == null)
                {
                    return;
                }

                if (property.PropertyType == typeof(int))
                {
                    property.SetValue(component, propertyData.AsInt, null);
                    return;
                }
                if (property.PropertyType == typeof(IntReactiveProperty))
                {
                    var reactiveProperty = new IntReactiveProperty(propertyData.AsInt);
                    property.SetValue(component, reactiveProperty, null);
                    return;
                }
                if (property.PropertyType == typeof(float))
                {
                    property.SetValue(component, propertyData.AsFloat, null);
                    return;
                }
                if (property.PropertyType == typeof(FloatReactiveProperty))
                {
                    var reactiveProperty = new FloatReactiveProperty(propertyData.AsFloat);
                    property.SetValue(component, reactiveProperty, null);
                    return;
                }
                if (property.PropertyType == typeof(bool))
                {
                    property.SetValue(component, propertyData.AsBool, null);
                    return;
                }
                if (property.PropertyType == typeof(BoolReactiveProperty))
                {
                    var reactiveProperty = new BoolReactiveProperty(propertyData.AsBool);
                    property.SetValue(component, reactiveProperty, null);
                    return;
                }
                if (property.PropertyType == typeof(string))
                {
                    property.SetValue(component, propertyData.Value, null);
                    return;
                }
                if (property.PropertyType == typeof(StringReactiveProperty))
                {
                    var reactiveProperty = new StringReactiveProperty(propertyData.Value);
                    property.SetValue(component, reactiveProperty, null);
                    return;
                }
                if (property.PropertyType == typeof(Vector2))
                {
                    property.SetValue(component, propertyData.AsVector2, null);
                    return;
                }
                if (property.PropertyType == typeof(Vector2ReactiveProperty))
                {
                    var reactiveProperty = new Vector2ReactiveProperty(propertyData.AsVector2);
                    property.SetValue(component, reactiveProperty, null);
                    return;
                }
                if (property.PropertyType == typeof(Vector3))
                {
                    property.SetValue(component, propertyData.AsVector3, null);
                    return;
                }
                if (property.PropertyType == typeof(Vector3ReactiveProperty))
                {
                    var reactiveProperty = new Vector3ReactiveProperty(propertyData.AsVector3);
                    property.SetValue(component, reactiveProperty, null);
                    return;
                }
            }
        }
Exemplo n.º 5
0
        public static JSONClass SerializeComponent(this object component)
        {
            var node = new JSONClass();

            foreach (var property in component.GetType().GetProperties())
            {
                if (property.CanRead && property.CanWrite)
                {
                    if (property.PropertyType == typeof(int))
                    {
                        node.Add(property.Name, new JSONData((int)property.GetValue(component, null)));
                        continue;
                    }
                    if (property.PropertyType == typeof(IntReactiveProperty))
                    {
                        var reactiveProperty = property.GetValue(component, null) as IntReactiveProperty;
                        if (reactiveProperty == null)
                        {
                            reactiveProperty = new IntReactiveProperty();
                        }
                        node.Add(property.Name, new JSONData((int)reactiveProperty.Value));
                        continue;
                    }
                    if (property.PropertyType == typeof(float))
                    {
                        node.Add(property.Name, new JSONData((float)property.GetValue(component, null)));
                        continue;
                    }
                    if (property.PropertyType == typeof(FloatReactiveProperty))
                    {
                        var reactiveProperty = property.GetValue(component, null) as FloatReactiveProperty;
                        if (reactiveProperty == null)
                        {
                            reactiveProperty = new FloatReactiveProperty();
                        }
                        node.Add(property.Name, new JSONData((float)reactiveProperty.Value));
                        continue;
                    }
                    if (property.PropertyType == typeof(bool))
                    {
                        node.Add(property.Name, new JSONData((bool)property.GetValue(component, null)));
                        continue;
                    }
                    if (property.PropertyType == typeof(BoolReactiveProperty))
                    {
                        var reactiveProperty = property.GetValue(component, null) as BoolReactiveProperty;
                        if (reactiveProperty == null)
                        {
                            reactiveProperty = new BoolReactiveProperty();
                        }
                        node.Add(property.Name, new JSONData((bool)reactiveProperty.Value));
                        continue;
                    }
                    if (property.PropertyType == typeof(string))
                    {
                        node.Add(property.Name, new JSONData((string)property.GetValue(component, null)));
                        continue;
                    }
                    if (property.PropertyType == typeof(StringReactiveProperty))
                    {
                        var reactiveProperty = property.GetValue(component, null) as StringReactiveProperty;
                        if (reactiveProperty == null)
                        {
                            reactiveProperty = new StringReactiveProperty();
                        }
                        node.Add(property.Name, new JSONData((string)reactiveProperty.Value));
                        continue;
                    }
                    if (property.PropertyType == typeof(Vector2))
                    {
                        node.Add(property.Name, new JSONData((Vector2)property.GetValue(component, null)));
                        continue;
                    }
                    if (property.PropertyType == typeof(Vector2ReactiveProperty))
                    {
                        var reactiveProperty = property.GetValue(component, null) as Vector2ReactiveProperty;
                        if (reactiveProperty == null)
                        {
                            reactiveProperty = new Vector2ReactiveProperty();
                        }
                        node.Add(property.Name, new JSONData((Vector2)reactiveProperty.Value));
                        continue;
                    }
                    if (property.PropertyType == typeof(Vector3))
                    {
                        node.Add(property.Name, new JSONData((Vector3)property.GetValue(component, null)));
                        continue;
                    }
                    if (property.PropertyType == typeof(Vector3ReactiveProperty))
                    {
                        var reactiveProperty = property.GetValue(component, null) as Vector3ReactiveProperty;
                        if (reactiveProperty == null)
                        {
                            reactiveProperty = new Vector3ReactiveProperty();
                        }
                        node.Add(property.Name, new JSONData((Vector3)reactiveProperty.Value));
                        continue;
                    }
                }
            }
            return(node);
        }
Exemplo n.º 6
0
        //======================================================================

        void Awake()
        {
            CurrentHp = new FloatReactiveProperty(maxHp);
        }
Exemplo n.º 7
0
        public static JSONObject Serialize(this object component)
        {
            var node = new JSONObject();

            foreach (var property in component.GetType().GetProperties())
            {
                if (property.CanRead && property.CanWrite)
                {
                    if (property.PropertyType == typeof(int) || property.PropertyType.IsEnum)
                    {
                        node.Add(property.Name, new JSONNumber((int)property.GetValue(component, null)));
                        continue;
                    }
                    if (property.PropertyType == typeof(IntReactiveProperty))
                    {
                        var reactiveProperty = property.GetValue(component, null) as IntReactiveProperty;
                        if (reactiveProperty == null)
                        {
                            reactiveProperty = new IntReactiveProperty();
                        }
                        node.Add(property.Name, new JSONNumber((int)reactiveProperty.Value));
                        continue;
                    }
                    if (property.PropertyType == typeof(float))
                    {
                        node.Add(property.Name, new JSONNumber((float)property.GetValue(component, null)));
                        continue;
                    }
                    if (property.PropertyType == typeof(FloatReactiveProperty))
                    {
                        var reactiveProperty = property.GetValue(component, null) as FloatReactiveProperty;
                        if (reactiveProperty == null)
                        {
                            reactiveProperty = new FloatReactiveProperty();
                        }
                        node.Add(property.Name, new JSONNumber((float)reactiveProperty.Value));
                        continue;
                    }
                    if (property.PropertyType == typeof(bool))
                    {
                        node.Add(property.Name, new JSONBool((bool)property.GetValue(component, null)));
                        continue;
                    }
                    if (property.PropertyType == typeof(BoolReactiveProperty))
                    {
                        var reactiveProperty = property.GetValue(component, null) as BoolReactiveProperty;
                        if (reactiveProperty == null)
                        {
                            reactiveProperty = new BoolReactiveProperty();
                        }
                        node.Add(property.Name, new JSONBool((bool)reactiveProperty.Value));
                        continue;
                    }
                    if (property.PropertyType == typeof(string))
                    {
                        node.Add(property.Name, new JSONString((string)property.GetValue(component, null)));
                        continue;
                    }
                    if (property.PropertyType == typeof(StringReactiveProperty))
                    {
                        var reactiveProperty = property.GetValue(component, null) as StringReactiveProperty;
                        if (reactiveProperty == null)
                        {
                            reactiveProperty = new StringReactiveProperty();
                        }
                        node.Add(property.Name, new JSONString((string)reactiveProperty.Value));
                        continue;
                    }
                    if (property.PropertyType == typeof(Vector2))
                    {
                        var jsonObject = ((Vector2)property.GetValue(component, null)).AsJSONObject();
                        node.Add(property.Name, jsonObject);
                        continue;
                    }
                    if (property.PropertyType == typeof(Vector2ReactiveProperty))
                    {
                        var reactiveProperty = property.GetValue(component, null) as Vector2ReactiveProperty;
                        if (reactiveProperty == null)
                        {
                            reactiveProperty = new Vector2ReactiveProperty();
                        }

                        var jsonObject = reactiveProperty.Value.AsJSONObject();
                        node.Add(property.Name, jsonObject);
                        continue;
                    }
                    if (property.PropertyType == typeof(Vector3))
                    {
                        var jsonObject = ((Vector3)property.GetValue(component, null)).AsJSONObject();
                        node.Add(property.Name, jsonObject);
                        continue;
                    }
                    if (property.PropertyType == typeof(Vector3ReactiveProperty))
                    {
                        var reactiveProperty = property.GetValue(component, null) as Vector3ReactiveProperty;
                        if (reactiveProperty == null)
                        {
                            reactiveProperty = new Vector3ReactiveProperty();
                        }

                        var jsonObject = reactiveProperty.Value.AsJSONObject();
                        node.Add(property.Name, jsonObject);
                        continue;
                    }
                    if (property.PropertyType == typeof(Color))
                    {
                        var jsonObject = ((Color)property.GetValue(component, null)).AsJSONObject();
                        node.Add(property.Name, jsonObject);
                        continue;
                    }
                    if (property.PropertyType == typeof(ColorReactiveProperty))
                    {
                        var reactiveProperty = property.GetValue(component, null) as ColorReactiveProperty;
                        if (reactiveProperty == null)
                        {
                            reactiveProperty = new ColorReactiveProperty();
                        }

                        var jsonObject = reactiveProperty.Value.AsJSONObject();
                        node.Add(property.Name, jsonObject);
                        continue;
                    }
                }
            }
            return(node);
        }
Exemplo n.º 8
0
    private void Awake()
    {
        InstPlayer.SetScene(this);
        InstItemTimer.SetScene(this);


        mPlayGameData = Resources.Load <CPlayGameData>("GameData/CPlayGameData");
        mUserData     = new UserData();
        mItemdata     = new CItemData();
        mUIPlayGame   = FindObjectOfType <CUIPlayGame>();

        if (mItemdata.Item4 == 1)
        {
            IsStartBoost = true;
            InstStartBoost.gameObject.SetActive(true);
        }

        mAudioData = mUIPlayGame.GetComponent <CAudio>();
        this.AudioData.StartBGSound();



        CPlayerController tController = null;

#if UNITY_EDITOR
        tController = GetComponentInChildren <CKeyboardPlayerController>();
#elif UNITY_ANDROID
        tController = GetComponentInChildren <CUIPlayerController>();
#endif


        //플레이어 컨트롤러 세팅
        tController.SetCallOnJump(InstPlayer.DoJump);
        tController.SetCallOnJump(() => mIsInputJumpAndSlide = true);
        tController.SetCallOnSlide(InstPlayer.DoSlide);
        tController.SetCallOnSlide(() => mIsInputJumpAndSlide = true);

        tController.SetCallOnScreenSlide(InstPlayer.SetRotateInput);
        InstPlayer.SetFuncHorizontal(tController.GetHorizontal);

        //플레이어의 상태 변화 콜백
        InstPlayer.SetCallOnRotate(InstTargetCamera.RotateCamera);
        InstPlayer.SetCallOnGameOver(OnGameOver);

        //게임오버 - 로비 이동
        mUIPlayGame.InstBtnMoveLobby.onClick.AddListener(OnMoveLobby);

        //일시정지 UI On,Off
        mUIPlayGame.InstBtnPause.onClick.AddListener(() => OnPause(true));
        mUIPlayGame.InstBtnPauseClose.onClick.AddListener(() => OnPause(false));

        //포기 확인
        mUIPlayGame.InstBtnSubmitRetire.onClick.AddListener(OnRetire);

        if (mItemdata.Item1 == 1)
        {
            mUIPlayGame.InstSliderAddHPBar.gameObject.SetActive(true);
            InstPlayer.AddHp.Subscribe((hp) =>
            {
                mUIPlayGame.InstSliderAddHPBar.value = (float)hp / InstPlayer.AddHpValue;
                if (mUIPlayGame.InstSliderAddHPBar.value <= 0)
                {
                    mUIPlayGame.InstSliderAddHPBar.gameObject.SetActive(false);
                }
            });
        }
        InstPlayer.CurrentHp.Subscribe((hp) => mUIPlayGame.InstSliderHPBar.value          = (float)hp / InstPlayer.Hp);
        InstPlayer.CurrentBoost.Subscribe((boost) => mUIPlayGame.InstSliderBoostBar.value = boost / InstPlayer.Boost);

        mScore = new FloatReactiveProperty();
        mScore.Subscribe((score) =>
        {
            TotalScore = (int)score + (mCoin.Value * (int)CoinPerScore);
            mUIPlayGame.SetTxtScore(TotalScore);
            mUIPlayGame.SetTxtPauseScore(TotalScore);
        });
        mCoin = new IntReactiveProperty();
        mCoin.Subscribe((coin) => mUIPlayGame.SetTxtCoin(coin));


        mTrackCreator = new Map.CTrackCreator(this.transform);
        mTrackCreator.OnShowEndTrack = (left, right) =>
        {
            mUIPlayGame.ShowTxtSelectTheme(left, right);
        };
        mTrackCreator.OnSelectTheme = (select) =>
        {
            mUIPlayGame.SelectTheme(select);
        };
        mTrackCreator.OnChangeStage = (stage, theme) =>
        {
            mCurrentStage = stage;
            if (IsStartBoost == true)
            {
                if (stage != 1)
                {
                    mItemdata.Item4 = 0;
                    IsStartBoost    = false;
                    InstItemTimer.Reset();
                }
            }

            if (mCurrentStageTick != null)
            {
                StopCoroutine(mCurrentStageTick);
            }
            InstPlayer.ResetSideSpeed();
            switch (theme)
            {
            case 0:
                mCurrentStageTick = StartCoroutine(StageTick_1());
                break;

            case 1:
                mCurrentStageTick = StartCoroutine(StageTick_2());
                break;

            case 2:
                InstPlayer.SideSpeed = 20.0f;
                mUIPlayGame.ShowSlideIcon();
                break;
            }
        };

        if (mItemdata.Item2 == 1)
        {
            mUIPlayGame.InstItem_1.gameObject.SetActive(false);
        }
        else
        {
            mUIPlayGame.InstItem_1.gameObject.SetActive(true);
        }
        if (mItemdata.Item3 == 1)
        {
            mUIPlayGame.InstItem_2.gameObject.SetActive(false);
        }
        else
        {
            mUIPlayGame.InstItem_2.gameObject.SetActive(true);
        }

        mTrackCreator.CreateTrackData();
        mTrackCreator.PositionTracks();
        mTrackCreator.UpdateTrackTile(0);
    }
Exemplo n.º 9
0
 void Awake()
 {
     fuel = new FloatReactiveProperty(initialFuel);
 }
Exemplo n.º 10
0
 protected ResizeHandle()
 {
     _size         = new FloatReactiveProperty(10);
     _cursor       = new StringReactiveProperty();
     _interactable = new BoolReactiveProperty(true);
 }
Exemplo n.º 11
0
    // Use this for initialization
    void Start()
    {
        this.collidedWith     = new HashSet <GameObject>();
        this.NumCarsToDegrade = TrackNodeManager.Instance.numCarsToDegrade;
        Observable.Interval(TimeSpan.FromMilliseconds(250)).Subscribe(
            _ => {
            switch (this.State.Value)
            {
            case Track.States.Medium:
                PlayerManager.Instance.ApprovalRating.Value +=
                    Random.Range(0.00f, 0.01f);
                break;

            case Track.States.Poor: {
                break;
            }

            case Track.States.Good:
                PlayerManager.Instance.ApprovalRating.Value +=
                    Random.Range(0.06f, 0.02f);
                break;

            default:
                throw new ArgumentOutOfRangeException();
            }
        });
        this.degradationCount = new FloatReactiveProperty();
        this.degradationCount.Subscribe(
            x => {
            if (x >= this.NumCarsToDegrade)
            {
                if (this.NumCarsToDegrade <= 0)
                {
                    throw new InvalidOperationException();
                }
                if (this.State.Value == States.Good)
                {
                    this.State.Value = States.Medium;
                }
                else if (this.State.Value == States.Medium)
                {
                    this.State.Value = States.Poor;
                }

                this.degradationCount.Value = 0;
            }
        });
        this.State = new ReactiveProperty <States> {
            Value = States.Good
        };
        var speedText = this.speedLimitText.GetComponent <TextMeshPro>();

        this.State.Subscribe(
            x => {
            this.degradationCount.Value = 0;
            var mat     = this.GetComponent <MeshRenderer>().material;
            var textMat = this.speedLimitText.GetComponent <MeshRenderer>()
                          .material;
            if (x == States.Good)
            {
                speedText.color = new Color(140 / 255f, 214 / 255f, 62 / 255f);
                mat.color       = Color.green;
            }

            if (x == States.Medium)
            {
                speedText.color = Color.yellow;
                mat.color       = Color.yellow;
            }

            if (x == States.Poor)
            {
                speedText.color = Color.red;
                mat.color       = Color.red;
            }
        });
        PlayerManager.Instance.CurrentSelectedTrack
        .Subscribe(
            x => {
            if (x == this)
            {
                this.gameObject.GetComponent <MeshRenderer>().material
                .shader = Shader.Find(
                    "Legacy Shaders/Self-Illumin/Bumped Diffuse");
            }
            else
            {
                this.gameObject.GetComponent <MeshRenderer>().material
                .shader = Shader.Find(
                    "Legacy Shaders/Bumped Specular");
            }
        });
    }
 public PlayerMovementController SetInput(IUserInput input)
 {
     m_Movement = input.CharacterMoving;
     return(this);
 }
Exemplo n.º 13
0
 public IF_VR_Glove_SteamVRManus_Interface()
 {
     HandYawOffsetLeft  = new FloatReactiveProperty();
     HandYawOffsetRight = new FloatReactiveProperty();
 }
Exemplo n.º 14
0
 public SettingsContext(Settings settings) : base(settings)
 {
     MovementSpeed    = new FloatReactiveProperty(settings.MovementSpeed);
     MouseSensitivity = new FloatReactiveProperty(settings.MouseSensitivity);
     JumpHeight       = new FloatReactiveProperty(settings.JumpHeight);
 }
Exemplo n.º 15
0
 public void CountSet(float i)
 {
     _timelimit = new FloatReactiveProperty(i);
     SelectManager.Selecting = true;
 }
Exemplo n.º 16
0
 private void Awake()
 {
     currentHealth = new FloatReactiveProperty(maxHealth);
 }