/** * Creates a new social game results screen (no choice because not player initing * @param game_player the game starter * @param game_victim the other player * @param social_game the game to be played */ public EngineStateSocialGame(int game_player, int game_victim, SGame social_game) : base(EngineManager.Engine) { sim_won = false; game_played = false; player = game_player; victim = game_victim; key_pressed = true; results_screen = false; quit = false; cursor = 0; stats_page = 0; stats = new List<string>(); if (!(player == -1 || victim == -1 || social_game == null)) { possible_games = new List<SGame>(); game = social_game; game.run(player, victim, stats); if (game.ssR.Count > 0 && SocialStatusRules.singleton.getSocialStatusRule(game.ssR[0]).type == SocialStatusRule.TYPE_END_GAME) { sim_won = true; } } else { quit = true; key_pressed = false; possible_games = new List<SGame>(); game = null; } }
public void addSocialGame(SGame game) { dictionary.Add(game.name+id, game); id++; }
/** * Creates a new social game menu (player init) * @param game_victim the other player */ public EngineStateSocialGame(int game_victim) : base(EngineManager.Engine) { sim_won = false; game_played = false; player = Constants.PLAYER; victim = game_victim; game = null; key_pressed = true; results_screen = false; quit = false; cursor = 0; //possible_games = ???? /// debug: /// possible_games = SocialGames.getAllGames(player, victim); possible_games.Add(new SGame("[CANCEL]")); stats_page = 0; stats = new List<string>(); // populate all stats to display stats.Add("Relations: " + SocialNetworks.singleton.getSocialNetwork("" + player).getInnerNetwork("" + victim).relation + " #" + victim); stats.Add("Relations: " + SocialNetworks.singleton.getSocialNetwork("" + victim).getInnerNetwork("" + player).relation + " #" + player); if (victim != Constants.COMPANION) { stats.Add("Relations: " + SocialNetworks.singleton.getSocialNetwork("" + victim).getInnerNetwork("" + Constants.COMPANION).relation + " #" + victim+"|"+Constants.COMPANION); } // add predicates for (int i = 0; i < SocialNetworks.singleton.getSocialNetwork("" + player).getInnerNetwork("" + victim).predicates.Count; i++) { stats.Add(SocialNetworks.singleton.getSocialNetwork("" + player).getInnerNetwork("" + victim).predicates[i] + " #0"); } // add personality for (int i = 0; i < PersonalityDescriptions.singleton.getPersDesc("" + victim).personality.Count; i++) { stats.Add(PersonalityDescriptions.singleton.getPersDesc("" + victim).personality[i] + " #" + victim); } // add culture foreach (KeyValuePair<string, InnerCulturalKnowledge> pair in CulturalKnowledgebase.singleton.getCulturalKnowledge(""+victim).innerCulKno) { stats.Add(pair.Key + ": " + pair.Value.relation + " #" + victim); } // add same things for player for (int i = 0; i < PersonalityDescriptions.singleton.getPersDesc("" + player).personality.Count; i++) { stats.Add(PersonalityDescriptions.singleton.getPersDesc("" + player).personality[i] + " #" + player); } // add culture foreach (KeyValuePair<string, InnerCulturalKnowledge> pair in CulturalKnowledgebase.singleton.getCulturalKnowledge("" + player).innerCulKno) { stats.Add(pair.Key + ": " + pair.Value.relation + " #" + player); } }
public override void update(GameTime gameTime) { if (!key_pressed && InputSet.getInstance().getButton(InputsEnum.BUTTON_4)) { if (game == null && cursor < possible_games.Count-1) { game = possible_games[cursor]; stats.Clear(); stats_page = 0; game.run(player, victim, stats); game_played = true; } else if ((results_screen || cursor == possible_games.Count-1) && !sim_won) { quit = true; } else { results_screen = true; } key_pressed = true; } else if (key_pressed && InputSet.getInstance().getLeftDirectionalX() == 0 && !InputSet.getInstance().getButton(InputsEnum.BUTTON_4) && InputSet.getInstance().getLeftDirectionalY() == 0) { key_pressed = false; } if (game == null) { if (!key_pressed && InputSet.getInstance().getLeftDirectionalY() > 0 && cursor > 0) { cursor--; key_pressed = true; } else if (!key_pressed && InputSet.getInstance().getLeftDirectionalY() < 0 && cursor < possible_games.Count - 1) { cursor++; key_pressed = true; } else if (!key_pressed && InputSet.getInstance().getLeftDirectionalX() < 0 && stats_page > 0) { stats_page--; key_pressed = true; } else if (!key_pressed && InputSet.getInstance().getLeftDirectionalX() > 0 && stats_page < stats.Count/(PAGE_SIZE+1)) { stats_page++; key_pressed = true; } } else if (results_screen) { if (!key_pressed && InputSet.getInstance().getLeftDirectionalX() < 0 && stats_page > 0) { stats_page--; key_pressed = true; } else if (!key_pressed && InputSet.getInstance().getLeftDirectionalX() > 0 && stats_page < stats.Count / (PAGE_SIZE + 1)) { stats_page++; key_pressed = true; } } if (quit && !key_pressed) { EngineManager.popState(); } }
public virtual bool update() { if (GameplayManager.ActiveArea.GlobalLocation == Area.PARTY) { if (victim != -1 && social_game != null) { // path to the victim if (!walking) { // check if adjacent to goal int x = (int)m_collider.Bounds.Center().X / Area.TILE_WIDTH; int y = (int)m_collider.Bounds.Center().Y / Area.TILE_HEIGHT; if (walk_target == -1) { //Console.WriteLine("victim= " + victim); walk_target = GameplayManager.ActiveArea.getObjectLocation(victim); //Console.WriteLine("walk_target= " + walk_target); } int gx = walk_target % Area.WIDTH_IN_TILES; int gy = walk_target / Area.WIDTH_IN_TILES; if (x + y * Area.WIDTH_IN_TILES == walk_target)//(gx - x) * (gx - x) + (gy - y) * (gy - y) <= 1) { // adjacent // interact! EngineManager.pushState(new EngineStateSocialGame(getDoodadIndex(), victim, social_game)); walk_target = -1; victim = -1; social_game = null; return true; } else { // need to walk to walk_dir = GameplayManager.ActiveArea.startPath(x + y * Area.WIDTH_IN_TILES, walk_target, PuzzleObject.TYPE_NONE, victim, Area.TILE_WIDTH-2, Area.TILE_HEIGHT-2); //Console.WriteLine("path: " + walk_dir); if (walk_dir == -2) { // bad, but, at location EngineManager.pushState(new EngineStateSocialGame(getDoodadIndex(), victim, social_game)); walk_target = -1; victim = -1; social_game = null; return true; } else if (walk_dir != -1) { walking = true; m_collider.handleMovement(new Vector2(-(float)m_collider.m_bounds.X + x * Area.TILE_WIDTH + (Area.TILE_WIDTH - (int)m_collider.Bounds.Width) / 2, - (float)m_collider.m_bounds.Y + y * Area.TILE_HEIGHT + (Area.TILE_HEIGHT - (int)m_collider.Bounds.Height) / 2)); } else { // need to pick another action / can't reach this one victim = -1; social_game = null; return true; } } } else { // walk torwards this thingy int travel = m_speed*3; int size = walk_dir < CompanionController.WALK_UP ? Area.TILE_WIDTH : Area.TILE_HEIGHT; if (distance + travel > size) { travel = (walk_dir < CompanionController.WALK_UP ? Area.TILE_WIDTH : Area.TILE_HEIGHT) - distance; distance = 0; walking = false; } else { distance += travel; } m_collider.handleMovement(new Vector2(walk_dir == CompanionController.WALK_LEFT ? -travel : walk_dir == CompanionController.WALK_RIGHT ? travel : 0, walk_dir == CompanionController.WALK_UP ? -travel : walk_dir == CompanionController.WALK_DOWN ? travel : 0)); AnimationController.requestAnimation(walk_dir == CompanionController.WALK_LEFT ? "left" : walk_dir == CompanionController.WALK_RIGHT ? "right" : walk_dir == CompanionController.WALK_UP ? "up" : "down", AnimationController.AnimationCommand.Play); AnimationController.update(); } } else { // pick a social game to play List<int> potential_players = GameplayManager.ActiveArea.getPartiers((int)m_collider.m_bounds.Center().X, (int)m_collider.m_bounds.Center().Y, (int)m_collider.m_bounds.Width, (int)m_collider.m_bounds.Height); int total = 0; List<List<SGame>> games = new List<List<SGame>>(); for (int i = 0; i < potential_players.Count; i++) { List<SGame> sgames = SocialGames.getAllGames(getDoodadIndex(), potential_players[i]); for (int j = 0; j < sgames.Count; j++) { total += sgames[j].ssR.Count + 1; if (sgames[j].ssR.Count > 0 && SocialStatusRules.singleton.getSocialStatusRule(sgames[j].ssR[0]).type == SocialStatusRule.TYPE_END_GAME) { victim = Constants.PLAYER; social_game = sgames[j]; return false; } } games.Add(sgames); } int game = (new Random()).Next(total); for (int i = 0; i < games.Count; i++) { for (int j = 0; j < games[i].Count; j++) { game -= games[i][j].ssR.Count + 1; if (game < 0) { victim = potential_players[i]; social_game = games[i][j]; break; } } if (game < 0) { break; } } if (victim == -1 && social_game == null) { return true; } //EngineManager.pushState(new EngineStateSocialGame(getDoodadIndex(), victim, social_game)); } return false; } return true; }
private void addSocialGames() { SGame a = new SGame("Praise Brewtopia!"); a.drelation_target = 1; SocialGames.singleton.addSocialGame(a); Random sRand = new Random(); for (int i = 1; i < cult_knowledge.Length; i++) { SGame aGame = new SGame("Admire " + cult_knowledge[i] + "!"); aGame.ssR.Add("p1 likes " + cult_knowledge[i]); aGame.ssR.Add("p2 likes " + cult_knowledge[i]); aGame.drelation_target = sRand.Next(CHANGE_MIN, CHANGE_MAX); SocialGames.singleton.addSocialGame(aGame); aGame = new SGame("Condemn " + cult_knowledge[i] + "!"); aGame.ssR.Add("p1 dislikes " + cult_knowledge[i]); aGame.ssR.Add("p2 dislikes " + cult_knowledge[i]); aGame.drelation_target = sRand.Next(CHANGE_MIN, CHANGE_MAX); SocialGames.singleton.addSocialGame(aGame); aGame = new SGame("Admire " + cult_knowledge[i] + "!"); aGame.ssR.Add("p1 likes " + cult_knowledge[i]); aGame.ssR.Add("p2 dislikes " + cult_knowledge[i]); aGame.drelation_target = -sRand.Next(CHANGE_MIN, CHANGE_MAX); SocialGames.singleton.addSocialGame(aGame); aGame = new SGame("Condemn " + cult_knowledge[i] + "!"); aGame.ssR.Add("p2 likes " + cult_knowledge[i]); aGame.ssR.Add("p1 dislikes " + cult_knowledge[i]); aGame.drelation_target = -sRand.Next(CHANGE_MIN, CHANGE_MAX); SocialGames.singleton.addSocialGame(aGame); } for (int i = 0; i < personalities.Length; i++) { string name = "He is a "; if (i % 2 == 0) { name += personalities[i + 1] + " #" + Constants.COMPANION; } else { name += personalities[i - 1] + " #" + Constants.COMPANION; } SGame game = new SGame(name); game.ssR.Add("p2 " + personalities[i]); game.ssR.Add("p2 trusts p1"); game.p3 = Constants.COMPANION; game.drelation_third_target = -random.Next(CHANGE_MIN, CHANGE_MAX); SocialGames.singleton.addSocialGame(game); } SGame end = new SGame("Let's blow this popsicle stand!"); end.ssR.Add("endgame"); SocialGames.singleton.addSocialGame(end); }