예제 #1
0
        void OnDeployableButtonClick(Deployable deployable, Button button)
        {
            // check whether layer is active
            Transform layerTransform = GameMapGrid.deployableParentDictionary [deployable.GetLayer()];

            if (!layerTransform.gameObject.activeSelf)
            {
                return;
            }

            // when clicking self
            if (button == lastDeployableButton)
            {
                return;
            }

            objectToDeploy      = deployable;
            currentLayerToErase = deployable.GetLayer();

            if (lastDeployableButton)
            {
                lastDeployableButton.image.color = button.image.color;
            }
            lastDeployableButtonColor = button.image.color;
            button.image.color        = new Color(0.5f, 0.5f, 0.5f, button.image.color.a);
            lastDeployableButton      = button;
        }
예제 #2
0
        public Deployable[] GetAllChildren(Deployable.DeployLayer deployLayer)
        {
            Transform parentTransform = deployableParentDictionary [deployLayer];
            var       result          = new Deployable[parentTransform.childCount];

            for (int i = 0; i < parentTransform.childCount; i++)
            {
                result [i] = parentTransform.GetChild(i).GetComponent <Deployable> ();
            }
            return(result);
        }
예제 #3
0
        private void ResetObjectToDeploy()
        {
            objectToDeploy      = null;
            currentLayerToErase = Deployable.DeployLayer._Null;

            if (lastDeployableButton)
            {
                lastDeployableButton.image.color = lastDeployableButtonColor;
                lastDeployableButton             = null;
            }
        }
예제 #4
0
        public void EraseDeployableObject(Ray ray, Deployable.DeployLayer selectedLayer)
        {
            RaycastHit hitInfo;

            Physics.Raycast(ray, out hitInfo, 100, 1 << gridPlaneLayer);
            if (hitInfo.collider)
            {
                Vector3    loc   = hitInfo.point - planeBottomLeftPosition;
                IntVector2 index = new IntVector2(loc.x * Columns / boundX, loc.y * Rows / boundY);

                MapGridCell[] cells          = deployableCellDictionary [selectedLayer];
                Deployable    toDeleteObject = cells [CalculateIndex(index)].InCellObject;
                if (toDeleteObject)
                {
                    UpdateTilesWithOffset(toDeleteObject, toDeleteObject.GridIndex, true);
                    Destroy(toDeleteObject.gameObject);
                }
            }
        }
예제 #5
0
 public void OnLayerToSelectChange(int index)
 {
     currentLayerToSelect = layerToSelectDictionary [index];
 }