Пример #1
0
    private void Start()
    {
        if (varName[0] == '$')
        {
            Debug.LogError($"{varName} is not a valid variable name for accessing defaultVariables." +
                           "Please give a variable name, unformatted for Yarn.");
        }
        storage = (CustomStorage)MainSingleton.Instance.dialogueRunner.variableStorage;

        /* Access defaultVariables with unformatted varName, e.g. 'name'
         * This is because yarn variables are stored as '$name' but defaultVariables, which
         * are a custom extension of Yarn, are stored as 'name' to be compatible with enums */
        data = storage.defaultVariables[varName];
        // set var name to be format '$name'
        varName = varName.YarnFormat();

        // set UI elements
        if (icon is Image)
        {
            ((Image)icon).sprite = data.icon;
        }
        else if (icon is SVGImage)
        {
            ((SVGImage)icon).sprite = data.icon;
        }

        Yarn.Value value = storage.GetValue(varName);
        SetPercentUI(value.AsNumber);

        storage.OnSetValue += OnYarnValueChanged;
    }
Пример #2
0
    // Use this for initialization
    void Start()
    {
        Charlie = NPCman.instance.GetCharacter("Charlie").gameObject; //Get charlie ref from NPC man
        terrain = FindObjectOfType <Terrain>();                       //this is hilariously slow never use this shhhhh
        myAnim  = GetComponent <Animator>();
        //highly recomend navmesh instead

        //Debug.Assert(RB,"needs rigidbody");
        //RB = GetComponent<Rigidbody>();
        //RB.isKinematic = true;

        //require component will only add animators to new NPC_follow components, so chuck in an assert just in case with a friendly message
        Debug.Assert(myAnim, gameObject.name + " is missing an animator component! Add it even if you don't have anims yet uwu");

        follow = gameObject.name != "Eden"; //don't follow if eden (Boolean expressions are much cleaner than if else)

        if (gameObject.name == "Avery")
        {
            GameObject dialogue = GameObject.Find("Yarn");
            Yarn.Value biStage  = dialogue.GetComponent <ExampleVariableStorage>().GetValue("$biStage");
            int        stage    = (int)biStage.AsNumber;
            if (stage == 0)
            {
                Yarn.Value forest = dialogue.GetComponent <ExampleVariableStorage>().GetValue("$forest");
                follow = forest.AsBool;
            }
        }
    }
Пример #3
0
 public override void Observe(string var_name, Yarn.Value value)
 {
     // Set food quest item
     if (var_name == "$food_quest" && value.AsNumber != 0)
     {
         if (value.AsNumber == 1)
         {
             playerItemHolder.HoldItem("bread");
             shopController.ReturnItem("grapes");
             shopController.ReturnItem("jar");
             shopController.TakeItem("bread");
         }
         else if (value.AsNumber == 2)
         {
             playerItemHolder.HoldItem("grapes");
             shopController.ReturnItem("bread");
             shopController.ReturnItem("jar");
             shopController.TakeItem("grapes");
         }
         else if (value.AsNumber == 3)
         {
             playerItemHolder.HoldItem("jar");
             shopController.ReturnItem("grapes");
             shopController.ReturnItem("bread");
             shopController.TakeItem("jar");
         }
         else if (value.AsNumber == -1)
         {
             //Quest complete
             SceneManager.LoadScene("Finish");
         }
     }
 }
Пример #4
0
 private void OnYarnValueChanged(string name, Yarn.Value value)
 {
     if (name == varName)
     {
         SetPercentUI(value.AsNumber);
     }
 }
