Example #1
0
    void Awake()
    {
        main = this;
        ChangeState <IdleState>(null);
        haloView      = GetComponentInChildren <HaloView>();
        blockMovement = BlockMovement.AddBlockMovement(gameObject, airBox, solidLayer);
        blockMovement.staticExtrusion = true;
        jumpSkill.Init(() => Input.GetButton("Jump"), this);
        rushSkill.Init(() => Input.GetButton("Rush"), this);
        swapSkill.Init(() => Input.GetButton("Swap"), this);
        swapCharges.Init(this);
        //swap energe update
        StartCoroutine(SwapDetect());
        cameraEdge           = new CameraEdge();
        cameraEdge.edge      = GameObject.Find("SceneEdge").GetComponent <BoxCollider2D>();
        cameraEdge.cameraPos = CameraPos.main;

        follow           = new CameraSmoothFollow();
        follow.mainPos   = true;
        follow.posGetter = () => cameraEdge.UpdatePos(blockMovement.Position);
        //follow.posGetter = () => blockMovement.Position;
        follow.distanceSpeedCurve = followDistanceSpeedCurve;
        follow.priority           = 2;
        follow.Register(this);
        playerPosDisQueue = new PositionDistanceQueue(() => PositionWithoutHalo
                                                      , posQueueDisMax
                                                      , posQueueCountMax);
        StartCoroutine(playerPosDisQueue.Update());

        scaleAd = ApCtrl.CreateAlphaData(ApCtrl.TransformScaleXY(transform), this);
        StartCoroutine(TransforDetect());

        sound = GetComponentInChildren <AudioSource>();
    }
Example #2
0
        public void ChecksApplyMultipleMoves()
        {
            GameBoard gameBoard = new GameBoard(3, 3);

            GameBlockPlayer player1 = gameBoard.CreateGameBlock(GameBoard.GameBlockType.Player, 0, 0) as GameBlockPlayer;
            GameBlockNormal gameBlockNormal1 = gameBoard.CreateGameBlock(GameBoard.GameBlockType.Normal, 0, 1) as GameBlockNormal;
            GameBlockMultipleMoves gameBlockMultiple =
                gameBoard.CreateGameBlock(GameBoard.GameBlockType.MultipleMoves, 0, 2, numberOfMultipleMoves: 2) as GameBlockMultipleMoves;
            GameBlockNormal gameBlockNormal2 = gameBoard.CreateGameBlock(GameBoard.GameBlockType.Normal, 1, 2) as GameBlockNormal;
            GameBlockPlayer player2 = gameBoard.CreateGameBlock(GameBoard.GameBlockType.Player, 2, 2) as GameBlockPlayer;

            gameBlockNormal1.SetAvailability(true);
            gameBlockNormal2.SetAvailability(true);
            gameBlockMultiple.NumberOfMovesApplied = 0;

            player1.AvailableMoves = 2;
            player2.AvailableMoves = 2;
            BlockMovement move1 = new BlockMovement(player1, MovementDirection.Right);
            BlockMovement move2 = new BlockMovement(player2, MovementDirection.Up);
            bool applyMove1 = player1.ApplyMove(null, MovementDirection.Right, move1);
            bool applyMove2 = player2.ApplyMove(null, MovementDirection.Up, move2);

            Assert.IsTrue(applyMove1);
            Assert.IsTrue(applyMove2);
        }
Example #3
0
    protected override void SetPuzzle(int selector)
    {
        switch (selector)
        {
        case 0:
            blockPosition = bP1;
            blockScale    = bS1;
            break;

        case 1:
            blockPosition = bP2;
            blockScale    = bS2;
            break;

        case 2:
            blockPosition = bP3;
            blockScale    = bS3;
            break;

        case 3:
            blockPosition = bP4;
            blockScale    = bS4;
            break;
        }

        for (int i = 0; i < blockPosition.Length; i++)
        {
            BlockMovement block = Instantiate(originalBlock) as BlockMovement;
            block.transform.SetParent(container.GetComponent <Transform>());
            block.transform.position = new Vector3(blockPosition[i][0], blockPosition[i][1], originalBlock.transform.position.z);
            block.transform.GetChild(0).localScale = new Vector3(blockScale[i][0], blockScale[i][1], 1);
        }
    }
