예제 #1
0
 void ChangeBlock()
 {
     if (currentBlock == GameBlock.None)
     {
         currentBlock    = GameBlock.BlockOneOne;
         checkPointIndex = 1;
         level           = "BLOCK  1-1";
         UpdateLevelLivesAmmo();
     }
     else if (currentBlock == GameBlock.BlockOneOne)
     {
         currentBlock    = GameBlock.BlockOneTwo;
         checkPointIndex = 2;
         level           = "BLOCK  1-2";
         UpdateLevelLivesAmmo();
     }
     else if (currentBlock == GameBlock.BlockOneTwo)
     {
         currentBlock    = GameBlock.BlockOneThree;
         checkPointIndex = 3;
         level           = "BLOCK  1-3";
         UpdateLevelLivesAmmo();
     }
     else if (currentBlock == GameBlock.BlockOneThree)
     {
         currentBlock    = GameBlock.BlockOneFour;
         checkPointIndex = 4;
         level           = "BLOCK  1-4";
         UpdateLevelLivesAmmo();
     }
 }
        protected GameBlock GetBlock(GameObject o)
        {
            MBDrawScope b     = o.GetComponent <MBDrawScope>();
            GameBlock   block = ((GameBlock)b.scope);

            return(block);
        }
예제 #3
0
        private void CreateFloor()
        {
            gameMesh = new IGraphicsComponent[numberOfBlocks, numberOfBlocks, 2];
            for (int i = 0; i < gameMesh.GetLength(1); ++i)
            {
                for (int j = 0; j < gameMesh.GetLength(0); ++j)
                {
                    IGameObject block;
                    if (IsSpawnPoint(i, j))
                    {
                        block = new GameBlock(BlockType.Dirt, new Point3D(i, j, 0));
                    }
                    else if (IsFinishPoint(i, j))
                    {
                        block = new GameBlock(BlockType.Dirt, new Point3D(i, j, 0));
                        IGameObject        blockFinish  = new GameBlock(BlockType.Dirt, new Point3D(i, j, 0));
                        IGraphicsComponent portalObject = new GraphicsComponent(blockFinish, resourceManager, gameCanvas);
                        gameMesh[i, j, 1] = portalObject;
                    }

                    else if (IsEdgeOfMap(i, j))
                    {
                        block = new GameBlock(BlockType.Edge, new Point3D(i, j, 0));
                    }
                    else
                    {
                        block = new GameBlock(resourceManager, new Point3D(i, j, 0));
                    }
                    IGraphicsComponent blockObject = new GraphicsComponent(block, resourceManager, gameCanvas);
                    gameMesh[i, j, 0] = blockObject;
                }
            }
        }
예제 #4
0
    private void RecursiveFall(int _runningIndex, bool _countsAsChain = false)
    {
        GameBlock me = GetGameBlock(_runningIndex);

        if (!me)
        {
            return;
        }
        if (me.BlockState != EBlockState.BS_Idle)
        {
            return;
        }

        //If im grounded then return
        if (IsBlockBelow(_runningIndex))
        {
            return;
        }

        if (_countsAsChain)
        {
            blocksInChain.Add(playGrid[_runningIndex]);
        }

        me.Fall();

        //If theres a block above me, make that fall too
        RecursiveFall(_runningIndex + width, _countsAsChain);
    }
예제 #5
0
    private void RecursiveCheckMatchBranch(ref List <GameBlock> _matches, int _runningIndex, Vector2Int _dir)
    {
        if (!IsIndexValid(_runningIndex))
        {
            return;
        }

        GameBlock me = GetGameBlock(_runningIndex);

        if (me == null)
        {
            return;
        }

        _matches.AddUnique(me);

        int nextIndex = _runningIndex + Index2DTo1D(_dir);

        //If im checking left and right and im about to exceed over to the next line, quit
        if (_dir.x != 0 && !AreIndexsOnSameRow(_runningIndex, nextIndex))
        {
            return;
        }

        GameBlock next = GetGameBlock(nextIndex);

        if (next != null && next.BlockType == me.BlockType && next.BlockState == EBlockState.BS_Idle)
        {
            RecursiveCheckMatchBranch(ref _matches, nextIndex, _dir);
        }
    }