Пример #5
0
    void OnSceneLoaded(Scene scene, LoadSceneMode mode)
    {
        if (loadingGame)
        {
            // Provide binary formatter a stream of bytes to read and create a save object from
            BinaryFormatter bf   = new BinaryFormatter();
            FileStream      file = File.Open(Application.persistentDataPath + "/gamesave.save", FileMode.Open);
            Save            save = (Save)bf.Deserialize(file);
            file.Close();

            foreach (var condition in save.sceneVars)
            {
                SceneItemManager.sceneItems.loadConditionStatuses[condition.loadIfThisVarTrue] = condition.varStatus;
            }

            player = FindObjectOfType <Player>();
            player.transform.position = new Vector3(save.playerX, save.playerY);

            dialogueVars = FindObjectOfType <ExampleVariableStorage>();
            for (int i = 0; i < save.dialogueVars.Count; i++)
            {
                object value;
                ExampleVariableStorage.SaveVariable variable = save.dialogueVars[i];

                switch (variable.type)
                {
                case Yarn.Value.Type.Number:
                    value = variable.valueAsFloat;
                    break;

                case Yarn.Value.Type.String:
                    value = variable.valueAsString;
                    break;

                case Yarn.Value.Type.Bool:
                    value = variable.valueAsBool;
                    break;

                case Yarn.Value.Type.Null:
                    value = null;
                    break;

                default:
                    throw new System.ArgumentOutOfRangeException();
                }

                var v = new Yarn.Value(value);

                dialogueVars.SetValue(variable.name, v);
            }



            FindObjectOfType <DialogueRunner>().dialogue.visitedNodes = save.nodesVisited;

            loadingGame = false;
        }
    }
Пример #6
0
    // Update is called once per frame
    void UpdateMoney(int scene)
    {
        //Disable on chair hitting scene
        GetComponent <Text>().enabled = ScenesToShow.Contains(scene);

        //Update val
        money            = EVS.GetValue("$money");
        displayText.text = "$" + money.AsNumber;         //Combine with string to avoid .toString()
    }
Пример #7
0
 public void PlaceInInventory()
 {
     PlayerController.Instance.Inventory.Add(this);
     gameObject.SetActive(false);
     Yarn.Value value = new Yarn.Value(true);
     SetVariables(); // For cases where it's never been awoken.
     VariableStorage.Instance.SetValue(InInventoryVariableName, value);
     DontDestroyOnLoad(this);
 }
Пример #8
0
        public override void SetValue(string variableName, Value value)
        {
            variableName             = variableName[0] == '$'? variableName :  string.Format("${0}", variableName);
            _variables[variableName] = new Yarn.Value(value);

            #if UNITY_EDITOR
            viewVariables[variableName] = value.AsString;
            #endif
        }
Пример #9
0
 /// Set a variable's value
 public override void SetValue(string variableName, Yarn.Value value)
 {
     // Copy this value into our list
     variables[variableName] = new Yarn.Value(value);
     foreach (var observer in observerList)
     {
         observer.Observe(variableName, value);
     }
 }
Пример #10
0
 public void Decrement(string variableName, float dec)
 {
     Yarn.Value yarnValue = GetValue(variableName);
     if (yarnValue.type != Yarn.Value.Type.Null && yarnValue.type != Yarn.Value.Type.Number)
     {
         Debug.LogErrorFormat("Variable '{0}' is not of type Number. Can't decrement.", variableName);
         return;
     }
     SetValue(variableName, new Yarn.Value(yarnValue.AsNumber - dec));
 }
Пример #11
0
 public void Update()
 {
     if (currCountdownValue >= 9)
     {
         var varStore   = variableStorage.GetComponent <VariableStorage>();
         var valueToSet = new Yarn.Value(true);
         varStore.SetValue("$lastStraw", valueToSet);
         lastStrawD = true;
     }
 }
Пример #12
0
    public void ResetEmotions()
    {
        gameEmotion = "nuetral";
        var True  = new Yarn.Value(true);
        var False = new Yarn.Value(false);

        variableStorage.SetValue("$Happy", False);
        variableStorage.SetValue("$Sad", False);
        variableStorage.SetValue("$Angry", False);
    }
 public void SetValue(string key, Yarn.Value val)
 {
     if (val.type == Yarn.Value.Type.Null)
     {
         values[key] = null;
     }
     else
     {
         values[key] = new BlackboardValue(val);
     }
 }