Example #4
0
 private void Awake()
 {
     mov = GetComponent <BlockMovement>();
     ChangeState <HomeState>(null);
     inRange   = enemyBox.gameObject.AddComponent <InRangeRecorder>();
     originPos = mov.Position;
     sound     = GetComponentInChildren <AudioSource>();
 }
Example #5
0
 public MovementController(IControllerFactory controllerFactory,
                           BlockMovement blockMovement,
                           GhostBlockMovement ghostBlockMovement)
     : base(controllerFactory)
 {
     _blockMovement      = blockMovement;
     _ghostBlockMovement = ghostBlockMovement;
 }
 public override void ResolveCollision(LinkCollisionResponse other)
 {
     if (!done && LinkBehavior.linkDirection == direction)
     {
         BehaviorScript script = new BlockMovement(direction, "boss_door");
         entity.AddComponent(script);
         done = true;
     }
 }
 //spawner에서 만들어진 블럭을 받아온다
 public void TakeControl(GameObject gameObject)
 {
     if (gameObject == null)
     {
         return;
     }
     controllingObject = gameObject;
     movementComonent  = controllingObject.GetComponent <BlockMovement>();
 }
    private void OnCollisionEnter(Collision collision)
    {
        BlockMovement blockScript = collision.gameObject.GetComponent <BlockMovement>();

        if (blockScript != null)
        {
            Destroy(collision.gameObject);
        }
    }
Example #9
0
 private void OverrideBlock(BlockMovement moveDirection, List <GameTile> newTetronimo, GameTile item)
 {
     if (moveDirection == BlockMovement.Down)
     {
         OverrideBlock(newTetronimo, item, FindGameTileByID(FindBlockBelow(item.ID)));
     }
     else
     {
         OverrideBlock(newTetronimo, item, FindGameTileByID(FindBlock(item.ID, moveDirection)));
     }
 }
Example #10
0
        private void MoveTetronimo(BlockMovement moveDirection)
        {
            List <GameTile> newTetronimo, copyOfCurrentTetronimo;

            CopyOldTetronimoAndDelete(out newTetronimo, out copyOfCurrentTetronimo);
            foreach (var item in copyOfCurrentTetronimo)
            {
                OverrideBlock(moveDirection, newTetronimo, item);
            }
            m_Tetronimo = newTetronimo;
        }
Example #11
0
    public void UndoMove()
    {
        if (this.movesHistory.Count > 0)
        {
            BlockMovement blockMovement = this.movesHistory.Pop();

            blockMovement.UndoMove();

            this.usedUndo = true;
        }
    }
Example #12
0
 private void instantiateBlocks()
 {
     m_blocks = new GameObject[m_poolSize];
     for (int i = 0; i < m_poolSize; ++i)
     {
         GameObject go = Instantiate(m_blockPrefab);
         m_blocks[i]           = go;
         go.transform.position = new Vector3(2000, 2000, 2000);
         BlockMovement movement = go.GetComponent <BlockMovement>();
         movement.m_manager           = this;
         movement.m_velocityMagnitude = blockInitialVelocity;
         movement.id = i;
     }
 }
Example #13
0
    // Start is called before the first frame update
    private void Start()
    {
        bc             = GetComponent <BlockCollision>();
        bm             = GetComponent <BlockMovement>();
        spriteRenderer = GetComponent <SpriteRenderer>();
        spriteColor    = spriteRenderer.color;

        dissolve      = GetComponent <Dissolve>();
        arrowDissolve = arrowTransform.gameObject.GetComponent <Dissolve>();

        obstacleChildRenderer = spike.GetComponent <SpriteRenderer>();
        obstacleChildCollider = spike.GetComponent <Collider2D>();
        collider = GetComponent <Collider2D>();
    }
Example #14
0
    private void AddBlocks()
    {
        for (int i = 0; i < LAYER_HEIGHT; i++)
        {
            for (int j = 0; j < LEVEL_DATA_WIDTH; j++)
            {
                BlockMovement blockMovement = propLayer[i, j].GetComponent <BlockMovement>();

                if (blockMovement != null)
                {
                    blocks.Add(blockMovement);
                }
            }
        }
    }
