Example #1
0
 public override void StatusUpdate(Cell[,] grid, int x, int y, CellManager cellManager)
 {
     if (updateCounter >= burnTime)
     {
         cellManager.SetCell(x, y, CellType.Dirt);
     }
 }
Example #2
0
 public override void CollectActionInfo(Cell[,] grid, int x, int y, CellManager cellManager)
 {
     updateCounter++;
     if (updateCounter >= updatesPerSandSpread)
     {
         numSand = 0;
         for (int dy = -2; dy < 3; dy++)
         {
             for (int dx = -2; dx < 3; dx++)
             {
                 int nx = x + dx;
                 int ny = y + dy;
                 if (dx == 0 && dy == 0)
                 {
                     continue;
                 }
                 if (nx < 0 || nx >= grid.GetLength(0))
                 {
                     continue;
                 }
                 if (ny < 0 || ny >= grid.GetLength(1))
                 {
                     continue;
                 }
                 sandPositions[numSand] = new Vector2(nx, ny);
                 numSand++;
             }
         }
     }
 }
Example #3
0
        private void CalcUnitListInteractable()
        {
            switch (BuildManager.State)
            {
            case BuildState.None:
                foreach (var icon in units.GetChildren())
                {
                    var cell_id = icon.GetComponent <CellIconController>().CellId;
                    if (LevelManager.AminoAcidAmount >= CellManager.GetCost(cell_id))
                    {
                        icon.GetComponentInChildren <Button>().interactable = true;
                    }
                    else
                    {
                        icon.GetComponentInChildren <Button>().interactable = false;
                    }
                }
                break;

            case BuildState.Building:
                foreach (var icon in units.GetChildren())
                {
                    if (icon.GetComponent <CellIconController>().CellId == BuildManager.BuildingCellId)
                    {
                        icon.GetComponentInChildren <Button>().interactable = true;
                    }
                    else
                    {
                        icon.GetComponentInChildren <Button>().interactable = false;
                    }
                }
                break;
            }
        }
Example #4
0
 public override void CollectActionInfo(Cell[,] grid, int x, int y, CellManager cellManager)
 {
     numBurns = 0;
     for (int dy = -1; dy < 2; dy++)
     {
         for (int dx = -1; dx < 2; dx++)
         {
             int nx = x + dx;
             int ny = y + dy;
             if (nx < 0 || nx >= grid.GetLength(0))
             {
                 continue;
             }
             if (ny < 0 || ny >= grid.GetLength(1))
             {
                 continue;
             }
             if (grid[nx, ny].isFlammable)
             {
                 burnPositions[numBurns] = new Vector2(nx, ny);
                 numBurns++;
             }
         }
     }
 }
Example #5
0
 public PathFinder()
 {
     cells           = CellManager.GetInstance();
     selectedUnit    = UnitSelection.GetInstance();
     units           = UnitsList.GetInstance();
     playerControler = PlayerControler.GetInstance();
 }
        private void UpdateEnhance(int amount)
        {
            var enhanceable = CellManager.IsEnhanceable(Cell.CellId);
            var levelupable = Cell.CurrentLevel < 3;

            Action <bool> setButtonState = delegate(bool state)
            {
                EnhanceButton.interactable = state;
                EnhanceButtonText.SetActive(state);
                NotEnoughButtonText.SetActive(!state);
                EnhanceCostText.color = state ? Color.green : Color.red;
            };

            if (enhanceable && levelupable)
            {
                var cost = Cell.CurrentLevel == 1 ? CellManager.GetEnhanceCost1(Cell.CellId) : CellManager.GetEnhanceCost2(Cell.CellId);
                EnhanceCostText.text = cost.ToString();
                var enough = amount >= cost;
                if (enough)
                {
                    setButtonState.Invoke(true);
                }
                else
                {
                    setButtonState.Invoke(false);
                }
            }
            else
            {
                EnhanceCostText.text = "----";
                setButtonState.Invoke(false);
            }
        }
