Beispiel #1
0
    // Update is called once per frame
    void Update()
    {
        if (this.state != oldState)
        {
            Debug.Log(this.name + " state: " + this.state);

            if (this.state == SampleState.Dissolving)
            {
                this.aligner.enabled = false;
            }
            else if (this.state == SampleState.Picked || this.state == SampleState.Returning)
            {
                this.aligner.localFrom = Vector3.up;
                this.aligner.to        = Vector3.up;
                this.aligner.enabled   = true;
            }
            else if (this.state == SampleState.Returned)
            {
                this.aligner.localFrom = Vector3.up;
                this.aligner.to        = Vector3.back;
                this.aligner.enabled   = true;

                this.positioner.enabled = true;

                MainBehaviour.Instance.pincet.state = PincetBehaviour.PincetState.Dropped;
            }

            this.oldState = this.state;
        }
    }
Beispiel #2
0
 protected virtual void Dispose(bool disposing)
 {
     if (!_disposed)
     {
         if (disposing)
         {
             if (ConstantSettingsBuffer != null)
             {
                 ConstantSettingsBuffer.Dispose();
             }
             if (SampleState != null)
             {
                 SampleState.Dispose();
             }
             if (ConstantMatrixBuffer != null)
             {
                 ConstantMatrixBuffer.Dispose();
             }
             if (Layout != null)
             {
                 Layout.Dispose();
             }
             if (PixelShader != null)
             {
                 PixelShader.Dispose();
             }
             if (VertexShader != null)
             {
                 VertexShader.Dispose();
             }
         }
         _disposed = true;
     }
 }
Beispiel #3
0
 public PlayEventComponent(SampleState state, PlayEventDetails details)
 {
     Pitch       = state.SemitoneOffset.ToFrequency();
     Volume      = details.Volume;
     TrackTime   = details.StartTime;
     MaxPlayTime = details.MaxPlayTime;
 }
        public void EqualsTest()
        {
            var loopCount = 1000;
            var state1    = SampleState.Create(loopCount);
            var state2    = SampleState.Create(loopCount);
            var watch     = new Stopwatch();

            var timeOfEquality     = 0;
            var timeOfCustomEquals = 0;

            {
                watch.Reset();
                watch.Start();
                Assert.IsTrue(state1.Equals(state2));
                watch.Stop();
                timeOfEquality = watch.Elapsed.Milliseconds;
            }
            {
                watch.Reset();
                watch.Start();
                Assert.IsTrue(state1.CustomEquals(state2));
                watch.Stop();
                timeOfCustomEquals = watch.Elapsed.Milliseconds;
            }

            var gain = 100 * (double)timeOfCustomEquals / timeOfEquality;

            UnityEngine.Debug.Log(string.Format(
                                      "[Perf] loops: {0}, CustomEquals: {1}[ms], AutoEquals: {2}[ms], gain {3}%",
                                      loopCount,
                                      timeOfCustomEquals,
                                      timeOfEquality,
                                      gain.ToString("F2")
                                      ));
        }
    protected void handleAudioTrigger(SampleState state)
    {
        switch (state)
        {
        case SampleState.Held:
            break;

        case SampleState.Pressed:
            if (HeldAudio != null)
            {
                HeldAudio.Play();
            }
            if (PressedAudio != null)
            {
                PressedAudio.Play();
            }
            break;

        case SampleState.Released:
            if (HeldAudio != null)
            {
                HeldAudio.Stop();
            }
            if (ReleasedAudio != null)
            {
                ReleasedAudio.Play();
            }
            break;

        default:
            break;
        }
    }
Beispiel #6
0
    // Update is called once per frame
    void Update()
    {
        if(this.state != oldState)
        {
            Debug.Log(this.name + " state: " + this.state);

            if(this.state == SampleState.Dissolving)
            {
                this.aligner.enabled = false;
            }
            else if(this.state == SampleState.Picked || this.state == SampleState.Returning)
            {
                this.aligner.localFrom = Vector3.up;
                this.aligner.to = Vector3.up;
                this.aligner.enabled = true;
            }
            else if(this.state == SampleState.Returned)
            {
                this.aligner.localFrom = Vector3.up;
                this.aligner.to = Vector3.back;
                this.aligner.enabled = true;

                this.positioner.enabled = true;

                MainBehaviour.Instance.pincet.state = PincetBehaviour.PincetState.Dropped;
            }

            this.oldState = this.state;
        }
    }
