protected void UpdateFadeIn(GameTime gameTime) { mFadeTimer.Update(gameTime); if (mFadeTimer.IsTime()) { mFadeTimer.Initialize(); mFadeState = FadeState.NONE; } }
private void DashUpdate(float deltaTime) { mDashTimer.Update(deltaTime); if (mDashTimer.Rate() <= 0.3f) { mVelocity.X = GameDevice.Instance().GetRandom().Next(-1, 2) * mSpeed; } else { mVelocity.Y = 0; mVelocity.X = ((int)mCurrentDir - 2) * (mDashSpeed - (mDashTimer.Rate() * 500)); if (mHitPoint <= mMaxHitPoint / 2) { mVelocity.X = ((int)mCurrentDir - 2) * (mDashSpeed * 1.2f - (mDashTimer.Rate() * 500)); } } if (mDashTimer.IsTime()) { mDashTimer.Initialize(); mAttackState = AttackState.Stay; if (mHitPoint <= mMaxHitPoint / 3) { mAttackState = AttackState.Attack; } } }
private void Dash(float deltaTime) { if (mMoveState != MoveState.Dash && Input.GetKeyTrigger(Keys.X) && mDashCount > 0) { GameDevice.Instance().GetSound().PlaySE("shotSE"); mMoveState = MoveState.Dash; SetAlpha(0.5f); mDashCount--; } if (mMoveState == MoveState.Dash) { mDashTimer.Update(deltaTime); mVelocity.Y = 0; mVelocity.X = ((int)mPreviousDir - 2) * mDashSpeed; //ダッシュ状態中、先行入力受付 Input.SetBufferKey(Keys.Space); Input.SetBufferKey(Keys.Z); //Input.SetBufferKey(Keys.X); if (mDashTimer.IsTime()) { mMoveState = MoveState.JumpDown; mDashTimer.Initialize(); SetAlpha(1.0f); Input.BufferInput(); } } }
private void DamageMove(float deltaTime) { if (mMoveState == MoveState.Damage) { mDamageMovetimer.Update(deltaTime); if (mDamageMovetimer.IsTime()) { mDamageMovetimer.Initialize(); mMoveState = MoveState.JumpDown; } } }
/// <summary> /// 更新継承処理 /// (当たり判定を生成し続ける) /// </summary> /// <param name="gameTime"></param> public override void Update(GameTime gameTime) { hitArea = new Rectangle(new Point((int)position.X, (int)position.Y), new Point(64)); //ボタンが押されるたびに小さく上下する if (Input.IskeyDown(Keys.Space) || Input.IskeyDown(Keys.Right) || Input.IsButtonDown(Buttons.A)) { //もし衝突フラグが立っていたら操作不能(操作が止まってくれない) //if (isHitFlag) position.X += 0; if (position.Y < 500) { position.Y += jumpPower; } else if (position.Y >= 500) { position.Y -= jumpPower; } //移動中(ボタン押下中)は移動SEを再生させる soundDevice.PlaySE("jam_walk"); } if (isHitFlag)//敵と衝突したら { //hitTimer.Initialize();//タイマーをセット hitTimer.Update(gameTime); //フラグが立った瞬間にタイマーを起動 if (hitTimer.IsTime()) //時間切れになったら { //フラグを戻し、挙動を元通りに isHitFlag = false; // hitTimer.Initialize(); //タイマーを元通りに soundDevice.PauseSE(); //SEとまらねぇ・・・ jumpPower = 15f; //移動速度を元に戻す mediator.InitScroll(); //ゲーム仲介者に委託 //↓のように定数をその都度示す手間をなくす //Camera_2D.pushScroll = 30f;//ボタンを押すことで進む量も元に戻す //Camera_2D.totalMove = 15f; } } if (isGetFlag)//アイテムをゲットした場合 { //speedUpTimer.Initialize(); speedUpTimer.Update(gameTime); if (speedUpTimer.IsTime())//時間切れになったら { isGetFlag = false; speedUpTimer.Initialize(); //タイマーをもとに戻す mediator.InitScroll(); //速度を元通りに } } }
public override void Update(GameTime gameTime) { motion.Update(gameTime); if (isMessage) { timer.Update(gameTime); } if (timer.IsTime()) { isMessage = false; timer.Initialize(); } }
private void InvisibleUpdate(float deltaTime) { if (mIsInvisible) { SetAlpha(0.5f); mInvisibleTimer.Update(deltaTime); if (mInvisibleTimer.IsTime()) { SetAlpha(1.0f); mIsInvisible = false; mInvisibleTimer.Initialize(); } } }
public override void Update(float deltaTime) { if (HitStop.mIsHitStop) { return; } base.Update(deltaTime); switch (mAttackState) { case AttackState.Stay: StayUpdate(deltaTime); break; case AttackState.Dash: DashUpdate(deltaTime); break; case AttackState.Jump: JumpUpdate(deltaTime); break; case AttackState.Attack: AttackUpdate(deltaTime); break; } Fall(); Translate(mVelocity * deltaTime); if (mIsPlayerAttackCollision) { mIsCollisionTimer.Update(deltaTime); mHitStopTimer -= deltaTime; if (mHitStopTimer <= 0) { mHitStopTimer = 0.1f; HitStop.mHitStopScale = 1.6f; HitStop.mHitStopTime = 0.3f; HitStop.mIsHitStop = true; } if (mIsCollisionTimer.IsTime()) { mIsCollisionTimer.Initialize(); mIsPlayerAttackCollision = false; } } }
private void AttackUpdate(float deltaTime) { mAttackTimer.Update(deltaTime); if (mAttackTimer.IsTime()) { mAttackTimer.Initialize(); int min = 0; int max = 0; if (mCurrentDir == Direction.Right) { min = 0; max = 2; } else { min = -1; max = 1; } if (mHitPoint <= mMaxHitPoint / 2) { if (mCurrentDir == Direction.Right) { min = 0; max = 3; } else { min = -2; max = 1; } } for (int i = min; i < max; i++) { for (int j = -1; j < 2; j++) { new BossAttack("boss", new Vector2(64, 64), mOrigin, new Vector2(i, j)); } } GameDevice.Instance().GetSound().PlaySE("shotSE"); mAttackState = AttackState.Stay; } else { mVelocity.X = GameDevice.Instance().GetRandom().Next(-1, 2) * mSpeed; } }
private bool isGetFlag; //アイテムゲット用フラグ /// <summary> /// コンストラクタ /// </summary> /// <param name="position">描画位置</param> /// <param name="rectangle">当たり判定の大きさ(矩形)</param> public Player(IGameMediator mediator) : base("kusai mini2", new Vector2(150, 500), 64, mediator) { #region 抽象クラスからの継承により省略 //position = new Vector2(150, 500); //positionの座標を基準とする一辺64の矩形(四角形)の当たり判定 //hitArea = new Rectangle(new Point((int)position.X, (int)position.Y), new Point(64)); #endregion #region Camera_2Dクラスのスクロール処理に移動 //フラグをfalseにするれないため一旦コメントアウト) //if (Input.GetKeyState(Keys.Right) || Input.GetKeyState(Keys.Space)) Inputクラスを活用すると反映されないから断念涙 //{ // position.X += 1f; //} #endregion #region 操作処理→Camera_2Dクラスに移動 //キーボード //if(Input.IskeyDown(Keys.Space) || Input.IskeyDown(Keys.Right)) //{ // position.X += 12.0f;//スピードを調節予定 //} ////ゲームパッド(新しく用意したよ) //if (Input.IsButtonDown(Buttons.A)) //{ // position.X += 12.0f; //} #endregion #region 敵と自分の当たり判定が交わったら→Game1クラスに委託 //if (hitArea.Intersects(enemy.HitArea())) //{ // Hit();//ヒットメソッドを発動 //} #endregion //item = new Item(); //enemy = new Enemy(); hitTimer = new CountDownTimer(2.5f); hitTimer.Initialize(); speedUpTimer = new CountDownTimer(1.5f); speedUpTimer.Initialize(); isGetFlag = false; jumpPower = 15f; }
private void StayUpdate(float deltaTime) { mStayTimer.Update(deltaTime); mVelocity.X = 0; if (ObjectManager.Instance().GetPlayer() != null) { float playerDir = ObjectManager.Instance().GetPlayer().GetOrigin().X - mOrigin.X; if (playerDir > 0) { mCurrentDir = Direction.Right; } else { mCurrentDir = Direction.Left; } } if (mCurrentDir == Direction.Left) { mName = "boss_left"; } if (mCurrentDir == Direction.Right) { mName = "boss_right"; } if (mStayTimer.IsTime()) { mStayTimer.Initialize(); if (ObjectManager.Instance().GetPlayer() != null) { if (Vector2.Distance(ObjectManager.Instance().GetPlayer().GetOrigin(), mOrigin) >= Screen.WIDTH / 3) { mAttackState = (AttackState)GameDevice.Instance().GetRandom().Next((int)AttackState.Dash, (int)AttackState.Jump + 1); //mAttackState = AttackState.Dash; } else { mAttackState = (AttackState)GameDevice.Instance().GetRandom().Next((int)AttackState.Jump, (int)AttackState.Attack + 1); } } } }
private void WeakAttack(float deltaTime) { if (Input.GetKeyTrigger(Keys.Z) && mAttackState == AttackState.None) { GameDevice.Instance().GetSound().PlaySE("shotSE"); new PlayerWeakAttack("sikaku", new Vector2(32, 32), mOrigin, (int)mCurrentDir, new CountDownTimer(0.1f)); mAttackState = AttackState.WeakAttack; } if (mAttackState == AttackState.WeakAttack) { mVelocity = Vector2.Zero; mWeakAttackTimer.Update(deltaTime); if (mWeakAttackTimer.IsTime()) { mWeakAttackTimer.Initialize(); mAttackState = AttackState.None; } } }
private void JumpUpdate(float deltaTime) { mJumpTimer.Update(deltaTime); if (mJumpTimer.Rate() <= 0.1f) { mVelocity.Y = -mJumpPower; if (mHitPoint <= mMaxHitPoint / 2) { mVelocity.Y = -mJumpPower * 1.2f; } } mVelocity.X = ((int)mCurrentDir - 2) * mSpeed; if (mHitPoint <= mMaxHitPoint / 2) { mVelocity.X = ((int)mCurrentDir - 2) * mSpeed * 1.2f; } if (mJumpTimer.IsTime()) { mJumpTimer.Initialize(); mAttackState = AttackState.Stay; } }