Пример #1
0
        public void SetBackgroundCellAt(int x, int y, Cell cell)
        {
            if (((0 <= x) && (x < Width)) &&
                ((0 <= y) && (y < Height)))
            {
                backgroundCells[x, y] = cell;

                List <Vector3Int> changedCellsPositions = new List <Vector3Int>();
                changedCellsPositions.Add(new Vector3Int(x, y, 0));
                OnLevelDataChanged?.Invoke(changedCellsPositions);
            }
        }
Пример #2
0
        public void SetBackgroundCellHidden(int x, int y, bool isHidden)
        {
            if (((0 <= x) && (x < Width)) &&
                ((0 <= y) && (y < Height)))
            {
                if (backgroundCells[x, y] != null)
                {
                    backgroundCells[x, y].IsHidden = isHidden;

                    List <Vector3Int> changedCellsPositions = new List <Vector3Int>();
                    changedCellsPositions.Add(new Vector3Int(x, y, 0));
                    OnLevelDataChanged?.Invoke(changedCellsPositions);
                }
            }
        }
Пример #3
0
    private void ExploreEnded(int indexInList)
    {
        Debug.Log("Explore Ended");
        exploreGroups  eG       = overallData.gameData.exploreGroups[indexInList];
        levels         lvl      = CLD.GetLevelByID(eG.destination);
        List <Ientity> loots    = new List <Ientity>(CalculateLoots(lvl, eG.crews));
        bool           explored = false;
        int            count    = 0;

        //return cats to count
        for (int i = 0; i < eG.crews.Length; i++)
        {
            if (i == 0 || eG.crews[i] == eG.crews[i - 1])
            {
                count++;
            }
            else
            {
                CatControl(eG.crews[i - 1], count, CatControlType.avaliable);
                count = 1;
            }
            if (i + 1 == eG.crews.Length)
            {
                CatControl(eG.crews[i], count, CatControlType.avaliable);
            }
        }
        //adding loots to inventory
        for (int i = 0; i < loots.Count; i++)
        {
            Debug.Log("aye" + loots[i].GetType());
            count = 1;
            for (int j = i + 1; j < loots.Count; j++)
            {
                Debug.Log("aye" + loots[j].GetType());
                if (loots[i].GetType() == loots[j].GetType() && loots[i].id == loots[j].id)
                {
                    Debug.Log("DIE");
                    count++;
                    loots.RemoveAt(j);
                    j--;
                }
            }
            if (loots[i].GetType() == typeof(catData))
            {
                CatControl(loots[i].id, count, CatControlType.count);
            }
            else
            {
                ItemControl(loots[i].id, count);
            }
        }
        //setting explored level
        foreach (exploredLevels exLvl in overallData.gameData.exploredLevels)
        {
            if (exLvl.id == lvl.id)
            {
                exLvl.rate += lvl.rate;
                explored    = true;
                if (exLvl.rate >= 100)
                {
                    unlockScore++;
                }
            }
        }
        if (!explored)
        {
            exploredLevels exLvl = new exploredLevels();
            exLvl.id   = lvl.id;
            exLvl.rate = lvl.rate;
            overallData.gameData.exploredLevels.Add(exLvl);
            if (exLvl.rate >= 100)
            {
                unlockScore++;
            }
        }
        overallData.gameData.exploreGroups.RemoveAt(indexInList);
        OnLevelDataChanged.Invoke();
        OnGroupDataChanged.Invoke();
        OnExploreEnded.Invoke();
    }