// Sets Up Initial the current values for the player
    private void setInitialPlayerAttributes()
    {
        // Sets up the current attributres for the player
        variableFlowchart.SetIntegerVariable("happiness", happiness);

        if (happiness <= 99)
        {
            curMood = 0;
        }
        else if (happiness >= 100 && happiness <= 199)
        {
            curMood = 1;
        }
        else if (happiness >= 200 && happiness <= 299)
        {
            curMood = 2;
        }
        else if (happiness >= 300 && happiness <= 399)
        {
            curMood = 3;
        }

        //moodValue = happiness % 100;

        variableFlowchart.SetIntegerVariable("curMood", curMood);
        variableFlowchart.SetIntegerVariable("weather", weather);
        variableFlowchart.SetStringVariable("currentDay", currentDay);
        variableFlowchart.SetStringVariable("nextDay", nextDay);
        variableFlowchart.SetBooleanVariable("isOnBreak", isOnBreak);
        variableFlowchart.SetBooleanVariable("dadWorkingToday", dadWorkingToday);
    }
    private void OnTriggerEnter(Collider other)
    {
        if (!BL_IsInteractable)
        {
            return;
        }

        if (other.gameObject.GetComponent <Entity>() != null)
        {
            Entity e_coll = other.gameObject.GetComponent <Entity>();
            if (e_coll.EntityType == Entity.Entities.Player)
            {
                if (objectiveMarker != null)
                {
                    objectiveMarker.SetActive(false);
                }

                if (dialogueOnContact != "")
                {
                    flowchart.SetStringVariable("dialogue", dialogueOnContact);
                    flowchart.SetStringVariable("acceptText", acceptDialogue);
                    flowchart.SetStringVariable("declineText", declineDialogue);
                    Flowchart.BroadcastFungusMessage("InitiateStep");
                }
            }
        }
    }
Esempio n. 3
0
 private void Process(string stringVariableName, string eventDataName)
 {
     ConditionsProcess(eventDataName);
     if (!string.IsNullOrEmpty(stringVariableName))
     {
         flowchart.SetStringVariable(stringVariableName, eventDataName);
     }
 }
Esempio n. 4
0
 void OnTriggerEnter2D(Collider2D other)
 {
     if (other.tag != "Player")
     {
         return;
     }
     flowChart.SetStringVariable("interacting", gameObject.tag);
 }
Esempio n. 5
0
    private void prepareFungusForConverstion(NpcController npc)
    {
        Customer info = npc.customerInfo;

        dialogFlowchart.SetStringVariable("openingLine", info.openingLine);
        dialogFlowchart.SetStringVariable("request", info.request);
        dialogFlowchart.SetBooleanVariable("ignoresYou", info.ignoresYou);
        dialogFlowchart.SetStringVariable("description", info.description);
        dialogFlowchart.SetStringVariable("exitLine", ExitLines.lines[Random.Range(0, ExitLines.lines.Length)]);
        dialogFlowchart.SendFungusMessage("initiateConversation");
    }
Esempio n. 6
0
 private void Awake()
 {
     _skipButton.onClick.AddListener(FinishIntro);
     _nextSentenceButon.onClick.AddListener(ShowNextSentence);
     _flowChart.SetStringVariable("PlayerName", PlayerPrefs.GetString("PlayerName", "Guardião"));
     SetMessages();
 }