예제 #6
0
 void CreateStar(int index, GameBlock gameBlock)
 {
     MissionManager.Instance.blockCount--;
     MissionManager.Instance.txtBlockCount.text = MissionManager.Instance.blockCount.ToString();
     //블록카운트에서 아이템블록 생성위치간의 이펙트 생성
     StartCoroutine(FlyStar(index, gameBlock));
 }
예제 #7
0
    void ClearBlock(GameBlock block, bool score)
    {
        if (block == SelectedBlock)
        {
            SelectBlock(null, null);
        }
        if (block.IsAnimating)
        {
            CurrentState = GameState.Selecting;
        }

        if (score)
        {
            // Collect Powerups
            if (block.PowerupId.HasValue)
            {
                if (block.PowerupId.Value == GameBlock.Powerup.BoardClear)
                {
                    Flier.Spawn(block.PowerupSprite, block.transform.position, BoardClearTransform.position, BoardClearTransform.gameObject, 1, Flier.AudioToPlay.ItemCollect);
                }
                else if (block.PowerupId.Value == GameBlock.Powerup.TimeStop)
                {
                    Flier.Spawn(block.PowerupSprite, block.transform.position, TimeStopTransform.position, TimeStopTransform.gameObject, 1, Flier.AudioToPlay.ItemCollect);
                }
            }

            Flier.Spawn(block.BlockSprite, block.transform.position, ScoreTransform.position, ScoreTransform.gameObject,
                        (collector.Count > 3) ? ScorePerBlock * (collector.Count - 2) : ScorePerBlock, Flier.AudioToPlay.BlockCollect
                        );
        }

        CloudPuff.Spawn(block.transform.position);
        GameBlock.Despawn(block);
    }
예제 #8
0
    public void SpawnBlock()
    {
        while (true)
        {
            int x = Mathf.Clamp(Random.Range(0, Cols), 0, Cols - 1);
            int y = Mathf.Clamp(Random.Range(0, Rows), 0, Rows - 1);

            if (Board[y, x] != null)
            {
                // Prevent the possibility of an infinite loop
                TestForFailure();
                if (CurrentState == GameState.GameOver)
                {
                    return;
                }
                continue;
            }

            tmpBlock = GenerateBlock(x, y, true);
            PendingBlock.Spawn(BlockSprites[tmpBlock.BlockType],
                               tmpBlock,
                               GetLocalPosition(x, y), UICanvas, _t, x, y);

            break;
        }
        ShowAndHideArrows();
    }
예제 #9
0
    GameBlock GenerateBlock(int x, int y, bool isDeactivated = false)
    {
        blockId = Mathf.Clamp(Random.Range(0, BlockSprites.Length), 0, BlockSprites.Length - 1);
        float random = Random.value;

        //if (random >= 0.75f)
        if (random >= 0.99f)
        {
            blockPowerup  = GameBlock.Powerup.BoardClear;
            powerupSprite = BoardClearPowerup;
        }
        //else if (random >= 0.5f)
        else if (random >= 0.95f)
        {
            blockPowerup  = GameBlock.Powerup.TimeStop;
            powerupSprite = TimeStopPowerup;
        }
        else
        {
            blockPowerup  = null;
            powerupSprite = null;
        }

        return(GameBlock.Spawn(BlockSprites[blockId], powerupSprite, GetLocalPosition(x, y), blockId, blockPowerup, _t, x, y, isDeactivated));
    }
예제 #10
0
 public Node(GameBlock gameBlock)
 {
     this._location   = gameBlock.Location;
     this._nodeEntity = gameBlock.PowerUp ?? gameBlock.Entity ?? gameBlock.Bomb;
     this._exploding  = gameBlock.Exploding;
     this._bombEntity = gameBlock.Bomb;
 }
예제 #11
0
    void GenerateNextBlock(GameObject currentBlock, out GameObject returnBlock)
    {
        int i              = groupBlock[numberGroup].Length - countRemainingBlock;
        int blockValue     = groupBlock[numberGroup][i];
        int indexNextBlock = blockValue / 100;

        Storage.CountBlockEarth = blockValue % 10;
        int       index = (blockValue / 10) % 10;
        GameBlock block = MessageSystemGameBlock.ReturnBlockFromGroup(indexNextBlock, index);

        GameObject    newBlock = block.GetGameObject();
        BoxCollider2D curBox   = currentBlock.GetComponent <BoxCollider2D>();
        float         offset   = 0;

        if (block.Extents != -1)
        {
            offset = curBox.bounds.extents.x + block.Extents;
        }
        else
        {
            GenerateNextEarth(currentBlock);
            Storage.CountBlockEarth++;
        }
        newBlock.transform.position = new Vector3(curBox.bounds.center.x + offset, newBlock.transform.position.y, newBlock.transform.position.z);
        MessageSystemGameBlock.SetupParent(newBlock, false);
        block.SetActiveFull(true);
        returnBlock = newBlock;
    }