Example #7
0
    public bool ProgressMission(CellManager cm)
    {
        // Count--;
        progressBar.text = Count.ToString();
        if (missionShouldProgress)
        {
            iTween.PunchScale(progressBar.gameObject, new Vector3(1.1f, 1.1f, 1.1f), 1f);
            missionShouldProgress = false;
        }
        if (Count <= 0)
        {
            checkMark.gameObject.SetActive(true);
            progressBar.transform.parent.gameObject.SetActive(false);
            Count            = 0;
            progressBar.text = "";
            if (!missionCompleted)
            {
                BreakCage();
                AnimateAnimal();
            }
            missionCompleted = true;
            return(LevelManager.instance.activeLevelData.MissionCompleted());
        }

        return(false);
    }
Example #8
0
    private bool FindPosValid(PointerEventData eventData, out Vector2 posCenter)
    {
        posCenter = Vector2.zero;
        var results = new List <RaycastResult>();

        EventSystem.current.RaycastAll(eventData, results);

        if (results.Count <= 0)
        {
            return(false);
        }
        else
        {
            if (!results[0].gameObject.tag.Equals(GameTag.CELL))
            {
                return(false);
            }
            var screenPos = results[0].gameObject.GetComponent <CellControl>().ConvertToWorldPos();
            var coord     = results[0].gameObject.GetComponent <CellControl>().Coordinate;
            if (CellManager.IsHasItem((int)coord.x, (int)coord.y))
            {
                return(false);
            }
            else
            {
                CellManager.AttachItem((int)coord.x, (int)coord.y);
            }

            posCenter = Camera.main.ScreenToWorldPoint(screenPos);
            return(true);
        }
    }
Example #9
0
        public Cell CreateCell(long cellId, Vector3Int cellPos)
        {
            if (ground == null)
            {
                ground = GameObject.Find("Level").transform.GetChild("Ground").GetComponent <Tilemap>();
            }
            var real_pos = ground.CellToWorld(cellPos) + new Vector3(1, 1);
            var cell     = Instantiate(Resources.Load <Transform>($"Prefabs/Unit/{CellManager.GetPrefab(cellId)}"));

            cell.position = real_pos;
            cell.SetParent(transform);

            var cell_comp = cell.gameObject.AddComponent <Cell>();

            cell_comp.CellId = cellId;
            var cell_fire_ctrl = cell.gameObject.AddComponent <CellFireController>();

            cell_fire_ctrl.WeaponId = CellManager.GetRookieWeaponId(cellId);

            Cells[cellPos] = cell_comp;

            LevelManager.AminoAcidAmount -= CellManager.GetCost(BuildManager.BuildingCellId);
            BuildManager.DeselectCell();

            return(cell_comp);
        }
Example #10
0
    // Update is called once per frame
    void Update()
    {
        ray = Camera.main.ScreenPointToRay(Input.mousePosition);
        if (Input.GetButtonDown("Fire"))
        {
            if (Physics.Raycast(ray, out hit, 1000f, FighterVision - 5)) //-1 to invert mask, -4 to ignore raycast
            {
                SelectActiveCell(false);

                if (hit.collider.gameObject.GetComponent <CellManager>() != null)
                {
                    selectedCell   = hit.collider.gameObject.GetComponent <CellManager>();
                    cellController = selectedCell.controller;
                    UIManager.Instance.BuildUI(cellController);
                    selectedCell.Selected(true);
                    //TODO controller calls build UI
                }

                else if (hit.collider.gameObject.GetComponent <WhereIs>() != null)
                {
                    whereIsBuffer = hit.collider.gameObject.GetComponent <WhereIs>();
                    fighterBuffer = whereIsBuffer.GetFighter();
                    if (fighterInFocus != null)
                    {
                        fighterInFocus.ToggleInFocus(false);
                    }
                    fighterInFocus = fighterBuffer;
                    fighterInFocus.ToggleInFocus(true);
                    UIManager.Instance.TrackFighter(fighterInFocus, whereIsBuffer, fighterBuffer.GetFighterType() == typeof(Tower));
                }
            }
        }
    }