Beispiel #7
0
 private void Paused()
 {
     if (sampleState == SampleState.ended)
     {
         sampleState = SampleState.findMax;
     }
     DoSampling(_screenHit - 36);
 }
Beispiel #8
0
 public LazyStateTest()
 {
     _address            = new Address("66eD03107F270d082AC1F71d8E50375f9372d8fC");
     _state              = new SampleState(_address, 123L, "hello");
     _serializedEncoding = (Dictionary)_state.Serialize();
     _loaded             = new LazySampleState(_state);
     _unloaded           = new LazySampleState(_serializedEncoding, d => new SampleState(d));
 }
        public T Create <T>(IEnumerable <object> events) where T : class, IAggregate
        {
            if (typeof(T) == typeof(SampleAggregate))
            {
                var state = new SampleState(events);
                return(new SampleAggregate(state) as T);
            }

            throw new ArgumentException("Unknown aggregate type");
        }
Beispiel #10
0
            public static SampleState Create(int loop)
            {
                var state = new SampleState();

                for (int i = 0; i < loop; i++)
                {
                    state.List.Add(SampleEntity.Create(loop));
                }

                return(state);
            }
Beispiel #11
0
    void UpdateAnim()
    {
        if (value == _target)
        {
            _target     = Vector3.one;
            sampleState = SampleState.Return;
            return;
        }

        value = Vector3.MoveTowards(value, _target, Time.deltaTime * speed);
    }
Beispiel #12
0
            // custom implementation of Clone is faster than default BinaryFormatter implementation.
//            public override object Clone()
//            {
//                return CustomClone();
//            }

            public SampleState CustomClone()
            {
                var state = new SampleState();

                foreach (var entity in state.List)
                {
                    state.List.Add(entity.CustomClone());
                }

                return(state);
            }
Beispiel #13
0
    void UpdateReturn()
    {
        if (value == Vector3.one)
        {
            isBeat      = true;
            sampleState = SampleState.Ready;
            return;
        }

        value = Vector3.MoveTowards(value, _target, Time.deltaTime * speed);
    }
Beispiel #14
0
        public void StateMachine_AddingAStateCallsStateAdded()
        {
            StateMachine <StateIds, StateEvents> sm = new(StateIds.SameState, StateIds.UnhandledState);
            var state = new SampleState(StateIds.State1);

            state.AddOccurrences.Should().Be(0);
            sm.AddState(state);
            state.AddOccurrences.Should().Be(1);

            new Action(() => sm.AddState(state))
            .Should().Throw <ArgumentException>("A state with the state id of State1 already exists");
            state.AddOccurrences.Should().Be(1);
        }
Beispiel #15
0
        protected override void CreateScene()
        {
            this.Load(WaveContent.Scenes.MyScene);

            this.CreateShip();
            this.CreateExplosion();

            this.CreateGrounds();
            this.CreateObstacles();

            this.state = SampleState.Playing;
            ScrollBehavior.ScrollSpeed = SCROLLSPEED;

            this.AddSceneBehavior(new CollisionSceneBehavior(), SceneBehavior.Order.PostUpdate);
        }
Beispiel #16
0
        /// <summary>
        /// Serves as the default hash function.
        /// </summary>
        /// <returns>A hash code for the current object.</returns>
        public override int GetHashCode()
        {
            var hashCode = -910965429;

            hashCode = (hashCode * -1521134295) + ValidData.GetHashCode();
            hashCode = (hashCode * -1521134295) + SampleState.GetHashCode();
            hashCode = (hashCode * -1521134295) + ViewState.GetHashCode();
            hashCode = (hashCode * -1521134295) + SourceTimestamp.GetHashCode();
            hashCode = (hashCode * -1521134295) + InstanceHandle.GetHashCode();
            hashCode = (hashCode * -1521134295) + PublicationHandle.GetHashCode();
            hashCode = (hashCode * -1521134295) + DisposedGenerationCount.GetHashCode();
            hashCode = (hashCode * -1521134295) + NoWritersGenerationCount.GetHashCode();
            hashCode = (hashCode * -1521134295) + SampleRank.GetHashCode();
            hashCode = (hashCode * -1521134295) + GenerationRank.GetHashCode();
            hashCode = (hashCode * -1521134295) + AbsoluteGenerationRank.GetHashCode();
            return(hashCode);
        }
 protected void handleFiltersUpdate(SampleState state)
 {
     //Helpers.CreateComponentIfMissing(transform, Envelopes);
     foreach (AudioEnvelope envelope in Envelopes)
     {
         if (state == SampleState.Pressed)
         {
             StartCoroutine("adaptAttack", envelope);
             StopCoroutine("adaptRelease");
         }
         if (state == SampleState.Released)
         {
             StartCoroutine("adaptRelease", envelope);
             StopCoroutine("adaptAttack");
         }
     }
 }
