// Use this for initialization
        void Start()
        {
            rigidbody = GetComponent<Rigidbody>();
            pivotCube = GetComponent<PivotCube>();

            var updatePlayData = FindObjectOfType<UpdatePlayData>();
            var height = updatePlayData.playData.height;
            var level = height / 5;
            var raito = 0.2f;
            speed += level * raito;

            pivotCube.OnPutAsObservable()
                .Subscribe(_ =>
                {
                    rigidbody.constraints |= RigidbodyConstraints.FreezePositionY;
                    Vector3 position = transform.position;
                    position.x = Mathf.Round(position.x);
                    position.y = Mathf.Round(position.y);
                    position.z = Mathf.Round(position.z);
                    transform.position = position;

                    Destroy(rigidbody);
                    Destroy(this);
                });

            this.FixedUpdateAsObservable()
                .Where(_ => pivotCube.activated)
                .Select(_ => speed)
                .Subscribe(Fall);
        }
        // Use this for initialization
        void Start()
        {
            pivotCube = transform.root.GetComponent<PivotCube>();
            GameObject[] ignoreCubes = pivotCube.children
                .Select(child => child.gameObject)
                .ToArray();

            var start = transform.position;
            var distance = 20f;
            var marker = GetMarker(start, distance, ignoreCubes);
            MarkDropPoint(marker);

            pivotCube.OnPutAsObservable()
                .Select(_ => marker)
                .Subscribe(UnmarkDropPoint);
        }
Exemple #3
0
        // Use this for initialization
        void Start()
        {
            pivotCube = transform.root.GetComponent<PivotCube>();

            this.FixedUpdateAsObservable()
                .Where(_ => pivotCube.activated)
                .Select(_ => IsGrounded(pivotCube.children))
                .Subscribe(nextIsGrounded => isGrounded = nextIsGrounded);

            var changeActivatedFromPivotCube = pivotCube.ObserveEveryValueChanged(x => x.activated)
                .Subscribe(nextActivated => activated = nextActivated);

            pivotCube.OnPutAsObservable()
                .Subscribe(_ =>
                {
                    activated = false;
                    changeActivatedFromPivotCube.Dispose();
                });
        }
Exemple #4
0
 private void OnPutCube(PivotCube pivotCube)
 {
     if (onPutCube != null)
     {
         onPutCube.OnNext(pivotCube);
     }
 }