Ejemplo n.º 1
0
    IEnumerator ExecuteActionTable(ActionTable <int> decision_table)
    {
        ResetStatistics();
        Projectiles.Clear();
        int count = 0;

        numWaves = TurnCount;

        while (count < TurnCount)
        {
            //if (IsGameGoing() || !(controller.User_Position.IsValid()))

            if (IsProjectileVisible() || controller.User_Position != GridCenter)
            {
                if (!IsProjectileVisible())
                {
                    controller.SetGridCenterVisibility(true);
                }
                yield return(new WaitForSeconds(0.1f));

                continue;
            }

            controller.SetGridCenterVisibility(false);
            yield return(new WaitForSeconds(TimeInterval / 2));

            Pair      destination = decision_table.GetNextPosition(controller.User_Position);
            Transform temp        = Instantiate(spawners[0].obj, spawnZone).transform;
            temp = controller.GetBoxCoordinates(temp, destination.x, destination.y);
            count++;
            yield return(new WaitForSeconds(TimeInterval));
        }
    }
Ejemplo n.º 2
0
        /// <summary>
        /// 数据初始化
        /// </summary>
        private void Initialization()
        {
            ActionTable.Add(WebSocketTypeEnum.Publish, (data) =>
            {
                Task.Run(() =>
                {
                    MessageQueue.Publish(data.Channel, data.Data);
                });
            });

            ActionTable.Add(WebSocketTypeEnum.Subscribe, (data) =>
            {
                Task.Run(() =>
                {
                    MessageQueue.Subscribe <object>(data.Channel, (result) =>
                    {
                        Publish(data.UserInfo, data.Channel, result);
                    });
                });
            });

            ActionTable.Add(WebSocketTypeEnum.Submit, (data) =>
            {
                Task.Run(() =>
                {
                    Publish(data.UserInfo, data.Channel, MessageQueue.PublishAsync(data.Channel, data.Data).Result);
                });
            });
        }
Ejemplo n.º 3
0
 public void Draw(ActionTable actable)
 {
     GUILayout.BeginVertical();
     GUILayout.Label("============== Action =================");
     if (GUILayout.Button("- Action"))
     {
         actable.m_ActionObjects.Remove(this);
     }
     {
         GUILayout.BeginHorizontal();
         GUILayout.Label("Name");
         this.m_Name = GUILayout.TextField(this.m_Name);
         GUILayout.Label("AniName");
         this.m_AniName = GUILayout.TextField(this.m_AniName);
         GUILayout.Label("Time");
         this.m_Time = EditorGUILayout.FloatField(this.m_Time);
         this.m_Loop = GUILayout.Toggle(this.m_Loop, "Loop");
         if (GUILayout.Button("+ Event"))
         {
             ActionObject.Event ev = new ActionObject.Event();
             this.m_Events.Add(ev);
         }
         GUILayout.EndHorizontal();
     }
     {
         GUILayout.BeginVertical();
         for (int i = 0; i < m_Events.Count; i++)
         {
             ActionObject.Event ev = this.m_Events[i];
             ev.Draw(this);
         }
         GUILayout.EndVertical();
     }
     GUILayout.EndVertical();
 }
Ejemplo n.º 4
0
    /*public void Begin()
     * {
     *  //EndRound();
     *  IsGameAlive = true;
     *  StopCoroutine(SendBucketCoordinates());
     *  StartCoroutine(SendBucketCoordinates());
     *  if (RequestedDestinations.Count > 0)
     *  {
     *      StartCoroutine(RequestedSpawn());
     *      return;
     *  }
     *  switch (PatternType)
     *  {
     *      case Pattern.Line:
     *          if (PatternParameters.Count > 1)
     *          {
     *              StartCoroutine(LineSpawn(PatternParameters[0], PatternParameters[1]));
     *          }
     *          else
     *          {
     *              StartCoroutine(LineSpawn(1, 1));
     *          }
     *          break;
     *      case Pattern.Sine:
     *          if (PatternParameters.Count > 0)
     *          {
     *              StartCoroutine(SineSpawn(PatternParameters[0]));
     *          }
     *          else
     *          {
     *              StartCoroutine(SineSpawn(10));
     *          }
     *          break;
     *      case Pattern.Cosine:
     *          if (PatternParameters.Count > 0)
     *          {
     *              StartCoroutine(CosineSpawn(PatternParameters[0]));
     *          }
     *          else
     *          {
     *              StartCoroutine(CosineSpawn(9));
     *          }
     *          break;
     *      case Pattern.SemiCircle:
     *          if (PatternParameters.Count > 0)
     *          {
     *              StartCoroutine(SemiCircleSpawn(PatternParameters[0]));
     *          }
     *          else
     *          {
     *              StartCoroutine(SemiCircleSpawn(5));
     *          }
     *          break;
     *  }
     * }*/

    public void BeginEpisode(ActionTable <int> decision_table)
    {
        IsGameAlive = true;
        StopCoroutine(SendBucketCoordinates());
        StartCoroutine(SendBucketCoordinates());

        StartCoroutine(ExecuteActionTable(decision_table));
    }
 public void Set(ActionTable act, HitData hitData = null, int skillLayer = 0)
 {
     this.m_ActionTable = act;
     this.m_cExcute     = ActionExcute.Create(act, this.m_cObj, hitData);
     this.m_HitData     = hitData;
     this.m_ActionMode  = ActingActionMode.Normal;
     this._skillLayer   = skillLayer;
 }
    public static ActionExcute Create(ActionTable table, GfxObject o, HitData hitdata = null)
    {
        GameObject   obj = new GameObject("ActionExcute");
        ActionExcute ac  = obj.AddComponent <ActionExcute>();

        ac.m_Table   = table;
        ac.m_HitData = hitdata;
        ac.StartAction(o);
        return(ac);
    }
    public void OnLoad(string path)
    {
        path = path.Substring(path.IndexOf("Assets"));
        ActionTable load_scene_data = (ActionTable)Instantiate(AssetDatabase.LoadAssetAtPath(path, typeof(ActionTable)));

        if (load_scene_data != null)
        {
            CopyFrom(load_scene_data);
        }
    }
 /// <summary>
 /// 退出状态
 /// </summary>
 /// <returns></returns>
 public override bool OnExit()
 {
     if (this.m_cExcute != null)
     {
         GameObject.Destroy(this.m_cExcute.gameObject);
         this.m_cExcute     = null;
         this.m_ActionTable = null;
     }
     return(base.OnExit());
 }
 public void CopyFrom(ActionTable src)
 {
     m_ActionObjects = new List <ActionObject>();
     // orderingActionTable	= src.orderingActionTable;
     m_IsLookTarget = src.m_IsLookTarget;
     foreach (ActionObject ao in src.m_ActionObjects)
     {
         ActionObject dest = new ActionObject();
         dest.CopyFrom(ao);
         m_ActionObjects.Add(dest);
     }
 }