Esempio n. 7
0
    void Awake()
    {
        introFlowchart = GameObject.Find("IntroFlowchart").GetComponent <Flowchart>();
        talkFlowchart  = GameObject.Find("TalksFlowchart").GetComponent <Flowchart>();
        //infoDump.firstTime = true;
        if (infoDump.firstTime)
        {
            introFlowchart.enabled = true;
            infoDump.firstTime     = false;
        }
        else
        {
            talkFlowchart.enabled = true;
            talkFlowchart.SetIntegerVariable("DroneSpeed", infoDump.droneSpeed);
            talkFlowchart.SetIntegerVariable("PhobosPower", infoDump.phobosPower);
            talkFlowchart.SetIntegerVariable("DeimosPower", infoDump.deimosPower);
            talkFlowchart.SetIntegerVariable("FuelRegen", infoDump.fuelRegen);

            talkFlowchart.SetBooleanVariable("HasQInfo", infoDump.hasQInfo);
            talkFlowchart.SetBooleanVariable("HasQAdvice", infoDump.hasQAdvice);
            talkFlowchart.SetStringVariable("WeaponsStatus", infoDump.weaponSystemStatus);

            talkFlowchart.SetBooleanVariable("TalkedToQ", infoDump.talkedToQ);
            talkFlowchart.SetBooleanVariable("TalkedToAresa", infoDump.talkedToAresa);
            talkFlowchart.SetBooleanVariable("TalkedToPD", infoDump.talkedToPD);
        }
    }
Esempio n. 8
0
    public void Start()
    {
        Flowchart flowchart = GameObject.Find("Flowchart").GetComponent <Flowchart>();

        flowchart.SetStringVariable("enterView", Globals.lastView);
        positionAnim = YouAreHere.GetComponent <Animator>();
    }
Esempio n. 9
0
    void GetItemMessage()
    {
        if (is_search)
        {
            Player_State.ismove = false;

            if (_itemup.item.ID == 0000)
            {
                _flowchart.ExecuteBlock("nothing");
            }
            else if (_itemup.item.ID == 1)
            {
                _flowchart.ExecuteBlock("Get_Lingshi");
                _itemup.PickUp();
                is_search = false;
            }
            else if (_itemup.item.ID > 0020)
            {
                _flowchart.SetStringVariable("classroom", _itemup.item.name);
                _flowchart.ExecuteBlock("Get_Key");
                _itemup.PickUp();
            }

            is_search = false;
        }
    }
Esempio n. 10
0
        /// <summary>
        /// Unity trigger for onLevelLoad events.
        /// </summary>
        /// <param name="level"></param>
        private void OnLevelWasLoaded(int level)
        {
            if (_saveGame == null)
            {
                return;
            }
            Flowchart  characFlowchart = null;
            Flowchart  itemFlowchart   = null;
            GameObject c1 = GameObject.Find("Char-Flowcharts");
            GameObject c2 = GameObject.Find("Item-Flowchart");

            characFlowchart = c1.GetComponent <Flowchart>();
            itemFlowchart   = c2.GetComponent <Flowchart>();

            Debug.LogWarning("TAKE ON UNITY");
            itemFlowchart.SetBooleanVariable("IsPluggedIn", _saveGame.IsPluggedIn);
            Debug.LogWarning("TAKE ON UNITY");
            itemFlowchart.SetBooleanVariable("IsBelt", _saveGame.IsBelt);
            Debug.LogWarning("TAKE ON UNITY");
            itemFlowchart.SetBooleanVariable("IsMachine", _saveGame.IsMachine);
            Debug.LogWarning("TAKE ON UNITY");
            characFlowchart.SetStringVariable("CURRENT_STATE", _saveGame.CURRENT_STATE);
            Debug.LogWarning("TAKE ON UNITY");
            characFlowchart.SetIntegerVariable("RNG", _saveGame.RNG);
            Debug.LogWarning("TAKE ON UNITY");
            ScoreManager = _saveGame.ScoreManager;
            Debug.LogWarning("TAKE ON UNITY");
            ScoreManager._stopwatch = new Stopwatch();
            Debug.LogWarning("TAKE ON UNITY");
            ScoreManager.resume();
            Debug.LogWarning("TAKE ON UNITY");
        }
Esempio n. 11
0
    public void GetLastScene()
    {
        Flowchart flow = FindObjectOfType <Flowchart>();
        var       s    = LastSceneHolder.LastSceneStatic;

        flow.SetStringVariable("lastScene", s);
    }
