public WeatherDelta(SymbolPhrase phrase, KnownWeatherPattern pattern)
 {
     this.phrase = phrase;
     weather = pattern;
     Aggregate();
     Normalize();
     Delta();
 }
 /// Return a sorted by best-match list of WeatherDelta's
 public static List<WeatherDelta> OrderedMatches(SymbolPhrase phrase)
 {
     var rtn = new List<WeatherDelta>();
     foreach (var pattern in Scene.FindComponents<KnownWeatherPattern>())
     {
         var match = new WeatherDelta(phrase, pattern);
         rtn.Add(match);
     }
     rtn = rtn.OrderBy(o => o.match).ToList();
     rtn.Reverse();
     return rtn;
 }
        /// Spawn objects and create a layout for the given history item
        private void SpawnHistoryPrefabsAndLayout(SymbolPhrase phrase, int offset)
        {
            var targets = new List<GameObject>();
            foreach (var symbol in phrase.symbols)
            {
                if (symbol.symbolPrefab == null)
                {
                    Debug.LogError(string.Format("Warning: Symbol {0} does not have a prefab assigned forward it's symbol", symbol));
                }
                else
                {
                    Scene.Spawn(symbol.symbolPrefab).Then((op) => targets.Add(op));
                }
            }
            Scene.Spawn(phrase.weatherPrefab).Then((op) => targets.Add(op));

            // assign parent
            foreach (var gp in targets)
            { gp.AddComponent<HistoryMarker>(); }

            // Apply layout
            var layout = new LinearLayout(history.historyDisplay, history.historyBorderSize, history.historySize, offset);
            LayoutManager.ApplyLayout(layout, targets);
        }
 private void UpdateDisplayedSymbols(SymbolPhrase phrase)
 {
     new UpdateSymbolDisplayStates(current, this).Execute(null);
     SetSymbolsReadyState(current.Ready);
 }
 private void ExecuteWeather(SymbolPhrase phrase)
 {
     new PickWeatherForPhrase(current, debug.weatherChoices).Execute((ip) =>
     {
         SetActiveState(true);
         var self = ip as PickWeatherForPhrase;
         if ((self != null) && (self.selected != null))
         {
             /// Push new state to weather.
             new UpdatePlantsWithNewWeather(self.selected).Execute(null);
         }
         new DispatchWeatherRequest(current).Execute(null);
     });
 }
        /// Execute a symbol stream
        public bool ExecutePhrase()
        {
            if (!current.Ready)
            {
                Debug.Log("Player tried to run an incomplete symbol, doing nothing");
                return false;
            }

            ExecuteWeather(current);

            history.history.Add(current);
            if (history.history.Count > history.historySize)
            { history.history.RemoveAt(0); }
            UpdatePhraseHistory();

            current = new SymbolPhrase();
            UpdateDisplayedSymbols(current);

            return true;
        }
 /// Clear selected symbols in the current phrase
 public void ClearPhrase()
 {
     current = new SymbolPhrase();
     UpdateDisplayedSymbols(current);
 }
 public UpdateSymbolDisplayStates(SymbolPhrase phrase, PlayerSymbolState player)
 {
     this.phrase = phrase;
     this.slots = player.selectSlots;
     this.player = player;
 }
 public PickWeatherForPhrase(SymbolPhrase phrase, bool debug)
 {
     this.phrase = phrase;
     this.debug = debug;
 }
 public DispatchWeatherRequest(SymbolPhrase phrase)
 { this.phrase = phrase; }