예제 #1
0
    void Start()
    {
        /*Person ResetCharacter = new Person(1, 7, 1, 1,
         *      1, 1, 1, "Assets/Prefabs/PlayerCharacter.prefab");
         * GameObject avatar = Instantiate(avatarPrefab) as GameObject;
         * avatar.transform.SetParent(characterCreationImage.transform, false);*/

        audioSource = this.GetComponent <AudioSource>();

        story = new Story(inkAsset.text);

        // ------------------ Observeable Variables
        // Stats
        story.ObserveVariable("energy", (string varName, object newValue) => {
            StatController.UpdateEnergyStat((int)newValue);
        });
        story.ObserveVariable("health", (string varName, object newValue) => {
            StatController.UpdateHealthStat((int)newValue);
        });
        story.ObserveVariable("wellness", (string varName, object newValue) => {
            StatController.UpdateWellnessStat((int)newValue);
        });

        // Date / UI Stuff
        story.ObserveVariable("fullDate", (string varName, object newValue) => {
            LabelController.UpdateDate((string)newValue);
        });
        story.ObserveVariable("today", (string varName, object newValue) => {
            LabelController.UpdateWeekday(newValue);
        });
        story.ObserveVariable("time", (string varName, object newValue) => {
            LabelController.UpdateTimeSlot(newValue);
        });
        story.ObserveVariable("location", (string varName, object newValue) => {
            LabelController.UpdateLocation((string)newValue);
        });
        story.ObserveVariable("background", (string varName, object newValue) => {
            LabelController.UpdateBackground((string)newValue);
        });

        // Inventory
        story.ObserveVariable("money", (string varName, object newValue) => {
            InventoryController.UpdateMoneyQuantity((float)newValue);
        });
        story.ObserveVariable("prepackagedMealCount", (string varName, object newValue) => {
            InventoryController.UpdatePrepackagedFoodQuantity((int)newValue);
        });
        story.ObserveVariable("foodIngredientsCount", (string varName, object newValue) => {
            InventoryController.UpdateIngredientsSet((int)newValue);
        });

        // Store
        story.ObserveVariable("storePrompt", (string varName, object newValue) => {
            StoreController.StoreState((int)newValue);
        });
        story.ObserveVariable("purchaseResponse", (string varName, object newValue) => {
            StoreController.UpdatePurchaseResponse((string)newValue);
        });

        // Conversation
        story.ObserveVariable("conversationActive", (string varName, object newValue) => {
            ConversationToggle((int)newValue);
        });
        story.ObserveVariable("relationshipWithPlayer", (string varName, object newValue) => {
            UpdateRelationships((int)newValue);
        });

        //  ------------------ External Functions
        story.BindExternalFunction("EndGame", () => EndGame());
        story.BindExternalFunction("UpdateNPCs", () => UpdateNPCs());


        //  ------------------ Font Options
        userFont           = Resources.GetBuiltinResource(typeof(Font), "Arial.ttf") as TMP_FontAsset;
        storyText.fontSize = userFontSize;
        storyText.font     = userFont;


        //  ------------------ Start Loop
        StoryLoop();
    }