Beispiel #18
0
        public void CloneTest()
        {
            var loopCount = 100;
            var state     = SampleState.Create(loopCount);
            var watch     = new Stopwatch();

            var timeOfCustomClone     = 0;
            var timeOfAutoClone       = 0;
            var timeOfReflectionClone = 0;

            {
                watch.Reset();
                watch.Start();
                state.CustomClone();
                watch.Stop();
                timeOfCustomClone = watch.Elapsed.Milliseconds;
            }
            {
                watch.Reset();
                watch.Start();
                state.Clone();
                watch.Stop();
                timeOfAutoClone = watch.Elapsed.Milliseconds;
            }
            {
                watch.Reset();
                watch.Start();
                state.ReflectionClone();
                watch.Stop();
                timeOfReflectionClone = watch.Elapsed.Milliseconds;
            }

            // dummy check
            Assert.IsTrue(true);

            {
                UnityEngine.Debug.Log(string.Format(
                                          "[Perf] loop: {0}, CustomClone: {1}[ms], ReflectionClone: {2}[ms], AutClone: {3}[ms]",
                                          loopCount,
                                          timeOfCustomClone,
                                          timeOfReflectionClone,
                                          timeOfAutoClone
                                          ));
            }
        }
Beispiel #19
0
    public async void SaveState(SampleState saveData)
    {
        if (this.identity == null)
        {
            throw new System.Exception("Not signed in!");
        }

        // Save state to the backend
        var state       = JsonConvert.SerializeObject(saveData);
        var saveStateTx = new EtherboyStateTx
        {
            Version = 0,
            Owner   = this.identity.Username,
            Data    = ByteString.CopyFromUtf8(state)
        };

        await this.contract.CallAsync("SaveState", saveStateTx);
    }
Beispiel #20
0
    public void SendData(string beatSampleNodeName, Vector3 target, float targetGlow)
    {
        if (this.gameObject.name == beatSampleNodeName && isBeat)
        {
            isBeat  = false;
            _target = target;

            sampleState = SampleState.Anim;
        }

        if (this.gameObject.name == beatSampleNodeName && isColorBeat)
        {
            isColorBeat = false;
            _targetGlow = targetGlow;

            sampleColorState = SampleColorState.Anim;
        }
    }
        private void UpdateInterfaceState(SampleState newState)
        {
            // Manage the UI state for the sample.
            _currentSampleState = newState;
            switch (_currentSampleState)
            {
            case SampleState.NotReady:
                AddStopButton.IsEnabled             = false;
                AddBarrierButton.IsEnabled          = false;
                ResetRoutingButton.IsEnabled        = false;
                AllowReorderStopsCheckbox.IsEnabled = false;
                PreserveFirstStopCheckbox.IsEnabled = false;
                PreserveLastStopCheckbox.IsEnabled  = false;
                ShowDirectionsButton.IsEnabled      = false;
                CalculateRouteButton.IsEnabled      = false;
                StatusLabel.Text = "Preparing sample...";
                break;

            case SampleState.AddingBarriers:
                StatusLabel.Text = "Tap the map to add a barrier.";
                break;

            case SampleState.AddingStops:
                StatusLabel.Text = "Tap the map to add a stop.";
                break;

            case SampleState.Ready:
                AddStopButton.IsEnabled             = true;
                AddBarrierButton.IsEnabled          = true;
                ResetRoutingButton.IsEnabled        = true;
                AllowReorderStopsCheckbox.IsEnabled = true;
                PreserveLastStopCheckbox.IsEnabled  = true;
                PreserveFirstStopCheckbox.IsEnabled = true;
                ShowDirectionsButton.IsEnabled      = true;
                CalculateRouteButton.IsEnabled      = true;
                StatusLabel.Text      = "Click 'Add stop' or 'Add barrier', then tap on the map to add stops and barriers.";
                BusyOverlay.IsVisible = false;
                break;

            case SampleState.Routing:
                BusyOverlay.IsVisible = true;
                break;
            }
        }
        private void UpdateInterfaceState(SampleState newState)
        {
            // Manage the UI state for the sample.
            _currentSampleState = newState;
            switch (_currentSampleState)
            {
            case SampleState.NotReady:
                _addStopButton.Enabled             = false;
                _addBarrierButton.Enabled          = false;
                _resetButton.Enabled               = false;
                _reorderStopsCheckbox.Enabled      = false;
                _preserveLastStopCheckbox.Enabled  = false;
                _preserveFirstStopCheckbox.Enabled = false;
                _directionsButton.Enabled          = false;
                _routeButton.Enabled               = false;
                _statusLabel.Text = "Preparing sample...";
                break;

            case SampleState.AddingBarriers:
                _statusLabel.Text = "Tap the map to add a barrier.";
                break;

            case SampleState.AddingStops:
                _statusLabel.Text = "Tap the map to add a stop.";
                break;

            case SampleState.Ready:
                _addStopButton.Enabled             = true;
                _addBarrierButton.Enabled          = true;
                _resetButton.Enabled               = true;
                _reorderStopsCheckbox.Enabled      = true;
                _preserveLastStopCheckbox.Enabled  = true;
                _preserveFirstStopCheckbox.Enabled = true;
                _directionsButton.Enabled          = true;
                _routeButton.Enabled               = true;
                _busyIndicator.Hide();
                _statusLabel.Text = "Click 'Add stop' or 'Add barrier', then tap on the map to add stops and barriers.";
                break;

            case SampleState.Routing:
                _busyIndicator.Show();
                break;
            }
        }