Ejemplo n.º 10
0
        /// <summary>
        ///     Builds the parse table from the given graph and starting element.
        /// </summary>
        /// <param name="graph"></param>
        /// <param name="startingElement"></param>
        private void buildParseTable(StateGraph <GrammarElement <T>, LRItem <T>[]> graph, NonTerminal <T> startingElement)
        {
            if (graph == null)
            {
                throw new ArgumentNullException("graph");
            }
            if (startingElement == null)
            {
                throw new ArgumentNullException("startingElement");
            }

            //clear the tables
            ActionTable.Clear();
            GotoTable.Clear();

            //get the breadth-first traversal of the graph
            List <StateNode <GrammarElement <T>, LRItem <T>[]> > t = graph.GetBreadthFirstTraversal().ToList();


            //add the transitions for each node in the traversal
            for (var i = 0; i < t.Count; i++)
            {
                //for each transition in the node, add either a shift action or goto action
                foreach (KeyValuePair <GrammarElement <T>, StateNode <GrammarElement <T>, LRItem <T>[]> > transition in t[i].FromTransitions)
                {
                    if (transition.Key is Terminal <T> )
                    {
                        //add a shift from this state to the next state
                        addAction((Terminal <T>)transition.Key, i, new ShiftAction <T>(this, t.IndexOf(transition.Value)));
                    }
                    else
                    {
                        addGoto((NonTerminal <T>)transition.Key, i, t.IndexOf(transition.Value));
                    }
                }

                //for each of the items in the state that are at the end of a production,
                //add either a reduce action or accept action
                foreach (LRItem <T> item in t[i].Value.Where(a => a.IsAtEndOfProduction()))
                {
                    //if we would reduce to the starting element, then accept
                    if (item.LeftHandSide.Equals(startingElement))
                    {
                        addAction(item.LookaheadElement, i, new AcceptAction <T>(this, item));
                    }
                    //otherwise, add a reduce action
                    else
                    {
                        addAction(item.LookaheadElement, i, new ReduceAction <T>(this, item));
                    }
                }
            }
        }
Ejemplo n.º 11
0
 /// <summary>
 ///     Adds a shift command to the action table at the position between the given element and given currentState, with the
 ///     given actions as the values.
 /// </summary>
 /// <param name="element"></param>
 /// <param name="currentState"></param>
 /// <param name="actions"></param>
 private void addAction(Terminal <T> element, int currentState, params ParserAction <T>[] actions)
 {
     //if the column already exists
     if (ActionTable.ContainsKey(currentState, element))
     {
         //add the actions
         ActionTable[currentState, element].AddRange(actions);
     }
     //otherwise, create new
     else
     {
         ActionTable.Add(currentState, element, actions.ToList());
     }
 }
Ejemplo n.º 12
0
 //skill state
 public void SkillState(ActionTable act, HitData hitData = null, int skillLayer = 0)
 {
     if (IsDie())
     {
         return;
     }
     if (hitData == null)
     {
         hitData           = new HitData();
         hitData.minAttack = Atk;
         hitData.maxAttack = Atk;
     }
     this.m_cStateControl.Skill(act, hitData, skillLayer);
 }
Ejemplo n.º 13
0
    void OnGUI()
    {
        scrollPosition = GUILayout.BeginScrollView(scrollPosition, GUILayout.Width(position.width), GUILayout.Height(position.height));

        EditorGUILayout.BeginHorizontal();
        if (GUILayout.Button("Load Scene"))
        {
            EditorSceneManager.OpenScene("Assets/Scripts/Editor/CharacterEffectEditor.unity");
            if (!EditorApplication.isPlaying)
            {
                EditorApplication.isPlaying = true;
            }
        }
        if (GUILayout.Button("Clear Action"))
        {
            this.m_ActionTable = new ActionTable();
            this.path          = string.Empty;
            this.fileName      = "NewAction";
        }
        if (GUILayout.Button("Load Action"))
        {
            this.path = EditorUtility.OpenFilePanel("Open Asset...", Application.dataPath + "/App/Art/Resources/Battle/Action/", "asset");
            if (this.path != string.Empty)
            {
                this.m_ActionTable.OnLoad(this.path);
                this.fileName = System.IO.Path.GetFileNameWithoutExtension(this.path);
            }
        }
        if (GUILayout.Button("Save Action"))
        {
            this.path = EditorUtility.SaveFilePanel("Save Asset...", Application.dataPath + "/App/Art/Resources/Battle/Action/", this.fileName, "asset");
            if (this.path != string.Empty)
            {
                this.m_ActionTable.OnSave(path);
            }
        }
        EditorGUILayout.EndHorizontal();

        if (this.m_ActionTable != null)
        {
            this.m_ActionTable.Draw();
        }

        GUILayout.EndScrollView();
    }
