public static void FallingPlayer() { if (!isLadder && !isPlat && !jumping) { if (!BlockCheck.BlockCheckBottom(playerPos.X, playerPos.Y, (int)playerSize.X, (int)playerSize.Y, weight)) { if (!isKnockBack) { playerPos.Y += SystemOperator.PixelPerSecond(weight); SystemOperator.moveCommonAmountY = SystemOperator.PixelPerSecond(weight); } if (!fallingStart) { fallingStartPoint = playerPos.Y; } fallingStart = true; isGround = false; } else { if (!isGround) { playerPos.Y = Math.Floor(playerPos.Y + SystemOperator.PixelPerSecond(weight) / 32) - 1; } if (fallingStart) { int block = 0; block = (int)(playerPos.Y - fallingStartPoint) / 32; if (block > fallingEndure) { Sound.SoundEffectSelector(SeName.Player_Damage); Sound.SoundEffectPlayer(SeName.Player_Damage); } } fallingStart = false; isGround = true; jumpCount = 0; } } Canvas.SetTop(ImageData.imgPlayer, playerPos.Y); }
public static void FallingItems() { for (int i = 0; i < lstItemData.Count; i++) { double posX = Canvas.GetLeft(lstItemData[i].imgItem); double posY = Canvas.GetTop(lstItemData[i].imgItem); if (!BlockCheck.BlockCheckBottom(posX, posY, (int)lstItemData[i].size.X, (int)lstItemData[i].size.Y, lstItemData[i].weight)) { posY += SystemOperator.PixelPerSecond(lstItemData[i].weight); } Canvas.SetTop(lstItemData[i].imgItem, posY); } }
private static void EnemyFalling(int index, bool direction, Vector pos, Vector size, int speed, Vector target) { if (!lstEnemyData[index].isLadder) { if ((!BlockCheck.BlockCheckBottom(pos.X, pos.Y, (int)size.X, (int)size.Y, lstEnemyData[index].weight))) { lstEnemyData[index].position.Y += SystemOperator.PixelPerSecond(lstEnemyData[index].weight); if (!lstEnemyData[index].isFalling) { lstEnemyData[index].fallingStartPoint = pos.Y; } lstEnemyData[index].isFalling = true; } else { if (lstEnemyData[index].isFalling) { int block = 0; block = (int)(pos.Y - lstEnemyData[index].fallingStartPoint) / 32; if (block > lstEnemyData[index].fallingEndure) { Sound.SoundEffectSelector(SeName.Shock); Sound.SoundEffectPlayer(SeName.Shock); lstEnemyData[index].life -= 1; } } lstEnemyData[index].isFalling = false; lstEnemyData[index].jumpCount = 0; } } }
public static void BoundObject(ref Vector pos, bool charaDir, ref Vector total, Vector target, ref Vector bps, ref double coefficient, ref bool boundDir, int weight, int speed, int jumppower, Vector size, ref bool isKnockBack) { double addY = 0; double radian = 0; bps.X = target.X / 32 * PixelPerSecond(64); bps.Y = target.Y * bps.X / target.X; addY = coefficient * weight / (target.X / 2) * 0.102; radian = Math.Atan(bps.Y - addY / bps.X) * Math.PI / 180; if (!boundDir) { if (total.Y < target.Y) { if (!charaDir) { if (!BlockCheck.BlockCheckLeft(pos.X - bps.X, pos.Y, (int)size.Y, speed) && pos.X - bps.X > 0) { pos.X -= bps.X; } } else { if (!BlockCheck.BlockCheckRight(pos.X + bps.X, pos.Y, (int)size.X, (int)size.Y, speed) && pos.X + bps.X < 1024 - (int)size.X) { pos.X += bps.X; } } if (!BlockCheck.BlockCheckTop(pos.X, pos.Y - bps.Y, (int)size.X, jumppower) && pos.Y - bps.Y > 0) { pos.Y -= bps.Y; } total.X += Math.Sqrt(Math.Pow(bps.X, 2)); total.Y += Math.Sqrt(Math.Pow(bps.Y, 2)); bps.X += bps.X; bps.Y += bps.Y; coefficient++; } else { boundDir = true; total.Y = target.Y; } } else { if (total.Y > 0) { if (!charaDir) { if (!BlockCheck.BlockCheckLeft(pos.X - bps.X, pos.Y, (int)size.Y, speed) && pos.X - bps.X > 0) { pos.X -= bps.X; } } else { if (!BlockCheck.BlockCheckRight(pos.X + bps.X, pos.Y, (int)size.X, (int)size.Y, speed) && pos.X + bps.X < 1024 - (int)size.X) { pos.X += bps.X; } } if (!BlockCheck.BlockCheckBottom(pos.X, pos.Y + bps.Y, (int)size.X, (int)size.Y, weight) && pos.Y + bps.Y < 768 - (int)size.Y) { pos.Y += bps.Y; } total.X += Math.Sqrt(Math.Pow(bps.X, 2)); total.Y -= Math.Sqrt(Math.Pow(bps.Y, 2)); bps.X += bps.X; bps.Y += bps.Y; coefficient--; } else { boundDir = false; isKnockBack = false; } } }