コード例 #1
0
    public void RemoveTilesFromLayout()
    {
        for (int i = 0; i < _prevTileTypes.Length; i++)
        {
            if (_prevTileTypes[i] != MineRecorder.GetMineFloor(mineType, _currentFloor)[i].tileType)
            {
                _tilesInScene[i].SetActive(false);
            }
        }

        _prevTileTypes = MakeCopyOfTileSetTypes(MineRecorder.GetMineFloor(mineType, _currentFloor));
    }
コード例 #2
0
    public void DisplayNewLayout()
    {
        DestroyCurrentTiles();
        mineType      = GameData.Instance.playerMineLocations[playerID];
        _currentFloor = GameData.Instance.playerFloors[playerID][GameData.Instance.playerMineLocations[playerID]];

        if (MineRecorder.CheckMineFloorExists(mineType, _currentFloor))
        {
            _tiles         = MineRecorder.GetMineFloor(mineType, _currentFloor);
            _prevTileTypes = MakeCopyOfTileSetTypes(_tiles);
        }
        else
        {
            _tiles         = MineRecorder.CreateMineFloor(mineType, _currentFloor, _gridWidth, _gridHeight);
            _prevTileTypes = MakeCopyOfTileSetTypes(_tiles);
        }
        SetOtherPlayerLocations();
        DrawGrid();
        StartCoroutine(RescanMap());
    }
コード例 #3
0
    public static TileType GetTileTypeToSeek(int playerIndex, bool random)
    {
        if (GameData.Instance.durabilityLevels[playerIndex] <= 0) //if can't use axe anymore, just try traversing as much as possible
        {
            return(TileType.Stair);
        }

        AIPersonality pers  = GameData.Instance.AIs[playerIndex];
        Mine          mine  = GameData.Instance.playerMineLocations[playerIndex];
        int           floor = 0;

        Tile[] currentMineLayout = new Tile[0];
        if (!GameData.Instance.playerFloors[playerIndex].ContainsKey(mine))
        {
            return(TileType.Stair);
        }
        floor = GameData.Instance.playerFloors[playerIndex][mine];

        currentMineLayout = MineRecorder.GetMineFloor(mine, floor);
        Dictionary <TileType, int> tileKinds   = new Dictionary <TileType, int>();
        List <TileType>            preferences = GetTilePreferences(pers);

        for (int i = 0; i < currentMineLayout.Length; i++)
        {
            TileType t = currentMineLayout[i].tileType;

            if (preferences.Contains(t) || random)
            {
                if (tileKinds.ContainsKey(t))
                {
                    tileKinds[t]++;
                }
                else
                {
                    tileKinds.Add(t, 1);
                }
            }
        }

        if (pers == AIPersonality.Basic)
        {
            int rand  = Random.Range(0, tileKinds.Count - 1);
            int index = 0;
            foreach (KeyValuePair <TileType, int> entry in tileKinds)
            {
                if (index == rand)
                {
                    return(entry.Key);
                }
                index++;
            }
        }
        if (pers == AIPersonality.Explorer)
        {
            if (tileKinds.ContainsKey(TileType.Hole))
            {
                return(TileType.Hole);
            }
            int rand = Random.Range(0, 10);
            if (rand < 5)
            {
                return(TileType.Stair);
            }
            return(TileType.Rock);
        }


        return(TileType.Stair);
    }