Beispiel #23
0
        private void ShuddownShader()
        {
            // Release the pixel constant buffer.
            if (ConstantPixelBuffer != null)
            {
                ConstantPixelBuffer.Dispose();
                ConstantPixelBuffer = null;
            }

            // Release the sampler state.
            if (SampleState != null)
            {
                SampleState.Dispose();
                SampleState = null;
            }

            // Release the matrix constant buffer.
            if (ConstantMatrixBuffer != null)
            {
                ConstantMatrixBuffer.Dispose();
                ConstantMatrixBuffer = null;
            }

            // Release the layout.
            if (Layout != null)
            {
                Layout.Dispose();
                Layout = null;
            }

            // Release the pixel shader.
            if (PixelShader != null)
            {
                PixelShader.Dispose();
                PixelShader = null;
            }

            // Release the vertex shader.
            if (VertexShader != null)
            {
                VertexShader.Dispose();
                VertexShader = null;
            }
        }
Beispiel #24
0
    public static void saveGame()
    {
        SampleState saveData = new SampleState();

        saveData.currentGold     = globalScript.currentGold;
        saveData.currentQuest    = globalScript.currentQuest;
        saveData.currentWeapon   = globalScript.currentWeapon;
        saveData.questStep       = globalScript.questStep;
        saveData.lastScene       = SceneManager.GetActiveScene().name;
        saveData.equippedBow     = globalScript.equippedBow;
        saveData.equippedHelm    = globalScript.equippedHelm;
        saveData.equippedSword   = globalScript.equippedSword;
        saveData.equippedMagic   = globalScript.equippedMagic;
        saveData.prevScene       = globalScript.previousScene;
        saveData.bow1Purchased   = globalScript.bow1Purchased;
        saveData.bow2Purchased   = globalScript.bow2Purchased;
        saveData.bow3Purchased   = globalScript.bow3Purchased;
        saveData.bow4Purchased   = globalScript.bow4Purchased;
        saveData.bow5Purchased   = globalScript.bow5Purchased;
        saveData.sword1Purchased = globalScript.sword1Purchased;
        saveData.sword2Purchased = globalScript.sword2Purchased;
        saveData.sword3Purchased = globalScript.sword3Purchased;
        saveData.sword4Purchased = globalScript.sword4Purchased;
        saveData.sword5Purchased = globalScript.sword5Purchased;
        saveData.helm1Purchased  = globalScript.helm1Purchased;
        saveData.helm2Purchased  = globalScript.helm2Purchased;
        saveData.helm3Purchased  = globalScript.helm3Purchased;
        saveData.helm4Purchased  = globalScript.helm4Purchased;
        saveData.helm5Purchased  = globalScript.helm5Purchased;

        if (!useBackend)
        {
            string jsonData = JsonUtility.ToJson(saveData);
            if (jsonData != null)
            {
                PlayerPrefs.SetString("savedData", jsonData);
            }
        }
        else
        {
            GameObject.Find("backend").GetComponent <backendClass> ().SaveState(saveData);
        }
    }
        public void UnloadDirect3D()
        {
            if (!Ready)
            {
                return;
            }

            TextureCache.Dispose();

            DefaultTextureView.Dispose();
            DefaultTexture.Dispose();
            SampleState.Dispose();
            DefaultEffect.Dispose();
            BackBufferView.Dispose();
            BackBuffer.Dispose();
            DepthBufferView.Dispose();
            DepthBuffer.Dispose();
            Device.Dispose();
        }