Example #15
0
        public void ChecksApplyMoveWithLoopedChangeDirection2()
        {
            GameBoard gameBoard = new GameBoard(1, 4);

            GameBlockPlayer player = gameBoard.CreateGameBlock(GameBoard.GameBlockType.Player, 0, 0) as GameBlockPlayer;
            gameBoard.CreateGameBlock(GameBoard.GameBlockType.ChangeDirection, 0, 1, MovementDirection.Right);
            GameBlockNormal gameBlockNormal1 = gameBoard.CreateGameBlock(GameBoard.GameBlockType.Normal, 0, 2) as GameBlockNormal;
            gameBoard.CreateGameBlock(GameBoard.GameBlockType.ChangeDirection, 0, 3, MovementDirection.Left);

            gameBlockNormal1.SetAvailability(true);

            player.AvailableMoves = 2;
            BlockMovement move = new BlockMovement(player, MovementDirection.Right);
            bool applyMove = player.ApplyMove(null, MovementDirection.Right, move);

            Assert.IsFalse(applyMove);
        }
Example #16
0
    private void OnCollisionEnter(Collision collision)
    {
        if (collision.gameObject.GetComponent <BotMaterial>() == null)
        {
            return;
        }
        //Debug.Log("Entered Collision method");
        Material      blockMat  = collision.gameObject.GetComponent <BotMaterial>().GetMaterial();
        BlockMovement blockMove = collision.gameObject.GetComponent <BlockMovement>();

        if (blockMat != null && blockMove != null && blockMat == this.GetComponent <Renderer>().sharedMaterial)
        {
            scoreCount += 1;
            // Debug.Log("Now destroying object...");
            Destroy(collision.gameObject);
        }
    }
Example #17
0
    public bool ApplyMove(IGameBlockParent parentBlock, MovementDirection direction, out BlockMovement move)
    {
        if (this.GameBlock == null)
        {
            move = null;
            return(false);
        }

        move = new BlockMovement(this.GameBlock as IGameBlockParent, direction);
        bool appliedMove = this.GameBlock.ApplyMove(parentBlock, direction, move);

        // Disable the TutorialAnimation once the move is applied
        foreach (Transform child in transform)
        {
            if (child.tag.Equals("TutorialAnimation"))
            {
                child.gameObject.SetActive(false);
            }
        }

        return(appliedMove);
    }
Example #18
0
        private int FindBlock(int id, BlockMovement move)
        {
            var resultID = 0;

            switch (move)
            {
            case BlockMovement.Down:
                resultID = FindBlockBelow(id);
                break;

            case BlockMovement.Left:
                resultID = id - 1;
                break;

            case BlockMovement.Right:
                resultID = id + 1;
                break;

            default:
                break;
            }
            return(resultID);
        }
Example #19
0
        public void ForceChangeDirectionCorrectly(
            MovementDirection forceDirection,
            int playerRow,
            int playerColumn,
            MovementDirection playerMovementDirection,
            int[] filledX,
            int[] filledY,
            bool moveGetsApplied)
        {
            GameBoard gameBoard = new GameBoard(5, 5);

            (gameBoard.CreateGameBlock(GameBoard.GameBlockType.Player, 0, 2) as IGameBlockParent).AvailableMoves = 2;
            (gameBoard.CreateGameBlock(GameBoard.GameBlockType.Player, 2, 0) as IGameBlockParent).AvailableMoves = 2;
            (gameBoard.CreateGameBlock(GameBoard.GameBlockType.Player, 2, 4) as IGameBlockParent).AvailableMoves = 2;
            (gameBoard.CreateGameBlock(GameBoard.GameBlockType.Player, 4, 2) as IGameBlockParent).AvailableMoves = 2;

            (gameBoard.CreateGameBlock(GameBoard.GameBlockType.Normal, 1, 2) as IGameBlockDestination).SetAvailability(true);
            (gameBoard.CreateGameBlock(GameBoard.GameBlockType.Normal, 2, 1) as IGameBlockDestination).SetAvailability(true);
            (gameBoard.CreateGameBlock(GameBoard.GameBlockType.Normal, 2, 3) as IGameBlockDestination).SetAvailability(true);
            (gameBoard.CreateGameBlock(GameBoard.GameBlockType.Normal, 3, 2) as IGameBlockDestination).SetAvailability(true);

            gameBoard.CreateGameBlock(GameBoard.GameBlockType.ChangeDirection, 2, 2, forceDirection);

            IGameBlockParent gameBlockParent = gameBoard.GameBlocks[playerRow, playerColumn] as IGameBlockParent;
            BlockMovement move = new BlockMovement(gameBlockParent, playerMovementDirection);
            bool moveApplied = gameBlockParent.ApplyMove(null, playerMovementDirection, move);

            Assert.AreEqual(moveGetsApplied, moveApplied);

            for (int i = 0; i < filledX.Length; i++)
            {
                IGameBlockDestination gameBlock = gameBoard.GameBlocks[filledX[i], filledY[i]] as IGameBlockDestination;

                Assert.IsFalse(gameBlock.IsAvailable);
            }
        }
