public static BuildTowerEventArgs Create(TowerData towerData, IPlacementArea placementArea, IntVector2 placeGrid, Vector3 position, Quaternion rotation, object userData = null)
        {
            BuildTowerEventArgs buildTowerEventArgs = ReferencePool.Acquire <BuildTowerEventArgs>();

            buildTowerEventArgs.TowerData     = towerData;
            buildTowerEventArgs.PlacementArea = placementArea;
            buildTowerEventArgs.PlaceGrid     = placeGrid;
            buildTowerEventArgs.Position      = position;
            buildTowerEventArgs.Rotation      = rotation;
            return(buildTowerEventArgs);
        }
        private void OnBuildTower(object sender, GameEventArgs e)
        {
            BuildTowerEventArgs ne = (BuildTowerEventArgs)e;

            if (ne == null)
            {
                return;
            }

            if (levelControl == null)
            {
                return;
            }

            levelControl.CreateTower(ne.TowerData, ne.PlacementArea, ne.PlaceGrid, ne.Position, ne.Rotation);
        }
        public bool TryBuildTower()
        {
            if (currentArea == null)
            {
                Log.Error("Current area is null");
                return(false);
            }

            Vector3    position = Vector3.zero;
            Quaternion rotation = currentArea.transform.rotation;

            TowerFitStatus fits = currentArea.Fits(m_GridPosition, entityDataTowerPreview.TowerData.Dimensions);

            if (fits == TowerFitStatus.Fits)
            {
                position = currentArea.GridToWorld(m_GridPosition, entityDataTowerPreview.TowerData.Dimensions);
                currentArea.Occupy(m_GridPosition, entityDataTowerPreview.TowerData.Dimensions);
                GameEntry.Event.Fire(this, BuildTowerEventArgs.Create(entityDataTowerPreview.TowerData, currentArea, m_GridPosition, position, rotation));
                return(true);
            }

            return(false);
        }