Esempio n. 1
0
 public void ExecuteOnGroup(string function, Group group, Action<ExecutionResult> continuation = null)
 {
     string pythonGroup = PythonConverter.GroupCtor(group);
     ScriptSource src = _engine.CreateScriptSourceFromString(string.Format("{0}({1})", function, pythonGroup),
                                                             SourceCodeKind.Statements);
     StartExecution(src, ActionsScope, continuation);
 }
Esempio n. 2
0
 public void ExecuteOnGroup(string function, Group group, Point position, Action<ExecutionResult> continuation = null)
 {
     string pythonGroup = PythonConverter.GroupCtor(group);
     ScriptSource src = _engine.CreateScriptSourceFromString(
         string.Format(CultureInfo.InvariantCulture,
                       "result = {0}({1}, {2:F3}, {3:F3})",
                       function, pythonGroup, position.X, position.Y),
         SourceCodeKind.Statements);
     StartExecution(src, ActionsScope, continuation);
 }
Esempio n. 3
0
        public void ExecuteOnGroup(string function, Group group, Action <ExecutionResult> continuation = null)
        {
            if (_engine == null)
            {
                return;                  //TODO: This blocks spectators from using hotkeys. Need to implement a better solution.
            }
            string       pythonGroup = PythonConverter.GroupCtor(group);
            ScriptSource src         = _engine.CreateScriptSourceFromString(string.Format("{0}({1})", function, pythonGroup),
                                                                            SourceCodeKind.Statements);

            StartExecution(src, ActionsScope, continuation);
        }
Esempio n. 4
0
 public string FormatObject(object o)
 {
     if (o == null)
     {
         return(string.Format("None"));
     }
     if (o is Array)
     {
         var o2 = o as Array;
         return(string.Format("[{0}]", string.Join(",", o2.Select(this.FormatObject))));
     }
     if (o is Player)
     {
         return(string.Format("Player({0})", (o as Player).Id));
     }
     if (o is Group)
     {
         var h = o as Group;
         return(PythonConverter.GroupCtor(h));
         //return string.Format("Group({0},\"{1}\",{2})", h.Id, h.Name,h.Owner == null ? "None" : FormatObject(h.Owner));
     }
     if (o is Card)
     {
         var h = o as Card;
         return(string.Format("Card({0})", h.Id));
     }
     if (o is Counter)
     {
         var h      = o as Counter;
         var player = Player.All.FirstOrDefault(x => x.Counters.Any(y => y.Id == h.Id));
         return(string.Format("Counter({0},{1},{2})", h.Id, FormatObject(h.Name), FormatObject(player)));
     }
     if (o is string)
     {
         return(string.Format("\"{0}\"", o));
     }
     return(o.ToString());
 }