Exemplo n.º 1
0
 public ArtificialIntelligence(NonPlayablePlayer p)
 {
     behaviourState  = (int)Behaviour.idle;
     this.DijsktraPF = new DijkstraPathFinder(maxDepth: p.getMaxActionPoints(),
                                              maxCost: p.getActionPoints(),
                                              maxIncrementalCost: p.getMaxActionPoints());
     this.AstarPF = new AstarPathFinder(maxDepth: 25,
                                        maxCost: 500,
                                        maxIncrementalCost: p.getMaxActionPoints());
     longDistancePathFinder = new LongDistancePathFinder(maxDepth: p.getMaxActionPoints(),
                                                         maxCost: p.getActionPoints(),
                                                         maxIncrementalCost: p.getMaxActionPoints());
     this.player = p;
 }
Exemplo n.º 2
0
 private void removePlayerWithID(long id)
 {
     for (int i = 0; i < AIPlayers.Count; i++)
     {
         NonPlayablePlayer p = AIPlayers[i];
         if (p.id == id)
         {
             if (!p.dead)
             {
                 killPlayer(p);
             }
             AIs.RemoveAt(i);
             break;
         }
     }
 }
Exemplo n.º 3
0
    private void spawnNonPlayablePlayers()
    {
        HexRegion region = mapGenerator.getRegion() as HexRegion;

        // TODO implement more functionality here

        // get tiles within vicinity
        Tile       tile = region.getTileAt(this.humanPlayer.getTilePos().index);
        PathResult pr   = (new DijkstraUniformCostPathFinder(uniformCost: 1f, maxDepth: enemySpawnPointSearchMaxDepth, maxCost: float.MaxValue))
                          .pathFromTo(region, tile, new HexTile(new Vector3(), new Vector2(float.MaxValue, float.MaxValue)));

        // spawn enemies at tiles with tribes
        foreach (Tile t in pr.getExploredTiles())
        {
            if ((t.getPos() - humanPlayer.getPos()).magnitude <= enemyDespawnRadius &&
                checkForPlayersAt(t) == null &&
                AIs.Count < maxEnemiesSpawned)
            {
                if (t.getTileType().GetType() == typeof(LandTileType))
                {
                    foreach (TileAttribute ta in t.getTileAttributes())
                    {
                        if (ta.GetType() == typeof(LocalTribe))
                        {
                            int strength        = (ta as LocalTribe).level * enemyStrengthPerTribeLevel;
                            NonPlayablePlayer p = new NonPlayablePlayer(50, strength);
                            p.setTilePos(t);
                            if (p.computeStrength() > 0)
                            {
                                AIs.Add(new ArtificialIntelligence(p));
                            }
                            break;
                        }
                    }
                }
            }
        }
    }