Beispiel #1
0
    private void Update()
    {
        if (!_mineSelected)
        {
            return;
        }

        SetOtherPlayerLocations();



        //Check for updated floors
        if (MineRecorder.IronDirty && !MineRecorder.CheckFlag(Mine.IronMine, playerID))
        {
            if (mineType != Mine.IronMine)
            {
                MineRecorder.SetBackFlag(Mine.IronMine, playerID);
            }
            else
            {
                Vector3 pos = _playerObject.transform.position;
                RemoveTilesFromLayout();
                MineRecorder.SetBackFlag(Mine.IronMine, playerID);
                _playerObject.transform.position = pos;
            }
        }
        if (MineRecorder.JellyDirty && !MineRecorder.CheckFlag(Mine.JellyMine, playerID))
        {
            if (mineType != Mine.JellyMine)
            {
                MineRecorder.SetBackFlag(Mine.JellyMine, playerID);
            }
            else
            {
                Vector3 pos = _playerObject.transform.position;
                RemoveTilesFromLayout();
                MineRecorder.SetBackFlag(Mine.JellyMine, playerID);
                _playerObject.transform.position = pos;
            }
        }
        if (MineRecorder.CoalDirty && !MineRecorder.CheckFlag(Mine.CoalMine, playerID))
        {
            if (mineType != Mine.CoalMine)
            {
                MineRecorder.SetBackFlag(Mine.CoalMine, playerID);
            }
            else
            {
                Vector3 pos = _playerObject.transform.position;
                RemoveTilesFromLayout();
                MineRecorder.SetBackFlag(Mine.CoalMine, playerID);
                _playerObject.transform.position = pos;
            }
        }
    }
Beispiel #2
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));
    }
 public void Break()
 {
     if (Random.Range(0, 10) < 1)
     {
         GameObject go = Instantiate(holePrefab, transform.position, Quaternion.identity);
         go.transform.parent   = transform.parent;
         go.transform.position = transform.position;
         MineRecorder.UpdateTileType(floorNumber, index, mineType, TileType.Hole);
     }
     else
     {
         MineRecorder.UpdateTileType(floorNumber, index, mineType, TileType.Blank);
     }
     AStarMapController.RequestScan();
 }
Beispiel #4
0
 private void OnTriggerEnter2D(Collider2D collision)
 {
     if (collision.gameObject.GetComponent <IBreakable>() != null)
     {
         if (collision.gameObject.GetComponent <BreakableRock>() != null)
         {
             BreakableRock br = collision.gameObject.GetComponent <BreakableRock>();
             MineRecorder.UpdateMineTileHealth(br.floorNumber, br.mineType, -1, br.index);
             if (MineRecorder.GetMineTileHealth(br.floorNumber, br.mineType, br.index) <= 0)
             {
                 if (GameData.Instance.playerOreSupplies[PlayerID].ContainsKey(br.tileType))
                 {
                     mrm.CollectResource(br.tileType, br.myTile.oreAmount);
                 }
                 br.Break();
             }
         }
     }
 }
Beispiel #5
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());
    }
Beispiel #6
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);
    }