public GameSession(TileSet tileSet, int maxPlayersAllowed, GameMode gameType, int gameID, int teams) { // SessionTeamsList = new TeamsList(); for (int i = 1; i <= teams; i++) { _sessionTeamsList.Teams.Add(new Team(i)); } IsStarted = false; GameLevel = new GameLevel(Constants.LEVEL_WIDTH, Constants.LEVEL_HEIGHT, tileSet); var playerNames = new List <string>(); _gameObjects = new List <AGameObject>(); _newObjects = new List <AGameObject>(); LocalGameDescription = new GameDescription(playerNames, maxPlayersAllowed, gameType, gameID, tileSet, teams); if (gameType == GameMode.Deathmatch) { _spiderFactory = new DeathmatchSpiderFactory(GameLevel); } else { _spiderFactory = new DefaultSpiderFactory(GameLevel); } _bonusFactory = new BonusFactory(); _wallFactory = new WallFactory(GameLevel); }
private void AssertWallEquals(string wallType, XY location) { var expected = WallFactory.Create("Wall-" + wallType); var actual = _layer[location].LowerObject; Assert.AreEqual(expected, actual, $"At [{location}] expected {expected.ToString()} but was {actual.ToString()}."); }
public Border(ScreenManager screenManager) { debugScreen = screenManager.Game.Services.GetService(typeof(IDebugScreen)) as IDebugScreen; borderWalls = WallFactory.FourBouncy(screenManager.GraphicsDevice.Viewport.Width / 2, screenManager.GraphicsDevice.Viewport.Height / 2, 2); borderTexture = screenManager.Content.Load<Texture2D>("Backgrounds/gray"); rightBound = borderWalls.Where(s => s.GetWallOrientation() == WallOrientationType.Horizontal).First().GetLength(); bottomBound = borderWalls.Where(s => s.GetWallOrientation() == WallOrientationType.Vertical).First().GetLength(); }
public override void BuildItemDropWalls() { Random r = new Random(); int rand = 0; var wallFactory = new WallFactory(); ItemArray itemsRepository = new ItemArray(); var iter = itemsRepository.GetIterator(); for (int i = 0; i < Map.Objects.GetLength(0); i++) { for (int j = 0; j < Map.Objects.GetLength(0); j++) { rand = r.Next(0, 10); if (j == 0 || j == (Map.Objects.GetLength(0) - 1) || i == 0 || i == (Map.Objects.GetLength(0) - 1)) { continue; } else { if (i % 2 == 0 && j % 2 == 0) { continue; } else { if (((i == 1 && (j == 1 || j == 2)) || (i == 2 && j == 1) || (i == (Map.Objects.GetLength(0) - 1) - 2 && j == (Map.Objects.GetLength(0) - 1) - 1) || (i == (Map.Objects.GetLength(0) - 1) - 1 && (j == (Map.Objects.GetLength(0) - 1) - 1 || j == (Map.Objects.GetLength(0) - 1) - 2)))) { //empty path continue; } else if (rand >= 9) { Map.Objects[i][j].entity = wallFactory.CreateWall(3); iter.HasNext(); Map.Objects[i][j].item = iter.Next(j, numSquaresY); } } } } } }
public override void BuildDestructableWalls() { Random r = new Random(); int rand = 0; var wallFactory = new WallFactory(); for (int i = 0; i < Map.Objects.GetLength(0); i++) { for (int j = 0; j < Map.Objects.GetLength(0); j++) { rand = r.Next(0, 10); if (j == 0 || j == (Map.Objects.GetLength(0) - 1) || i == 0 || i == (Map.Objects.GetLength(0) - 1)) { continue; } else { if (i % 2 == 0 && j % 2 == 0) { continue; } else { if (((i == 1 && (j == 1 || j == 2)) || (i == 2 && j == 1) || (i == (Map.Objects.GetLength(0) - 1) - 2 && j == (Map.Objects.GetLength(0) - 1) - 1) || (i == (Map.Objects.GetLength(0) - 1) - 1 && (j == (Map.Objects.GetLength(0) - 1) - 1 || j == (Map.Objects.GetLength(0) - 1) - 2)))) { //empty path continue; } else if (rand >= 6) { Map.Objects[i][j].entity = wallFactory.CreateWall(1); } } } } } }
private void AddNewItem() { int x = 0, y = 0; Random r = new Random(); while (!(Map.Objects[x][y].entity == null)) { x = r.Next(0, numSquaresX); y = r.Next(0, numSquaresY); } var wallFactory = new WallFactory(); ItemArray itemsRepository = new ItemArray(); var iter = itemsRepository.GetIterator(); Map.Objects[x][y].entity = wallFactory.CreateWall(3); iter.HasNext(); Map.Objects[x][y].item = iter.Next(y, numSquaresY); }
/// <summary> /// Konstruktor klase World. /// </summary> public World(String scenePath, String sceneFileName, int width, int height, OpenGL gl) { // Inicijalizacija scene za arrow i castle: OVDE SAM ISKULIRAO STA SE PROSLEDI IZ MAIN-A ZA PUTANJE, JER MORAM DVE SCENE TJ DVA MODELA UCITATI var scenePathForArrow = scenePath + "\\NewArrow"; sceneFileName = "Arrow.obj"; this.m_scene_arrow = new AssimpScene(scenePathForArrow, sceneFileName, gl); var scenePathForCastle = scenePath + "\\NewCastle"; sceneFileName = "castle.obj"; this.m_scene_castle = new AssimpScene(scenePathForCastle, sceneFileName, gl); this.m_width = width; this.m_height = height; _wallFactory = new WallFactory(this); m_textures = new uint[m_textureCount]; FaktorSkaliranjaStrele = 1; }
// Выполняется при нажатии на кнопку «Порекомендовать» private void shareButton_Click(object sender, EventArgs e) { try { int id = int.Parse(idInput.Text); Share(id); } catch (FormatException) { try { _wallFactory = new WallFactory(_manager); _wallFactory.Manager.Method("getProfiles"); _wallFactory.Manager.Params("uids", idInput.Text); XmlNode result = _wallFactory.Manager.Execute().GetResponseXml().FirstChild; Console.WriteLine(result); XmlUtils.UseNode(result); int id = XmlUtils.Int("uid"); Console.WriteLine(id); Share(id); } catch (Exception) { actionsStatus.Text = "Введен некорректный ID, либо нет соединения с ВКонтакте."; actionsStatusTimer.Enabled = true; } } catch (ApiRequestErrorException) { actionsStatus.Text = "Сайт вернул неверный ответ. Попробуйте изменить текст для публикации."; actionsStatusTimer.Enabled = true; } catch (Exception) { actionsStatus.Text = "Нет соединения с ВКонтакте. Проверьте работоспособность интернета."; actionsStatusTimer.Enabled = true; } }
/// <summary> /// Gets called when a Scene is loaded into memory. /// Load all the stuff needed for Game Scenes /// </summary> protected override void OnSceneLoad() { // Get the green floor SpriteBatch floorBatch = this.ManagerForSpriteBatch.Find(SpriteBatch.Name.Shields); SpriteEntity floorSprite = SpriteEntityManager.Self.Find(Sprite.Name.Floor); floorBatch.Attach(floorSprite, floorSprite.Id); ///// GameObject Factories //////////////////////////// // Create all the shields ShieldFactory shieldFactory = new ShieldFactory(SpriteBatch.Name.Shields); shieldFactory.CreateShields(); // Create all the Walls WallFactory wallFactory = new WallFactory(); wallFactory.CreateWalls(); // Create all the Aliens AlienFactory alienFactory = new AlienFactory(SpriteBatch.Name.Aliens); alienFactory.LoadResources(); alienFactory.CreateAliens(); // Create the player PlayerFactory playerFactory = new PlayerFactory(this); playerFactory.InitializeResources(); playerFactory.CreatePlayer(); // Create the UFO UFOFactory ufoFactory = new UFOFactory(); ufoFactory.CreateObjects(); }
public override void BuildIndestructableWalls() { Random r = new Random(); var wallFactory = new WallFactory(); for (int i = 0; i < Map.Objects.GetLength(0); i++) { for (int j = 0; j < Map.Objects.GetLength(0); j++) { if (j == 0 || j == (Map.Objects.GetLength(0) - 1) || i == 0 || i == (Map.Objects.GetLength(0) - 1)) { Map.Objects[i][j].entity = wallFactory.CreateWall(2); } else { if (i % 2 == 0 && j % 2 == 0) { Map.Objects[i][j].entity = wallFactory.CreateWall(2); } } } } }
/// <summary> /// Allows the game to perform any initialization it needs to before starting to run. /// This is where it can query for any required services and load any non-graphic /// related content. Calling base.Initialize will enumerate through any components /// and initialize them as well. /// </summary> protected override void Initialize() { AggregateFactory = new AggregateFactory(this); WeaponFactory = new WeaponFactory(this); DoorFactory = new DoorFactory(this); RoomFactory = new RoomFactory(this); CollectableFactory = new CollectibleFactory(this); WallFactory = new WallFactory(this); EnemyFactory = new EnemyFactory(this); SkillEntityFactory = new SkillEntityFactory(this); NPCFactory = new NPCFactory(this); // Initialize Components PlayerComponent = new PlayerComponent(); LocalComponent = new LocalComponent(); RemoteComponent = new RemoteComponent(); PositionComponent = new PositionComponent(); MovementComponent = new MovementComponent(); MovementSpriteComponent = new MovementSpriteComponent(); SpriteComponent = new SpriteComponent(); DoorComponent = new DoorComponent(); RoomComponent = new RoomComponent(); HUDSpriteComponent = new HUDSpriteComponent(); HUDComponent = new HUDComponent(); InventoryComponent = new InventoryComponent(); InventorySpriteComponent = new InventorySpriteComponent(); ContinueNewGameScreen = new ContinueNewGameScreen(graphics, this); EquipmentComponent = new EquipmentComponent(); WeaponComponent = new WeaponComponent(); BulletComponent = new BulletComponent(); PlayerInfoComponent = new PlayerInfoComponent(); WeaponSpriteComponent = new WeaponSpriteComponent(); StatsComponent = new StatsComponent(); EnemyAIComponent = new EnemyAIComponent(); NpcAIComponent = new NpcAIComponent(); CollectibleComponent = new CollectibleComponent(); CollisionComponent = new CollisionComponent(); TriggerComponent = new TriggerComponent(); EnemyComponent = new EnemyComponent(); NPCComponent = new NPCComponent(); //QuestComponent = new QuestComponent(); LevelManager = new LevelManager(this); SpriteAnimationComponent = new SpriteAnimationComponent(); SkillProjectileComponent = new SkillProjectileComponent(); SkillAoEComponent = new SkillAoEComponent(); SkillDeployableComponent = new SkillDeployableComponent(); SoundComponent = new SoundComponent(); ActorTextComponent = new ActorTextComponent(); TurretComponent = new TurretComponent(); TrapComponent = new TrapComponent(); ExplodingDroidComponent = new ExplodingDroidComponent(); HealingStationComponent = new HealingStationComponent(); PortableShieldComponent = new PortableShieldComponent(); PortableStoreComponent = new PortableStoreComponent(); ActiveSkillComponent = new ActiveSkillComponent(); PlayerSkillInfoComponent = new PlayerSkillInfoComponent(); MatchingPuzzleComponent = new MatchingPuzzleComponent(); pI = new PlayerInfo(); Quests = new List <Quest>(); #region Initialize Effect Components AgroDropComponent = new AgroDropComponent(); AgroGainComponent = new AgroGainComponent(); BuffComponent = new BuffComponent(); ChanceToSucceedComponent = new ChanceToSucceedComponent(); ChangeVisibilityComponent = new ChangeVisibilityComponent(); CoolDownComponent = new CoolDownComponent(); DamageOverTimeComponent = new DamageOverTimeComponent(); DirectDamageComponent = new DirectDamageComponent(); DirectHealComponent = new DirectHealComponent(); FearComponent = new FearComponent(); HealOverTimeComponent = new HealOverTimeComponent(); PsiOrFatigueRegenComponent = new PsiOrFatigueRegenComponent(); InstantEffectComponent = new InstantEffectComponent(); KnockBackComponent = new KnockBackComponent(); TargetedKnockBackComponent = new TargetedKnockBackComponent(); ReduceAgroRangeComponent = new ReduceAgroRangeComponent(); ResurrectComponent = new ResurrectComponent(); StunComponent = new StunComponent(); TimedEffectComponent = new TimedEffectComponent(); EnslaveComponent = new EnslaveComponent(); CloakComponent = new CloakComponent(); #endregion base.Initialize(); }
/// <summary> /// Опубликовываем запись на стене с картинкой альбома /// </summary> /// <param name="id">ID пользователя, где будем размещать запись</param> private void Share(int id) { iTunesApp app = new iTunesAppClass(); // И снова регистрируем iTunes, как класс приложения // Получаем нужную нам информацию о композиции string artist = app.CurrentTrack.Artist; string name = app.CurrentTrack.Name; string playlist = app.CurrentTrack.Playlist.Name; string album = app.CurrentTrack.Album; string genre = app.CurrentTrack.Genre; string prefix = _templatestatus; int count = app.CurrentTrack.PlayedCount; string shareText = Properties.Settings.Default.messageToPost; // Преобразуем ключевые слова shareText = shareText.Replace("{name}", name); shareText = shareText.Replace("{artist}", artist); shareText = shareText.Replace("{playlist}", playlist); shareText = shareText.Replace("{count}", count.ToString()); shareText = shareText.Replace("{album}", album); shareText = shareText.Replace("{genre}", genre); shareText = shareText.Replace("{prefix}", prefix); Console.WriteLine(shareText); _wallFactory = new WallFactory(_manager); // Инициализируем «фабрику» стены try { if (_coverArt) { _wallFactory = new WallFactory(_manager); // Инициализируем «фабрику» стены _wallFactory.Manager.Method("photos.getWallUploadServer"); _wallFactory.Manager.Params("uid", id); XmlNode result = _wallFactory.Manager.Execute().GetResponseXml(); XmlUtils.UseNode(result); string uploadUrl = XmlUtils.String("upload_url"); HttpUploaderFactory uf = new HttpUploaderFactory(); NameValueCollection files = new NameValueCollection(); files.Add("photo", _imageDirectory); string resp = uf.Upload(uploadUrl, null, files); Console.WriteLine(resp); var apiResponse = JObject.Parse(resp); string server = (string)apiResponse["server"]; string photo = (string)apiResponse["photo"]; string hash = (string)apiResponse["hash"]; _wallFactory.Manager.Method("photos.saveWallPhoto"); _wallFactory.Manager.Params("server", server); _wallFactory.Manager.Params("photo", photo); _wallFactory.Manager.Params("hash", hash); XmlNode result2 = _wallFactory.Manager.Execute().GetResponseXml().FirstChild; XmlUtils.UseNode(result2); string photoId = XmlUtils.String("id"); Console.WriteLine(photoId); _wallFactory.Manager.Method("wall.post"); _wallFactory.Manager.Params("owner_id", id); _wallFactory.Manager.Params("message", shareText); _wallFactory.Manager.Params("attachments", photoId); _wallFactory.Manager.Params("uid", id); _wallFactory.Manager.Execute(); } else { _wallFactory = new WallFactory(_manager); // Инициализируем «фабрику» стены _wallFactory.Manager.Method("wall.post"); _wallFactory.Manager.Params("owner_id", id); _wallFactory.Manager.Params("message", shareText); Console.WriteLine(_wallFactory.Manager.Execute().ToString()); } actionsStatus.Text = "Опубликовано."; // Уведомляем пользователя об успешности actionsStatusTimer.Enabled = true; // Включаем таймер, который каждые n-секунд сбрасывает специальной поле статуса действий } catch (FormatException) { actionsStatus.Text = "Введен некорректный ID."; actionsStatusTimer.Enabled = true; } catch (ApiRequestErrorException) { actionsStatus.Text = "Сайт вернул неверный ответ. Попробуйте изменить текст для публикации."; actionsStatusTimer.Enabled = true; } catch (Exception) { actionsStatus.Text = "Нет соединения с ВКонтакте. Проверьте работоспособность интернета."; actionsStatusTimer.Enabled = true; } }
public void Explode(int x, int y) { if (Map.Objects[x][y].bomb == null) { return; } CompositeDirectory destroyedEntities = new CompositeDirectory(); int radius = Map.Objects[x][y].bomb.explosionRadius(2); Map.Objects[x][y].destroy(); var wallFactory = new WallFactory(); bool up = false, down = false, left = false, right = false; for (int i = 1; i <= radius; i++) { if (x + i < numSquaresX && !(Map.Objects[x + i][y].entity is IndestructableWall) && !(Map.Objects[x + i][y].entity is Fire) && !right) { if (Map.Objects[x][y].bomb is FireBomb) { Map.Objects[x + i][y].entity = new Fire(x + i, y); } else if (Map.Objects[x][y].bomb is IceBomb) { if (!(Map.Objects[x + 1][y].entity is DestructableWall)) { Map.Objects[x + i][y].entity = wallFactory.CreateWall(4); } else { right = true; } } else { DestructionTemplate destroyedObject = Map.Objects[x + i][y].destroy(); if (destroyedObject != null) { destroyedEntities.add(destroyedObject); } } } else { right = true; } if (x - i >= 0 && !(Map.Objects[x - i][y].entity is IndestructableWall) && !(Map.Objects[x - i][y].entity is Fire) && !left) { if (Map.Objects[x][y].bomb is FireBomb) { Map.Objects[x - i][y].entity = new Fire(x - i, y); } else if (Map.Objects[x][y].bomb is IceBomb) { if (!(Map.Objects[x - 1][y].entity is DestructableWall)) { Map.Objects[x - i][y].entity = wallFactory.CreateWall(4); } else { left = true; } } else { DestructionTemplate destroyedObject = Map.Objects[x - i][y].destroy(); if (destroyedObject != null) { destroyedEntities.add(destroyedObject); } } } else { left = true; } if (y + i < numSquaresX && !(Map.Objects[x][y + i].entity is IndestructableWall) && !(Map.Objects[x][y + i].entity is Fire) && !up) { if (Map.Objects[x][y].bomb is FireBomb) { Map.Objects[x][y + i].entity = new Fire(x, y - i); } else if (Map.Objects[x][y].bomb is IceBomb) { if (!(Map.Objects[x][y + i].entity is DestructableWall)) { Map.Objects[x][y + i].entity = wallFactory.CreateWall(4); } else { down = true; } } else { DestructionTemplate destroyedObject = Map.Objects[x][y + i].destroy(); if (destroyedObject != null) { destroyedEntities.add(destroyedObject); } } } else { down = true; } if (y - i >= 0 && !(Map.Objects[x][y - i].entity is IndestructableWall) && !(Map.Objects[x][y - i].entity is Fire) && !down) { if (Map.Objects[x][y].bomb is FireBomb) { Map.Objects[x][y - i].entity = new Fire(x, y - i); } else if (Map.Objects[x][y].bomb is IceBomb) { if (!(Map.Objects[x][y - i].entity is DestructableWall)) { Map.Objects[x][y - i].entity = wallFactory.CreateWall(4); } else { up = true; } } else { DestructionTemplate destroyedObject = Map.Objects[x][y - i].destroy(); if (destroyedObject != null) { destroyedEntities.add(destroyedObject); } } } else { up = true; } } Player player = GetPlayer(Map.Objects[x][y].bomb.playerId); if (player != null) { player.destroyedEntities.add(destroyedEntities); } Map.Objects[x][y].bomb = null; }
}; //Enums have a place! Tile(Walls wall) { walls = WallFactory.getConfiguration(wall); }
private void PutWallSpace(FacilityLayer layer, XY location) { var wallType = GetWallType(GetNearbyFloorLocations(layer, location)); layer[location].LowerObject = WallFactory.Create("Wall-" + wallType); }