Example #20
0
 private void Awake()
 {
     Movement   = GetComponent <BlockMovement>();
     _rigidbody = GetComponent <Rigidbody>();
     _collider  = GetComponent <Collider>();
 }
Example #21
0
 // Use this for initialization
 void Start()
 {
     currentMovingBlock         = blockManager.getCurrentBlockPrefab();
     currentMovingBlockMovement = currentMovingBlock.GetComponent <BlockMovement>();
 }
Example #22
0
        public void ChecksApplyMultipleMovesWithLoop()
        {
            GameBoard gameBoard = new GameBoard(1, 4);

            GameBlockPlayer player1 = gameBoard.CreateGameBlock(GameBoard.GameBlockType.Player, 0, 0) as GameBlockPlayer;
            GameBlockNormal gameBlockNormal1 = gameBoard.CreateGameBlock(GameBoard.GameBlockType.Normal, 0, 1) as GameBlockNormal;
            GameBlockMultipleMoves gameBlockMultiple =
                gameBoard.CreateGameBlock(GameBoard.GameBlockType.MultipleMoves, 0, 2, numberOfMultipleMoves: 2) as GameBlockMultipleMoves;
            gameBoard.CreateGameBlock(GameBoard.GameBlockType.ChangeDirection, 0, 3, MovementDirection.Left);

            gameBlockNormal1.SetAvailability(true);
            gameBlockMultiple.NumberOfMovesApplied = 0;

            player1.AvailableMoves = 3;
            BlockMovement move = new BlockMovement(player1, MovementDirection.Right);
            bool applyMove1 = player1.ApplyMove(null, MovementDirection.Right, move);

            Assert.IsTrue(applyMove1);
        }
Example #23
0
        public void CorrectlyMovesWithExtraBlock()
        {
            GameBoard gameBoard = new GameBoard(1, 4);

            GameBlockPlayer gameBlockPlayer = gameBoard.CreateGameBlock(GameBoard.GameBlockType.Player, 0, 0) as GameBlockPlayer;
            GameBlockExtraMove gameBlockExtraMove = gameBoard.CreateGameBlock(GameBoard.GameBlockType.ExtraMove, 0, 1) as GameBlockExtraMove;
            GameBlockNormal gameBlockNormal1 = gameBoard.CreateGameBlock(GameBoard.GameBlockType.Normal, 0, 2) as GameBlockNormal;
            GameBlockNormal gameBlockNormal2 = gameBoard.CreateGameBlock(GameBoard.GameBlockType.Normal, 0, 3) as GameBlockNormal;

            gameBlockPlayer.AvailableMoves = 1;
            gameBlockNormal1.SetAvailability(true);
            gameBlockNormal2.SetAvailability(true);

            BlockMovement move = new BlockMovement(gameBlockPlayer, MovementDirection.Right);
            Assert.IsTrue(gameBlockPlayer.ApplyMove(null, MovementDirection.Right, move));
            Assert.IsFalse(gameBlockNormal1.IsAvailable);
            Assert.IsFalse(gameBlockNormal2.IsAvailable);
        }