Esempio n. 12
0
    public void OnPointerClick(PointerEventData eventData)
    {
        Vector3 pos       = new Vector3(eventData.position.x, eventData.position.y, 0);
        int     linkIndex = TMP_TextUtilities.FindIntersectingLink(text, pos, null); //--UI camera

        if (linkIndex > -1)
        {
            TMP_LinkInfo linkInfo = text.textInfo.linkInfo[linkIndex];
            bool         find     = false;
            foreach (string link in links)
            {
                if (link == linkInfo.GetLinkText())
                {
                    find = true;
                }
            }

            if (!find)
            {
                links.Add(linkInfo.GetLinkText());
                print("linkTextLength" + linkInfo.linkTextLength);
                print("linkTextfirstCharacterIndex" + linkInfo.linkTextfirstCharacterIndex);
                print(linkInfo.linkIdFirstCharacterIndex);
                //text.text = text.text.Insert(linkInfo.linkIdFirstCharacterIndex+linkInfo.linkIdLength+1+linkInfo.linkTextLength+15, "(dddd)");
                flowChart.SetStringVariable("ddd", "Wadwadadwa");
            }
            Debug.Log(linkInfo.GetLinkText());
            //Application.OpenURL(linkInfo.GetLinkID());
        }
    }
Esempio n. 13
0
 void nameChange()
 {
     nameInput.SetActive(false);
     theName = nameInput.GetComponent <InputField>().text;
     mainCharacter.GetComponent <Character>().nameText = theName;
     flowchart.SetStringVariable("PlayerName", theName);
     flowchart.ExecuteBlock("Greet Player");
 }
Esempio n. 14
0
 public void GetInput(string guess)
 {
     Debug.Log("Should Work... x : " + guess);
     GlobalFungus.playerName = guess;
     flowchart.SetStringVariable("playerName", guess);
     flowchart.SetIntegerVariable("waitPlayerName", 0);
     GlobalVariables.buttonFlag = true;
 }
Esempio n. 15
0
    private void setTalk()
    {
        SetBg(_actionDatas[_actionIndex].Args[(int)SayArgument.bgImageName]);

        flowchart.SetStringVariable("Dialogue", _actionDatas[_actionIndex].Args[(int)SayArgument.content]);

        setRoleImage(_actionDatas[_actionIndex]);
        setCharactername(_actionDatas[_actionIndex]);
    }
    private int randNum;                    // Stores a random number



    // Public Class Methods //

    // WHen called, this method will generate seed a number and correspond that number to another method that
    // the numver lands on.
    public void seedSchoolBusEvent()
    {
        randNum = Random.Range(0, 3);

        switch (randNum)
        {
        case 0:                 // Loud peole on bus
            _busEventLoudPeople();
            break;

        case 1:                 // Annoying person hitting my seat
            _busEventHittingSeat();
            break;

        case 2:                 // sitting with friend
            _busEventSittingWithFriend();
            break;
        }

        schoolTree.SetStringVariable("schoolStr", strDialougeText1);
    }
Esempio n. 17
0
    public void QuestNPCDialogue(string BlockType, string dialogue, bool completed, bool failed)
    {
        fullText   = dialogue;
        paragraphs = dialogue.Split(new string[] { parseKeyword }, System.StringSplitOptions.None);
        if (BlockType == "QuestAccepted")
        {
            //Have we completed it yet?
            if (!completed)
            {
                FungusFlow.SetStringVariable("paragraph1", paragraphs[paragraphs.Length - 2]);
            }
            //If we have, then what was our victory state
            else if (completed && !failed)
            {
                ParagraphedConversation(paragraphs, 2);
            }
            else if (completed && failed)
            {
                FungusFlow.SetStringVariable("paragraph1", paragraphs[paragraphs.Length - 1]);
            }
        }
        else if (BlockType == "HasQuest")
        {
            ParagraphedConversation(paragraphs, 2);
            FungusFlow.SetStringVariable("accepted", paragraphs[paragraphs.Length - 2]);
            FungusFlow.SetStringVariable("declined", paragraphs[paragraphs.Length - 1]);
        }

        InitiateFlow(BlockType);
    }