Example #11
0
        //todo change to return whole state
        private List <Line> GetState()
        {
            var state = new BoardStateBase(new List <Line>(), new List <Line>(), type, board);

            for (int i = 0; i < board.GetLength(0); i++)
            {
                for (int j = 0; j < board.GetLength(1); j++)
                {
                    var cell = CellManager.Get(i, j);
                    if (board[i, j] != type || usedCells.Contains(cell))
                    {
                        continue;
                    }
                    var factory = new LineModifier(cell, state, GetBackwardsDirections());
                    factory.AddCellToLines();
                    foreach (var lineCell in state.MyLines.SelectMany(l => l))
                    {
                        usedCells.Add(lineCell);
                    }
                }
            }
            state.MyLines.Sort();
            state.OppLines.Sort();
            return(state.MyLines);
        }
Example #12
0
    // Use this for initialization
    void Start()
    {
        globalOffsetX = -transform.position.x + (nbX * (sizeX + offsetX)) / 2 - (sizeX + offsetX) / 2;
        globalOffsetY = transform.position.y + (nbY * (sizeY + offsetY)) / 2 - (sizeY + offsetY) / 2;
        CellManager.setGridSize(nbX, nbY);

        foreach (Transform child in transform)
        {
            if (outOfBounds)
            {
                child.gameObject.SetActive(false);
            }
            else
            {
                child.transform.position = new Vector3(-globalOffsetX + ix * (sizeX + offsetX), globalOffsetY - iy * (sizeY + offsetY), 0);
                //child.transform.rotation *= transform.rotation;		// a * on Quaternions is a + on angles  DO NOT WORK

                CellManager.AddCell(child.gameObject.GetComponent <CellScript>(), ix, iy);

                ix++;
                if (ix >= nbX)
                {
                    ix = 0;
                    iy++;
                }
                if (iy > nbY)
                {
                    outOfBounds = true;
                    Debug.LogError("OutOfBounds : more children than spaces in the grid.");
                }
            }
        }
    }
Example #13
0
 public override void StatusUpdate(Cell[,] grid, int x, int y, CellManager cellManager)
 {
     if (numNeighbors > 0)
     {
         cellManager.SetCell(x, y, CellType.Dirt);
     }
 }
Example #14
0
    void StartDelete()
    {
        FSoundManager.PlaySound("UI/MathOpen");

        isOpeningDelete = true;

        okBox.isTouchable     = false;
        deleteBox.isTouchable = false;
        RemoveSwatches();
        RemoveKeyboard();

        Cell deleteCancelCell = CellManager.GetCellFromGrid(2, 4, 3, 3);
        Cell deleteOkCell     = CellManager.GetCellFromGrid(5, 7, 3, 3);

        deleteCancelBox = new SpriteBox(slot.player, "Icons/Cancel", 100, 100);
        deleteCancelBox.SetToCell(deleteCancelCell);
        deleteCancelBox.anchorCell = deleteCancelCell;
        AddChild(deleteCancelBox);

        deleteOkBox = new SpriteBox(slot.player, "Icons/Checkmark", 100, 100);
        deleteOkBox.SetToCell(deleteOkCell);
        deleteOkBox.anchorCell = deleteOkCell;
        AddChild(deleteOkBox);

        deleteOkBox.isTouchable     = false;
        deleteCancelBox.isTouchable = false;

        nameBox.fixedScale = nameBox.nameLabel.scale;
        nameBox.contentContainer.AddChild(deleteQMark = new FSprite("Icons/QuestionMark"));
        deleteQMark.color    = Color.black;
        nameBox.questionMark = deleteQMark;

        deleteModeTweenable.To(1.0f, 0.7f, new TweenConfig().onComplete(HandleDeleteModeOpen));
        HandleDeleteModeChange();
    }