Ejemplo n.º 14
0
 public ActionData GetActionData(int guid)
 {
     foreach (Transform child in actionManager)
     {
         ActionTable actionTable = child.GetComponentInChildren <ActionTable> () as ActionTable;
         if (actionTable != null)
         {
             foreach (ActionData actionData in actionTable.DataList)
             {
                 if (actionData.Guid == guid)
                 {
                     return(actionData);
                 }
             }
         }
     }
     return(null);
 }
    //skill
    public void Skill(ActionTable act, HitData hitData = null, int skillLayer = 0)
    {
        if (this.m_cCurrentState != null && (this.m_cCurrentState.GetStateType() == STATE_TYPE.STATE_IDLE || this.m_cCurrentState.GetStateType() == STATE_TYPE.STATE_MOVE || this.m_cCurrentState.GetStateType() == STATE_TYPE.STATE_SKILL))
        {
            if (CheckSkill(skillLayer))
            {
                return;
            }
            if (this.m_cCurrentState != null)
            {
                this.m_cCurrentState.OnExit();
            }

            this.m_cStateWrap.m_cSkillState.Set(act, hitData, skillLayer);
            this.m_cCurrentState = this.m_cStateWrap.m_cSkillState;
            this.m_cCurrentState.OnEnter();
        }
    }
Ejemplo n.º 16
0
        internal void SendNotificationEvent(String table, String nameEvent, ActionTable action, String jsonTableData)
        {
            Boolean                       eventValid             = false;
            NotificationEvents            notificationEvent      = NotificatioEventDb.GetNotificationEvent(table, nameEvent);
            List <NotificationConditions> notificationConditions = null;

            eventValid = (action == ActionTable.I && notificationEvent.EventInsert);
            if (!eventValid)
            {
                eventValid = (action == ActionTable.U && notificationEvent.EventUpdate);
            }
            if (!eventValid)
            {
                eventValid = (action == ActionTable.D && notificationEvent.EventDelete);
            }


            if (eventValid && notificationEvent.Nortify)
            {
                notificationConditions = notificationEvent.NotificationConditions.ToList();
                String query          = null;
                String codntionParams = null;
                foreach (NotificationConditions itemCondition in notificationConditions)
                {
                    itemCondition.NotificationQueryCondition.ToList().ForEach(t => { query = String.Concat(query, t.QueryCondition); codntionParams = String.Concat(codntionParams, t.ParameterDimical, ";"); });
                    codntionParams = codntionParams.Remove(codntionParams.Length - 1);
                    if (itemCondition.Notify)
                    {
                        if (!String.IsNullOrEmpty(jsonTableData))
                        {
                            query = QueryResolve(query, codntionParams, jsonTableData);
                        }

                        query = String.Concat("Select * From ", table, " Where ", query);
                        if (NotificationQuerys.ExecuteCondition(query))
                        {
                            SendDestination(itemCondition.NotificationDestination?.ToList());
                        }
                    }
                }
            }
        }
    public void OnSave(string path)
    {
        string asset_path = path.Substring(path.IndexOf("Assets"));//path setup

        ActionTable ao = (ActionTable)AssetDatabase.LoadAssetAtPath(asset_path, typeof(ActionTable));

        if (ao == null)
        {
            ActionTable new_ao = ScriptableObject.CreateInstance <ActionTable>();
            if (new_ao != null)
            {
                AssetDatabase.CreateAsset(new_ao, asset_path);
                ao = new_ao;
            }
        }
        if (ao != null)
        {
            ao.CopyFrom(this);
            EditorUtility.SetDirty(ao);
            AssetDatabase.SaveAssets();
            AssetDatabase.Refresh();
        }
    }
Ejemplo n.º 18
0
 public ActionTablePlayer(ActionTable table, long handsToPlay)
 {
     this.handsToPlay = handsToPlay;
     this.Table = table;
 }
