Пример #1
0
    public void doAddQuestionOneshotEvent(eventScript newEvent)
    {
        NPC tempNPC;

        //If our keyList has Names AND all of its associated Arrays are of proper length, then do the checks.
        if (newEvent.keyList.Length > 0 && newEvent.answersToAdd.Length >= newEvent.keyList.Length && newEvent.eventsToAdd.Length >= newEvent.keyList.Length)
        {
            for (int i = 0; i < newEvent.keyList.Length; i++)//We check every NPC in the scene to see if it should be changed.
            {
                print(i);
                if (hashList.ContainsKey(newEvent.keyList[i]))//If the name in our keyList (which can contain multiples of the same name) is in the scene, add the answer to that node.
                {
                    tempNPC = (NPC)(hashList[newEvent.keyList[i]]);//Make a TempNPC so we can edit it.
                    if (newEvent.eventsToAdd[i] == null) //If there's not a corresponding event to our answer, just add the answer.
                    {
                        tempNPC.myConvo.addQuestion(newEvent.answersToAdd[i], newEvent.eventsToAdd[i], newEvent.nextNodesToAdd[i]);
                        tempNPC.myConvo.hasNext = true;
                    }
                    else
                    {
                        tempNPC.myConvo.addQuestion(newEvent.answersToAdd[i], newEvent.eventsToAdd[i], newEvent.nextNodesToAdd[i]);//Otherwise add the answer and the event.
                        tempNPC.myConvo.hasNext = true;
                    }
                    hashList[newEvent.keyList[i]] = tempNPC;//Then we make sure to put the tempNode back where it came from.
                }
            }
        }
        else//Else fail and tell us why.
        {
            print("Node [" + this.name + "] KeyList[]/answersToAdd[]/eventsToAdd[] array size mismatch. The array lengthss must be >= KeyList.Length!");
        }
        timeLeft += newEvent.adjustAmount;//We add/subtract any minutes the event gives us.
        if (timeLeft < 0) { timeLeft = 0; }//If the time subtracted was larger than the amount of time we had left, just set it to 0.
        timerActivated = newEvent.shouldActivateTimer;//Activate the timer, if we're told.


        newEvent.oneshotClear();//Since we're passed a pointer, this makes the node passed to us INCAPABLE of adding answers again.
    }