Example #24
0
        public void DeniesMoveWithExtraBlockWithNotEnoughBlocks()
        {
            GameBoard gameBoard = new GameBoard(1, 3);

            GameBlockPlayer gameBlockPlayer = gameBoard.CreateGameBlock(GameBoard.GameBlockType.Player, 0, 0) as GameBlockPlayer;
            GameBlockExtraMove gameBlockExtraMove = gameBoard.CreateGameBlock(GameBoard.GameBlockType.ExtraMove, 0, 1) as GameBlockExtraMove;
            GameBlockNormal gameBlockNormal = gameBoard.CreateGameBlock(GameBoard.GameBlockType.Normal, 0, 2) as GameBlockNormal;

            gameBlockPlayer.AvailableMoves = 1;
            gameBlockNormal.SetAvailability(true);

            BlockMovement move = new BlockMovement(gameBlockPlayer, MovementDirection.Right);
            Assert.IsFalse(gameBlockPlayer.ApplyMove(null, MovementDirection.Right, move));
            Assert.IsTrue(gameBlockNormal.IsAvailable);
        }
Example #25
0
        public void MoveOneGameBlock(
            int nothing,
            MovementDirection direction,
            int startAvailableMoves,
            int endAvailableMoves,
            bool startAvailability,
            bool endAvailability,
            int playerRow,
            int playerColumn)
        {
            GameBoard gameBoard = new GameBoard(3, 3);

            gameBoard.CreateGameBlock(GameBoard.GameBlockType.Player, 0, 0);
            gameBoard.CreateGameBlock(GameBoard.GameBlockType.Player, 0, 1);
            gameBoard.CreateGameBlock(GameBoard.GameBlockType.Player, 0, 2);
            gameBoard.CreateGameBlock(GameBoard.GameBlockType.Player, 1, 0);
            gameBoard.CreateGameBlock(GameBoard.GameBlockType.Player, 1, 2);
            gameBoard.CreateGameBlock(GameBoard.GameBlockType.Player, 2, 0);
            gameBoard.CreateGameBlock(GameBoard.GameBlockType.Player, 2, 1);
            gameBoard.CreateGameBlock(GameBoard.GameBlockType.Player, 2, 2);

            GameBlockNormal gameBlockNormal = gameBoard.CreateGameBlock(GameBoard.GameBlockType.Normal, 1, 1) as GameBlockNormal;
            gameBlockNormal.SetAvailability(startAvailability);

            GameBlockPlayer gameBlockPlayer = gameBoard.GameBlocks[playerRow, playerColumn] as GameBlockPlayer;
            gameBlockPlayer.AvailableMoves = startAvailableMoves;

            BlockMovement move = new BlockMovement(gameBlockPlayer, direction);
            gameBlockPlayer.ApplyMove(null, direction, move);

            Assert.AreEqual(endAvailability, gameBlockNormal.IsAvailable);
            Assert.AreEqual(endAvailableMoves, gameBlockPlayer.AvailableMoves);
        }