예제 #12
0
    GameObject GenerateNextBlock(int index, GameObject currentBlock)
    {
        GameBlock     block    = MessageSystemGameBlock.ReturnDisactiveGameObject(index);
        GameObject    newBlock = block.GetGameObject();
        BoxCollider2D curBox   = currentBlock.GetComponent <BoxCollider2D>();
        float         offset   = 0;

        if (newBlock.name == "Barrier_Grey" || newBlock.name == "Portal_Grey")
        {
            Storage.CountTripleBlock = 3;
        }
        if (block.Extents != -1)
        {
            offset = curBox.bounds.extents.x + block.Extents;
        }
        else
        {
            GenerateNextEarth(currentBlock);
            Storage.CountBlockEarth++;
        }
        newBlock.transform.position = new Vector3(curBox.bounds.center.x + offset, newBlock.transform.position.y, newBlock.transform.position.z);
        MessageSystemGameBlock.SetupParent(newBlock, false);
        block.SetActiveFull(true);
        if (Storage.CountTripleBlock != 0)
        {
            Storage.CountTripleBlock--;
        }
        return(newBlock);
    }
예제 #13
0
    public void TestForClear(int x, int y)
    {
        CopyBoard();
        collector.Clear();

        // Only the currently moved block can trigger a clear
        TestBlock(x, y);

        // Destroy blocks if we matched 3 of a kind
        if (collector.Count >= 3)
        {
            SoundBoard.PlayBlockMatch();

            // Destroy all the blocks
            while (collector.Count > 0)
            {
                ClearBlock(collector[0], true);
                collector.RemoveAt(0);
            }
        }

        // Finish testing this block
        currentlyTesting = null;
        collector.Clear();
    }
예제 #14
0
        private Dictionary <int, int> CountBlocksPerDistance(GameMap gameMap)
        {
            var quadrantWidth  = (gameMap.MapWidth) / 2;
            var quadrantHeight = (gameMap.MapWidth) / 2;

            var blocksPerDistance = new Dictionary <int, int>();

            for (var x = 1; x < quadrantWidth; x++)
            {
                for (var y = 1; y < quadrantHeight; y++)
                {
                    GameBlock block = gameMap.GetBlockAtLocation(x, y);
                    if (block.Entity != null && block.Entity.GetType() == typeof(DestructibleWallEntity))
                    {
                        int radius = (int)Math.Floor(DetermineRadius(1, 1, x, y));

                        if (blocksPerDistance.ContainsKey(radius))
                        {
                            blocksPerDistance[radius]++;
                        }
                        else
                        {
                            blocksPerDistance.Add(radius, 1);
                        }
                    }
                }
            }

            return(blocksPerDistance);
        }
        /// <summary>
        /// Request the movement of a player on the game map
        /// </summary>
        /// <param name="playerEntity">The player to move</param>
        /// <param name="destination">The destination block for the move</param>
        public void RequestMovement(PlayerEntity playerEntity, GameBlock destination)
        {
            if (_playerMovementDestinations.ContainsKey(playerEntity))
            {
                throw new InvalidCommandException("Command Transaction already contains a destination for player " + playerEntity);
            }

            _playerMovementDestinations.Add(playerEntity, destination);
        }
예제 #16
0
    public override void Start(GameBlock _block)
    {
        base.Start(_block);

        gameBlock.BlockState = EBlockState.BS_Swap;

        startScale        = gameBlock.transform.localScale;
        animStartLocation = gameBlock.transform.position;
    }
예제 #17
0
 public void BlockMouseClick(GameBlock block)
 {
     if (!block.currSelected) {
         nextSelectionTime = Time.time + keyDelay;
         DeselectBlock (blockslist [currentSelection]);
         currentSelection = System.Array.IndexOf (blockslist, block);
         SelectBlock (blockslist [currentSelection]);
     }
 }