Ejemplo n.º 19
0
        private IEnumerable <string> buildRules(ActionTable <int, object> actionTable, TokenInfo tokenInfo, Func <int, string> symbolNameConvert,
                                                string treeNodeName)
        {
            IEnumerable <ParseAction <int, object> >[,] actions;
            int[,] edges;
            IEnumerable <NfaCell <int, object> >[,] recovery;

            actionTable.GetData(out actions, out edges, out recovery);

            // sub-structures are created in separate methods -- this is artificial and the only reason is buggy mono
            // with around 30K lines it starts crashing with "method too complex" error
            string edges_func         = "createEdges";
            string edges_table_name   = "__edges_table__";
            int    edges_func_counter = 0;
            {
                int edges_func_limit = 20000;
                int lines            = 0;

                for (int y = 0; y < edges.GetLength(0); ++y)
                {
                    for (int x = 0; x < edges.GetLength(1); ++x)
                    {
                        if (edges[y, x] != ActionTable <int, object> .NoTarget)
                        {
                            if (lines == 0)
                            {
                                yield return("public static void " + edges_func + edges_func_counter + "(int[,] " + edges_table_name + ")");

                                yield return("{");

                                ++edges_func_counter;
                            }
                            yield return(edges_table_name + "[" + y + "," + x + "] = " + edges[y, x] + ";");

                            ++lines;
                            if (lines == edges_func_limit)
                            {
                                yield return("}");

                                lines = 0;
                            }
                        }
                    }
                }

                if (lines > 0)
                {
                    yield return("}");
                }
            }

            string recovery_table_name = "__recovery_table__";
            string recovery_func       = "createRecoveryTable";

            yield return("public static IEnumerable<NfaCell<" + tokenInfo.ElemTypeName + ", " + treeNodeName + ">>[,] " + recovery_func + "()");

            yield return("{");

            yield return("var " + recovery_table_name + " = " + CodeWords.New + " IEnumerable<NfaCell<" + tokenInfo.ElemTypeName + "," + treeNodeName + ">>["
                         + recovery.GetLength(0) + "," + recovery.GetLength(1) + "];");

            for (int y = 0; y < recovery.GetLength(0); ++y)
            {
                for (int x = 0; x < recovery.GetLength(1); ++x)
                {
                    if (recovery[y, x] != null)
                    {
                        yield return(recovery_table_name + "[" + y + "," + x + "] = " + CodeWords.New + " NfaCell<" + tokenInfo.ElemTypeName + "," + treeNodeName + ">[]{"
                                     + String.Join(",", recovery[y, x].Select(it => dumpNfaCell(it, tokenInfo.ElemTypeName, symbolNameConvert, treeNodeName)))
                                     + "};");
                    }
                }
            }
            yield return("return " + recovery_table_name + ";");

            yield return("}");

            string symbols_rep_name = "symbols_rep";
            string symbols_func     = "createSymbolsRep";

            yield return("public static StringRep<" + tokenInfo.ElemTypeName + "> " + symbols_func + "()");

            yield return("{");

            yield return(buildStringRep(symbols_rep_name, grammar.SymbolsRep, symbolNameConvert));

            yield return("return " + symbols_rep_name + ";");

            yield return("}");

            // ---- main creation method

            yield return("public " + (grammar.ParserTypeInfo.WithOverride ? "override " : "") + parserTypeName(tokenInfo, treeNodeName) + " CreateParser(" + grammar.ParserTypeInfo.Params.Make() + ")");

            yield return("{");

            yield return(parserTypeName(grammar.TokenTypeInfo, grammar.TreeNodeName) + " " + parserField + " = null;");

            string actions_table_name        = "__actions_table__";
            var    dup_action_cmds           = new List <string>();
            int    dup_action_cmds_pack_size = 5000; // another Mono bug counter measure, we have to split big methods into several small ones

            var actions_buffer = new StringBuilder();

            {
                var actions_cache = new Dictionary <IEnumerable <ParseAction <int, object> >, Tuple <int, int> >(new SequenceEquality <ParseAction <int, object> >());

                actions_buffer.Append("var " + actions_table_name + " = " + CodeWords.New + " IEnumerable<ParseAction<" + tokenInfo.ElemTypeName + "," + treeNodeName + ">>[" + actions.GetLength(0) + "," + actions.GetLength(1) + "];");
                for (int y = 0; y < actions.GetLength(0); ++y)
                {
                    for (int x = 0; x < actions.GetLength(1); ++x)
                    {
                        if (actions[y, x] != null)
                        {
                            Tuple <int, int> coords;
                            if (actions_cache.TryGetValue(actions[y, x], out coords))
                            {
                                // another piece of code moved out of main creation method to avoid mono bug ("method too complex")
                                dup_action_cmds.Add(actions_table_name + "[" + y + "," + x + "] = " + actions_table_name + "[" + coords.Item1 + "," + coords.Item2 + "];");
                            }
                            else
                            {
                                actions_cache.Add(actions[y, x], Tuple.Create(y, x));
                                actions_buffer.Append(actions_table_name + "[" + y + "," + x + "] = " + CodeWords.New + " ParseAction<" + tokenInfo.ElemTypeName + "," + treeNodeName + ">[]{"
                                                      + String.Join(",", actions[y, x].Select(it => dumpParseAction(it, tokenInfo.ElemTypeName, symbolNameConvert, treeNodeName))) + "};");
                            }
                        }
                    }
                }
            }

            foreach (string line in functionsRegistry.Dump())
            {
                yield return(line);
            }


            yield return(actions_buffer.ToString());

            string actions_table_func = "actionsTableDuplicates";

            {
                var buffer = new StringBuilder();


                for (int i = 0; i <= dup_action_cmds.Count / dup_action_cmds_pack_size; ++i)
                {
                    buffer.Append(actions_table_func + i + "(" + actions_table_name + ");" + Environment.NewLine);
                }

                buffer.Append("var " + edges_table_name + " = ActionTableData<" + tokenInfo.ElemTypeName + "," + treeNodeName + ">.CreateEdgesTable(" + edges.GetLength(0) + "," + edges.GetLength(1) + ");" + Environment.NewLine);
                for (int f = 0; f < edges_func_counter; ++f)
                {
                    buffer.Append(edges_func + f + "(" + edges_table_name + ");" + Environment.NewLine);
                }
                buffer.Append("var " + recovery_table_name + " = " + recovery_func + "();" + Environment.NewLine);
                buffer.Append("var " + symbols_rep_name + " = " + symbols_func + "();" + Environment.NewLine);

                buffer.Append(parserField + " = " + CodeWords.New + " " + parserTypeName(tokenInfo, treeNodeName) + "(" + CodeWords.New + " ActionTableData<"
                              + tokenInfo.ElemTypeName + ","
                              + treeNodeName + ">(" + Environment.NewLine);
                buffer.Append("actionsTable:" + actions_table_name + ",");
                buffer.Append("edgesTable:" + edges_table_name + ",");
                buffer.Append("recoveryTable:" + recovery_table_name + ",");
                buffer.Append("startSymbol:" + symbolNameConvert(actionTable.StartSymbol) + ",");
                buffer.Append("eofSymbol:" + symbolNameConvert(actionTable.EofSymbol) + ",");
                buffer.Append("syntaxErrorSymbol:" + symbolNameConvert(actionTable.SyntaxErrorSymbol) + ",");
                buffer.Append("lookaheadWidth:" + actionTable.LookaheadWidth);
                buffer.Append("),");
                buffer.Append(symbols_rep_name);
                buffer.Append(");" + Environment.NewLine);
                buffer.AppendLine(CodeWords.Return + " " + parserField + ";");

                buffer.Append("}" + Environment.NewLine);

                yield return(buffer.ToString());
            }

            for (int i = 0; i <= dup_action_cmds.Count / dup_action_cmds_pack_size; ++i)
            {
                foreach (string s in dumpActionsTableDuplicates(dup_action_cmds.Skip(i * dup_action_cmds_pack_size).Take(dup_action_cmds_pack_size),
                                                                actions_table_name, actions_table_func + i, tokenInfo, treeNodeName))
                {
                    yield return(s);
                }
            }
        }