Example #26
0
        public void MoveTwoByTwoGameBlock(
            int nothing,
            MovementDirection direction,
            int startAvailableMoves,
            int endAvailableMoves,
            bool[] startAvailability,
            bool[] endAvailability,
            int playerRow,
            int playerColumn)
        {
            GameBoard gameBoard = new GameBoard(4, 4);

            gameBoard.CreateGameBlock(GameBoard.GameBlockType.Player, 0, 0);
            gameBoard.CreateGameBlock(GameBoard.GameBlockType.Player, 0, 1);
            gameBoard.CreateGameBlock(GameBoard.GameBlockType.Player, 0, 2);
            gameBoard.CreateGameBlock(GameBoard.GameBlockType.Player, 0, 3);
            gameBoard.CreateGameBlock(GameBoard.GameBlockType.Player, 1, 0);
            gameBoard.CreateGameBlock(GameBoard.GameBlockType.Player, 1, 3);
            gameBoard.CreateGameBlock(GameBoard.GameBlockType.Player, 2, 0);
            gameBoard.CreateGameBlock(GameBoard.GameBlockType.Player, 2, 3);
            gameBoard.CreateGameBlock(GameBoard.GameBlockType.Player, 3, 0);
            gameBoard.CreateGameBlock(GameBoard.GameBlockType.Player, 3, 1);
            gameBoard.CreateGameBlock(GameBoard.GameBlockType.Player, 3, 2);
            gameBoard.CreateGameBlock(GameBoard.GameBlockType.Player, 3, 3);

            GameBlockNormal gameBlockNormal11 = gameBoard.CreateGameBlock(GameBoard.GameBlockType.Normal, 1, 1) as GameBlockNormal;
            GameBlockNormal gameBlockNormal12 = gameBoard.CreateGameBlock(GameBoard.GameBlockType.Normal, 1, 2) as GameBlockNormal;
            GameBlockNormal gameBlockNormal21 = gameBoard.CreateGameBlock(GameBoard.GameBlockType.Normal, 2, 1) as GameBlockNormal;
            GameBlockNormal gameBlockNormal22 = gameBoard.CreateGameBlock(GameBoard.GameBlockType.Normal, 2, 2) as GameBlockNormal;
            gameBlockNormal11.SetAvailability(startAvailability[0]);
            gameBlockNormal12.SetAvailability(startAvailability[1]);
            gameBlockNormal21.SetAvailability(startAvailability[2]);
            gameBlockNormal22.SetAvailability(startAvailability[3]);

            GameBlockPlayer gameBlockPlayer = gameBoard.GameBlocks[playerRow, playerColumn] as GameBlockPlayer;
            gameBlockPlayer.AvailableMoves = startAvailableMoves;

            BlockMovement move = new BlockMovement(gameBlockPlayer, direction);
            gameBlockPlayer.ApplyMove(null, direction, move);

            Assert.AreEqual(endAvailability[0], gameBlockNormal11.IsAvailable);
            Assert.AreEqual(endAvailability[1], gameBlockNormal12.IsAvailable);
            Assert.AreEqual(endAvailability[2], gameBlockNormal21.IsAvailable);
            Assert.AreEqual(endAvailability[3], gameBlockNormal22.IsAvailable);
            Assert.AreEqual(endAvailableMoves, gameBlockPlayer.AvailableMoves);
        }
Example #27
0
        public void MoveThreeByOneGameBlock(
            int nothing,
            MovementDirection direction,
            int startAvailableMoves,
            int endAvailableMoves,
            bool[] startAvailability,
            bool[] endAvailability,
            int playerRow)
        {
            GameBoard gameBoard = new GameBoard(5, 1);

            gameBoard.CreateGameBlock(GameBoard.GameBlockType.Player, 0, 0);
            gameBoard.CreateGameBlock(GameBoard.GameBlockType.Player, 4, 0);

            GameBlockNormal gameBlockNormal1 = gameBoard.CreateGameBlock(GameBoard.GameBlockType.Normal, 1, 0) as GameBlockNormal;
            GameBlockNormal gameBlockNormal2 = gameBoard.CreateGameBlock(GameBoard.GameBlockType.Normal, 2, 0) as GameBlockNormal;
            GameBlockNormal gameBlockNormal3 = gameBoard.CreateGameBlock(GameBoard.GameBlockType.Normal, 3, 0) as GameBlockNormal;

            gameBlockNormal1.SetAvailability(startAvailability[0]);
            gameBlockNormal2.SetAvailability(startAvailability[1]);
            gameBlockNormal3.SetAvailability(startAvailability[2]);

            GameBlockPlayer gameBlockPlayer = gameBoard.GameBlocks[playerRow, 0] as GameBlockPlayer;
            gameBlockPlayer.AvailableMoves = startAvailableMoves;

            BlockMovement move = new BlockMovement(gameBlockPlayer, direction);
            gameBlockPlayer.ApplyMove(null, direction, move);

            Assert.AreEqual(endAvailability[0], gameBlockNormal1.IsAvailable);
            Assert.AreEqual(endAvailability[1], gameBlockNormal2.IsAvailable);
            Assert.AreEqual(endAvailability[2], gameBlockNormal3.IsAvailable);
            Assert.AreEqual(endAvailableMoves, gameBlockPlayer.AvailableMoves);
        }