// 前方に分岐撃ち void NWay(ref int jobIndex, ref Position2D enemyPosition, ref EnemyParam param, ref EnemyData data, int bulletCount) { float range = math.radians(this.BarrageParamPtr->CommonWay.Range); var angle = MathHelper.Aiming(enemyPosition.Value, this.PlayerPosition); int halfBulletCount = (int)(bulletCount / 2); for (int i = 0; i < bulletCount; ++i) { CommandBuffer.Instantiate(jobIndex, this.EnemyBulletPrefab); CommandBuffer.SetComponent(jobIndex, enemyPosition); CommandBuffer.SetComponent(jobIndex, new BulletData { Speed = param.BulletParam.Speed, Angle = angle + ((i - halfBulletCount) * range), Lifespan = param.BulletParam.Lifespan, }); } }
bool Movement(ref int jobIndex, ref Position2D enemyPosition, ref EnemyParam param, ref EnemyData data, ref float deltaTime) { // 破棄管理 if (param.Lifespan <= data.DeltaTimeCounter) { var destroyable = this.Destroyables[jobIndex]; destroyable = Destroyable.Kill; this.Destroyables[jobIndex] = destroyable; return(true); } // 移動 float2 dir = new float2(0f); switch ((SpawnPoint)data.SpawnPoint) { case SpawnPoint.LeftTop: case SpawnPoint.LeftMiddle: case SpawnPoint.LeftBottom: dir = new float2(1f, 0f); break; case SpawnPoint.RightTop: case SpawnPoint.RightMiddle: case SpawnPoint.RightBottom: dir = new float2(-1f, 0f); break; case SpawnPoint.TopLeft: case SpawnPoint.TopMiddle: case SpawnPoint.TopRight: dir = new float2(0f, -1f); break; case SpawnPoint.BottomLeft: case SpawnPoint.BottomMiddle: case SpawnPoint.BottomRight: dir = new float2(0f, 1f); break; } enemyPosition.Value += (dir * param.Speed * deltaTime); return(false); }
// 敵の生成 void SpawnBullet(ref Position2D pos, ref BarrageSettings_DirectionBullet settings) { if (this._playerGroup.Position.Length <= 0) { return; } PostUpdateCommands.CreateEntity(MainECS_Manager.EnemyBulletArchetype); PostUpdateCommands.SetComponent(pos); PostUpdateCommands.SetComponent( new BulletData { ShotSpeed = settings.CommonBarrageSettings.ShotSpeed, ShotAngle = this.Aiming(pos.Value, this._playerGroup.Position[0].Value), Lifespan = settings.CommonBarrageSettings.Lifespan }); PostUpdateCommands.AddSharedComponent(MainECS_Manager.EnemyBulletLook); PostUpdateCommands.AddSharedComponent(MainECS_Manager.BulletCollision); }
// 前方にランダムに分岐撃ち void RandomWay(ref int jobIndex, ref Position2D enemyPosition, ref EnemyParam param, ref EnemyData data) { float range = this.BarrageParamPtr->RandomWay.Range; this.RandomPtr->state += 1; range = this.RandomPtr->NextFloat(-range, range); range = math.radians(range); var angle = MathHelper.Aiming(enemyPosition.Value, this.PlayerPosition); CommandBuffer.Instantiate(jobIndex, this.EnemyBulletPrefab); CommandBuffer.SetComponent(jobIndex, enemyPosition); CommandBuffer.SetComponent(jobIndex, new BulletData { Speed = param.BulletParam.Speed, Angle = angle + range, Lifespan = param.BulletParam.Lifespan, }); }