private void Movement_MovementChanged(object sender, MovementValue e) { System.Diagnostics.Debug.WriteLine("x:" + e.AccX.ToString() + " y:" + e.AccY.ToString() + " z:" + e.AccZ.ToString()); graphCtrl1.AddValue(e.AccX); graphCtrl2.AddValue(e.AccY); graphCtrl3.AddValue(e.AccZ); }
public void fire(Vector2 start, Vector2 target) { m_Positions[0] = start; m_Positions[1] = start; m_PosXInFunction = start.X; if (target.X > start.X) { m_Direction = MovementValue.RIGHT; } else { m_Direction = MovementValue.LEFT; } m_Sin[0] = new SinFunction(50.0f, 0.08f, 0.0f, start.Y); m_Sin[1] = new SinFunction(50.0f, 0.08f, SinFunction.degreesToRadians(180.0f), start.Y); m_Positions[0] = new Vector2(start.X, 0); m_Positions[1] = new Vector2(start.X, 0); for (int i = 0; i < m_CollisionRects.Length; i++) { m_Particles[i].Stop = false; } }
private void OnMovementChanged(object sender, MovementValue e) { //Sends every 4th item to event hub if (++_skipCounter % 4 != 1) { return; } Task.Run(() => { bool success = false; MemoryStream stream = new MemoryStream(); DataContractJsonSerializer serializer = new DataContractJsonSerializer(typeof(MovementValue)); string serializedMsg = string.Empty; try { serializer.WriteObject(stream, e); success = true; } catch (Exception) { } stream.Position = 0; StreamReader streamReader = new StreamReader(stream); if (success) { try { serializedMsg = streamReader.ReadToEnd(); } catch (Exception) { } } if (serializedMsg != string.Empty) { _client.SendData(serializedMsg); } }); }
public void update(GameTime gameTime) { if (IsActive == true) { if (m_BossState != BossState.DYING && m_BossState != BossState.DEAD) { float elapsedTime = (float)gameTime.ElapsedGameTime.Milliseconds / 1000; if (m_BossState == BossState.IDLE) { Vector2 temp; Vector2.Subtract(ref m_Position, ref m_StartPos, out temp); if (temp.Length() > (m_IdleMoveDist - (m_IdleMoveDist * m_LerpDist))) { do { m_TargetPos = new Vector2(m_Random.Next(100) - 50, m_Random.Next(100) - 50); } while (m_TargetPos.X == 0 && m_TargetPos.Y == 0); m_TargetPos.Normalize(); m_TargetPos.X = m_TargetPos.X * m_IdleMoveDist; m_TargetPos.Y = m_TargetPos.Y * m_IdleMoveDist; } m_Position = Vector2.Lerp(m_Position, m_StartPos + m_TargetPos, m_LerpAmount); Position = m_Position; m_StateChangeTimer += elapsedTime; if (m_StateChangeTimer > m_StateDelay) { m_StateChangeTimer = 0.0f; do { m_BossState = (BossState)(m_Random.Next((int)BossState.COUNT)); //m_BossState = BossState.CHARGING; } while (m_BossState == BossState.LAVA_WAVE && m_LavaWave.IsActive == true); } m_Animate.changAnimation(1); } else if (m_BossState == BossState.CHARGING) { //boss is charging here ------------------------------------------------------------------------------------------------ for (int i = 0; i < m_Particles.Length; i++) { Vector2 temp; temp = new Vector2(m_Random.Next(100) - 50, m_Random.Next(100) - 50); temp.Normalize(); temp.X = temp.X * m_ChargeDist; temp.Y = temp.Y * m_ChargeDist; m_Particles[i].SpawnPoint = new Vector2(m_Animate.DestinationRectangle.X, m_Animate.DestinationRectangle.Y) + temp; m_Particles[i].DominantDirection = new Vector2(m_Animate.DestinationRectangle.X, m_Animate.DestinationRectangle.Y) - m_Particles[i].SpawnPoint; m_Particles[i].Stop = false; m_BossLaserPlayed = false; if (m_BossChargingSoundPlayer == false) { Sounds.playSound("BossCharging", 1.0f); m_BossChargingSoundPlayer = true; } } m_StateChangeTimer += elapsedTime; if (m_StateChangeTimer > m_StateDelay) { m_StateChangeTimer = 0.0f; m_BossState = BossState.FIRING; for (int i = 0; i < m_Particles.Length; i++) { m_Particles[i].Stop = true; } m_PlayerPos = new Vector2(Player.collisionRectangle().Center.X, Player.collisionRectangle().Center.Y); if (m_Animate.DestinationRectangle.Y < m_PlayerPos.Y) { m_Direction = MovementValue.DOWN; } else { m_Direction = MovementValue.UP; } } } else if (m_BossState == BossState.FIRING) { m_Position.Y += m_Speed * elapsedTime * (int)m_Direction; Position = m_Position; m_BossChargingSoundPlayer = false; if (m_Direction == MovementValue.DOWN && m_Animate.DestinationRectangle.Y > m_PlayerPos.Y || m_Direction == MovementValue.UP && m_Animate.DestinationRectangle.Y < m_PlayerPos.Y) { //boss shoots here --------------------------------------------------------------------------- if (m_BossLaserPlayed == false) { Sounds.playSound("BossLaser", 1.0f); m_BossLaserPlayed = true; } m_BeamManager.addBeam(new Vector2(m_Animate.DestinationRectangle.X, m_Animate.DestinationRectangle.Y), m_PlayerPos); m_BossState = BossState.IDLE; m_Direction = MovementValue.NONE; } } else if (m_BossState == BossState.LAVA_WAVE) { if (m_Position.X < m_StartPos.X + m_RetreatPos.X) { m_Position.X += m_Speed * elapsedTime; } else if ((m_Position.Y - m_Animate.DestinationRectangle.Height / 2 > m_StartPos.Y + m_RetreatPos.Y) && m_Drop == false) { m_Position.Y -= m_Speed * elapsedTime; if (m_Position.Y - m_Animate.DestinationRectangle.Height / 2 < m_StartPos.Y + m_RetreatPos.Y) { m_Drop = true; } } else if (m_Position.Y < m_StartPos.Y && m_Drop == true) { m_Position.Y += m_Speed * elapsedTime; if (m_BossWavePlayed == false) { Sounds.playSound("Wave", 1.0f); m_BossWavePlayed = true; } if (m_Position.Y > m_StartPos.Y) { m_LavaWave.SpawnTheWave(new Vector2(m_Position.X, Level.getHeightOfArray() * 32 - 2)); m_Drop = false; m_BossState = BossState.IDLE; m_BossWavePlayed = false; } } Position = m_Position; } else if (m_BossState == BossState.NARWHAL) { if (Vector2.Subtract(m_Position, m_StartPos + m_RainPos).Length() > m_RainJumpDist) { Vector2 temp = new Vector2(m_StartPos.X + m_RainPos.X - m_Position.X, m_StartPos.Y + m_RainPos.Y - m_Position.Y); temp.Normalize(); m_Position += temp * m_Speed / 4.0f * elapsedTime; } else { if (m_BossRoarPlayed == false) { Sounds.playSound("BossRoar", 1.0f); m_BossRoarPlayed = true; } m_StateChangeTimer += elapsedTime; Vector2 temp; do { temp = new Vector2(m_Random.Next(100) - 50, m_Random.Next(100) - 50); } while (temp.X == 0 && temp.Y == 0); temp.Normalize(); temp.X *= m_RainJumpDist; temp.Y *= m_RainJumpDist; m_Position = m_StartPos + m_RainPos + temp; m_NarwhalGun.NARWHAL(new Vector2(m_Position.X + m_GunPos.X, m_Position.Y + m_GunPos.Y)); //spitting narwhals here------------------------------------------------------------------------ if (m_StateChangeTimer > RAIN_LENGTH) { m_StateChangeTimer = 0.0f; m_BossState = BossState.IDLE; m_BossRoarPlayed = false; } } Position = m_Position; } } else if (m_BossState == BossState.DYING) { m_Position = Vector2.Lerp(m_Position, m_StartPos + m_Hidden, m_LerpAmount); //boss is dead here------------------------------------------------------------------------------------------ if (m_BossDeathPlayed == false) { Sounds.playSound("BossDeath", 1.0f); m_BossDeathPlayed = true; } Vector2 temp; do { temp = new Vector2(m_Random.Next(100) - 50, m_Random.Next(100) - 50); } while (temp.X == 0 && temp.Y == 0); temp.Normalize(); temp.X *= m_RainJumpDist / 2; temp.Y *= m_RainJumpDist / 2; m_Position += temp; Position = m_Position; if (m_Position.Y > m_StartPos.Y + m_Hidden.Y) { m_BossState = BossState.DEAD; } } else { if (m_Position.Y < m_StartPos.Y + m_Hidden.Y + m_MoreHidden.Y) { m_Position.Y++; Position = m_Position; Vector2 tempy = m_Lava.Pos; tempy.Y++; m_Lava.Pos = tempy; } } collisioncheck(); m_NarwhalGun.update(gameTime); m_BeamManager.update(gameTime); m_LavaWave.update(gameTime); m_Animate.update(gameTime); m_Lava.update(gameTime); for (int i = 0; i < m_Particles.Length; i++) { m_Particles[i].update(gameTime); } } }
private void Movement_MovementChanged(object sender, MovementValue e) { graphCtrl1.AddValue(e.GyroX); graphCtrl2.AddValue(e.GyroY); graphCtrl3.AddValue(e.GyroZ); }