Пример #14
0
    void AddDefaultsToStorage()
    {
        Yarn.Value valToAdd;

        foreach (DefaultVariable var in defaultVariables)
        {
            valToAdd              = new Yarn.Value();
            valToAdd.type         = var.type;
            valToAdd.variableName = "$" + var.name;
            SetValue("$" + var.name, valToAdd);
        }
    }
Пример #15
0
    /// Erase all variables and reset to default values
    public override void ResetToDefaults()
    {
        Clear();

        // For each default variable that's been defined, parse the string
        // that the user typed in in Unity and store the variable
        foreach (var variable in defaultVariables)
        {
            object value;

            switch (variable.type)
            {
            case Yarn.Value.Type.Number:
                float f = 0.0f;
                float.TryParse(variable.value, out f);
                value = f;
                break;

            case Yarn.Value.Type.String:
                value = variable.value;
                break;

            case Yarn.Value.Type.Bool:
                bool b = false;
                bool.TryParse(variable.value, out b);
                value = b;
                break;

            case Yarn.Value.Type.Variable:
                // We don't support assigning default variables from other variables
                // yet
                Debug.LogErrorFormat("Can't set variable {0} to {1}: You can't " +
                                     "set a default variable to be another variable, because it " +
                                     "may not have been initialised yet.", variable.name, variable.value);
                continue;

            case Yarn.Value.Type.Null:
                value = null;
                break;

            default:
                throw new System.ArgumentOutOfRangeException();
            }

            var v = new Yarn.Value(value);
            if (GameManager.Instance.DialogVariables.ContainsKey("$" + variable.name) == false)
            {
                SetValue("$" + variable.name, v);
            }
        }
    }
Пример #16
0
    private void OnTriggerExit(Collider other)
    {
        Yarn.Value biStage = dialogue.GetComponent <ExampleVariableStorage>().GetValue("$biStage");
        int        stage   = (int)biStage.AsNumber;

        if (gameObject.name == "MeetingBounds")
        {
            if (other.gameObject.name == "Charlie" && enabled && stage == 2)
            {
                dialogue.GetComponent <DialogueRunner>().StartDialogue("MeetingHint");
                //enabled = false;
            }
        }
    }
Пример #17
0
    public override void ResetToDefaults()
    {
        Clear();
        foreach (var variable in defaultVariables)
        {
            object value;
            switch (variable.type)
            {
            case Yarn.Value.Type.Number:
                float f = 0.0f;
                float.TryParse(variable.value, out f);
                value = f;
                break;

            case Yarn.Value.Type.String:
                value = variable.value;
                break;

            case Yarn.Value.Type.Bool:
                bool b = false;
                bool.TryParse(variable.value, out b);
                value = b;
                break;

            case Yarn.Value.Type.Variable:
                Debug.LogErrorFormat("Can't set variable {0} to {1}: You can't " +
                                     "set a default variable to be another variable, because it " +
                                     "may not have been initialised yet.", variable.name, variable.value);
                continue;

            case Yarn.Value.Type.Null:
                value = null;
                break;

            default:
                throw new System.ArgumentOutOfRangeException();
            }
            var v = new Yarn.Value(value);
            SetValue("$" + variable.name, v);
        }
        if (debugTextView != null)
        {
            debugTextView.enabled = false;
        }
        if (Debug.isDebugBuild || Application.isEditor)
        {
            SetValue("$debug", new Yarn.Value(true));
        }
    }
Пример #18
0
 void positioning()
 {
     if (scene == "TamsOffice")
     {
         Yarn.Value biStage = dialogue.GetComponent <ExampleVariableStorage>().GetValue("$biStage");
         int        stage   = (int)biStage.AsNumber;
         if (stage != 5)
         {
             GameObject temp = GameObject.Find("Avery");
             temp.GetComponent <ActivateCharacter>().setMesh(false, true);
             GameObject temp2 = GameObject.Find("Maison");
             temp2.GetComponent <ActivateCharacter>().setMesh(false, true);
         }
     }
 }