Example #15
0
    /**
     * Use this for initialization
     */
    void Start()
    {
        currentAcidLevel = "neutral";


        // make sure game is not paused
        Time.timeScale  = 1;
        deadcellcounter = 0;

        totalfoodcounter    = 0;
        disolvedfoodcounter = 0;



        // get references
        cellManager   = FindObjectOfType(typeof(CellManager)) as CellManager;
        sFM           = FindObjectOfType(typeof(StomachFoodManager)) as StomachFoodManager;
        endGameScript = FindObjectOfType(typeof(BadgePopupSystem)) as BadgePopupSystem;

        // initialize arrays
        elapsedTime        = new float[cellManager.cellScripts.Length];
        nextCellActionTime = new float[cellManager.cellScripts.Length];
        lastCellState      = new string[cellManager.cellScripts.Length];

        deathsForThisCellInARow = new int[cellManager.cellScripts.Length];


        // populate arrays
        for (int i = 0; i < cellManager.cellScripts.Length; i++)
        {
            nextCellActionTime[i] = Mathf.Infinity;
            elapsedTime[i]        = 0f;
        }
    }
Example #16
0
        private static IEnumerable <Cell> GetAdjustmentCells(this Cell startCell)
        {
            var x    = startCell.X;
            var y    = startCell.Y;
            var cell = CellManager.Get(x + 1, y + 1);

            yield return(cell);

            cell = CellManager.Get(x + 1, y - 1);
            yield return(cell);

            cell = CellManager.Get(x - 1, y + 1);
            yield return(cell);

            cell = CellManager.Get(x - 1, y - 1);
            yield return(cell);

            cell = CellManager.Get(x + 1, y);
            yield return(cell);

            cell = CellManager.Get(x - 1, y);
            yield return(cell);

            cell = CellManager.Get(x, y + 1);
            yield return(cell);

            cell = CellManager.Get(x, y - 1);
            yield return(cell);
        }
        ///////////////////////////////////////////////////////////////

        public MapGenerator()
        {
            maxRows                    = MapGeneratorLayout.rowSize;
            maxColumns                 = MapGeneratorLayout.columnSize;
            minDistanceWall            = MapGeneratorLayout.minDistanceWall;
            randomAnswersetNumber      = MapGeneratorLayout.randomAnswersetNumber;
            encodingFolder             = MapGeneratorLayout.encodingFolder;
            minRoomSize                = MapGeneratorLayout.minRoomSize;
            pruningPercentage          = MapGeneratorLayout.pruningPercentage;
            sameOrientationPercentage  = MapGeneratorLayout.sameOrientationPercentage;
            MapGenerator.IS_DEBUG_MODE = MapGeneratorLayout.debug;

            if (MapGeneratorLayout.randomSeed == -1)
            {
                randomGenerator = new System.Random();
            }
            else
            {
                randomGenerator = new System.Random(MapGeneratorLayout.randomSeed);
            }

            matrixCells = CellManager.Instance;
            partitions  = new List <Partition>();
            connections = new List <Connected8>();
        }
    public Dijkstras(CellManager cm, GameObject distanceText) : base(cm)
    {
        this.distanceText = distanceText;

        frontier  = new List <Cell>();
        distances = new int[cellManager.width, cellManager.height];
        visited   = new bool[cellManager.width, cellManager.height];
        row       = endRow;
        col       = endCol;

        frontier.Add(cellManager.Cell(startCol, startRow));
        distances[startCol, startRow] = 0;

        if (cellManager.width <= 30 && cellManager.height <= 30)
        {
            distanceTextClone = Object.Instantiate(distanceText);
            distanceTextClone.transform.position             = cellManager.Cell(startCol, startRow).fillSprite.transform.position;
            distanceTextClone.transform.localScale           = cellManager.Cell(startCol, startRow).fillSprite.transform.localScale;
            distanceTextClone.GetComponent <TextMesh>().text = "0";
        }

        // sets all fills to be active and white, for displaying the solution
        for (int col = 0; col < cellManager.width; col++)
        {
            for (int row = 0; row < cellManager.height; row++)
            {
                cellManager.Cell(col, row).fillSprite.SetActive(true);
                cellManager.Cell(col, row).SetFillColor(Color.white);
            }
        }
    }