Ejemplo n.º 20
0
        public IEnumerable <string> Build(Grammar grammar, GenOptions options)
        {
            this.report            = new GrammarReport <int, object>();
            this.grammar           = grammar;
            this.precedenceTable   = new PrecedenceTable <int>(grammar.SymbolsRep);
            this.functionsRegistry = new FunctionRegistry();

            transformMultiplications();

            try
            {
                createRules();
                if (grammar.PostValidate(s => report.AddError(s), s => report.AddWarning(s)))
                {
                    createPrecedences();
                }
            }
            catch (ParseControlException ex)
            {
                Console.WriteLine(ex.Message);
                return(null);
            }
            catch (Exception ex)
            {
                Console.WriteLine("Error while building parser: " + ex.Message);
                Console.WriteLine(ex.StackTrace);
                return(null);
            }


            Productions <int, object> productions = productionBuilder.GetProductions(grammar.GetSymbolId(Grammar.EOFSymbol),
                                                                                     grammar.GetSymbolId(Grammar.ErrorSymbol), report);

            if (report.HasGrammarErrors)
            {
                Console.WriteLine(String.Join(Environment.NewLine, report.ReportGrammarProblems()));
                return(null);
            }
            else
            {
                ActionTable <int, object> action_table = ParserFactory.CreateActionTable(productions, precedenceTable, report, lookaheadWidth);

                if (action_table == null)
                {
                    if (!options.NoOutput)
                    {
                        Console.WriteLine("Grammar has errors, reports were written " + report.WriteReports("report_"));
                    }
                    return(null);
                }
                else
                {
                    if (options.ReportOther)
                    {
                        Console.WriteLine("Reports were written " + report.WriteReports("report_"));
                    }

                    return(buildNamespaceHeader(grammar)
                           .Concat(buildClassHeader(grammar.ParserTypeInfo))
                           .Concat(buildRules(action_table, grammar.TokenTypeInfo,
                                              (id => grammar.TokenTypeInfo.FieldNameOf(grammar.GetSymbolName(id))), grammar.TreeNodeName))
                           .Concat(buildClassFooter())
                           .Concat(buildNamespaceFooter())
                           );
                }
            }
        }
Ejemplo n.º 21
0
Archivo: Action.cs Proyecto: mxmstr/neo
    private void LoadActionData()
    {
        string filePath = Path.Combine(Application.streamingAssetsPath, m_ActionSource);

        m_ActionTable = JsonUtility.FromJson <ActionTable>(File.ReadAllText(filePath));
    }
Ejemplo n.º 22
0
        /// <summary>
        ///     Gets the action(s) given the current state and the next input.
        /// </summary>
        /// <param name="state"></param>
        /// <param name="nextInput"></param>
        /// <exception cref="System.ArgumentNullException" />
        /// <returns>
        ///     A array of ShiftActions if the operation is to move, ReduceActions if the operation is to Reduce, or AcceptActions
        ///     if the parse is valid.
        ///     Returns null if the action does not exist.
        /// </returns>
        public ParserAction <T>[] this[int currentState, GrammarElement <T> nextInput]
        {
            get
            {
                if (nextInput == null)
                {
                    throw new ArgumentNullException("nextInput");
                }

                if (nextInput is Terminal <T> )
                {
                    //if the given state is in the table
                    if (ActionTable.ContainsKey(currentState))
                    {
                        var actions = new List <ParserAction <T> >();
                        //if the next input is in the table
                        if (ActionTable[currentState].ContainsKey((Terminal <T>)nextInput))
                        {
                            Terminal <T> key = ActionTable[currentState].GetKey((Terminal <T>)nextInput);

                            //if the stored column is not negated
                            if (!key.Negated)
                            {
                                //return the action
                                actions.AddRange(ActionTable[currentState][key].ToArray());
                            }
                        }
                        //Negated values will never match the end of input element
                        if (!((Terminal <T>)nextInput).EndOfInput)
                        {
                            //Negated values act as an 'and' clause instead of an 'or' clause
                            //input is not 'a' and input is not 'b', instead of input is not 'a' or input is not 'b'

                            //If all of the negated keys do not equal the next input.
                            if (ActionTable[currentState].All(a => (a.Key.Negated && !a.Key.Equals(nextInput)) || !a.Key.Negated))
                            {
                                //if the state is contained in the table, and if there is a negated input element that does not match the given input
                                //A Terminal with a null value that is negated will match anything except END_OF_INPUT.
                                KeyValuePair <Terminal <T>, List <ParserAction <T> > > result = ActionTable[currentState].FirstOrDefault(a => a.Key.Negated && !a.Key.Equals(nextInput));
                                if (!result.Equals(default(KeyValuePair <Terminal <T>, List <ParserAction <T> > >)))
                                {
                                    actions.AddRange(result.Value.ToArray());
                                }
                            }
                        }
                        return(actions.ToArray());
                    }
                }
                else
                {
                    //if the given state and next input are in the table
                    if (GotoTable.ContainsKey(currentState) &&
                        GotoTable[currentState].ContainsKey((NonTerminal <T>)nextInput))
                    {
                        //return a new shift action representing the goto movement.
                        return(new[] { new ShiftAction <T>(this, GotoTable[currentState, (NonTerminal <T>)nextInput].Value) });
                    }
                }

                //the item does not exist in the table, return null.
                return(null);
            }
        }
