Exemplo n.º 1
0
        public void ResetGame()
        {
            playSceneState = PlaySceneState.main;
            pathManager.InitPath();
            distance   = 0;
            kill       = 0;
            addCoin    = 0;
            combo      = 0;
            totalCombo = 0;
            score      = 0;
            uiManager.UpdateKill(this.kill);
            uiManager.UpdateDistance(this.distance);
            uiManager.UpdateCoin(false);
            uiManager.UpdateScoreUI(this.score, 0);

            isClear             = false;
            isContinued         = false;
            pausePanel.isPaused = false;
            pausePanel.button_pause.gameObject.SetActive(true);

            isHpDecreasing = false;
            isSpIncreasing = false;
            if (gameOverCoroutine != null)
            {
                StopCoroutine(gameOverCoroutine);
            }
            if (hpDecreasingCoroutine != null)
            {
                StopCoroutine(hpDecreasingCoroutine);
            }
            if (spIncreasingCoroutine != null)
            {
                StopCoroutine(spIncreasingCoroutine);
            }
            if (autoMoveCoroutine != null)
            {
                StopCoroutine(autoMoveCoroutine);
            }
            if (this.champion != null)
            {
                Destroy(this.champion.gameObject);
            }
            GameObject        championPrefab    = PrefabManager.Instance.GetChampionPrefab(GameManager.Instance.GetLastPlayChampion());
            GameObject        championInstance  = Instantiate(championPrefab) as GameObject;
            ChampionComponent championComponent = championInstance.GetComponent <ChampionComponent>();
            Node startNode = new Node(1, 1);

            championComponent.InitChampionComponent(startNode, Direction.right);
            this.champion = championComponent;

            cameraController.SetPosition(startNode);
            cameraController.SetTarget(championComponent);
            cameraController.SetInitialRotation(startNode);
            // cameraController.SetPivotAngle(Direction.right);

            uiManager.InitUIManager();
        }
Exemplo n.º 2
0
        public void ContinueGame()
        {
            playSceneState  = PlaySceneState.ready;
            isContinued     = true;
            champion.isDead = false;
            SectionComponent sectionComponent = pathManager.currentSectionComponent.nextSectionComponent;
            Node             continueNode     = new Node(0, 0);

            if (sectionComponent.sectionData.direction == Direction.right)
            {
                continueNode = sectionComponent.sectionData.origin + new Node(sectionComponent.sectionData.sectionType == SectionType.corner ? 1 : 0, 1);
            }
            else if (sectionComponent.sectionData.direction == Direction.up)
            {
                continueNode = sectionComponent.sectionData.origin + new Node(1, sectionComponent.sectionData.sectionType == SectionType.corner ? 1 : 0);
            }
            else if (sectionComponent.sectionData.direction == Direction.down)
            {
                continueNode = sectionComponent.sectionData.origin + new Node(1, sectionComponent.sectionData.height - 1 - (sectionComponent.sectionData.sectionType == SectionType.corner ? 1 : 0));
            }
            champion.InitChampionComponent(continueNode, sectionComponent.sectionData.direction);
            champion.animator.SetTrigger("continue");
            gameOverPanel.HideGameOverPanel();
            pausePanel.button_pause.gameObject.SetActive(true);
            gameOverPanel.animator_continue.SetTrigger("slideout");
            uiManager.animator_control.SetTrigger("slidein");
            uiManager.InitHpUI(champion.maxHp, champion.startingHp, false);
            // cameraController.SetInitialRotation(continueNode);

            Quaternion     targetRotation        = Quaternion.identity;
            BlockComponent currentBlockComponent = pathManager.GetBlockComponentByOrigin(continueNode);

            if (currentBlockComponent.sectionComponent.sectionData.direction == Direction.right)
            {
                if (currentBlockComponent.sectionComponent.beforeSectionComponent == null)
                {
                    if (currentBlockComponent.sectionComponent.nextSectionComponent.nextSectionComponent.sectionData.direction == Direction.up)
                    {
                        targetRotation = Quaternion.Euler(cameraController.championRightUpAngle);
                    }
                    else if (currentBlockComponent.sectionComponent.nextSectionComponent.nextSectionComponent.sectionData.direction == Direction.down)
                    {
                        targetRotation = Quaternion.Euler(cameraController.championRightDownAngle);
                    }
                }
                else if (currentBlockComponent.sectionComponent.beforeSectionComponent.beforeSectionComponent == null)
                {
                    if (currentBlockComponent.sectionComponent.nextSectionComponent.nextSectionComponent.sectionData.direction == Direction.up)
                    {
                        targetRotation = Quaternion.Euler(cameraController.championRightUpAngle);
                    }
                    else if (currentBlockComponent.sectionComponent.nextSectionComponent.nextSectionComponent.sectionData.direction == Direction.down)
                    {
                        targetRotation = Quaternion.Euler(cameraController.championRightDownAngle);
                    }
                }
                else if (currentBlockComponent.sectionComponent.beforeSectionComponent.beforeSectionComponent.sectionData.direction == Direction.down)
                {
                    targetRotation = Quaternion.Euler(cameraController.championRightDownAngle);
                }
                else if (currentBlockComponent.sectionComponent.beforeSectionComponent.beforeSectionComponent.sectionData.direction == Direction.up)
                {
                    targetRotation = Quaternion.Euler(cameraController.championRightUpAngle);
                }
            }
            else if (currentBlockComponent.sectionComponent.sectionData.direction == Direction.up)
            {
                targetRotation = Quaternion.Euler(cameraController.championUpAngle);
            }
            else if (currentBlockComponent.sectionComponent.sectionData.direction == Direction.down)
            {
                targetRotation = Quaternion.Euler(cameraController.championDownAngle);
            }
            cameraController.AnimatePivotAngle(targetRotation, 0.3f);
        }