示例#1
0
        public void OnChooseExchange(Exchange exchange, string lastIncomingChoice)
        {
            LastChosenExchange = exchange;
            LatestExchange     = exchange;
            int numTimesChosen = 0;

            if (!State.CompletedExchanges.TryGetValue(exchange.Name, out numTimesChosen))
            {
                State.CompletedExchanges.Add(exchange.Name, 0);
            }
            numTimesChosen++;
            State.CompletedExchanges [exchange.Name] = numTimesChosen;
            //save before broadcasting so mission scripts etc. can access data
            //Save();
            //broadcast choice
            Player.Get.AvatarActions.ReceiveAction(AvatarAction.NpcConverseExchange, WorldClock.AdjustedRealTime);

            //now that we've concluded we call on choose for global scripts
            for (int i = 0; i < State.GlobalScripts.Count; i++)
            {
                ExchangeScript globalScript = State.GlobalScripts [i];
                globalScript.OnChoose(lastIncomingChoice);
            }

            OnExchangeChosen.SafeInvoke();
        }
示例#2
0
        public void CheckRequirements()
        {
            if (mCheckingRequirements)
            {
                //if we're already checking
                //this means a loop is in progress
                //the loop will return false if the requirements really aren't met
                //so return true in the meantime
                mRequirementsMet = true;
                return;
            }

            mCheckingRequirements = true;
            for (int i = Scripts.Count - 1; i >= 0; i--)
            {
                ExchangeScript requirement = Scripts [i];
                if (requirement == null)
                {
                    Scripts.RemoveAt(i);
                }
                else if (!Scripts [i].RequirementsMet)
                {
                    mRequirementsMet      = false;
                    DtsOnFailure          = Scripts [i].DtsOnFailure;
                    mCheckingRequirements = false;
                                        #if DEBUG_CONVOS
                    Debug.Log("--- Exchange " + Name + " requirements met for " + Scripts [i].ScriptName + "? - " + mRequirementsMet.ToString());
                                        #endif
                    return;
                }
            }
            mCheckingRequirements = false;
            mRequirementsMet      = true;
        }
示例#3
0
 public void LoadScripts()
 {
     for (int i = 0; i < SavedScripts.Count; i++)
     {
         //get the type of the object from the string
         KeyValuePair <string, string> savedScript = SavedScripts [i];
         ExchangeScript script = (ExchangeScript)WIScript.XmlDeserializeFromString(savedScript.Key, savedScript.Value);
         if (script != null)
         {
             script.exchange = this;
             Scripts.Add(script);
         }
     }
 }