public static void CollisionPtoE() { if (!flagDamaged) { for (int i = 0; i < SpawnEnemy.lstEnemyData.Count; i++) { Vector p1 = new Vector(Canvas.GetLeft(ImageData.imgPlayer), Canvas.GetTop(ImageData.imgPlayer)); Vector size1 = new Vector(playerSize.X, playerSize.Y); Vector p2 = new Vector(Canvas.GetLeft(SpawnEnemy.lstEnemyData[i].imgEnemy), Canvas.GetTop(SpawnEnemy.lstEnemyData[i].imgEnemy)); Vector size2 = new Vector(SpawnEnemy.lstEnemyData[i].size.X, SpawnEnemy.lstEnemyData[i].size.Y); if (CollisionCheck.Collision(p1, p2, size1, size2)) { if (!Sound.seStop) { Sound.SoundEffectSelector(SeName.Player_Damage); Sound.SoundEffectPlayer(SeName.Player_Damage); Sound.seStop = true; } if (!isKnockBack) { //playerPos = new Vector(Canvas.GetLeft(ImageData.imgPlayer), Canvas.GetTop(ImageData.imgPlayer)); boundDirectionX = SystemOperator.FaceEachOther(playerPos.X, SpawnEnemy.lstEnemyData[i].position.X); knockBackTotalDis = new Vector(0, 0); knockBackBps = new Vector(0, 0); coefficient = 0; boundDirectionY = false; knockBackTargetDis = new Vector(64, 64); isKnockBack = true; } if (playerNowHp > 0) { playerNowHp -= SpawnEnemy.lstEnemyData[i].ofepower; ImageData.imgPlayer.Opacity = 0.6; } flagDamaged = true; damageInvincibleTotal = 0; Console.WriteLine("Break"); break; } } } }
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); } }