Esempio n. 18
0
    public bool OnMouseDown(string id, string desc, string examine, string use)
    {
        if (isTextPanelOpen())
        {
            return(false);
        }
        flowChart.ExecuteBlock("PlaySound");
        string text = "";

        if (tool.Equals("eye"))
        {
            text = examine;
        }
        else if (tool.Equals("hand"))
        {
            text = use;
        }
        else if (tool.Equals("combine"))
        {
            if (isCombining)
            {
                if (!combinations.CanCombine(obj1_id, id))
                {
                    text = "I can't seem to use the " + obj1_desc + " with the " + desc + ".";
                }
                else
                {
                    text = combinations.CombineObjects(obj1_id, id);
                }
                isCombining = false;
                combineText = "";
                obj1_id     = "";
                obj1_desc   = "";
            }
            else
            {
                isCombining = true;
                combineText = actionText.text;
                obj1_id     = id;
                obj1_desc   = desc;
                return(false);
            }
        }
        UpdateActionText("");
        if (canEnd())   // To trigger on end condition
        {
            endButton.gameObject.SetActive(true);
        }
        flowChart.SetStringVariable("msg", text);
        flowChart.ExecuteBlock("DialogBox");
        return(true);
    }
Esempio n. 19
0
    public void SetQuestion()
    {
        Flowchart.SetStringVariable("_question", _questionListDatas[_questionIndex].Question);
        string zero = null;

        if (_questionIndex + 1 < 10)
        {
            zero = "0";
        }
        PageNum.text = zero + (_questionIndex + 1) + "/" + _questionListDatas.Length;

        setDollStateIndex();
    }
