public override void OnMove() { if (!IsValid()) { return; } if (!m_pParent.IsPlayable()) { return; } if (m_bFirst) { HitCheck(); m_bFirst = false; } float Wind = m_pParent.GetWind((int)Math.Floor(m_X / 32), (int)Math.Floor(m_Y / 32)); float Friction = m_pParent.GetFriction((int)Math.Floor(m_X / 32), (int)Math.Floor((m_Y + 14) / 32)); float Gravity = GetGravity(); if (m_pParent.ItemCompleted()) { Smile(); } if (Cf3Setting.theSetting.m_Hyper != 0) { m_nPower = 4; } // 動かしま~す if (m_State == f3MainCharaState.STANDING || m_State == f3MainCharaState.SLEEPING || m_State == f3MainCharaState.BLINKING) { // 立ってるとき m_DX -= WINDFACTOR * (m_DX - Wind) * RUNFRICTION; TL.BringClose(ref m_DX, 0.0f, Friction); if (m_DX == 0) { m_Direction = f3MapObjectDirection.DIR_FRONT; } if (m_State == f3MainCharaState.STANDING && ++m_Sleepy >= 30 * 40 / 3) { Sleep(); } if (m_State == f3MainCharaState.BLINKING && --m_PoseCounter == 0) { m_State = f3MainCharaState.STANDING; } if (m_State == f3MainCharaState.STANDING && CApp.theApp.random(120) == 0) { Blink(); } if (m_PowerY <= 0 && m_pInput.GetKeyPressed((int)F3KEY.F3KEY_JUMP)) { StartJump(); } if (m_PowerX <= 0 && m_pInput.GetKeyPressed((int)F3KEY.F3KEY_LEFT)) { Run(f3MapObjectDirection.DIR_LEFT); } if (m_PowerX >= 0 && m_pInput.GetKeyPressed((int)F3KEY.F3KEY_RIGHT)) { Run(f3MapObjectDirection.DIR_RIGHT); } if (m_pInput.GetKeyPressed((int)F3KEY.F3KEY_DOWN)) { Sit(); } if (m_pInput.GetKeyPushed((int)F3KEY.F3KEY_ATTACK)) { BreatheIn(); } if (!m_HitBottom) { Fall(); } } else if (m_State == f3MainCharaState.RUNNING) { // 走ってるとき int AXL = 0, AXR = 0; if (m_PowerX <= 0 && m_pInput.GetKeyPressed((int)F3KEY.F3KEY_LEFT)) { AXL = 1; } if (m_PowerX >= 0 && m_pInput.GetKeyPressed((int)F3KEY.F3KEY_RIGHT)) { AXR = 1; } m_DX -= Friction * (m_DX - Wind) * RUNFRICTION; m_DX += Friction * 2.0f * (AXR - AXL); if (AXL != 0 && AXR == 0) { m_Direction = f3MapObjectDirection.DIR_LEFT; } if (AXR != 0 && AXL == 0) { m_Direction = f3MapObjectDirection.DIR_RIGHT; } if (AXL == 0 && AXR == 0) { Stop(); } if (m_PowerY <= 0 && m_pInput.GetKeyPressed((int)F3KEY.F3KEY_JUMP)) { StartJump(); } if (m_pInput.GetKeyPressed((int)F3KEY.F3KEY_DOWN)) { Sit(); } if (m_pInput.GetKeyPushed((int)F3KEY.F3KEY_ATTACK)) { BreatheIn(); } if (!m_HitBottom) { Fall(); } } else if (m_State == f3MainCharaState.WALKING) { // 歩いてるとき int AXL = 0, AXR = 0; if (m_PowerX <= 0 && m_pInput.GetKeyPressed((int)F3KEY.F3KEY_LEFT)) { AXL = 1; } if (m_PowerX >= 0 && m_pInput.GetKeyPressed((int)F3KEY.F3KEY_RIGHT)) { AXR = 1; } m_DX += WALKACCEL * (AXR - AXL); m_DX -= m_DX * WALKFRICTION; if (AXL != 0 && AXR == 0) { m_Direction = f3MapObjectDirection.DIR_LEFT; } if (AXR != 0 && AXL == 0) { m_Direction = f3MapObjectDirection.DIR_RIGHT; } if (AXL == 0 && AXR == 0) { m_Direction = f3MapObjectDirection.DIR_FRONT; } if (!m_pInput.GetKeyPressed((int)F3KEY.F3KEY_DOWN)) { Stop(); } if (m_PowerY <= 0 && m_pInput.GetKeyPushed((int)F3KEY.F3KEY_JUMP)) { StartJump(); } if (m_pInput.GetKeyPushed((int)F3KEY.F3KEY_ATTACK)) { BreatheIn(); } if (!m_HitBottom) { Fall(); } } else if (m_State == f3MainCharaState.CHARGING) { // パワー充填中 if (m_ChargePower > 0) { m_ChargePower -= m_ChargeDec; if (m_ChargePower < 0) { m_ChargePower = 0; } } m_X -= m_DX; if (m_pInput.GetKeyPushed((int)F3KEY.F3KEY_DOWN)) { Sit(); } if (m_pInput.GetKeyPushed((int)F3KEY.F3KEY_ATTACK)) { BreatheIn(); } if (!m_pInput.GetKeyPressed((int)F3KEY.F3KEY_JUMP)) { Jump(); } if (!m_HitBottom) { Fall(); } } else if (m_State == f3MainCharaState.JUMPING) { // 空中 if (m_DY >= 0) { int AXL = 0, AXR = 0; if (m_PowerX <= 0 && m_pInput.GetKeyPressed((int)F3KEY.F3KEY_LEFT)) { AXL = 1; } if (m_PowerX >= 0 && m_pInput.GetKeyPressed((int)F3KEY.F3KEY_RIGHT)) { AXR = 1; } m_DX -= (m_DX - Wind) * JUMPFRICTIONX; m_DX += JUMPACCEL * (AXR - AXL); if (AXL != 0 && AXR == 0) { m_Direction = f3MapObjectDirection.DIR_LEFT; } if (AXR != 0 && AXL == 0) { m_Direction = f3MapObjectDirection.DIR_RIGHT; } } if (m_HitLeft || m_HitRight) { m_Direction = f3MapObjectDirection.DIR_FRONT; } m_DY += Gravity; if (m_DY >= 0) { if (m_PowerY >= 0 && m_pInput.GetKeyPressed((int)F3KEY.F3KEY_DOWN)) { m_DY += Gravity * ADDGRAVITY; } m_DY -= m_DY * JUMPFRICTIONY; if (m_pInput.GetKeyPressed((int)F3KEY.F3KEY_UP)) { m_DY += Gravity; m_DY -= m_DY * JUMPFRICTIONY; } } if (m_pInput.GetKeyPushed((int)F3KEY.F3KEY_ATTACK)) { BreatheIn(); } if (m_HitBottom) { Land(); } } else if (m_State == f3MainCharaState.BREATHEIN) { // 冷気充填中 m_ChargePower += 1.0f; if (m_pInput.GetKeyPushed((int)F3KEY.F3KEY_LEFT)) { m_Direction = f3MapObjectDirection.DIR_LEFT; } if (m_pInput.GetKeyPushed((int)F3KEY.F3KEY_RIGHT)) { m_Direction = f3MapObjectDirection.DIR_RIGHT; } if (m_pInput.GetKeyPushed((int)F3KEY.F3KEY_UP)) { m_Direction = f3MapObjectDirection.DIR_FRONT; } if (m_HitBottom) { m_DX -= WINDFACTOR * (m_DX - Wind) * RUNFRICTION; TL.BringClose(ref m_DX, 0.0f, Friction); if (m_pInput.GetKeyPushed((int)F3KEY.F3KEY_DOWN)) { Sit(); } } else { m_ChargePower += 1.0f; if (m_DY >= 0) { m_DX -= (m_DX - Wind) * JUMPFRICTIONX; } m_DY += Gravity; if (m_DY >= 0) { m_DY -= m_DY * JUMPFRICTIONY; } } if (!m_pInput.GetKeyPressed((int)F3KEY.F3KEY_ATTACK)) { BreatheOut(); } } else if (m_State == f3MainCharaState.BREATHEOUT) { // 冷気放出!! m_ChargePower -= 1.0f; if (m_HitBottom) { m_DX -= WINDFACTOR * (m_DX - Wind) * RUNFRICTION; TL.BringClose(ref m_DX, 0.0f, Friction); } else { if (m_DY >= 0) { m_DX -= (m_DX - Wind) * JUMPFRICTIONX; } m_DY += Gravity; if (m_DY >= 0) { m_DY -= m_DY * JUMPFRICTIONY; } } if (m_ChargePower <= 0.0f) { if (m_nPower != 0) { if (m_HitBottom) { Land(); } else { Fall(); } } else { Tire(); } } } else if (m_State == f3MainCharaState.TIRED) { // ちかれたー! m_PoseCounter--; if (m_HitBottom) { m_DX -= WINDFACTOR * (m_DX - Wind) * RUNFRICTION; TL.BringClose(ref m_DX, 0.0f, Friction); } else { m_DX -= (m_DX - Wind) * JUMPFRICTIONX; if (m_HitLeft || m_HitRight) { m_Direction = f3MapObjectDirection.DIR_FRONT; } m_DY += Gravity; m_DY -= m_DY * JUMPFRICTIONY; } if (m_PoseCounter == 0) { Land(); } } else if (m_State == f3MainCharaState.FROZEN) { // 凍っちゃった… m_PoseCounter--; if (m_HitBottom) { m_DX -= WINDFACTOR * (m_DX - Wind) * RUNFRICTION / 5; TL.BringClose(ref m_DX, 0.0f, Friction / 5); } else { m_DX -= (m_DX - Wind) * JUMPFRICTIONX / 5; m_DY += Gravity * (1 + ADDGRAVITY); m_DY -= m_DY * JUMPFRICTIONY / 5; } if (m_PoseCounter == 0) { Land(); } } // 速度飽和(めり込み防止) TL.Saturate(-RUNMAX, ref m_DX, RUNMAX); TL.Saturate(-JUMPMAX, ref m_DY, FALLMAX); // 実際の移動+当たり判定 // 1回の移動ごとに当たり判定 // という手順ですり抜けバグは解消されるはず m_HitLeft = m_HitRight = m_HitTop = m_HitBottom = false; m_X += m_DX; HitCheck(); if (!m_HitTop && !m_HitBottom) { m_Y += m_DY; HitCheck(); } }
public override void OnMove() { if (m_State == f3EelPitcherState.EELLEAF) { TL.BringClose(ref m_Y, m_RootY - m_Level * 32, 4.0f); m_DX = m_DX + (m_pParent.GetWind((int)Math.Floor(m_X / 32), (int)Math.Floor(m_Y / 32)) - m_DX) * m_Level * 0.1f + (m_RootX - m_X) * 0.025f; TL.Saturate(-14.0f, ref m_DX, 14.0f); m_X += m_DX; if (m_pParent.GetHit((int)Math.Floor((m_X - 16) / 32), (int)Math.Floor(m_Y / 32), HIT.HIT_RIGHT)) { m_DX = 0; m_X = (int)Math.Floor(m_X / 32) * 32 + 16; } else if (m_pParent.GetHit((int)Math.Floor((m_X + 16) / 32), (int)Math.Floor(m_Y / 32), HIT.HIT_LEFT)) { m_DX = 0; m_X = (int)Math.Floor(m_X / 32) * 32 + 16; } } else if (m_State == f3EelPitcherState.EELFROZEN) { if (--m_Delay == 0) { m_Y += 16; m_State = f3EelPitcherState.EELSEED; m_Delay = 200; new Cf3MapObjectEffect(m_X, m_Y, 0); } } else if (m_State == f3EelPitcherState.EELSEED) { TL.BringClose(ref m_DY, 8.0f, 1.0f); m_DX += (m_pParent.GetWind((int)Math.Floor(m_X / 32), (int)Math.Floor(m_Y / 32)) - m_DX) * 0.2f; TL.Saturate(-14.0f, ref m_DX, 14.0f); m_X += m_DX; if (m_pParent.GetHit((int)Math.Floor((m_X - 16) / 32), (int)Math.Floor(m_Y / 32), HIT.HIT_RIGHT)) { m_DX = 0; m_X = (int)Math.Floor(m_X / 32) * 32 + 16; } else if (m_pParent.GetHit((int)Math.Floor((m_X + 16) / 32), (int)Math.Floor(m_Y / 32), HIT.HIT_LEFT)) { m_DX = 0; m_X = (int)Math.Floor(m_X / 32) * 32 + 16; } m_Y += m_DY; if ((int)Math.Floor(m_Y / 32) != (int)Math.Floor((m_Y - m_DY) / 32)) { // 32ドット境界をまたいだ!! if (m_pParent.GetHit((int)Math.Floor(m_X / 32), (int)Math.Floor(m_Y / 32), HIT.HIT_TOP) || (int)Math.Floor(m_Y / 32) >= m_pParent.GetHeight()) { Seed(); } else { if (m_pParent.GetHit((int)Math.Floor((m_X - 16) / 32), (int)Math.Floor(m_Y / 32), HIT.HIT_RIGHT)) { m_DX = 0; m_X = (int)Math.Floor(m_X / 32) * 32 + 16; } else if (m_pParent.GetHit((int)Math.Floor((m_X + 16) / 32), (int)Math.Floor(m_Y / 32), HIT.HIT_LEFT)) { m_DX = 0; m_X = (int)Math.Floor(m_X / 32) * 32 + 16; } } } } else if (m_State == f3EelPitcherState.EELBUD) { if (--m_Delay == 0) { m_State = f3EelPitcherState.EELLEAF; } } else if (m_State == f3EelPitcherState.EELDEAD) { Kill(); } }
public override void GetViewPos(out int vx, out int vy) { if (m_pParent.IsPlayable()) { int tx = 0, ty = 0; if (m_pInput.GetKeyPressed((int)F3KEY.F3KEY_RIGHT)) { tx += 1; } if (m_pInput.GetKeyPressed((int)F3KEY.F3KEY_LEFT)) { tx += 2; } if (m_pInput.GetKeyPressed((int)F3KEY.F3KEY_DOWN)) { ty += 1; } if (m_pInput.GetKeyPressed((int)F3KEY.F3KEY_UP)) { ty += 2; } if (tx == 0) { ; } else if (tx == 1) { m_VOffsetToX = 100; } else if (tx == 2) { m_VOffsetToX = -100; } else if (tx == 3) { m_VOffsetToX = 0; } if (ty == 0) { ; } else if (ty == 1) { m_VOffsetToY = 50; } else if (ty == 2) { m_VOffsetToY = -50; } else if (ty == 3) { m_VOffsetToY = 0; } TL.BringClose(ref m_VOffsetX, m_VOffsetToX, 1 + (m_DX * m_VOffsetToX < 0 ? 1 : 0) + (m_VOffsetX * m_VOffsetToX < 0 ? 1 : 0)); TL.BringClose(ref m_VOffsetY, m_VOffsetToY, 1 + (m_DY * m_VOffsetToY < 0 ? 1 : 0) + (m_VOffsetY * m_VOffsetToY < 0 ? 1 : 0)); var ox = m_VOffsetX; var oy = m_VOffsetY; vx = (int)(m_X + ox); vy = (int)(m_Y + oy); } else { vx = (int)m_X; vy = (int)m_Y; } }
public override void OnMove() { if (!IsValid()) { return; } if (m_Type == NDT.NDT_UNDEFINED) { // このタイミングで初期化 if (m_pParent.GetHit((int)Math.Floor(m_X / 32), (int)Math.Floor((m_Y + 16) / 32), HIT.HIT_TOP)) { m_Type = NDT.NDT_HORIZONTAL; m_State = NDS.NDS_STOP; } else { m_Type = NDT.NDT_VERTICAL; m_StartY = m_Y; m_State = NDS.NDS_STOP; } } if (m_Type == NDT.NDT_HORIZONTAL) { if (m_State == NDS.NDS_STOP) { TL.BringClose(ref m_Speed, 0.0f, 1.0f); if (m_Speed == 0) { if (!m_pParent.GetHit((int)Math.Floor((m_X + 15) / 32), (int)Math.Floor((m_Y + 16) / 32), HIT.HIT_TOP) || m_pParent.GetHit((int)Math.Floor((m_X + 15) / 32), (int)Math.Floor((m_Y) / 32), HIT.HIT_LEFT)) { m_State = NDS.NDS_LEFT; } else { m_State = NDS.NDS_RIGHT; } } } else if (m_State == NDS.NDS_LEFT) { m_X -= 1; if (!m_pParent.GetHit((int)Math.Floor((m_X - 16) / 32), (int)Math.Floor((m_Y + 16) / 32), HIT.HIT_TOP) || m_pParent.GetHit((int)Math.Floor((m_X - 16) / 32), (int)Math.Floor((m_Y) / 32), HIT.HIT_RIGHT)) { m_State = NDS.NDS_STOP; m_Speed = 20; } } else if (m_State == NDS.NDS_RIGHT) { m_X += 1; if (!m_pParent.GetHit((int)Math.Floor((m_X + 15) / 32), (int)Math.Floor((m_Y + 16) / 32), HIT.HIT_TOP) || m_pParent.GetHit((int)Math.Floor((m_X + 15) / 32), (int)Math.Floor((m_Y) / 32), HIT.HIT_LEFT)) { m_State = NDS.NDS_STOP; m_Speed = 20; } } } else if (m_Type == NDT.NDT_VERTICAL) { if (m_State == NDS.NDS_STOP) { if (m_Speed != 0) { TL.BringClose(ref m_Speed, 0.0f, 1.0f); if (m_Speed == 0) { m_State = NDS.NDS_UP; } } } else if (m_State == NDS.NDS_UP) { TL.BringClose(ref m_Y, m_StartY, 1.0f); if (m_Y == m_StartY) { m_State = NDS.NDS_STOP; } } else if (m_State == NDS.NDS_DOWN) { m_Speed += 0.2f; TL.Saturate(0.0f, ref m_Speed, 10.0f); m_Y += m_Speed; if (m_pParent.GetHit((int)Math.Floor(m_X / 32), (int)Math.Floor((m_Y + 16) / 32), HIT.HIT_TOP)) { m_Y = (float)Math.Floor((m_Y + 16) / 32) * 32 - 15; m_Speed = 20; m_State = NDS.NDS_STOP; } else if (m_Y > m_pParent.GetHeight() * 32 + 16) { m_Type = NDT.NDT_DEAD; new Cf3MapObjectEffect(m_X, m_Y, 1); } } } else if (m_Type == NDT.NDT_DEAD) { Kill(); } }