public static void EnemyAction() { for (int i = 0; i < lstEnemyData.Count; i++) { EnemyTriggerAreaSetting(i); //DebugView if (lstEnemyData[i].isDamage) { EnemyInvincibleTimeCount(i); if (lstEnemyData[i].isKnockBack) { SystemOperator.BoundObject(ref lstEnemyData[i].position, SystemOperator.FaceEachOther(lstEnemyData[i].position.X, PlayerStatus.playerPos.X), ref lstEnemyData[i].totalDistance, lstEnemyData[i].targetDistance, ref lstEnemyData[i].bps, ref lstEnemyData[i].coefficient, ref lstEnemyData[i].boundDirection, lstEnemyData[i].weight, lstEnemyData[i].speed, lstEnemyData[i].jumpPower, lstEnemyData[i].size, ref lstEnemyData[i].isKnockBack); } } if (!lstEnemyData[i].isKnockBack) { EnemyFalling(i, lstEnemyData[i].direction, lstEnemyData[i].position, lstEnemyData[i].size, lstEnemyData[i].speed, lstEnemyData[i].targetDistance); } switch (lstEnemyData[i].state) { case EnemyState.Spawn: lstEnemyData[i].state = EnemyState.Idle; break; case EnemyState.Idle: EnemyIdle(i); break; case EnemyState.Normal: EnemyNormal(i); break; case EnemyState.Active: EnemyActiv(i); break; case EnemyState.Death: if (!lstEnemyData[i].isWaiting && !lstEnemyData[i].isDeath) { lstEnemyData[i].totalWaitTime = 0; lstEnemyData[i].targetWaitTime = 2000; lstEnemyData[i].isWaiting = true; } else { EnemyWaiting(i); } break; } Canvas.SetLeft(lstEnemyData[i].imgEnemy, lstEnemyData[i].position.X); Canvas.SetTop(lstEnemyData[i].imgEnemy, lstEnemyData[i].position.Y); } }
public static void MovePlayer(Canvas canvas) { if (KeyController.keyLeft) { if (!BlockCheck.BlockCheckLeft(playerPos.X, playerPos.Y, (int)playerSize.Y, moveSpeed) && !ObjectChecker.obstacleLeft) { if (playerPos.X - SystemOperator.PixelPerSecond(moveSpeed) > 0) { playerPos.X -= SystemOperator.PixelPerSecond(moveSpeed); SystemOperator.moveCommonAmountX = moveSpeed; } playerDirection = false; } } if (KeyController.keyRight) { if (!BlockCheck.BlockCheckRight(playerPos.X, playerPos.Y, (int)playerSize.X, (int)playerSize.Y, moveSpeed) && !ObjectChecker.obstacleRight) { if (playerPos.X + SystemOperator.PixelPerSecond(moveSpeed) < 992) { playerPos.X += SystemOperator.PixelPerSecond(moveSpeed); SystemOperator.moveCommonAmountX = moveSpeed; } playerDirection = true; } } if (KeyController.keyLeft || KeyController.keyRight) { isMove = true; } else { isMove = false; } if (KeyController.keyUp && !TalkCommander.isTalk && !ObjectChecker.obstacleUp) { if (isLadder) { if (playerPos.Y - SystemOperator.PixelPerSecond(moveSpeed) > 0) { playerPos.Y -= SystemOperator.PixelPerSecond(moveSpeed); SystemOperator.moveCommonAmountY = moveSpeed; } } } if (KeyController.keyDown && !TalkCommander.isTalk && !ObjectChecker.obstacleDown) { if (isLadder) { if (playerPos.Y + SystemOperator.PixelPerSecond(moveSpeed) < 768) { playerPos.Y += SystemOperator.PixelPerSecond(moveSpeed); SystemOperator.moveCommonAmountY = moveSpeed; } } if (isPlat) { if (playerPos.Y + SystemOperator.PixelPerSecond(moveSpeed) < 768) { playerPos.Y += SystemOperator.PixelPerSecond(moveSpeed); SystemOperator.moveCommonAmountY = moveSpeed; } } if (!isLadder) { isSquat = true; } } else { isSquat = false; } //jump if (KeyController.keySpace && jumpCount == 0) { if (playerPos.Y - jumpPower > 0) { jumpCount++; jumping = true; } } if (jumping) { if (jumpTotalLength < jumpMaxHeight && !BlockCheck.BlockCheckTop(playerPos.X, playerPos.Y, (int)playerSize.X, jumpPower) && !ObjectChecker.obstacleUp) { playerPos.Y -= SystemOperator.PixelPerSecond(jumpPower); SystemOperator.moveCommonAmountY = SystemOperator.PixelPerSecond(jumpPower); jumpTotalLength += SystemOperator.PixelPerSecond(jumpPower); } else { jumping = false; jumpTotalLength = 0; } } //itemget if (KeyController.keyA) { PlayerItemGetting(canvas); } //Attack if (KeyController.keyS) { SubWeapon.SubWeaponGenerate(canvas, playerPos.X, playerPos.Y); } if (KeyController.keyD) { if (!isMainAttack) { MainWeapon.imgMainWeapon.Visibility = Visibility.Visible; meleeDirection = playerDirection; isMainAttack = true; } } if (KeyController.keyE) { if (ObjectChecker.isTrigger && !TalkCommander.isTalk) { ObjectBehavior.OnTriggerReactEvent(); } } if (isKnockBack) { SystemOperator.BoundObject(ref playerPos, boundDirectionX, ref knockBackTotalDis, knockBackTargetDis, ref knockBackBps, ref coefficient, ref boundDirectionY, weight, moveSpeed, jumpPower, playerSize, ref isKnockBack); } //image change if (GameTransition.gameTransition == GameTransitionType.StageDuring) { if (KeyController.keyLeft || KeyController.keyRight) { if (!playerDirection) { ImageData.imgPlayer.Source = ImageData.ImageSourceSelector(CategoryName.Player, StageData.lstDbPlayer.spriteMoveL); } else { ImageData.imgPlayer.Source = ImageData.ImageSourceSelector(CategoryName.Player, StageData.lstDbPlayer.spriteMoveR); } } else { if (!playerDirection) { ImageData.imgPlayer.Source = ImageData.ImageSourceSelector(CategoryName.Player, StageData.lstDbPlayer.spriteIdleL); } else { ImageData.imgPlayer.Source = ImageData.ImageSourceSelector(CategoryName.Player, StageData.lstDbPlayer.spriteIdleR); } } if (isSquat) { if (!playerDirection) { ImageData.imgPlayer.Source = ImageData.ImageSourceSelector(CategoryName.Player, StageData.lstDbPlayer.spriteSquatL); } else { ImageData.imgPlayer.Source = ImageData.ImageSourceSelector(CategoryName.Player, StageData.lstDbPlayer.spriteSquatR); } } if (jumping) { if (!playerDirection) { ImageData.imgPlayer.Source = ImageData.ImageSourceSelector(CategoryName.Player, StageData.lstDbPlayer.spriteJumpL); } else { ImageData.imgPlayer.Source = ImageData.ImageSourceSelector(CategoryName.Player, StageData.lstDbPlayer.spriteJumpR); } } if (isLadder && (KeyController.keyUp || KeyController.keyDown)) { ImageData.imgPlayer.Source = ImageData.ImageSourceSelector(CategoryName.Player, StageData.lstDbPlayer.spriteLadder); } } Canvas.SetLeft(ImageData.imgPlayer, playerPos.X); Canvas.SetTop(ImageData.imgPlayer, playerPos.Y); }