Esempio n. 20
0
    IEnumerator Entry()
    {
        int flashCount = 0;

        while (flashCount < 5)
        {
            warningMessage.SetActive(true);
            yield return(new WaitForSeconds(0.6f));

            warningMessage.SetActive(false);
            yield return(new WaitForSeconds(0.2f));

            flashCount++;
        }
        warningMessage.SetActive(false);

        CameraFollow.instance.otherLook = hero;
        yield return(new WaitForSeconds(2));

        flowchart.SetStringVariable("hero_entry", ST_entryText);
        Fungus.Flowchart.BroadcastFungusMessage("Entry");
    }
    // Public Class Methods

    // Checks to see if any values caused any change to the player.
    public void playerMoodCheck()
    {
        int    prevMood = curMood; // Stores the previous player mood
        string moodStr  = null;


        // Updates the current mood by the happiness value's hundredth place
        if (happiness <= 99)
        {
            curMood = 0;
        }
        else if (happiness >= 100 && happiness <= 199)
        {
            curMood = 1;
        }
        else if (happiness >= 200 && happiness <= 299)
        {
            curMood = 2;
        }
        else if (happiness >= 300 && happiness <= 399)
        {
            curMood = 3;
        }


        // If the current mood changed either by less than or greater than prevMood. Or Even stayed the same.
        if (curMood < prevMood)
        {
            happiness -= 25;
            moodStr    = "You wake up, but you don't feel good right now. You feel like your mood just got shot.";
        }
        else if (curMood > prevMood)
        {
            curMood++;
            happiness += 10;
            moodStr    = "As you wake up, your mood just feels overall better. You feel a slightly bit happier.";
        }
        else
        {
            moodStr = "You feel as your mood didn't change much at all, in fact you feel relativley as you felt yesterday.";
        }


        // Updates attributes
        updatePlayerAttributes();
        homeTreeMorning.SetStringVariable("calculateMoodText", moodStr);
    }
    private int randNum;                    // Stores random number



    // Class implemtnation

    // Seeds the evening events
    //  Using the dadWorkingEvening variable, we will use this to check if
    // dad is home to properly seed the events that will happen
    public void seedDayEvents()
    {
        // Checks if dad is working in the evening
        dadWorkingDay = homeTreeDay.GetBooleanVariable("dadWorkingDay");

        // IF The dad is working in the eveng, allow for special evening based events to happenj
        if (dadWorkingDay)
        {
            // Seeds random number for the rng
            randNum = Random.Range(0, 4);
            switch (randNum)
            {
            case 0:     // internet down
                _homeEventEveningInternetDown();
                break;

            case 1:     // New episode of favorite youtube channel
                _homeEventEveningNewYTEpisode();
                break;

            case 2:     // Mail delivery
                _homeEventEveningMailDelivery();
                break;

            case 3:     // Fridge refilled
                _homeEventEveningFridgeRefilled();
                break;
            }
        }

        else
        {
            randNum = Random.Range(0, 2);
            switch (randNum)
            {
            case 0:     // Dad hostile lecture
                _homeEventEveningDadHostileLecture();
                break;

            case 1:     // Dad calm, happy talk
                _homeEventEveningDadHappyTalk();
                break;
            }
        }

        homeTreeDay.SetStringVariable("strDay", strDialougeText1);
    }
    private void LoadGameData()
    {
        // Path.Combine combines strings into a file path
        // Application.StreamingAssets points to Assets/StreamingAssets in the Editor, and the StreamingAssets folder in a build
        //string filePath = Path.Combine(Application.streamingAssetsPath, gameDataFileName);

        //string filePath = Path.Combine(Application.dataPath + "/Resources/", gameDataFileName);

                #if UNITY_STANDALONE_OSX
        string filePath = Path.Combine(Application.dataPath + "/Data/Assets/Resources/", gameDataFileName);
                #else
        string filePath = Path.Combine("Assets/Resources/", gameDataFileName);
                #endif

        if (File.Exists(filePath))
        {
            // Read the json from the file into a string
            string dataAsJson = File.ReadAllText(filePath, System.Text.UTF8Encoding.UTF8);
            // Pass the json to JsonUtility, and tell it to create a GameData object from it
            Notes loadedData = JsonUtility.FromJson <Notes>(dataAsJson);

            // Retrieve the allRoundData property of loadedData
            int rnd = Random.Range(0, 2);

            switch (rnd)
            {
            case 0:
                string[] p1 = loadedData.nota1.Split(';');
                flow.SetStringVariable("Projeto", p1 [0]);
                flow.SetStringVariable("Orcamento", p1 [1]);
                Projeto.Instance.orcamento = int.Parse(p1[1]);
                break;

            case 1:
                string[] p2 = loadedData.nota2.Split(';');
                flow.SetStringVariable("Projeto", p2[0]);
                flow.SetStringVariable("Orcamento", p2[1]);
                Projeto.Instance.orcamento = int.Parse(p2[1]);
                break;

            case 2:
                string[] p3 = loadedData.nota3.Split(';');
                flow.SetStringVariable("Projeto", p3[0]);
                flow.SetStringVariable("Orcamento", p3[1]);
                Projeto.Instance.orcamento = int.Parse(p3[1]);
                break;
            }
        }
        else
        {
            Debug.LogError("Cannot load game data!");
        }
    }