예제 #18
0
        private void BlockTest(object sender, RibbonControlEventArgs e)
        {
            GameBlock gb = new GameBlock(100, 100, 30, Blocks_base.BlockType.Ts, 2);

            CorPoint[]    points = gb.GetCorPoints();
            Worksheet     ws     = Globals.ThisAddIn.Application.ActiveSheet;
            ShowSomething ss     = new ShowSomething(ws);

            ss.Show();
        }
예제 #19
0
    public override void Move(LevelMoment next, LevelMoment prev, Lemming lemming, GameBlock block)
    {
        lemming.position = block.pos;

        LevelData.Instance.WormHole(next);
        next.timeTraveler = lemming;
        next.lemmings.Remove(lemming);
        next.phasedLemmings.Remove(lemming);
        next.fail--;
    }
예제 #20
0
    public virtual void Drop()
    {
        if (!transform.parent.name.Contains("pos"))
        {
            bMove = true;
            return;
        }
        //Debug.Log(pos.ToString() + " : Drop");
        iVector3 down = pos.Down;

        if (rTr.anchoredPosition3D.sqrMagnitude > 1f)
        {
            bMove = true;
        }
        if (down.y.CompareTo(0) < 0)
        {
            return;
        }
        bool drop = false;

        if (BlockTools.ValidPos(down))
        {
            GameBlock gameBlock = InGameManager.Instance.GetGameBlock(down);
            if (gameBlock == null)
            {
                drop = true;
            }
            else
            {
                if (gameBlock.bMove)
                {
                    //drop = true;
                }
                if (gameBlock.bDestroy)
                {
                    drop = true;
                }
                if (!gameBlock.bMove && !gameBlock.bDestroy)
                {
                    if (!bBounce)
                    {
                        bBounce = true;
                        //Debug.Log("Bounce : " + pos.ToString());
                        Bounce();
                    }
                }
            }
        }
        if (drop)
        {
            pos = down;
            transform.SetParent(InGameManager.Instance.positionList[BlockTools.iVector3ToIndex(down)].transform);
            bMove = true;
        }
    }
예제 #21
0
        public void SpawnFinishPoint(BlockType type)
        {
            if (!type.Equals(BlockType.FinishLocked) && !type.Equals(BlockType.FinishUnlocked))
            {
                throw new ArgumentException("Invalid finish type parameter!");
            }
            IGameObject        finishPoint  = new GameBlock(type, new Point3D(numberOfBlocks - 2, numberOfBlocks - 2, 1));
            IGraphicsComponent portalObject = new GraphicsComponent(finishPoint, resourceManager, gameCanvas);

            gameMesh[numberOfBlocks - 2, numberOfBlocks - 2, 1] = portalObject;
        }
예제 #22
0
    GrayBlock GetGrayBlock(iVector3 position)
    {
        GrayBlock grayBlock = null;
        GameBlock gameBlock = InGameManager.Instance.GetGameBlock(position);

        if (gameBlock != null)
        {
            grayBlock = gameBlock.GetComponent <GrayBlock>();
        }
        return(grayBlock);
    }
예제 #23
0
    public override bool ShouldEnd()
    {
        GameBlock below = GameGrid.GetGameBlock(gameBlock.Index - GameGrid.width);

        if (below)
        {
            return(below.BlockState != EBlockState.BS_Fall);
        }

        return(false);
    }
예제 #24
0
    public void TestBlock(int x, int y)
    {
        // Already tested
        if (boardCopy[y, x] == null)
        {
            return;
        }

        // Can't actually test this yet
        if (boardCopy[y, x].IsPending)
        {
            boardCopy[y, x] = null;
            return;
        }

        // Start testing
        else if (currentlyTesting == null)
        {
            currentlyTesting = boardCopy[y, x];
            boardCopy[y, x]  = null;
            collector.Add(currentlyTesting);
        }

        // Not the same shape... leave and come back to this later
        else if (currentlyTesting.BlockType != boardCopy[y, x].BlockType)
        {
            return;
        }

        // Matching shape
        else
        {
            collector.Add(boardCopy[y, x]);
            boardCopy[y, x] = null;
        }

        // Test around the block
        if (x > 0)
        {
            TestBlock(x - 1, y);
        }
        if (y > 0)
        {
            TestBlock(x, y - 1);
        }
        if (x < Cols - 1)
        {
            TestBlock(x + 1, y);
        }
        if (y < Rows - 1)
        {
            TestBlock(x, y + 1);
        }
    }