Beispiel #26
0
        protected override void CreateScene()
        {
            this.CreateExplosion();
            this.CreateShip();

            Vector2 topLeftCorner = Vector2.Zero;

            WaveServices.ViewportManager.RecoverPosition(ref topLeftCorner);

            this.ground  = this.CreateGround("ground1", topLeftCorner.X);
            this.ground2 = this.CreateGround("ground2", topLeftCorner.X + 1024);
            this.ground3 = this.CreateGround("ground3", topLeftCorner.X + 2048);
            this.CreateObstacles();
            this.CreateBackground();

            this.state = SampleState.Playing;
            ScrollBehavior.ScrollSpeed = SCROLLSPEED;

            this.AddSceneBehavior(new CollisionSceneBehavior(), SceneBehavior.Order.PostUpdate);
        }
        private void UpdateInterfaceState(SampleState newState)
        {
            // Manage the UI state for the sample.
            _currentSampleState = newState;
            switch (_currentSampleState)
            {
            case SampleState.NotReady:
                _stopsOrBarriersPicker.Enabled = false;
                _resetButton.Enabled           = false;
                _settingsButton.Enabled        = false;
                _directionsButton.Enabled      = false;
                _routeButton.Enabled           = false;
                _statusLabel.Text = "Preparing sample...";
                _activityIndicator.StartAnimating();
                break;

            case SampleState.AddingBarriers:
                _statusLabel.Text = "Tap the map to add a barrier.";
                break;

            case SampleState.AddingStops:
                _statusLabel.Text = "Tap the map to add a stop.";
                break;

            case SampleState.Ready:
                _stopsOrBarriersPicker.Enabled = true;
                _resetButton.Enabled           = true;
                _settingsButton.Enabled        = true;
                _directionsButton.Enabled      = true;
                _routeButton.Enabled           = true;
                _statusLabel.Text = "Tap 'stops' or 'barriers', then tap the map to add.";
                _stopsOrBarriersPicker.SelectedSegment = -1;
                _activityIndicator.StopAnimating();
                break;

            case SampleState.Routing:
                _activityIndicator.StartAnimating();
                _statusLabel.Text = "Calculating route...";
                break;
            }
        }
Beispiel #28
0
        private void SampleSmooth(int _smoothType)
        {
            float[,] tempCol = new float[fieldN, fieldN];
            for (int i = 0; i < fieldN; i++)
            {
                for (int j = 0; j < fieldN; j++)
                {
                    int jl = j - 1; if (jl < 0)
                    {
                        jl = fieldN - 1;
                    }
                    int jr = j + 1; if (jr == fieldN)
                    {
                        jr = 0;
                    }
                    int iu = i - 1; if (iu < 0)
                    {
                        iu = fieldN - 1;
                    }
                    int id = i + 1; if (id == fieldN)
                    {
                        id = 0;
                    }
                    float p1 = field[jl, iu] * _smoothing[_smoothType, 0];
                    float p2 = field[j, iu] * _smoothing[_smoothType, 1];
                    float p3 = field[jr, iu] * _smoothing[_smoothType, 2];
                    float p4 = field[jl, i] * _smoothing[_smoothType, 3];
                    float p5 = field[j, i] * _smoothing[_smoothType, 4];
                    float p6 = field[jr, i] * _smoothing[_smoothType, 5];
                    float p7 = field[jl, id] * _smoothing[_smoothType, 6];
                    float p8 = field[j, id] * _smoothing[_smoothType, 7];
                    float p9 = field[jr, id] * _smoothing[_smoothType, 8];
                    tempCol[j, i] = (p1 + p2 + p3 + p4 + p5 + p6 + p7 + p8 + p9) / _smoothing[_smoothType, 9];
                }
            }

            field = tempCol;
            RegenTexture();
            sampleState = SampleState.findMax;
        }
