public AIGameState(ModosVictoria condicionVictoria, Matrix matrix, List <RawPlayer> players, int currentTurn, int currentPlayer, int playerActions, float victoryValue) { this.matrix = matrix; this.players = players; this.currentTurn = currentTurn; this.currentPlayer = currentPlayer; this.playerActions = playerActions; this.condicionVictoria = condicionVictoria; this.victoryValue = victoryValue; }
public static AIInterface GetAIByVictoryCondition(GameController g, ModosVictoria modo) { switch (modo) { case ModosVictoria.ASESINATO: //Debug.Log("Asesinato AI"); return(new AIMurder(g)); case ModosVictoria.CONQUISTA: //Debug.Log("Conquista AI"); return(new AIConquer(g)); case ModosVictoria.MASA: //Debug.Log("Masa AI"); return(new AIMasa(g)); } return(new AIRandom(g)); }
// Use this for initialization void Start() { /* * TipDialog a = new TipDialog (); * a.SetButtonImage(SpritesLoader.GetInstance ().GetResource ("Buttons/button_template")); * a.SetBackgroundImage(SpritesLoader.GetInstance ().GetResource ("Panels/emergent")); * a.SetInfoTextText ("Has aceptado"); * a.Hide (); * TwoOptionsDialog t = new TwoOptionsDialog(); * t.SetButtonsImage(SpritesLoader.GetInstance ().GetResource ("Buttons/button_template")); * t.SetBackgroundImage(SpritesLoader.GetInstance ().GetResource ("Panels/emergent")); * t.SetAceptButtonColor (new Color(0f,0f,1f)); * t.SetDeclineButtonColor (new Color(1f,0f,0f)); * t.SetOnClickAceptFunction(()=>{ * a.Show(); * }); */ /* * Time.timeScale = 1; * ChainTextDialog ctd = new ChainTextDialog (); * ctd.SetButtonImage(SpritesLoader.GetInstance ().GetResource ("Buttons/button_template")); * ctd.SetBackgroundImage(SpritesLoader.GetInstance ().GetResource ("Panels/emergent")); */ TileFactory.tileMaterial = tileMaterial; //InGameMarker igm = new InGameMarker (); //igm.SetSprite (SpritesLoader.GetInstance().GetResource("Test/testTileSlim")); FloatingTextController.Initialize(); uiController = Camera.main.GetComponent <UIController>(); soundController = gameObject.GetComponent <SoundController>(); camController = Camera.main.GetComponent <CameraController>(); conquerSprite = SpritesLoader.GetInstance().GetResource("Tiles/conquest_flag"); //panelTip = GameObject.Find("PanelTip"); //ja tenim el panell, per si el necessitem activar, i desactivar amb : panelTip.GetComponent<DialogInfo> ().Active (boolean); //textTip = GameObject.Find("TextTip"); //ja tenim el textBox, per canviar el text : textTip.GetComponent<Text> ().text = "Text nou"; //panelTip.GetComponent<DialogInfo>().Active(false); //textTip.GetComponent<Text>().text = "Aquí es mostraran els diferents trucs que pot fer el jugador"; players = new List <Player>(); Time.timeScale = 1f; if (ModosVictoria.IsDefined(typeof(ModosVictoria), GameSelection.modoVictoria)) { condicionVictoria = (ModosVictoria)GameSelection.modoVictoria; } else { condicionVictoria = ModosVictoria.ASESINATO; //por defecto } MAX_TURNS = GameSelection.MAX_TURNS; int maxPlayers = GameSelection.playerColors.Count; if (maxPlayers == 0) { GameSelection.playerColors.Add(new Color(0, 0, 1)); GameSelection.playerColors.Add(new Color(1, 0, 0)); GameSelection.playerCores.Add(SlimeCoreTypes.SLOTH); GameSelection.playerCores.Add(SlimeCoreTypes.WRATH); GameSelection.playerIAs.Add(false); GameSelection.playerIAs.Add(true); maxPlayers = 2; } for (int i = 0; i < maxPlayers; i++) { if (GameSelection.playerIAs [i]) { //players.Add(new Player("Jugador "+(i+1),StatsFactory.GetStat(GameSelection.playerCores[i]))); Debug.Log("Ia true"); players.Add(new Player("Jugador " + (i + 1), StatsFactory.GetStat(GameSelection.playerCores[i]), AIManager.GetAIByVictoryCondition(this, condicionVictoria))); } else { players.Add(new Player("Jugador " + (i + 1), StatsFactory.GetStat(GameSelection.playerCores[i]))); } players[i].SetColor(GameSelection.playerColors[i]); } matrix = GameSelection.map;//new Matrix(11, 0.3f, 1234567); if (matrix == null) { matrix = new Matrix(5 * players.Count, 0.3f, Random.Range(0, 10000)); } MapDrawer.instantiateMap(matrix.getIterable()); int numSlimesPerPlayer = 2; List <List <Vector2> > positions = matrix.GetPositions(players.Count, numSlimesPerPlayer); int j = 0; foreach (Player player in players) { List <Vector2> positionsSlimes = positions[j]; foreach (Vector2 positionSlime in positionsSlimes) { SlimeFactory.instantiateSlime(player, positionSlime); } j++; } if (players.Count == 0) { players.Add(new Player("Jugador 1", StatsFactory.GetStat(SlimeCoreTypes.WRATH), AIManager.GetAIByVictoryCondition(this, condicionVictoria))); // Test with 2 players players.Add(new Player("Jugador 2", StatsFactory.GetStat(SlimeCoreTypes.GLUTTONY))); players[0].SetColor(Color.blue); players[1].SetColor(Color.red); positions = matrix.GetPositions(players.Count, 1); SlimeFactory.instantiateSlime(players[0], positions[0][0]); SlimeFactory.instantiateSlime(players[1], positions[1][0]); } //matrix = new Matrix(MapParser.ReadMap(MapTypes.Medium)); currentTurn = 0; currentPlayer = players[0]; playerActions = 0; uiController.UpdateRound(currentTurn + 1); uiController.UpdatePlayer(GetCurrentPlayer().GetColor()); uiController.UpdateActions(playerActions, GetCurrentPlayer().actions); uiController.ShowBothPanels(); //iniciem la informacio de game over totalTiles = matrix.TotalNumTiles(); //Debug.Log("TILES TOTALS: "+ totalTiles); // La condicio de victoria s'assigna mes amunt, aqui nomes s'actualitzen els requisits. switch (condicionVictoria) { case ModosVictoria.CONQUISTA: //define percentage tiles to win if (MAX_TURNS == 0) { percentageTilesToWin = 0.25f; } else { percentageTilesToWin = 0.75f; } //Debug.Log("Porcentaje de conquista para ganar: "+percentageTilesToWin); break; case ModosVictoria.MASA: //define mass to win massToWin = 0; foreach (Player player in players) { if (player.GetTotalMass() > massToWin) { massToWin = player.GetTotalMass(); } } massToWin *= 2; //Debug.Log("Masa total del jugador para ganar: "+massToWin); break; } GameOverInfo.Init(); AudioClip clip = SoundsLoader.GetInstance().GetResource("Sounds/MainGameTheme"); soundController.PlayLoop(clip); camController.InitMaxZoom(); status = GameControllerStatus.CHECKINGLOGIC; }