Example #19
0
        public void Sale()
        {
            var total_cost = 0;
            var cost1      = CellManager.GetCost(CellId);
            var cost2      = CellManager.GetEnhanceCost1(CellId);
            var cost3      = CellManager.GetEnhanceCost2(CellId);

            switch (CurrentLevel)
            {
            case 1:
                total_cost = cost1;
                break;

            case 2:
                total_cost = cost1 + cost2;
                break;

            case 3:
                total_cost = cost1 + cost2 + cost3;
                break;
            }
            LevelManager.AminoAcidAmount += (int)(total_cost * 0.5f);
            cc.DestroyCell(this);
            AudioController.PlaySE("sale");
        }
Example #20
0
        public void Enhance()
        {
            var cost = CurrentLevel == 1 ? CellManager.GetEnhanceCost1(CellId) : CellManager.GetEnhanceCost2(CellId);

            LevelManager.AminoAcidAmount -= cost;
            CurrentLevel++;
            if (CurrentLevel == 2)
            {
                transform.GetChild(0).gameObject.SetActive(true);
                transform.GetChild(1).gameObject.SetActive(false);
            }
            else
            {
                transform.GetChild(0).gameObject.SetActive(false);
                transform.GetChild(1).gameObject.SetActive(true);
            }
            GetComponent <CellFireController>().WeaponId = CurrentLevel == 2 ? CellManager.GetVeteranWeaponId(CellId) : CellManager.GetEliteWeaponId(CellId);
            var cb = GetComponent <CellBuild>();

            if (cb != null)
            {
                cb.Refresh();
            }
            else
            {
                gameObject.AddComponent <CellBuild>();
            }
            AudioController.PlaySE("enhance");
        }
Example #21
0
    public Keeper()
    {
        instance = this;

        SKDataManager.LoadData();

        CellManager.Recalculate();

        AddChild(mainContainer = new FContainer());

        SetupMegaBoxes();

        mainContainer.AddChild(slotList = new SlotList(Config.LIST_WIDTH, Config.HEIGHT));

        AddChild(effectContainer = new FContainer());

        slotList.SignalPlayerChange += HandlePlayerChange;

        HandlePlayerChange();

        Futile.screen.SignalResize       += HandleSignalResize;
        Futile.instance.SignalLateUpdate += HandleLateUpdate;

        FSoundManager.PlaySound("UI/Start");
    }
Example #22
0
 private void DrawObstacle()
 {
     if (m_IsDebugObstacleCreated)
     {
         return;
     }
     m_IsDebugObstacleCreated = true;
     if (null != m_SpatialSystem && null != m_PlayerSelf)
     {
         CellManager cellMgr = m_SpatialSystem.GetCellManager();
         if (null != cellMgr)
         {
             int maxRows = cellMgr.GetMaxRow();
             int maxCols = cellMgr.GetMaxCol();
             for (int i = 0; i < maxRows; ++i)
             {
                 for (int j = 0; j < maxCols; ++j)
                 {
                     Vector3 pt     = cellMgr.GetCellCenter(i, j);
                     byte    status = cellMgr.GetCellStatus(i, j);
                     if (BlockType.GetBlockType(status) != BlockType.NOT_BLOCK)
                     {
                         GfxSystem.DrawCube(pt.X, pt.Y, pt.Z, true);
                     }
                 }
             }
         }
     }
 }