Beispiel #29
0
    public static void loadGame(SampleState saveData)
    {
        if (!useBackend)
        {
            saveData = JsonUtility.FromJson <SampleState> (PlayerPrefs.GetString("savedData"));
        }
        if (saveData != null)
        {
            globalScript.currentGold     = saveData.currentGold;
            globalScript.currentQuest    = saveData.currentQuest;
            globalScript.currentWeapon   = saveData.currentWeapon;
            globalScript.questStep       = saveData.questStep;
            globalScript.lastPlayedScene = saveData.lastScene;
            globalScript.equippedBow     = saveData.equippedBow;
            globalScript.equippedHelm    = saveData.equippedHelm;
            globalScript.equippedSword   = saveData.equippedSword;
            globalScript.equippedMagic   = saveData.equippedMagic;
            globalScript.previousScene   = saveData.prevScene;
            globalScript.bow1Purchased   = saveData.bow1Purchased;
            globalScript.bow2Purchased   = saveData.bow2Purchased;
            globalScript.bow3Purchased   = saveData.bow3Purchased;
            globalScript.bow4Purchased   = saveData.bow4Purchased;
            globalScript.bow5Purchased   = saveData.bow5Purchased;
            globalScript.sword1Purchased = saveData.sword1Purchased;
            globalScript.sword2Purchased = saveData.sword2Purchased;
            globalScript.sword3Purchased = saveData.sword3Purchased;
            globalScript.sword4Purchased = saveData.sword4Purchased;
            globalScript.sword5Purchased = saveData.sword5Purchased;
            globalScript.helm1Purchased  = saveData.helm1Purchased;
            globalScript.helm2Purchased  = saveData.helm2Purchased;
            globalScript.helm3Purchased  = saveData.helm3Purchased;
            globalScript.helm4Purchased  = saveData.helm4Purchased;
            globalScript.helm5Purchased  = saveData.helm5Purchased;

            if (globalScript.lastPlayedScene != "")
            {
                globalScript.changeScene(globalScript.lastPlayedScene);
            }
        }
    }
Beispiel #30
0
        protected override void CreateScene()
        {
            this.CreateExplosion();
            this.CreateShip();

            Vector2 topLeftCorner = Vector2.Zero;
            WaveServices.ViewportManager.RecoverPosition(ref topLeftCorner);

            this.ground = this.CreateGround("ground1", topLeftCorner.X);
            this.ground2 = this.CreateGround("ground2", topLeftCorner.X + 1024);
            this.ground3 = this.CreateGround("ground3", topLeftCorner.X + 2048);
            this.CreateObstacles();
            this.CreateBackground();

            this.state = SampleState.Playing;
            ScrollBehavior.ScrollSpeed = SCROLLSPEED;
        }
Beispiel #31
0
 /// <summary>
 /// Reduces the application.
 /// </summary>
 /// <param name="previous">The previous.</param>
 /// <param name="action">The action.</param>
 /// <returns>The SampleState.</returns>
 public static SampleState ReduceApplication(SampleState previous, IAction action)
 {
     return(new SampleState());
 }
Beispiel #32
0
        protected override void Draw(TimeSpan gameTime)
        {
            base.Draw(gameTime);

            if (this.state == SampleState.Playing)
            {
                // Playing update
                ScrollBehavior.ScrollSpeed += SCROLLACCELERATION * (float)gameTime.TotalSeconds;

                // Gets the elements colliders
                PerPixelCollider shipCollider = this.ship.FindComponent<PerPixelCollider>();
                PerPixelCollider groundCollider = this.ground.FindComponent<PerPixelCollider>();
                PerPixelCollider groundCollider2 = this.ground2.FindComponent<PerPixelCollider>();
                PerPixelCollider groundCollider3 = this.ground3.FindComponent<PerPixelCollider>();
                PerPixelCollider obstacleCollider;
                bool collision = false;

                if (shipCollider.Intersects(groundCollider) || shipCollider.Intersects(groundCollider2) || shipCollider.Intersects(groundCollider3))
                {
                    // Checks collision of the ground.
                    collision = true;
                }
                else
                {

                    // Iterates through the obstacles to detect intersection
                    foreach (var obstacle in this.obstacles)
                    {
                        obstacleCollider = obstacle.FindComponent<PerPixelCollider>();

                        if (shipCollider.Intersects(obstacleCollider))
                        {
                            collision = true;
                            break;
                        }
                    }
                }

                if (collision)
                {
                    this.Explosion();
                    this.State = SampleState.Waiting;
                }
            }
            else
            {
                this.countDown += (int)gameTime.TotalMilliseconds;
                if (this.countDown > WAITINGTIME)
                {
                    this.State = SampleState.Playing;
                }
            }
        }