예제 #25
0
 public void ResetSelection(GameBlock block, int x, int y)
 {
     CurrentState = GameState.Selecting;
     if (block == SelectedBlock)
     {
         SelectBlock(x, y);
     }
     else if (selectedX.HasValue && selectedY.HasValue)
     {
         SelectBlock(selectedX, selectedY);
     }
 }
예제 #26
0
    public void BlockStateChanged(GameBlock _block, EBlockState _oldState, EBlockState _newState)
    {
        if (_oldState == EBlockState.BS_Swap)
        {
            RecursiveFall(_block.Index);
        }

        if (_newState == EBlockState.BS_Idle)
        {
            MarkBlockDirty(_block);
        }
    }
예제 #27
0
    public void MarkBlockDirty(GameBlock _block)
    {
        if (!_block)
        {
            return;
        }

        if (!dirtyBlocks.Contains(_block))
        {
            dirtyBlocks.Add(_block);
        }
    }
예제 #28
0
    public bool IsBlockBelow(int _index)
    {
        //Am i on the bottom index
        if (_index / width == 1)
        {
            return(true);
        }

        GameBlock blockBelow = GetGameBlock(_index - width);

        return(blockBelow != null);
    }
예제 #29
0
 void InitializeFromPool(Sprite sprite, GameBlock realBlock, Vector3 localPosition, Canvas canvas, Transform parent)
 {
     StopAllCoroutines();
     _i.sprite = sprite;
     RealBlock = realBlock;
     _t.SetParent(canvas.transform, true);
     _t.localPosition = Vector3.zero;
     _t.localScale    = Vector3.one;
     _t.position      = parent.transform.position + localPosition;
     timer            = 0;
     StartCoroutine(TIMER_COROUTINE);
 }
예제 #30
0
    public override void Move(LevelMoment next, LevelMoment prev, Lemming lemming, GameBlock block)
    {
        Vector3Int i = block.pos;

        if (fade > '0')
        {
            next.level[i.x, i.y, i.z] = fade;
        }
        else
        {
            next.level[i.x, i.y, i.z] = GameBoardCubeDictionary.OPEN_CUBE;
        }
    }
예제 #31
0
    public GameBlock GetGameBlock(iVector3 pos)
    {
        GameBlock gameBlock = null;

        if (pos.x >= 0 && pos.y <= 4 && pos.z == 0)
        {
            if (positionList != null && positionList.Count != 0)
            {
                gameBlock = positionList[BlockTools.iVector3ToIndex(pos)].GetComponentInChildren <GameBlock>();
            }
        }
        return(gameBlock);
    }
예제 #32
0
    public void SelectBlock(GameBlock block)
    {
        block.currSelected = true;

        iTween.MoveTo (block.gameObject, iTween.Hash ("z", -1f, "y", 1.2f, "time", 0.5f, "easetype", iTween.EaseType.easeOutCubic));
        iTween.ScaleTo (block.gameObject, iTween.Hash ("x", 1.5f, "y", 1.5f, "z", 1.5f, "time", 0.5f, "easetype", iTween.EaseType.linear));
        block.GetComponent<CamTiltMouse> ().TurnOn ();

        cameraMoveTarget.x = blockslist [currentSelection].transform.position.x;

        manager.Process (block.info);
    }
예제 #33
0
 public void BlockMouseExit(GameBlock block)
 {
     if (!block.currSelected)
         iTween.ScaleTo (block.gameObject, iTween.Hash ("x", 1f, "y", 1f, "z", 1f, "time", 0.2f, "easetype", iTween.EaseType.linear));
 }
예제 #34
0
    public void DeselectBlock(GameBlock block)
    {
        block.currSelected = false;

        iTween.MoveTo (block.gameObject, iTween.Hash ("z", 0f, "y", 0f, "time", 0.5f, "easetype", iTween.EaseType.easeOutCubic));
        iTween.ScaleTo (block.gameObject, iTween.Hash ("x", 1f, "y", 1f, "z", 1f, "time", 0.5f, "easetype", iTween.EaseType.linear));
        block.GetComponent<CamTiltMouse> ().TurnOff ();
    }