Пример #19
0
 public override void SetValue(string variableName, Yarn.Value value)
 {
     variables[variableName] = new Yarn.Value(value);
     if (variableName.StartsWith("$computer_"))
     {
         switch (value.type)
         {
         case Yarn.Value.Type.Bool:
             computer.SetValue(variableName, value.AsBool);
             break;
         }
     }
     else if (variableName.StartsWith("$hackboy_"))
     {
         switch (value.type)
         {
         case Yarn.Value.Type.Bool:
             hackboy.SetValue(variableName, value.AsBool);
             break;
         }
     }
 }
    public BlackboardValue(Yarn.Value val)
    {
        switch (val.type)
        {
        case Yarn.Value.Type.Number:
            type        = Type.Number;
            numberValue = val.AsNumber;
            break;

        case Yarn.Value.Type.String:
            type        = Type.String;
            stringValue = val.AsString;
            break;

        case Yarn.Value.Type.Bool:
            type      = Type.Bool;
            boolValue = val.AsBool;
            break;

        case Yarn.Value.Type.Null:
            type = Type.Null;
            break;
        }
    }
Пример #21
0
    public void RestartLoop()
    {
        player.transform.position = playerStart.position;
        cam.transform.position    = camStart.position;
        player.inputEnabled       = false;
        player.AnimatePassedOut();
        player.facingRight   = false;
        startedFirstCutscene = false;
        courtDoor.Close();

        // reset dialogue vars except for ones that we want to conserve
        // between loops
        Yarn.Value diedOnce        = dialogueVars.GetValue("$DiedOnce");
        Yarn.Value pickedFirstTime = dialogueVars.GetValue("$PickedFirstTime");
        dialogueVars.ResetToDefaults();
        dialogueVars.SetValue("$DiedOnce", diedOnce);
        dialogueVars.SetValue("$PickedFirstTime", pickedFirstTime);


        // hacky. should find better way of dealing with this
        logan.AnimateSmoking();

        StartCoroutine(WaitAFrameThenMarkInMenuFalse());
    }
Пример #22
0
    void positionStage0()
    {
        //positioning for blossom island
        Yarn.Value forestComplete = dialogue.GetComponent <ExampleVariableStorage>().GetValue("$foundDog");
        bool       temp           = forestComplete.AsBool;

        Yarn.Value forest = dialogue.GetComponent <ExampleVariableStorage>().GetValue("$forest");
        bool       temp2  = forest.AsBool;

        Yarn.Value house = dialogue.GetComponent <ExampleVariableStorage>().GetValue("$afterhouse");
        string     spawn = house.AsString;

        Yarn.Value t          = dialogue.GetComponent <ExampleVariableStorage>().GetValue("$forestLoad");
        bool       forestLoad = t.AsBool;

        if (gameObject.name == "Avery")
        {
            //set avery's position on the other side of the gate so players can't talk to them before they should
            if (!temp && !temp2)
            {
                transform.position -=
                    new Vector3(10, 0, 0);
            }

            if (forestLoad && !temp)
            {
                GameObject spot = GameObject.Find("SpotPos");
                transform.position = spot.transform.position + new Vector3(1, 0, 1);
            }
        }

        if (gameObject.name == "Jack")
        {
            Yarn.Value finnyes = dialogue.GetComponent <ExampleVariableStorage>().GetValue("$finnyes");
            bool       temp3   = finnyes.AsBool;

            //place jack with finn if matched
            if (temp3)
            {
                GameObject destination = GameObject.Find("JackDestination");
                Vector3    pos         = destination.gameObject.transform.position;
                gameObject.transform.position = pos;
            }
        }

        if (gameObject.name == "Kim")
        {
            //place kim near forest entrance after charlie returns
            if (temp)
            {
                GameObject destination = GameObject.Find("KimDestination");
                Vector3    pos         = destination.gameObject.transform.position;
                gameObject.transform.position = pos;
            }
        }
        print("load " + forestLoad + " forestBool " + temp + gameObject.name);
        if (gameObject.name == "Charlie")
        {
            //place charlie outside nancy's house when they finish killing the bats
            if (spawn == "nancy")
            {
                GameObject destination = GameObject.Find("CharlieBats");
                Vector3    pos         = destination.gameObject.transform.position;
                gameObject.transform.position = pos;
            }
            //place charlie near forest entrance after they return
            if (temp)
            {
                GameObject destination = GameObject.Find("CharlieForest");
                Vector3    pos         = destination.gameObject.transform.position;
                gameObject.transform.position = pos;
            }

            if (forestLoad && !temp)
            {
                GameObject spot = GameObject.Find("SpotPos");
                transform.position = spot.transform.position;
            }
        }
    }