Beispiel #33
0
        private void btnOk_Click(object sender, EventArgs e)
        {
            string matCode      = txtMatCode.Text.Trim();
            string matName      = txtMatName.Text.Trim();
            string supplierCode = txtSupplierCode.Text.Trim();
            string supplierName = txtSupplierName.Text.Trim();
            string vehno        = txtVehNo.Text.Trim();

            string sampleType  = cmbSampleTypes.Text.Trim();
            string sampleState = cmbSampleStates.Text.Trim();
            string zydanhao    = txtZyDanHao.Text.Trim();
            string jydanhao    = txtJyDanHao.Text.Trim();

            if (!string.IsNullOrEmpty(matCode))
            {
                result = "mat.INVCODE like '%" + matCode + "%'";
            }
            if (!string.IsNullOrEmpty(matName))
            {
                if (result != "")
                {
                    result += " AND ";
                }

                result += " mat.INVNAME like '%" + matName + "%'";
            }

            if (!string.IsNullOrEmpty(zydanhao))
            {
                if (result != "")
                {
                    result += " AND ";
                }

                result += " (main.ZyDanHao like '%" + zydanhao + "%' or exists (select * from qc_sample_lab lab11 inner join qc_mixcheckgroup mkg11 on mkg11.sample_lab_id=lab11.sample_lab_id where mkg11.sample_mix_id= main.sample_mix_id and (lab11.storecode like '%" + zydanhao + "%' or mkg11.storecode like '%" + zydanhao + "%'))) ";
            }

            if (!string.IsNullOrEmpty(jydanhao))
            {
                if (result != "")
                {
                    result += " AND ";
                }

                result += " exists (select * from qc_sample_lab lab11 inner join qc_mixcheckgroup mkg11 on mkg11.sample_lab_id=lab11.sample_lab_id where mkg11.sample_mix_id= main.sample_mix_id and lab11.jycode like '%" + jydanhao + "%') ";
            }

            if (!string.IsNullOrEmpty(sampleType))
            {
                if (result != "")
                {
                    result += " AND ";
                }

                SampleType st = SampleType.普通样;

                if (Enum.TryParse <SampleType>(sampleType, out st))
                {
                    result += " main.SampleType = " + Convert.ToInt32(st).ToString() + " ";
                }
                else
                {
                    MessageBox.Show("检验类型格式不对");
                    return;
                }
            }

            if (!string.IsNullOrEmpty(sampleState))
            {
                if (result != "")
                {
                    result += " AND ";
                }

                SampleState st = SampleState.初始状态;

                if (Enum.TryParse <SampleState>(sampleState, out st))
                {
                    result += " main.SampleState = " + Convert.ToInt32(st).ToString() + " ";
                }
                else
                {
                    MessageBox.Show("检验状态格式不对");
                    return;
                }
            }

            if (!string.IsNullOrEmpty(supplierCode))
            {
                if (result != "")
                {
                    result += " AND ";
                }

                result += " main.SupplierCode like '%" + supplierCode + "%'";
            }

            if (!string.IsNullOrEmpty(supplierName))
            {
                if (result != "")
                {
                    result += " AND ";
                }

                result += " supplier.CUSTNAME like '%" + supplierName + "%'";
            }

            if (!string.IsNullOrEmpty(vehno))
            {
                if (result != "")
                {
                    result += " AND ";
                }

                result += " main.VehNo like '%" + vehno + "%'";
            }

            if (!string.IsNullOrEmpty(this.dateEdit_Begin.Text.Trim()))
            {
                if (result != "")
                {
                    result += " AND ";
                }
                result += " main.Mix_Time >= CONVERT(datetime,'" + this.dateEdit_Begin.Text.Trim() + "',20)";
            }

            if (!string.IsNullOrEmpty(this.dateEdit_End.Text.Trim()))
            {
                if (result != "")
                {
                    result += " AND ";
                }

                result += " main.Mix_Time <= CONVERT(datetime,'" + this.dateEdit_End.Text.Trim() + "',20)";
            }

            if (!string.IsNullOrEmpty(this.dateEdit_nc_Begin.Text.Trim()))
            {
                if (result != "")
                {
                    result += " AND ";
                }
                result += " main.UploadNcTime >= CONVERT(datetime,'" + this.dateEdit_nc_Begin.Text.Trim() + "',20)";
            }

            if (!string.IsNullOrEmpty(this.dateEdit_nc_End.Text.Trim()))
            {
                if (result != "")
                {
                    result += " AND ";
                }

                result += " main.UploadNcTime <= CONVERT(datetime,'" + this.dateEdit_nc_End.Text.Trim() + "',20)";
            }

            if (!string.IsNullOrEmpty(this.textMYYDH.Text.Trim()))
            {
                CheckGroups.LoadDataByWhere("main.ZupiHao like '%" + this.textMYYDH.Text.Trim() + "%' order by main.Sample_Mix_ID desc");
                if (CheckGroups.Count > 0)
                {
                    if (result != "")
                    {
                        result += " AND ";
                    }

                    result += "  main.Sample_Mix_ID='" + CheckGroups[0].Sample_Mix_ID + "'";
                }
            }
        }
        public void ReportGetSampleCompleted(int streamType, IStreamSource streamSource, TsPesPacket packet)
        {
            if (null == packet)
            {
                Debug.WriteLine("SimulatedMediaElementManager.ReportGetSampleCompleted({0}) null packet", streamType);

                return;
            }

            Debug.WriteLine("SimulatedMediaElementManager.ReportGetSampleCompleted({0}) at {1}/{2}", streamType, packet.PresentationTimestamp, packet.DecodeTimestamp);

            var timestamp = packet.PresentationTimestamp;
            var oldestTimestamp = TimeSpan.MaxValue;
            var oldestIndex = -1;

            lock (_lock)
            {
                SampleState sampleState;

                if (!_streams.TryGetValue(streamType, out sampleState))
                {
                    sampleState = new SampleState
                    {
                        IsPending = false,
                        Timestamp = timestamp
                    };

                    _streams[streamType] = sampleState;
                }
                else
                {
                    sampleState.IsPending = false;
                    sampleState.Timestamp = timestamp;
                }

                foreach (var kv in _streams)
                {
                    var sampleTimestamp = kv.Value.Timestamp;

                    if (sampleTimestamp >= oldestTimestamp)
                        continue;

                    oldestTimestamp = sampleTimestamp;
                    oldestIndex = kv.Key;
                }

                if (oldestIndex >= 0)
                {
                    if (streamType != oldestIndex)
                        sampleState = _streams[oldestIndex];

                    if (sampleState.IsPending)
                        oldestIndex = -1;
                    else
                        sampleState.IsPending = true;
                }
            }

            if (oldestIndex >= 0)
            {
                var t = Task.Run(async () =>
                {
                    await Task.Delay((int)(10 * (1 + _random.GetRandomNumber()))).ConfigureAwait(false);

                    var mediaStreamSource = _mediaStreamConfigurator;

                    if (null != mediaStreamSource)
                        mediaStreamSource.GetSampleAsync(oldestIndex);
                });

                TaskCollector.Default.Add(t, "SimulatedMediaElementManager.ReportGetSampleCompleted");
            }
        }