Ejemplo n.º 23
0
    void Update()
    {
        /* body.RotationA = RotationA;
         * body.CallRotateA();
         *
         * joint2.RotationB = RotationB;
         * joint2.RotationD = RotationD;
         * joint2.CallRotateB();
         *
         * joint3.RotationC = RotationC;
         * joint3.CallRotateC();*/

        //if (!manager.controller.AI.IsActive)
        //{
        fk.Move(j1, j2, j3, j4);
        //}
        if (has_update)
        {
            if (SendCommand)
            {
                manager.BeginEpisode(RequestedDestinations);
                SendCommand           = false;
                RequestedDestinations = new List <string>();
            }

            if (InitializeCommand)
            {
                manager.controller.Initialize();
                InitializeCommand = false;
            }

            if (resizePending != -1)
            {
                manager.ResizeShield(resizePending);
                resizePending = -1;
            }

            if (Speed != -1)
            {
                manager.controller.ReceivedSpeedChange(Speed);
                Speed = -1;
            }

            if (table_data != "")
            {
                ActionTable <int> table = new ActionTable <int>(manager.controller.XValues.Count - 1, manager.controller.YValues.Count - 1, _zero: 0, _one: 1, _initializer: table_data);
                manager.BeginEpisode(table);
                table_data = "";
            }

            if (turn_count != -1)
            {
                manager.TurnCount = turn_count;
                turn_count        = -1;
            }
            if (show_grid != -1)
            {
                if (show_grid == 1)
                {
                    manager.controller.SetGridVisibility(true);
                }
                else
                {
                    manager.controller.SetGridVisibility(false);
                }
                show_grid = -1;
            }

            if (has_simulation != "")
            {
                string temp = has_simulation.Replace('(', ' ');
                temp = temp.Replace(')', ' ');
                temp = temp.Trim();
                SendScore("resultsimulation:" + has_simulation + ":" + manager.RL.RequestSimulationData(manager, int.Parse(temp.Split(',')[0]), int.Parse(temp.Split(',')[1])));
                //Debug.Log(manager.RL.RequestSimulationData(manager, int.Parse(temp.Split(',')[0]), int.Parse(temp.Split(',')[1])));
                has_simulation = "";
            }

            has_update = false;
        }
    }
Ejemplo n.º 24
0
    void OnGUI()
    {
        scrollPosition = GUILayout.BeginScrollView(scrollPosition, GUILayout.Width(position.width), GUILayout.Height(position.height));

        EditorGUILayout.BeginHorizontal();
        if (GUILayout.Button("Load Scene"))
        {
            EditorSceneManager.OpenScene("Assets/scripts/core/skilleditor/Editor/CharacterEffectEditor.unity");
            if (!EditorApplication.isPlaying)
            {
                EditorApplication.isPlaying = true;
            }
        }
        if (GUILayout.Button("Clear Action"))
        {
            if (m_ActionTable != null && this.m_ActionTable.previewCharacterSource != null)
            {
                GameObject.Destroy(this.m_ActionTable.previewCharacterSource);
                this.m_ActionTable.previewCharacterSource = null;
                this.m_ActionTable.player = null;
            }
            this.m_ActionTable = new ActionTable();
            // this.m_ActionTable = ScriptableObject.CreateInstance<ActionTable>();
            this.m_ActionTable.Init();
            this.path     = string.Empty;
            this.fileName = "NewAction";
        }
        if (GUILayout.Button("Load Action"))
        {
            this.path = EditorUtility.OpenFilePanel("Open Asset...", Application.dataPath + "/App/Art/Resources/Battle/Action/", "json");
            if (this.path != string.Empty)
            {
                this.m_ActionTable.OnLoad(this.path);
                this.fileName = System.IO.Path.GetFileNameWithoutExtension(this.path);
            }
        }
        if (GUILayout.Button("Save Action"))
        {
            this.path = EditorUtility.SaveFilePanel("Save Asset...", Application.dataPath + "/App/Art/Resources/Battle/Action/", this.fileName, "json");
            if (this.path != string.Empty)
            {
                this.m_ActionTable.OnSave(path);
            }
        }
        if (GUILayout.Button("Read Action"))
        {
            this.path = EditorUtility.OpenFilePanel("Open Asset...", Application.dataPath + "/App/Art/Resources/Battle/Action/", "bytes");
            if (this.path != string.Empty)
            {
                this.m_ActionTable.Read(this.path);
                this.fileName = System.IO.Path.GetFileNameWithoutExtension(this.path);
            }
        }
        if (GUILayout.Button("Write Action"))
        {
            this.path = EditorUtility.SaveFilePanel("Save Asset...", Application.dataPath + "/App/Art/Resources/Battle/Action/", this.fileName, "bytes");
            if (this.path != string.Empty)
            {
                this.m_ActionTable.Write(path);
            }
        }
        EditorGUILayout.EndHorizontal();

        if (this.m_ActionTable != null)
        {
            this.m_ActionTable.Draw();
        }

        GUILayout.EndScrollView();
    }
Ejemplo n.º 25
0
 public void PlayAction(ActionTable action)
 {
     m_Action = action;
     m_IsActing = true;
     m_ActingTime = 0f;
 }
Ejemplo n.º 26
0
 void Awake()
 {
     m_ActionTable = new ActionTable();
     m_ActionTable.Init();
 }
Ejemplo n.º 27
0
    //skill state
    public void SkillState(string path, HitData hitData, int skillLayer = 0)
    {
        ActionTable act = Resources.Load("Battle/Action/" + path) as ActionTable;

        SkillState(act, hitData, skillLayer);
    }