Пример #23
0
 public void SetValue(string variableName, string value)
 {
     // Copy this value into our list
     variables[variableName] = new Yarn.Value(value);
 }
    public void CheckQuest()
    {
        if (quest != null && quest.activeQuest == true)
        {
            //Checks to see if that quest goal is active
            if (quest.goalOneActive == true && quest != null)
            {
                //Searches for the quest goal one item in the player inventory
                if (inventoryItemList.itemList.Contains(quest.goalOne.questItem))
                {
                    //sets the goal to achieved
                    quest.goalOne.goalAchieved = true;
                    //Increases the number of completed goals
                    quest.goalsCompleted += 1;
                    //Logs that the goal is complete
                    Debug.Log("Goal One Complete");
                }
            }
            if (quest.goalTwoActive == true && quest != null)
            {
                if (inventoryItemList.itemList.Contains(quest.goalTwo.questItem))
                {
                    quest.goalTwo.goalAchieved = true;
                    quest.goalsCompleted      += 1;
                    Debug.Log("Goal Two Complete");
                }
            }
            if (quest.goalThreeActive == true && quest != null)
            {
                if (inventoryItemList.itemList.Contains(quest.goalThree.questItem))
                {
                    quest.goalThree.goalAchieved = true;
                    quest.goalsCompleted        += 1;
                    Debug.Log("Goal Three Complete");
                }
            }
            if (quest.goalFourActive == true && quest != null)
            {
                if (inventoryItemList.itemList.Contains(quest.goalFour.questItem))
                {
                    quest.goalFour.goalAchieved = true;
                    quest.goalsCompleted       += 1;
                    Debug.Log("Goal Four Complete");
                }
            }
            if (quest.goalFiveActive == true && quest != null)
            {
                if (inventoryItemList.itemList.Contains(quest.goalFive.questItem))
                {
                    quest.goalFive.goalAchieved = true;
                    quest.goalsCompleted       += 1;
                    Debug.Log("Goal Five Complete");
                }
            }
        }

        // Can this bit be written with a function? Something like this?
        /// public void removeGoalItem(Quest)
        /// {
        ///     inventoryItemList.itemList.Remove(questItem);
        ///     goalActive = false;
        /// }
        ///
        /// To run then use:
        /// if (quest.goalOneActive == true)
        /// {
        ///     removeGoalItem(quest.goalOne);
        /// }

        if (quest != null && quest.numberOfGoals <= quest.goalsCompleted)
        {
            //Set quest as complete
            quest.giveRewardItem = true;
            Debug.Log("Reward Given");
            //Deletes the items from the players Inventory
            if (quest.goalOneActive == true)
            {
                inventoryItemList.itemList.Remove(quest.goalOne.questItem);
                //Inactivates the goal
                quest.goalOne.goalActive = false;
            }
            if (quest.goalTwoActive == true)
            {
                inventoryItemList.itemList.Remove(quest.goalTwo.questItem);
                quest.goalTwo.goalActive = false;
            }
            if (quest.goalThreeActive == true)
            {
                inventoryItemList.itemList.Remove(quest.goalThree.questItem);
                quest.goalThree.goalActive = false;
            }
            if (quest.goalFourActive == true)
            {
                inventoryItemList.itemList.Remove(quest.goalFour.questItem);
                quest.goalFour.goalActive = false;
            }
            if (quest.goalFiveActive == true)
            {
                inventoryItemList.itemList.Remove(quest.goalFive.questItem);
                quest.goalFive.goalActive = false;
            }
        }

        //If the quest is complete
        if (quest != null && quest.giveRewardItem == true)
        {
            //Give item one to player inventory
            inventoryItemList.itemList.Add(quest.rewardItem);
            quest.giveRewardItem = false;
            quest.activeQuest    = false;
            quest.goalsCompleted = 0;
            Debug.Log("Quest Complete");

            //Sets the quest complete variable within Yarn and progresses the conversation
            VariableStorage varStore = dialogueRunner.GetComponent <VariableStorage>();
            var             questSet = new Yarn.Value(true);
            varStore.SetValue("$quest_complete", questSet);
        }
    }