Esempio n. 24
0
    //If a block is activated by the user, then this is not needed in the flowchart
    //Copies the variables in the list from the GM flowcharts to the activated flowchart
    public void CopyGameMasterToFlowchart()
    {
        gm = GameObject.Find("GameMaster").GetComponent <GameMaster>();
        Flowchart gmQuest = gm.GetQuestFlowchart();
        Flowchart target  = this.GetComponent <Flowchart>();

        Variable sourceVar = null;

        for (int i = 0; i < varNames.Length; i++)
        {
            sourceVar = gmQuest.GetVariable(varNames[i]);

            StringVariable tempstr = sourceVar as StringVariable;
            if (tempstr != null)
            {
                target.SetStringVariable(varNames[i], tempstr.Value);
                continue;
            }

            BooleanVariable tempBool = sourceVar as BooleanVariable;
            if (tempBool != null)
            {
                target.SetBooleanVariable(varNames[i], tempBool.Value);
                continue;
            }

            IntegerVariable tempInt = sourceVar as IntegerVariable;
            if (tempInt != null)
            {
                target.SetIntegerVariable(varNames[i], tempInt.Value);
                continue;
            }

            FloatVariable tempFloat = sourceVar as FloatVariable;
            if (tempFloat != null)
            {
                target.SetFloatVariable(varNames[i], tempFloat.Value);
                continue;
            }
        }
    }
    void Start()
    {
        if (GameObject.Find("VariablesSaveSlot"))
        {
            SaveVaribleObject = GameObject.Find("VariablesSaveSlot");
            if (!SaveVaribleObject.GetComponent <LoadSave>().imLoaded)
            {
                myFlowchart.SetIntegerVariable("Time", SaveVaribleObject.GetComponent <LoadSave>().dayTime);
                myFlowchart.SetIntegerVariable("Money", SaveVaribleObject.GetComponent <LoadSave>().money);
                myFlowchart.SetStringVariable("Name", SaveVaribleObject.GetComponent <LoadSave>().playerName);
                myFlowchart.SetBooleanVariable("PrologEnd", SaveVaribleObject.GetComponent <LoadSave>().prologEnd);

                myFlowchart.SetIntegerVariable("KateAlpha", SaveVaribleObject.GetComponent <LoadSave>().kateAlpha);
                myFlowchart.SetIntegerVariable("KatePretty", SaveVaribleObject.GetComponent <LoadSave>().katePretty);
                myFlowchart.SetIntegerVariable("KlaraAlpha", SaveVaribleObject.GetComponent <LoadSave>().klaraAlpha);
                myFlowchart.SetIntegerVariable("KlaraPretty", SaveVaribleObject.GetComponent <LoadSave>().klaraPretty);
                myFlowchart.SetIntegerVariable("LizzyAlpha", SaveVaribleObject.GetComponent <LoadSave>().lizzyAlpha);
                myFlowchart.SetIntegerVariable("LizzyPretty", SaveVaribleObject.GetComponent <LoadSave>().lizzyPretty);
                myFlowchart.SetIntegerVariable("SaraAlpha", SaveVaribleObject.GetComponent <LoadSave>().saraAlpha);
                myFlowchart.SetIntegerVariable("SaraPretty", SaveVaribleObject.GetComponent <LoadSave>().saraPretty);

                SaveVaribleObject.GetComponent <LoadSave>().imLoaded = true;
            }
        }

        money   = myFlowchart.GetIntegerVariable("Money");
        dayTime = myFlowchart.GetIntegerVariable("Time");

        LoadAndSaveInterface.SetActive(false);
        SettingsInterface.SetActive(false);
        MapInterface.SetActive(false);
        PhoneInterface.SetActive(false);
        InventoryInterface.SetActive(false);

        TimeCheck(dayTime);
        MoneyText.SetText(money.ToString());
        PlaceText.SetText(SceneManager.GetActiveScene().name);
        DayText.SetText("Friday");
    }
Esempio n. 26
0
    public void OnDeath()
    {
        isDead = true;
        if (GM.conditionReportText != null)
        {
            GM.conditionReportText.text = charName + " Has Died!";
            StartCoroutine(GM.HasGottenHealthCondition());
            Debug.Log(charName + " has died");

            GameObject.Find("LevelScripting").GetComponent <Flowchart>().SetStringVariable("DeadName", charName);
        }
        else
        {
            // Start the encounter and switch to the scene
            //GameManager_r.Instance.ChangeScreen(2);
            //Destroy(gameObject);
            Debug.Log("No Report Text, but " + charName + "is dead");
            Flowchart thisFlowchart = GameObject.Find("LevelScripting").GetComponent <Flowchart>();
            thisFlowchart.SetStringVariable("DeadName", charName);
            thisFlowchart.ExecuteBlock("Death");
            Debug.Log("Changing to second screen");
        }
        gameObject.SetActive(false);
    }
