Ejemplo n.º 1
0
    public PauseMgr(GoalMgr goalMgr, Action onPauseAction, Action onResumeAction, Action onGameExitAction)
    {
        this.onPauseAction    = onPauseAction;
        this.onResumeAction   = onResumeAction;
        this.onGameExitAction = onGameExitAction;

        GoalPrefab = Resources.Load <GameObject>("Prefabs/UI/Pause_Goal");

        pauseCanvas         = GameObject.Find("UICanvas").transform.Find("PauseCanvas").GetComponent <Canvas>();
        pauseCanvas.enabled = false;

        menuTF   = pauseCanvas.transform.Find("Menu");
        paper1TF = pauseCanvas.transform.Find("Paper1");
        paper2TF = pauseCanvas.transform.Find("Paper2");
        radioTF  = pauseCanvas.transform.Find("Radio");

        menuInitPos   = menuTF.position;
        paper1InitPos = paper1TF.position;
        paper2InitPos = paper2TF.position;
        radioInitPos  = radioTF.position;

        menuMoveAmount   = new Vector3(638, 0);
        paper1MoveAmount = new Vector3(-100, 765);
        paper2MoveAmount = new Vector3(0, 768);
        radioMoveAmount  = new Vector3(-271, 0);

        // Paper
        Vector3     goalPos  = paper2TF.transform.position + new Vector3(-200, 180);
        List <Goal> goalList = goalMgr.GetMainGoals();

        goalList.AddRange(goalMgr.GetSubGoals());

        foreach (Goal goal in goalList)
        {
            GameObject goalObj = GameObject.Instantiate(GoalPrefab, goalPos, Quaternion.identity, paper2TF);
            goalObj.GetComponent <Text>().text = goal.GetExplanationText();
            goalObj.transform.Find("Status").GetComponent <Text>().text = goal.GetStatusText();

            goalPos.y += GOAL_POS_INTERVAL_Y;
        }

        // Menu
        menuHeader = menuTF.Find("Header").gameObject;
        Transform itemsTF = pauseCanvas.transform.Find("Menu").Find("Items");

        for (int i = 0; i < itemsTF.childCount; i++)
        {
            menuPosList.Add(itemsTF.GetChild(i).position);
        }

        // Sure
        sureCanvas         = pauseCanvas.transform.Find("SureCanvas").GetComponent <Canvas>();
        sureCanvas.enabled = false;

        sureCanvas.transform.Find("Window").Find("Yes").GetComponent <Button>().onClick.AddListener(Sure_Yes);
        sureCanvas.transform.Find("Window").Find("No").GetComponent <Button>().onClick.AddListener(Sure_No);
    }
Ejemplo n.º 2
0
    private void StageEnd()
    {
        if (!bStageEndSetup)
        {
            if (goalMgr.IsAllSatisfied())
            {
                reportCanvas.enabled = true;
                report = new Report(reportCanvas.gameObject, goalMgr.GetMainGoals(), goalMgr.GetSubGoals(), gameInfo);

                GameData gameData = new GameData();
                gameData.Money += report.Reward;
                gameData.SetRank(_stage, report.Rank);
                gameData.Save();
            }
            else
            {
                stageEnd.SetActive(true);
                stageEndText.text = "임무 실패";
            }

            bStageEndSetup = true;
        }
        BGM.Stop();
    }