Beispiel #35
0
        protected override void CreateScene()
        {
            this.Load(WaveContent.Scenes.MyScene);

            this.CreateShip();
            this.CreateExplosion();

            this.CreateGrounds();
            this.CreateObstacles();

            this.state = SampleState.Playing;
            ScrollBehavior.ScrollSpeed = SCROLLSPEED;

            this.AddSceneBehavior(new CollisionSceneBehavior(), SceneBehavior.Order.PostUpdate);
        }
Beispiel #36
0
        protected override void CreateScene()
        {
            FixedCamera2D camera2d = new FixedCamera2D("camera");
            EntityManager.Add(camera2d);
                
            this.CreateExplosion();
            this.CreateShip();

            Vector2 topLeftCorner = Vector2.Zero;
            WaveServices.ViewportManager.RecoverPosition(ref topLeftCorner);

            this.ground = this.CreateGround("ground1", topLeftCorner.X);
            this.ground2 = this.CreateGround("ground2", topLeftCorner.X + 1024);
            this.ground3 = this.CreateGround("ground3", topLeftCorner.X + 2048);
            this.CreateObstacles();
            this.CreateBackground();

            this.state = SampleState.Playing;
            ScrollBehavior.ScrollSpeed = SCROLLSPEED;
            
            this.AddSceneBehavior(new CollisionSceneBehavior(), SceneBehavior.Order.PostUpdate);
        }