Пример #25
0
    // Update is called once per frame
    void Update()
    {
        if (scenario.GetCurrentNode() == getDrinks)
        {
            didDrink = true;
        }

        if (!scenario.gameOver && !scenario.pause)
        {
            distanceFromEnemy = Vector3.Distance(transform.position, enemy.transform.position);

            var dist = new Yarn.Value(Mathf.RoundToInt(distanceFromEnemy));

            scenario.SetValue("$distance", dist);

            if (Input.GetKey(KeyCode.Space))
            {
                anim.Play("playerFeint");
                isHoldingGun = true;
            }
            else
            {
                isHoldingGun = false;
            }

            if (scenario.GetCurrentNode() == blamEnd)
            {
                scenario.saidBlam         = false; // you survived the monologue
                scenario.startedMonologue = false;
                blamVisual.SetActive(false);
            }
            if (scenario.startedMonologue)
            {
                blamVisual.SetActive(true);
            }

            if (timeTillShot == 0)
            {
                if (scenario.isTyping() && !scenario.isOptionsVisible)
                {
                    if (scenario.GetCurrentNode() == scenario.startMonologue || scenario.GetCurrentNode() == scenario.startBanter)
                    {
                        enemyAnim.Play("enemyLaugh");
                    }
                    else if (scenario.GetCurrentNode() == warningShot1 || scenario.GetCurrentNode() == warningShot2)
                    {
                        enemyAnim.Play("enemyNervous1");
                    }
                    else if (scenario.GetCurrentNode() == warningShot3)
                    {
                        enemyAnim.Play("enemyNervous2");
                    }
                    else
                    {
                        enemyAnim.Play("enemyTalk");
                    }
                }
                else
                {
                    enemyAnim.Play("enemyIdle");
                }

                if (!wasShot)
                {
                    if (Input.GetKeyDown(KeyCode.LeftArrow) || Input.GetKeyDown(KeyCode.A) || Input.GetKeyDown(KeyCode.RightArrow) || Input.GetKeyDown(KeyCode.D))
                    {
                        scenario.numPresses++;
                    }

                    if (Input.GetKey(KeyCode.LeftArrow) || Input.GetKey(KeyCode.A))
                    {
                        anim.Play("playerShuffle");
                        Move(Vector2.left);
                    }
                    else if (Input.GetKey(KeyCode.RightArrow) || Input.GetKey(KeyCode.D))
                    {
                        anim.Play("playerShuffle");
                        Move(Vector2.right);
                    }
                    else
                    {
                        if (!isHoldingGun)
                        {
                            anim.Play("playerIdle");
                        }
                    }
                }
            }

            if (timeTillWarning == 1f && !scenario.isTyping())
            {
                if (distanceFromEnemy < warningDist)
                {
                    if (scenario.GetCurrentNode() != warningShot1 && scenario.GetCurrentNode() != null && scenario.GetCurrentNode() != warningShot2 && scenario.GetCurrentNode() != warningShot3)
                    {
                        scenario.nodeBeforeWarning = scenario.GetCurrentNode();
                    }
                    if (isHoldingGun)
                    {
                        if (!warnedAboutGun)
                        {
                            scenario.StartNewNode(handOnGun);
                            warnedAboutGun = true;
                        }
                        else
                        {
                            if (distanceFromEnemy < 6f)
                            {
                                scenario.StartNewNode(shotInFoot);
                                didGetShotInFoot = true;
                            }

                            else
                            {
                                scenario.StartNewNode(shotBcGun);
                            }

                            enemyAnim.Play("enemyNervousFire");
                            anim.Play("playerShot");
                            AudioSource.PlayClipAtPoint(missShot, transform.position, 1f);
                            timeTillShot = 2f;
                            wasShot      = true;
                        }
                    }
                    else if (!didShootFloor)
                    {
                        switch (scenario.warnings)
                        {
                        case 0:
                            scenario.StartNewNode(warningShot1);
                            scenario.warnings++;
                            break;

                        case 1:
                            scenario.StartNewNode(warningShot2);
                            scenario.warnings++;
                            break;

                        case 2:
                            scenario.StartNewNode(warningShot3);
                            scenario.warnings++;
                            break;

                        case 3:
                            enemyAnim.Play("enemyNervousFire");
                            AudioSource.PlayClipAtPoint(missShot, transform.position, 1f);
                            timeTillShot = 2f;
                            scenario.warnings++;
                            break;
                        }
                    }
                }
                else
                {
                    if (scenario.warnings > 0 && !string.IsNullOrEmpty(scenario.nodeBeforeWarning))
                    {
                        if (!wentBack)
                        {
                            scenario.StartNewNode(scenario.nodeBeforeWarning);
                            wentBack = true;
                        }
                        else
                        {
                            timeTillWarning = 1f;
                            return;
                        }
                        //scenario.nodeBeforeWarning = "";
                    }
                    else
                    {
                        return;
                    }
                }
                timeTillWarning -= 0.2f;
            }

            if (!scenario.isRunning() && timeTillWarning < 1f && timeTillWarning > 0f)
            {
                timeTillWarning -= Time.deltaTime;
            }

            if (timeTillWarning <= 0f)
            {
                timeTillWarning = 1f;
            }

            if (timeTillShot > 0 && timeTillShot < 2.1f)
            {
                timeTillShot -= Time.deltaTime;
            }
            else if (timeTillShot < 0f)
            {
                if (scenario.warnings >= 3)
                {
                    if (distanceFromEnemy < 6f)
                    {
                        scenario.StartNewNode(shotInFoot);
                        anim.Play("playerShot");
                        didGetShotInFoot = true;
                        wasShot          = true;
                    }
                    else
                    {
                        didShootFloor = true;
                        scenario.StartNewNode(shotFloor);
                    }
                    timeTillShot = 0f;
                }
            }
        }
        else
        {
            if (scenario.gameOver)
            {
                if (!wasShot)
                {
                    if (scenario.saidBlam || scenario.saidYoMama || scenario.seenAll)
                    {
                        enemyAnim.Play("enemyConfidentFire");
                        anim.Play("playerShot");
                        AudioSource.PlayClipAtPoint(shot, transform.position, 1f);
                        endTExt.text = "Ouch… no comin’ back from that one…\nmaybe some smoother talkin’ could’a saved ya.\nOr maybe just bringin’ bullets to a duel in the first place!";
                        wasShot      = true;
                    }
                    else if (!scenario.isTyping())
                    {
                        enemyAnim.Play("enemyIdle");
                    }
                }
                if (didGetShotInFoot)
                {
                    endTExt.text = "Unfortunately that whole leg needed to be amputated so that fella never could get his fair shot at ya.\nMaybe next time don’t get so close that a fella can’t even shoot a warnin’ shot!";
                }
                if (didDrink)
                {
                    endTExt.text = "The two of y’all had a nice heart to heart over some drinks and found some common ground.\nTurns out this town is big enough for the both of y’all.";
                }
            }
            if (scenario.pause)
            {
                if (pauseTimer == 0f)
                {
                    enemyAnim.Play("enemyConfidentFire");
                    AudioSource.PlayClipAtPoint(shot, transform.position, 1f);
                }

                if (pauseTimer > 0.75f)
                {
                    pauseTimer     = 0f;
                    scenario.pause = false;
                }
                pauseTimer += Time.deltaTime;
            }
        }
    }
