Example #1
0
        // Extract from Laalys actions' name the associated ComponentMonitoring and game action
        private static List <KeyValuePair <ComponentMonitoring, string> > extractTuplesFromActionsName(string [] actions)
        {
            List <KeyValuePair <ComponentMonitoring, string> > results = new List <KeyValuePair <ComponentMonitoring, string> >();

            // extract Monitoring id from actions' name
            foreach (string action in actions)
            {
                string[] tokens = action.Split('_');
                // last token is id
                int id;
                if (tokens.Length > 2 && Int32.TryParse(tokens[tokens.Length - 1], out id))
                {
                    ComponentMonitoring cm = MonitoringManager.getMonitorById(id);
                    if (cm != null)
                    {
                        // second to last is game action name => Add pair
                        results.Add(new KeyValuePair <ComponentMonitoring, string>(cm, tokens[tokens.Length - 2]));
                    }
                    else
                    {
                        UnityEngine.Debug.LogError("No MonitoringComponent with id: " + id);
                    }
                }
                else
                {
                    UnityEngine.Debug.LogError("Action name malformed: " + action);
                }
            }
            return(results);
        }