Ejemplo n.º 28
0
        public static string GetQuestPartCategoriesForID(int id)
        {
            Set <String> categoriesSet = new Set <String>();

            // look for trigger categories
            DataRow[] triggerRows = TriggerTable.Select(COL_QUESTPARTTRIGGER_QUESTPARTID + "=" + id);
            foreach (DataRow triggerRow in triggerRows)
            {
                DataRow triggerTypeRow = GetTriggerTypeRowForID((int)triggerRow[COL_QUESTPARTTRIGGER_TYPE]);
                if (!String.IsNullOrEmpty((string)triggerTypeRow[COL_TRIGGERTYPE_CATEGORY]))
                {
                    string   categoryString = (string)triggerTypeRow[COL_TRIGGERTYPE_CATEGORY];
                    string[] categories     = categoryString.Split(';');

                    foreach (string category in categories)
                    {
                        CategoryComparator comparer = new CategoryComparator(category);
                        if (comparer.Compare(triggerRow))
                        {
                            categoriesSet.Add(comparer.Name);
                        }
                    }
                }
            }

            // look for requirement categories
            DataRow[] requRows = RequirementTable.Select(COL_QUESTPARTREQUIREMENT_QUESTPARTID + "=" + id);
            foreach (DataRow requRow in requRows)
            {
                DataRow requTypeRow = GetRequirementTypeRowForID((int)requRow[COL_QUESTPARTREQUIREMENT_TYPE]);
                if (!String.IsNullOrEmpty((string)requTypeRow[COL_REQUIREMENTTYPE_CATEGORY]))
                {
                    string   categoryString = (string)requTypeRow[COL_REQUIREMENTTYPE_CATEGORY];
                    string[] categories     = categoryString.Split(';');

                    foreach (string category in categories)
                    {
                        CategoryComparator comparer = new CategoryComparator(category);
                        if (comparer.Compare(requRow))
                        {
                            categoriesSet.Add(comparer.Name);
                        }
                    }
                }
            }

            // look for action categories
            DataRow[] actionRows = ActionTable.Select(COL_QUESTPARTACTION_QUESTPARTID + "=" + id);
            foreach (DataRow actionRow in actionRows)
            {
                DataRow actionTypeRow = GetActionTypeRowForID((int)actionRow[COL_QUESTPARTACTION_TYPE]);
                if (!String.IsNullOrEmpty((string)actionTypeRow[COL_ACTIONTYPE_CATEGORY]))
                {
                    string   categoryString = (string)actionTypeRow[COL_ACTIONTYPE_CATEGORY];
                    string[] categories     = categoryString.Split(';');

                    foreach (string category in categories)
                    {
                        CategoryComparator comparer = new CategoryComparator(category);
                        if (comparer.Compare(actionRow))
                        {
                            categoriesSet.Add(comparer.Name);
                        }
                    }
                }
            }


            StringBuilder categoryStringBuilder = new StringBuilder();

            for (int i = 0; i < categoriesSet.Count; i++)
            {
                categoryStringBuilder.Append(categoriesSet[i]);
                categoryStringBuilder.Append(";");
            }

            return(categoryStringBuilder.ToString());
        }
Ejemplo n.º 29
0
    private void OnGUI()
    {
        { // Column 1
            EditorGUILayout.BeginHorizontal ();
            // Load Sceme
            if (GUILayout.Button ("Load Scene")) {
                EditorApplication.OpenScene (ACTION_EDITOR_SCENE);
            }

            EditorGUILayout.EndHorizontal ();
        }

        { // Column 2
            EditorGUILayout.BeginVertical ("Box");
            // Setup Scene
            GUILayout.Label ("Setup Scene");

            EditorGUILayout.BeginHorizontal ();
            // Set Character
            if (GUILayout.Button ("Load Chara", GUILayout.Width (120))) {
                m_CharaPath = EditorUtility.OpenFilePanel ("Load Character...", Asset.Character.ASSET_DIR, Asset.Character.EXTENSION);
                CreateCharacter ();
            }

            GUILayout.TextField (string.IsNullOrEmpty (m_CharaPath) ? "" : m_CharaPath.Substring (m_CharaPath.IndexOf ("Character")));
            EditorGUILayout.EndHorizontal ();

            EditorGUILayout.BeginHorizontal ();
            // Set Character
            if (GUILayout.Button ("Load Weapon", GUILayout.Width (120))) {
                m_WeaponPath = EditorUtility.OpenFilePanel ("Load Weapon...", Asset.Weapon.ASSET_DIR, Asset.Weapon.EXTENSION);
                CreateWeapon ();
            }

            GUILayout.TextField (string.IsNullOrEmpty (m_WeaponPath) ? "" : m_WeaponPath.Substring (m_WeaponPath.IndexOf ("Weapon")));
            EditorGUILayout.EndHorizontal ();

            EditorGUILayout.BeginHorizontal ();
            GUILayout.FlexibleSpace ();

            // Init Scene
            if (GUILayout.Button ("Init Scene", GUILayout.Width (120))) {
                InitScene ();
            }

            // Clean Scene
            if (GUILayout.Button ("Clean Scene", GUILayout.Width (120))) {
                CleanScene ();
            }
            EditorGUILayout.EndHorizontal ();

            EditorGUILayout.EndVertical ();
        }

        { // Column 3
            EditorGUILayout.BeginVertical ("Box");
            // Set up Action
            GUILayout.Label ("Setup Action");

            {
                EditorGUILayout.BeginHorizontal ();
                // Load Action
                if (GUILayout.Button ("Load Action", GUILayout.Width (120))) {
                    m_ActionPath = EditorUtility.OpenFilePanel ("Open Action...", Asset.Action.ASSET_DIR, "asset");
                    if (!string.IsNullOrEmpty (m_ActionPath)) {
                        m_ActionFileName = System.IO.Path.GetFileNameWithoutExtension (m_ActionPath);
                        m_ActionTable = (ActionTable)GameObject.Instantiate (
                            AssetDatabase.LoadAssetAtPath (m_ActionPath.Substring (m_ActionPath.IndexOf ("Assets")), typeof(ActionTable)));

                        //initialize frame anim
                        m_ActionTable.ActionObjects.ForEach((actionObj) => {
                            actionObj.LoadAnimation(actionObj.m_AnmPath);
                        });
                    }
                }

                GUILayout.TextField (string.IsNullOrEmpty (m_ActionPath) ? "" : m_ActionPath.Substring (m_ActionPath.IndexOf ("Action")));
                EditorGUILayout.EndHorizontal ();
            }

            {
                EditorGUILayout.BeginHorizontal ();

                GUILayout.FlexibleSpace ();

                { // Time Scale
                    GUILayout.Label ("Action Speed:", GUILayout.Width (80f));
                    m_SpeedScale = EditorGUILayout.FloatField (m_SpeedScale, GUILayout.Width (60f));
                    GUILayout.Space (20f);
                    if (!m_PauseActing)
                        Time.timeScale = m_SpeedScale;
                }

                if (m_Character != null && m_Character.IsActing && !m_PauseActing) {
                    if (GUILayout.Button ("Pause Action")) {
                        if (m_Character.IsActing) {
                            m_PauseActing = true;
                            Time.timeScale = 0f;
                        }
                    }
                } else {
                    if (GUILayout.Button ("Play Action", GUILayout.Width (120))) {
                        if (!m_Character.IsActing) {
                            for (int i = 0; i < ActionEditorManager.I.anchorEffect.childCount; i++) {
                                Transform child = ActionEditorManager.I.anchorEffect.GetChild (i);

                                if (child != null) {
                                    DestroyImmediate (child.gameObject);
                                }
                            }

                            m_Character.PlayAction (m_ActionTable);
                        } else if (m_PauseActing) {
                            m_PauseActing = false;
                            Time.timeScale = m_SpeedScale;
                        }
                    }
                }

                if (GUILayout.Button ("Action +", GUILayout.Width (120))) {
                    m_ActionTable.ActionObjects.Add (new ActionObject ());
                }

                // Save Action
                if (GUILayout.Button ("Save Action", GUILayout.Width (120))) {
                    m_ActionPath = EditorUtility.SaveFilePanel ("Save Action...", Asset.Action.ASSET_DIR, m_ActionFileName, "asset");

                    if (m_ActionPath != null && m_ActionTable != null) {
                        m_ActionTable.OnSave (m_ActionPath);

                        m_ActionFileName = System.IO.Path.GetFileNameWithoutExtension (m_ActionFileName);
                    }
                }

                // Clear Action
                if (GUILayout.Button ("Clear Action", GUILayout.Width (120))) {
                    m_ActionPath = string.Empty;
                    m_ActionFileName = string.Empty;
                    m_ActionTable = null;
                }

                if (m_ActionTable == null)
                    m_ActionTable = new ActionTable ();
                EditorGUILayout.EndHorizontal ();
            }

            EditorGUILayout.EndVertical ();

        }

        m_ActionTable.OnEditorDraw (m_Character, 22f * 8 + 5f);

        Repaint();
    }
