Esempio n. 1
0
    private void FixedUpdate()
    {
        if (activeBlock != null)
        {
            Block block = activeBlock.GetComponent <Block>();
            //Once you cannot keep moving down, you stop being the active block
            if (!block.GetFreeDirections()[1])
            {
                StoreBlock(activeBlock);
                List <GameObject> wordBlocks = wordHandler.ParseRow(activeBlock);
                string            wordString = wordHandler.ParseWord(wordBlocks);
                if (wordString != string.Empty)
                {
                    var score = scoreHandler.CalculateScore(wordString);
                    scoreHandler.AddToTotal(score);
                    if (floatingScorePrefab != null)
                    {
                        var transformAt = wordBlocks[0].transform;
                        ShowFloatingScoreText(score, transformAt.transform.TransformPoint(transformAt.position));
                        FindObjectOfType <AudioManager>().Play("Ding");
                    }
                }
                if (wordBlocks != null && wordBlocks.Count > 0)
                {
                    wordBlocks.ForEach(x => x.transform.position = new Vector3(100, 100, 0));
                    wordBlocks.ForEach(x => Destroy(x));
                    foreach (GameObject blockObject in blockStore.GetAllBlocks())
                    {
                        if (blockObject != null)
                        {
                            blockObject.layer = 2;
                            blockObject.GetComponent <Block>().CheckCollision();
                            blockObject.layer = 0;
                        }
                    }
                }

                activeBlock.layer = 0;
                ClearActiveBlock();
            }
        }
        if (activeBlock == null)
        {
            activeBlock = SpawnBlock();
            userInputHandler.SetActiveObject(activeBlock);
        }
    }