public void Initialize() { for (float angle = 0f; angle < 360f; angle += Step) { var position = CoordinatesExtensions.GetRotatedUnitVector2(angle) * Radius; var entity = spaceStation.CreateEntity(gameContext, position, angle, 0); } }
public void Initialize() { // Log.Info($"Создание игровой комнаты с номером {matchModel.MatchId}"); Dictionary <int, ushort> playerInfos = new Dictionary <int, ushort>(matchModel.GameUnits.Count()); var zoneEntity = FlameCircle.CreateEntity(gameContext, Vector2.zero, 0f); gameContext.SetZone(zoneEntity.id.value); var step = 360f / matchModel.GameUnits.Count(); var halfStep = step * 0.5f; GameUnitsFactory factory = new GameUnitsFactory(); List <GameUnitModel> gameUnits = factory.Create(matchModel); for (int gameUnitIndex = 0; gameUnitIndex < gameUnits.Count; gameUnitIndex++) { GameUnitModel gameUnit = gameUnits[gameUnitIndex]; float angle = gameUnitIndex * step + halfStep; Vector2 position = CoordinatesExtensions.GetRotatedUnitVector2(angle) * 40f; GameEntity playerEntity = PlayerPrototypes[gameUnit.WarshipName.ToLower()] .CreateEntity(gameContext, position, 180f + angle, (byte)(gameUnitIndex + 1)); if (playerEntity.hasDrop) { playerEntity.drop.objects.Add(UpgradeBonus); } else { playerEntity.AddDrop(new List <EntityCreatorObject> { UpgradeBonus }); } playerEntity.AddPlayer(gameUnit.TemporaryId); playerEntity.AddAccount(gameUnit.AccountId); playerInfos.Add(playerEntity.account.id, playerEntity.id.value); if (gameUnit.IsBot()) { Match.MakeBot(playerEntity); } if (Skins.TryGetValue(gameUnit.SkinName, out var skin)) { skin.AddSkin(playerEntity, gameContext); } var powerLevel = gameUnit.WarshipPowerLevel - 1; if (powerLevel > 0) { var newHp = playerEntity.maxHealthPoints.value * (1f + powerLevel * WarshipImprovementConstants.HealthPointsCoefficient); var newSpeed = playerEntity.maxVelocity.value * (1f + powerLevel * WarshipImprovementConstants.LinearVelocityCoefficient); var newRotation = playerEntity.maxAngularVelocity.value * (1f + powerLevel * WarshipImprovementConstants.AngularVelocityCoefficient); var attackCoefficient = 1f + powerLevel * WarshipImprovementConstants.AttackCoefficient; playerEntity.ReplaceMaxHealthPoints(newHp); playerEntity.ReplaceHealthPoints(newHp); playerEntity.ReplaceMaxVelocity(newSpeed); playerEntity.ReplaceMaxAngularVelocity(newRotation); foreach (var child in playerEntity.GetAllChildrenGameEntities(gameContext)) { child.AddAttackIncreasing(attackCoefficient); } } var wallAngle = angle + halfStep; var wallDirection = CoordinatesExtensions.GetRotatedUnitVector2(wallAngle); for (var r = 11; r < 50; r += 25) { for (var j = r; j < r + 10; j++) { RandomAsteroid.CreateEntity(gameContext, wallDirection * j, (float)random.NextDouble() * 360f); } } SpaceStation.CreateEntity(gameContext, wallDirection * 10f, wallAngle, 0); SpaceStation.CreateEntity(gameContext, wallDirection * 25f, wallAngle, 0); SpaceStation.CreateEntity(gameContext, wallDirection * 35f, 180f + wallAngle, 0); RandomBonus.CreateEntity(gameContext, wallDirection * 30f, 0); } Boss.CreateEntity(gameContext, Vector2.zero, (float)random.NextDouble() * 360f, 0); foreach (var playerInfo in matchModel.GameUnits.Players) { udpSendUtils.SendPlayerInfo(matchModel.MatchId, playerInfo.TemporaryId, playerInfos); } }