Exemple #1
0
 //Used for getting the previously saved properties
 void ReadDefaults()
 {
     myProperties = FindObjectOfType <MapDesignerProperties>();
     if (myProperties == null)
     {
         Debug.LogError("Couldn't find a game object with 'MapDesignerProperties' attached to it. Please create an object with 'MapDesignerProperties' attached to it");
         return;
     }
     myProperties = FindObjectOfType <MapDesignerProperties>();
 }
Exemple #2
0
        private void Awake()
        {
            SpriteRenderer renderer = GetComponent <SpriteRenderer>();

            defaultSprite         = renderer.sprite;
            renderer.sortingOrder = -10;
            borderObject.GetComponent <SpriteRenderer>().enabled = isSelected;
            bombAlerter   = transform.Find("Canvas/Counter").GetComponent <Text>();
            targetPos     = currentGrid.transform.position;
            gM            = FindObjectOfType <GridManager>();
            mapProperties = FindObjectOfType <MapDesignerProperties>();
            sV            = FindObjectOfType <SharedVariables>();
            topGrid       = GetTopGrid(currentGrid);
        }
Exemple #3
0
        private MyGrid GetTopGrid(MyGrid currentGrid)
        {
            if (mapProperties == null)
            {
                mapProperties = GetComponent <MapDesignerProperties>();
            }

            int gridId               = currentGrid.GridId;
            int gridSize             = gM.grids.Count;
            int horizontalCellAmount = mapProperties.horizontalAmount;

            int topGridIndex = gridSize - (horizontalCellAmount - (gridId % horizontalCellAmount));

            //  Debug.Log("topGridIndex : " + topGridIndex);
            return(gM.grids[topGridIndex]);
        }
        public List <MyGrid> FindAdjacentGrids(Transform selectedGrid, MapDesigner.MapDesignerProperties myProperties, MyGrid[] grids)
        {
            List <MyGrid> resultSet = new List <MyGrid>();

            float cellPadding = myProperties.tilePadding;

            foreach (MyGrid item in grids)
            {
                float tempDist = Vector2.Distance(selectedGrid.position, item.transform.position);
                if (tempDist <= cellPadding && tempDist != 0)
                {
                    resultSet.Add(item);
                }
            }

            return(resultSet);
        }
Exemple #5
0
        //Basic initialization
        public void Awake()
        {
            ReadDefaults();
            willUpdate = true;

            GameObject tempOldLevel = GameObject.Find(myProperties.levelName);

            if (tempOldLevel != null)
            {
                oldLevel = tempOldLevel;
                ToggleRealLevelRenderer(false);
            }


            inGamePropertyObject = GameObject.FindObjectOfType <MapDesignerProperties>();
            gridProp             = inGamePropertyObject.GetComponent <GridSystem.GridManager>();
        }
Exemple #6
0
        public MyGrid GetAnyTopGrid()
        {
            if (mapProperties == null)
            {
                mapProperties = GetComponent <MapDesignerProperties>();
            }
            int horizontalCellAmount = mapProperties.horizontalAmount;
            int gridSize             = gM.grids.Count;

            for (int i = gridSize - horizontalCellAmount - 1; i < gridSize; i++)
            {
                if (gM.grids[i].assignedCell == null)
                {
                    return(gM.grids[i]);
                }
            }
            return(null);
        }
        public bool CheckGivenPairForPossibleMoves(MyGrid[] group, MyGrid selectedGrid, MapDesigner.MapDesignerProperties myProperties, MyGrid[] allMap)
        {
            float cellPadding = myProperties.tilePadding;


            int groupSize = group.Length;

            for (int i = 0; i < groupSize; i++)
            {
                for (int j = 0; j < groupSize; j++)
                {
                    if (i == j)
                    {
                        continue;
                    }
                    float distBetween = Vector2.Distance(group[i].transform.position, group[j].transform.position);
                    if (distBetween <= cellPadding)
                    {
                        MyGrid[] newSelectedCellGroup = { selectedGrid, group[i], group[j] };

                        List <MyGrid> tempAdjacentOfCell = new List <MyGrid>();
                        foreach (MyGrid item in newSelectedCellGroup)
                        {
                            tempAdjacentOfCell.AddRange(FindAdjacentGrids(item.transform, myProperties, allMap));
                        }

                        List <MyGrid> adjacentOfCell = tempAdjacentOfCell.Distinct().ToList();
                        for (int a = 0; a < 2; a++)
                        {
                            for (int x = 0; x < groupSize; x++)
                            {
                                for (int y = 0; y < groupSize; y++)
                                {
                                    if (x == y)
                                    {
                                        continue;
                                    }
                                    float distBetweenCells = Vector2.Distance(group[x].transform.position, group[y].transform.position);
                                    if (distBetween <= cellPadding)
                                    {
                                        MyGrid[] groupToPass          = { group[x], group[y], newSelectedCellGroup[a] };
                                        bool     markedForDestruction = CheckSameColor(groupToPass);
                                        if (markedForDestruction)
                                        {
                                            return(false);
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
            return(true);
        }
Exemple #8
0
 // Save the new properties file
 void SaveDefaults()
 {
     inGamePropertyObject = myProperties;
 }