コード例 #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();
        }
コード例 #2
0
 public void GameOver(string upperMessage, string lowerMessage, bool forceGameOver = false)
 {
     playSceneState = PlaySceneState.gameover;
     if (gameOverCoroutine != null)
     {
         StopCoroutine(gameOverCoroutine);
     }
     gameOverCoroutine = StartCoroutine(GameOverHelper(forceGameOver));
     pausePanel.button_pause.gameObject.SetActive(false);
     gameOverPanel.SetMessage(upperMessage, lowerMessage);
 }
コード例 #3
0
        public void OpenChampionPanel(PlaySceneState from)
        {
            string lastPlayChampionId = GameManager.Instance.GetLastPlayChampion();

            // Debug.Log("lastPlayChampionId: " + lastPlayChampionId);

            for (int i = 0; i < champions.Length; i++)
            {
                if (champions[i].championId.Equals(lastPlayChampionId))
                {
                    currentChampionIndex = i;
                    break;
                }
            }
            championCameraTransform.position = new Vector3(currentChampionIndex, 0, 1000);
            OnChampionIndexChange(currentChampionIndex);
            this.from = from;
            animator.SetTrigger("fadein");
            StartCoroutine(OpenChampionPanelHelper());
        }
コード例 #4
0
 public void OpenSettingPanel(PlaySceneState from)
 {
     this.from = from;
     this.settingPanelStatus = SettingPanelStatus.root;
     animator.SetTrigger("fadein");
 }
コード例 #5
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);
        }
コード例 #6
0
        //TODO:특수스킬이나 아이템 사용과 같은 입력이 들어올 수 있으
        public void PlayerAction(PlayerInput input)
        {
            // if (!isHpDecreasing)
            // {
            //     isHpDecreasing = true;
            //     hpDecreasingCoroutine = StartCoroutine(DecreasingPlayerHp());
            // }
            if (isClear)
            {
                return;
            }

            if (playSceneState == PlaySceneState.main ||
                playSceneState == PlaySceneState.gameover ||
                playSceneState == PlaySceneState.pause)
            {
                return;
            }
            if (playSceneState == PlaySceneState.ready)
            {
                playSceneState = PlaySceneState.play;
            }
            if (!isSpIncreasing)
            {
                isSpIncreasing        = true;
                spIncreasingCoroutine = StartCoroutine(IncreasingPlayerSp());
            }

            //플레이어의 방향과 서있는 블럭의 타잎에 따라 다음에 가야할 노드와 회전유무가 정해진다.
            if (input == PlayerInput.left || input == PlayerInput.right || input == PlayerInput.forward)
            {
                if (champion.isDead)
                {
                    // Debug.Log("player is dead");
                    return;
                }
                if (champion.isMoving)
                {
                    Debug.Log("champion is moving. so skip action");
                    return;
                }
                if (champion.isAttacking)
                {
                    return;
                }

                Node           targetNode         = champion.origin;
                Node           nextNode           = GetNextNode(champion, input);
                BlockComponent blockComponent     = pathManager.GetBlockComponentByOrigin(champion.origin);
                BlockComponent nextBlockComponent = pathManager.GetBlockComponentByOrigin(nextNode); //null 일 수도있다
                Direction      targetDirection    = champion.direction;

                if (champion.isWatered)
                {
                    champion.isWatered = false;
                    champion.MoveChampion(champion.origin, champion.origin, GameManager.championMoveDuration, MoveType.walk, false);
                    return;
                }
                else if (champion.isBitten)
                {
                    champion.isBitten = false;
                    champion.MoveChampion(champion.origin, champion.origin, GameManager.championMoveDuration, MoveType.walk, false);
                    return;
                }


                //스트레이트 블럭 위에 있고 입력받은곳에 적이 있는지 확인해야한다
                //공격후 적이 죽는다면 적이 있던 자리로 이동하고 적이 죽지 않으면 원래 있던 자리로 돌아와야 한다
                // Debug.Log("player.origin: " + player.origin.ToString());
                TrapComponent trapComponent = pathManager.GetTrapComponent(nextNode);
                if (trapComponent != null && trapComponent.isObstacle)
                {
                    champion.MoveChampion(champion.origin, champion.origin, GameManager.championMoveDuration, MoveType.walk, false);
                    return;
                }

                if (IsEnemyInDirection(nextNode))
                {
                    champion.Attack(champion.origin, nextNode, GameManager.championMoveDuration);
                    return;
                }
                else
                {
                    targetDirection = champion.direction;
                    if (champion.direction == Direction.right)
                    {
                        if (input == PlayerInput.left)
                        {
                            targetNode += new Node(1, 1);
                        }
                        else if (input == PlayerInput.right)
                        {
                            targetNode += new Node(1, -1);
                        }
                        else if (input == PlayerInput.forward)
                        {
                            targetNode += new Node(1, 0);
                        }
                    }
                    else if (champion.direction == Direction.up)
                    {
                        if (input == PlayerInput.left)
                        {
                            targetNode += new Node(-1, 1);
                        }
                        else if (input == PlayerInput.right)
                        {
                            targetNode += new Node(1, 1);
                        }
                        else if (input == PlayerInput.forward)
                        {
                            targetNode += new Node(0, 1);
                        }
                    }
                    else if (champion.direction == Direction.down)
                    {
                        if (input == PlayerInput.left)
                        {
                            targetNode += new Node(1, -1);
                        }
                        else if (input == PlayerInput.right)
                        {
                            targetNode += new Node(-1, -1);
                        }
                        else if (input == PlayerInput.forward)
                        {
                            targetNode += new Node(0, -1);
                        }
                    }
                    if (nextBlockComponent != null && (nextBlockComponent.blockData.blockCategory == BlockCategory.turn || nextBlockComponent.blockData.blockCategory == BlockCategory.shortcut_end))
                    {
                        targetDirection = nextBlockComponent.blockData.direction;
                    }
                }

                bool isRotate = champion.direction != targetDirection;
                champion.MoveChampion(champion.origin, targetNode, GameManager.championMoveDuration, MoveType.walk
                                      , isRotate);
                if (isRotate)
                {
                    champion.RotateChampion(champion.direction, targetDirection, GameManager.championMoveDuration);
                }
            }
            else
            {
                //이동이외의 입력이 들어온다면 여기서 구현해야 한다
            }
        }