Пример #26
0
    // Can set all of this inside a function at some point

    //On collider enter searches the players inventory and checks for specific quest items
    void OnTriggerEnter(Collider col)
    {
        //Are all goals complete?
        if (quest != null && quest.numberOfGoals == quest.goalsCompleted)
        {
            //Set quest as complete
            quest.giveRewardItem = true;
            Debug.Log("Reward Given");
        }

        //If the quest is complete
        //Move this to be inside a Yarn Command
        if (quest != null && quest.giveRewardItem == true)
        {
            //Give item one to player inventory
            inventoryItemList.itemList.Add(quest.rewardItem);
            quest.giveRewardItem = false;
            quest.activeQuest    = false;
            quest.goalsCompleted = 0;
            Debug.Log("Quest Complete");

            //Sets the quest complete variable within Yarn and progresses the conversation
            var questSet = new Yarn.Value(true);
            GetComponent <ExampleVariableStorage>().SetValue("$quest_complete", questSet);
        }

        if (col.tag == "Player" && quest != null && quest.activeQuest == true)
        {
            //Checks to see if that quest goal is active
            if (quest.goalOneActive == true && quest != null)
            {
                //Searches for the quest goal one item in the player inventory
                if (inventoryItemList.itemList.Contains(quest.goalOne.questItem))
                {
                    //sets the goal to achieved
                    quest.goalOne.goalAchieved = true;
                    //Increases the number of completed goals
                    quest.goalsCompleted += 1;
                    //Inactivates the goal
                    quest.goalOne.goalActive = false;
                    //Deletes the item from the players Inventory
                    inventoryItemList.itemList.Remove(quest.goalOne.questItem);
                    //Logs that the goal is complete
                    Debug.Log("Goal One Complete");
                }
            }
            if (quest.goalTwoActive == true && quest != null)
            {
                if (inventoryItemList.itemList.Contains(quest.goalTwo.questItem))
                {
                    quest.goalTwo.goalAchieved = true;
                    quest.goalsCompleted      += 1;
                    quest.goalTwo.goalActive   = false;
                    inventoryItemList.itemList.Remove(quest.goalTwo.questItem);
                    Debug.Log("Goal Two Complete");
                }
            }
            if (quest.goalThreeActive == true && quest != null)
            {
                if (inventoryItemList.itemList.Contains(quest.goalThree.questItem))
                {
                    quest.goalThree.goalAchieved = true;
                    quest.goalsCompleted        += 1;
                    quest.goalThree.goalActive   = false;
                    inventoryItemList.itemList.Remove(quest.goalThree.questItem);
                    Debug.Log("Goal Three Complete");
                }
            }
            if (quest.goalFourActive == true && quest != null)
            {
                if (inventoryItemList.itemList.Contains(quest.goalFour.questItem))
                {
                    quest.goalFour.goalAchieved = true;
                    quest.goalsCompleted       += 1;
                    quest.goalFour.goalActive   = false;
                    inventoryItemList.itemList.Remove(quest.goalFour.questItem);
                    Debug.Log("Goal Four Complete");
                }
            }
            if (quest.goalFiveActive == true && quest != null)
            {
                if (inventoryItemList.itemList.Contains(quest.goalFive.questItem))
                {
                    quest.goalFive.goalAchieved = true;
                    quest.goalsCompleted       += 1;
                    quest.goalFive.goalActive   = false;
                    inventoryItemList.itemList.Remove(quest.goalFive.questItem);
                    Debug.Log("Goal Five Complete");
                }
            }
        }
    }
 /// Set a variable's value
 public override void SetValue(string variableName, Yarn.Value value)
 {
     // Copy this value into our list
     variables["$" + variableName] = new Yarn.Value(value);
 }
Пример #28
0
 public abstract void Observe(string var_name, Yarn.Value value); // Extend this based on what class you are creating
Пример #29
0
 /// Set a variable's value
 public override void SetValue(string variableName, Yarn.Value value)
 {
     GameManager.Instance.DialogVariables[variableName] = new Yarn.Value(value);
 }
 public ObjectInTime(Vector3 _position, int _currentHealth, Yarn.Value _isAlarmRinging)
 {
     position       = _position;
     currentHealth  = _currentHealth;
     isAlarmRinging = _isAlarmRinging;
 }