Example #23
0
 private void OpenDoor(DOORComponent component)
 {
     if (!component.doorData.leadsToAnotherCell)
     {
         component.Interact();
     }
     else
     {
         // The door leads to another cell, so destroy all currently loaded cells.
         CellManager.DestroyAllCells();
         // Move the player.
         _playerTransform.position         = component.doorData.doorExitPos;
         _playerTransform.localEulerAngles = new Vector3(0, component.doorData.doorExitOrientation.eulerAngles.y, 0);
         // Load the new cell.
         CELLRecord newCell;
         if (component.doorData.leadsToInteriorCell)
         {
             var cellInfo = CellManager.StartCreatingCellByName(-1, 0, component.doorData.doorExitName);
             LoadBalancer.WaitForTask(cellInfo.ObjectsCreationCoroutine);
             newCell = (CELLRecord)cellInfo.CellRecord;
             OnInteriorCell(newCell);
         }
         else
         {
             var cellId = CellManager.GetCellId(component.doorData.doorExitPos, _currentWorld);
             newCell = (CELLRecord)Data.FindCellRecord(cellId);
             CellManager.UpdateCells(_playerCameraObj.transform.position, _currentWorld, true, CellRadiusOnLoad);
             OnExteriorCell(newCell);
         }
         _currentCell = newCell;
     }
 }
        public void Init(List <GameObject> tiles)
        {
            mapTiles = tiles;
            CellManager matrixCells = CellManager.Instance;

            if (matrixCells.allCells.Count > 0)
            {
                maxRow = matrixCells.allCells.Max(c => c.getRow());
                maxCol = matrixCells.allCells.Max(c => c.getColumn());
                matrix = new string[maxRow, maxCol];
            }

            Debug.Log("Row: " + maxRow + " Col: " + maxCol);

            foreach (Cell cell in matrixCells.allCells)
            {
                if (cell.getType().Equals("wall"))
                {
                    matrix[cell.getRow() - 1, cell.getColumn() - 1] = "w";
                }
                else if (cell.getType().Equals("vdoor"))
                {
                    matrix[cell.getRow() - 1, cell.getColumn() - 1] = "|";
                }
                else if (cell.getType().Equals("hdoor"))
                {
                    matrix[cell.getRow() - 1, cell.getColumn() - 1] = "=";
                }
            }

            DrawScene();
        }
Example #25
0
    public static void ShowWindow()
    {
        var window = EditorWindow.GetWindow <MapWindow>(false, "Map Generator");

        window.minSize = new Vector2(200, 100);

        _cellManager = GameObject.Find("CellContainer").GetComponent <CellManager>();
    }
Example #26
0
    void Start()
    {
        maze.SetActive(false);
        GameObject mazeClone = Instantiate(maze);

        scm = new SquareCellManager(10, 10);
        mazeClone.SetActive(true);
    }
Example #27
0
 private void OnMouseEnter()
 {
     if (isInMoveRange)
     {
         CellManager.ShowPath(this);
     }
     over = true;
 }
Example #28
0
 // TODO : CanPlay = false here or in Character ?
 private void Unselect(bool played)
 {
     // if (played && selectedCell.target != null)
     //  selectedCell.target.canPlay = false;
     selectedCell.Unselect();
     selectedCell = null;
     CellManager.ResetGrid(ResetMode.normal);
 }
Example #29
0
 void Reset()
 {
     path            = "Modules/Gera";
     normalType      = 0;
     timeManager     = gameObject.AddComponent <TimeManager> ();
     fieldsInspector = gameObject.AddComponent <FieldsInspector> ();
     cellManager     = gameObject.AddComponent <CellManager> ();
 }
Example #30
0
 public static bool WinCheck()
 {
     if (CellManager.GetInstance().EnemyPortalCount() == 0 && UnitsList.GetInstance().GetAllEnemies().Length == 0)
     {
         return(true);
     }
     return(false);
 }