Ejemplo n.º 3
0
    private void StageSetup()
    {
        // Create TileMgr Instance
        TileMgr.CreateInstance(stage);
        TalkMgr.CreateInstance(stage);

        // Load XML
        XmlDocument doc       = new XmlDocument();
        TextAsset   textAsset = (TextAsset)Resources.Load("Stage/Stage" + stage);

        doc.LoadXml(textAsset.text);
        XmlNode stageNode = doc.SelectSingleNode("Stage");

        string startTimeStr = stageNode.SelectSingleNode("StartTime").InnerText;

        string[] startTimeTokens = startTimeStr.Split(':');
        currTime = int.Parse(startTimeTokens[0]) * 60 + int.Parse(startTimeTokens[1]);

        // Stage Content
        string stageNamePreviewText = stageNode.SelectSingleNode("StageNamePreview").InnerText;
        string stageNameText        = stageNode.SelectSingleNode("StageName").InnerText;
        string stageContentText     = stageNode.SelectSingleNode("StageContent").InnerText;

        string[] stageContentLines = stageContentText.Split('\n');
        for (int i = 1; i < stageContentLines.Length; i++)
        {
            stageContentLines[i] = stageContentLines[i].Trim();
        }
        for (int i = 1; i <= 2 && i < stageContentLines.Length; i++)
        {
            stageContentLines[i] = "          " + stageContentLines[i];
        }

        stageContentText = "";
        for (int i = 1; i < stageContentLines.Length; i++)
        {
            stageContentText += stageContentLines[i] + "\n";
        }

        // Disaster & Goal & PlayState
        XmlNode disastersNode = stageNode.SelectSingleNode("Disasters");
        XmlNode goalsNode     = stageNode.SelectSingleNode("Goals");

        disasterMgr = new DisasterMgr(disastersNode);
        goalMgr     = new GoalMgr(goalsNode);
        gameInfo    = new GameInfo(stage);

        gameInfo.CurrTime = currTime;
        gameInfo.Deadline = goalMgr.GetDeadline();

        StartCoroutine(disasterMgr.UpdateWillActiveDisasterArea()); // 다음 턴 재난 지역 타일맵에 동기화

        // Load Canvas
        GameObject canvas = GameObject.Find("UICanvas");

        selectCanvas = canvas.transform.Find("SelectCanvas").GetComponent <Canvas>();
        playCanvas   = canvas.transform.Find("PlayCanvas").GetComponent <Canvas>();
        reportCanvas = canvas.transform.Find("ReportCanvas").GetComponent <Canvas>();

        selectCanvas.enabled = false;
        playCanvas.enabled   = false;
        reportCanvas.enabled = false;

        // Load Select UI
        Transform operatorCard = selectCanvas.transform.Find("OperatorSelect/OperatorCard");

        operatorCardNum = 0;
        for (int i = 0; i < operatorCard.childCount; i++)
        {
            GameObject go = operatorCard.GetChild(i).gameObject;
            if (go.activeSelf)
            {
                operatorCards[i] = go;
                operatorCardNum++;
            }
        }

        selectCanvas.transform.Find("StageGoal/StageNamePreview").GetComponentInChildren <Text>().text = stageNamePreviewText;
        Text stageName = selectCanvas.transform.Find("StageGoal/StageName").GetComponent <Text>();

        stageName.text = stageNameText;
        stageName.rectTransform.sizeDelta = new Vector2(stageName.preferredWidth, stageName.preferredHeight);

        RectTransform stageBar = selectCanvas.transform.Find("StageGoal/StageBar").GetComponent <RectTransform>();

        stageBar.SetSizeWithCurrentAnchors(RectTransform.Axis.Horizontal, stageName.rectTransform.rect.width + 20);

        GameObject  goalPrefab = Resources.Load <GameObject>("Prefabs/UI/SelectUI_Goal");
        Transform   goals      = selectCanvas.transform.Find("StageGoal/Goals");
        List <Goal> mainGoals  = goalMgr.GetMainGoals();

        for (int i = 0; i < mainGoals.Count; i++)
        {
            string explanation = mainGoals[i].GetExplanationText();
            string status      = mainGoals[i].GetStatusText();

            GameObject goal = Instantiate(goalPrefab, goals);
            goal.transform.Find("Explanation").GetComponent <Text>().text = explanation;
            goal.transform.Find("Status").GetComponent <Text>().text      = status;
            goal.transform.localPosition = new Vector3(0, -20 + -30 * i);
        }

        RectTransform content = selectCanvas.transform.Find("StageGoal/Content").GetComponent <RectTransform>();

        content.GetComponent <Text>().text = stageContentText;
        content.anchoredPosition          += new Vector2(0, -20 + -30 * mainGoals.Count + -20);

        startBtnText = selectCanvas.transform.Find("StartBtn").GetComponentInChildren <Text>();
        ChangeStartBtnText();

        // Load Play UI
        _fadeImage = playCanvas.transform.Find("Fade").GetComponent <Image>();

        _mentalText   = playCanvas.transform.Find("PlayerCard/CurrentMental").GetComponent <Text>();
        _stateText    = playCanvas.transform.Find("PlayerCard/CurrentState").GetComponent <Text>();
        _charNameText = playCanvas.transform.Find("PlayerCard/Player_KorName").GetComponent <Text>();
        _CardProfile  = playCanvas.transform.Find("PlayerCard/Player_Image").GetComponent <Image>();

        disasterAlaram     = playCanvas.transform.Find("MiddleUI/DisasterAlarm").gameObject;
        disasterAlaramText = disasterAlaram.transform.Find("Text").GetComponent <Text>();

        stageEnd     = playCanvas.transform.Find("MiddleUI/StageEnd").gameObject;
        stageEndText = stageEnd.transform.Find("Text").GetComponent <Text>();

        timerText = GameObject.Find("UICanvas/PlayCanvas/TopUI/TurnEndBtn/TimerText").GetComponent <Text>();
        ChangeTimerText();

        pauseMgr = new PauseMgr(goalMgr, OnPause, OnResume, OnGameExit);

        // Load Resources
        operatorPrefabs[0] = Resources.Load <GameObject>("Prefabs/Operator/Captain");
        operatorPrefabs[1] = Resources.Load <GameObject>("Prefabs/Operator/HammerMan");
        operatorPrefabs[2] = Resources.Load <GameObject>("Prefabs/Operator/Rescuers");
        operatorPrefabs[3] = Resources.Load <GameObject>("Prefabs/Operator/Nurse");

        operatorProfileImage[0] = Resources.Load <Sprite>("Sprite/PlayScene/UI/PlayerCard/IDcard-leader");
        operatorProfileImage[1] = Resources.Load <Sprite>("Sprite/PlayScene/UI/PlayerCard/IDcard-hammerman");

        operatorDepoyedSprite = Resources.Load <Sprite>("Sprite/PlayScene/OperatorSelect_UI/Operator/Operater_card-Depolyed");

        _currGameState = GameState.SELECT_OPERATOR;
    }