Esempio n. 27
0
        private void Initialize()
        {
            gameManager.GameStateObservable
            .Subscribe(state =>
            {
                flowchart.SetStringVariable("GameState", state.ToString());
                ExecuteNarrative(state);
            });

            gameManager.IsPlayable.Where(x => x)
            .SelectMany(gameManager.PowerGauge.CurrentPower)
            .TakeUntil(gameManager.GameStateObservable.Where(state => state != GameState.InGame))
            .Subscribe(power =>
            {
                flowchart.SetFloatVariable("Power", power);
            });

            gameManager.Rocket.Height
            .TakeUntil(gameManager.GameStateObservable.Where(state => state != GameState.Ending))
            .Subscribe(height =>
            {
                flowchart.SetFloatVariable("Height", height);
            });
        }
    void Update()
    {
        // パラメータを受け取るまで処理しない
        if (loadEventParam == null)
        {
            return;
        }

        // イベントシーンスタート
        if (!eventStarted)
        {
            flowchart.SendFungusMessage(loadEventParam);
            eventStarted = true;
            SetInitBackground(loadEventParam);
        }

        // イベント終了時:タイトルへ戻る場合
        if (flowchart.GetVariable <BooleanVariable>(GameUtil.Const.FUNGUS_KEY_BACK_END).Value)
        {
            SceneManager.LoadScene(GameUtil.Const.SCENE_NAME_TITLE);
        }

        // イベント終了時:ゲームシーンへ遷移する場合
        if (flowchart.GetVariable <BooleanVariable>(GameUtil.Const.FUNGUS_KEY_EVENT_END).Value)
        {
            // 読み込んだイベントで遷移先を指定
            switch (loadEventParam)
            {
            // エピソードN開始 -> ステージN
            case GameUtil.Const.FUNGUS_KEY_EVENT_EPISODE1_START:
                SceneManager.LoadScene(GameUtil.Const.SCENE_NAME_STAGE1);
                break;

            case GameUtil.Const.FUNGUS_KEY_EVENT_EPISODE2_START:
                SceneManager.LoadScene(GameUtil.Const.SCENE_NAME_STAGE2);
                break;

            case GameUtil.Const.FUNGUS_KEY_EVENT_EPISODE3_START:
                SceneManager.LoadScene(GameUtil.Const.SCENE_NAME_STAGE3);
                break;

            case GameUtil.Const.FUNGUS_KEY_EVENT_EPISODE4_START:
                SceneManager.LoadScene(GameUtil.Const.SCENE_NAME_STAGE4);
                break;

            case GameUtil.Const.FUNGUS_KEY_EVENT_EPISODE5_START:
                SceneManager.LoadScene(GameUtil.Const.SCENE_NAME_STAGE5);
                break;

            // エピソードN終了 -> エピソードN+1開始
            case GameUtil.Const.FUNGUS_KEY_EVENT_EPISODE1_END:
                LoadEpisode(GameUtil.Const.FUNGUS_KEY_EVENT_EPISODE2_START);
                break;

            case GameUtil.Const.FUNGUS_KEY_EVENT_EPISODE2_END:
            case GameUtil.Const.FUNGUS_KEY_EVENT_EPISODE2_END_2:
                LoadEpisode(GameUtil.Const.FUNGUS_KEY_EVENT_EPISODE3_START);
                break;

            case GameUtil.Const.FUNGUS_KEY_EVENT_EPISODE3_END:
                LoadEpisode(GameUtil.Const.FUNGUS_KEY_EVENT_EPISODE4_START);
                break;

            case GameUtil.Const.FUNGUS_KEY_EVENT_EPISODE4_END:
                LoadEpisode(GameUtil.Const.FUNGUS_KEY_EVENT_EPISODE5_START);
                break;

            // エンディング
            case GameUtil.Const.FUNGUS_KEY_EVENT_EPISODE5_END:
                assetsManager.PlayBGM(GameUtil.Const.BGM_KEY_STOP);
                SceneManager.LoadScene(GameUtil.Const.SCENE_NAME_END);
                break;
            }
        }

        // 再生中のオーディオと異なる曲が指定されたら再生
        string playBGMKey = flowchart.GetVariable <StringVariable>(GameUtil.Const.FUNGUS_KEY_PLAY_BGM).Value;

        if (!string.IsNullOrEmpty(playBGMKey))
        {
            if (assetsManager.getPlayingAudio() != assetsManager.getAudioClip(playBGMKey))
            {
                assetsManager.PlayBGM(playBGMKey);
            }
            flowchart.SetStringVariable(GameUtil.Const.FUNGUS_KEY_PLAY_BGM, null);
        }

        // 効果音が指定されたら再生
        string playSEKey = flowchart.GetVariable <StringVariable>(GameUtil.Const.FUNGUS_KEY_PLAY_SE).Value;

        if (!string.IsNullOrEmpty(playSEKey))
        {
            assetsManager.PlayOneShot(playSEKey);
            flowchart.SetStringVariable(GameUtil.Const.FUNGUS_KEY_PLAY_SE, null);
        }

        // 背景の切替処理
        string setBackKey = flowchart.GetVariable <StringVariable>(GameUtil.Const.FUNGUS_KEY_SET_BACKGROUD).Value;

        if (!string.IsNullOrEmpty(setBackKey))
        {
            SwitchBackground(setBackKey);
            flowchart.SetStringVariable(GameUtil.Const.FUNGUS_KEY_SET_BACKGROUD, null);
        }
    }
        private void SyncToFungus(string inkVariableName, object inkVariableNewValue)
        {
            bool     hasChanged;
            Variable fungusVariable     = fungusGlobalVariables.GetVariable(inkVariableName);
            Type     fungusVariableType = fungusVariable.GetValue().GetType();

            if (fungusVariableType == typeof(int))
            {
                int intValue = (fungusVariable as IntegerVariable).Value;
                hasChanged = (intValue != (int)inkVariableNewValue);
            }
            else if (fungusVariableType == typeof(string))
            {
                string stringValue = (fungusVariable as StringVariable).Value;
                hasChanged = (stringValue != (string)inkVariableNewValue);
            }
            else if (fungusVariableType == typeof(float))
            {
                float floatValue = (fungusVariable as FloatVariable).Value;
                hasChanged = (floatValue != (float)inkVariableNewValue);
            }
            else if (fungusVariableType == typeof(bool))
            {
                bool boolValue = (fungusVariable as BooleanVariable).Value;
                hasChanged = (boolValue != (0 != (int)inkVariableNewValue));
            }
            else
            {
                hasChanged = false;
            }
            if (hasChanged)
            {
                // Picks the first flowchart: any flowchart is OK, it's a global variable
                Flowchart flowchart       = syncVariables[inkVariableName][0];
                Type      inkVariableType = inkVariableNewValue.GetType();
                try
                {
                    Debug.Log(inkVariableName + "=" + inkVariableNewValue + " (Ink->Fungus)");
                    if (inkVariableType == typeof(int))
                    {
                        if (fungusVariableType == typeof(bool))
                        {
                            flowchart.SetBooleanVariable(inkVariableName, (0 != (int)inkVariableNewValue));
                        }
                        else
                        {
                            flowchart.SetIntegerVariable(inkVariableName, (int)inkVariableNewValue);
                        }
                    }
                    else if (inkVariableType == typeof(string))
                    {
                        flowchart.SetStringVariable(inkVariableName, (string)inkVariableNewValue);
                    }
                    else if (inkVariableType == typeof(float))
                    {
                        flowchart.SetFloatVariable(inkVariableName, (float)inkVariableNewValue);
                    }
                    else // it's an Ink list
                    {
                        throw new InvalidCastException();
                    }
                    foreach (Flowchart affectedFlowchart in syncVariables[inkVariableName])
                    {
                        BroadcastToFungus(refreshVariablesMessage, affectedFlowchart);                         // rough and simple
                        BroadcastToFungus(refreshVariablesMessage + " " + inkVariableName, affectedFlowchart); // fine-grained
                    }
                }
                catch (InvalidCastException)
                {
                    Debug.LogError("Sync variable mismatch: " + inkVariableName + " is " + inkVariableType + " in Ink but it's not in Fungus");
                }
            }
            else
            {
                Debug.Log(inkVariableName + " is already in sync with Fungus");
            }
        }
Esempio n. 30
0
 public void SetPlayerName()
 {
     flowchart.SetStringVariable("Name", nameInput.text.ToString());
 }