Ejemplo n.º 30
0
    public void Draw(ActionTable actable)
    {
        GUILayout.BeginVertical();
        TimeLine();
        for (int i = 0; i < mEvents.Count; i++)
        {
            float rate = mEvents[i].mTime / mTotalTime;
            TimeLine(rate, Color.red);
        }
        if (mCurrentEvent != null)
        {
            float rate = mCurrentEvent.mTime / mTotalTime;
            TimeLine(rate, Color.blue);
        }
        mTotalTimelineBGTex.Apply();
        GUILayout.Label(mTotalTimelineBGTex);

        GUILayout.BeginHorizontal();
        GUILayout.Label("============== Action =================");
        GUILayout.EndHorizontal();

        {
            GUILayout.BeginHorizontal();

            GUILayout.BeginHorizontal();
            // this.mName = EditorGUILayout.TextField("Name",this.mName);
            this.mTotalTime  = EditorGUILayout.FloatField("Total Time", this.mTotalTime);
            mActionEventType = (ActionObject.ActionType)EditorGUILayout.EnumPopup("Event Type", mActionEventType);
            GUILayout.EndHorizontal();

            GUILayout.BeginHorizontal();
            if (GUILayout.Button("Change Event"))
            {
                if (mCurrentEventIndex >= 0 && mCurrentEventIndex < mEvents.Count)
                {
                    ActionEvent ev = ActionFactory.CreateActionEvent(mActionEventType);
                    if (ev != null)
                    {
                        ev.SetActionObject(this);
                        this.mEvents[mCurrentEventIndex] = ev;
                        this.mCurrentEvent = ev;
                    }
                }
            }
            if (GUILayout.Button("Add Event"))
            {
                ActionEvent ev = ActionFactory.CreateActionEvent(mActionEventType);
                if (ev != null)
                {
                    ev.SetActionObject(this);
                    mCurrentEvent      = ev;
                    mCurrentEventIndex = mEvents.Count;
                    this.mEvents.Add(ev);
                }
            }
            if (GUILayout.Button("Delete Event"))
            {
                if (EditorUtility.DisplayDialog("Remove Event", "Are you sure to remove Event?", "Remove", "Cancel"))
                {
                    if (mCurrentEvent != null)
                    {
                        mEvents.Remove(mCurrentEvent);
                        mCurrentEvent      = null;
                        mCurrentEventIndex = -1;
                    }
                }
            }
            GUILayout.EndHorizontal();

            GUILayout.EndHorizontal();
        }
        {
            GUILayout.BeginHorizontal();
            for (int i = 0; i < mEvents.Count; i++)
            {
                ActionEvent ev = this.mEvents[i];
                // ev.Draw(this);
                if (GUILayout.Button("" + i))
                {
                    mCurrentEvent      = ev;
                    mCurrentEventIndex = i;
                }
            }
            GUILayout.EndHorizontal();

            GUILayout.BeginVertical();
            if (mCurrentEvent != null)
            {
                GUILayout.Label("============== Event " + mCurrentEventIndex + " =================");
                mCurrentEvent.Draw(this);
            }
            GUILayout.EndVertical();
        }
        GUILayout.EndVertical();
    }
Ejemplo n.º 31
0
 public ActionTablePlayer(ActionTable table, long handsToPlay)
 {
     this.handsToPlay = handsToPlay;
     this.Table       = table;
 }