Exemplo n.º 1
0
    void ServerProc()
    {
        while (true)
        {
            if (!working)
            {
                break;
            }
            if (listener.Pending())
            {
                AddNewClient(listener.AcceptTcpClient());
            }

            foreach (var pair in clientDic)
            {
                if (!pair.Value.Connected)
                {
                    continue;
                }
                try
                {
                    stream = pair.Value.GetStream();
                    reader = new BinaryReader(stream);
                    short  length = reader.ReadInt16();
                    byte[] buffer = reader.ReadBytes(length);
                    string msg    = Encoding.UTF8.GetString(buffer);
                    GEvent.OnEvent(eEvent.AddMsg, string.Format("{0}:{1}", pair.Key, msg));
                }
                catch
                {
                }
            }
        }
    }
Exemplo n.º 2
0
 //发出一个事件
 static bool sendVoteEvent(GEvent e)
 {
     //如果存在这个事件
     if (dictvote.ContainsKey(e.type))
     {
         List <VoteCallback> list = (dictvote[e.type] as List <VoteCallback>).ToList();
         votecallback        fn   = null;
         for (int i = 0; i < list.Count; i++)
         {
             fn      = list[i].cb;
             e.param = list[i].param;
             if (fn != null)
             {
                 if (!fn(e))
                 {
                     e.release();
                     e = null;
                     return(false);
                 }
             }
         }
     }
     e.release();
     e = null;
     return(true);
 }
Exemplo n.º 3
0
 public static void Open(TimelineWindow.TreeNode _node, GEvent e)
 {
     Open();
     rootNode = _node.root;
     curEvt   = e;
     Inst.Repaint();
 }
Exemplo n.º 4
0
        private void _on_Button_pressed(int index)
        {
            GD.Print(index.ToString());
            gEventObj.options[index].Selected();

            var nextEventKey = gEventObj.options[index].Next;

            GD.Print(nextEventKey);

            if (nextEventKey != "")
            {
                this.Visible = false;

                GEvent nextEvent = gEventObj.GetNext(nextEventKey);
                if (nextEvent != null)
                {
                    nextEventDialog = MainScene.ShowDialog(nextEvent);
                    nextEventDialog.Connect("tree_exited", this, nameof(Exit));
                    return;
                }
                SpecialEventDialog spEvent = SpecialEventDialog.GetEvent(nextEventKey);
                if (spEvent != null)
                {
                    nextEventDialog = MainScene.ShowSpecialDialog(spEvent);
                    nextEventDialog.Connect("tree_exited", this, nameof(Exit));
                    return;
                }
            }

            Exit();
        }
Exemplo n.º 5
0
        // Constructor
        public EventBlock(GCommand command)
        {
            // Initialize Component
            InitializeComponent();

            StackContentText.Text = command.FriendlyName;

            _GCommand = command;
            _GEvent   = new GEvent(_GCommand);

            // Initialize Hole List
            HoleList.Add(NextConnectHole);

            for (int i = 0; i < _GEvent.Arguments?.Count; i++)
            {
                VariableBlock variableBlock = BlockUtils.CreateVariableBlock(_GEvent.Arguments[i].Name, command.Optionals[i].FriendlyName);
                BaseBlock     baseBlock     = variableBlock as BaseBlock;

                baseBlock.MouseLeftButtonDown += BaseBlock_MouseLeftButtonDown;

                AllowVariableList.Add(variableBlock);
                ParameterBox.Children.Add(baseBlock);
            }

            // Initialize Block
            InitializeBlock();
        }
Exemplo n.º 6
0
    /**
     * Allows this object to be compared with other objects
     *
     * @return
     *      Less than zero - this precedes obj
     *      0 - this is same position as obj
     *      Greater than zero - obj precedes this
     */
    public int CompareTo(object obj)
    {
        if (obj == null)
        {
            return(1);
        }

        GEvent otherGEvent = obj as GEvent;

        if (otherGEvent != null)
        {
            if (this.Turn == otherGEvent.Turn)
            {
                if (this.Timestamp < otherGEvent.Timestamp)
                {
                    return(-1);
                }

                return(1);
            }
            else if (this.Turn < otherGEvent.Turn)
            {
                return(-1);
            }
            else
            {
                return(1);
            }
        }
        else
        {
            throw new ArgumentException("Object is not a GEvent");
        }
    }
Exemplo n.º 7
0
        public GoogleMap(jQueryObject container, GoogleMapOptions opt)
            : base(container, opt)
        {
            var center = new LatLng(options.Latitude ?? 0, options.Longitude ?? 0);

            map = new Map(container[0], new MapOptions
            {
                Center      = center,
                MapTypeId   = options.MapTypeId ?? MapTypeId.roadmap,
                Zoom        = options.Zoom ?? 15,
                ZoomControl = true
            });

            if (options.MarkerTitle != null)
            {
                new Marker(new MarkerOptions {
                    Position = new LatLng(
                        options.MarkerLatitude ?? options.Latitude ?? 0,
                        options.MarkerLongitude ?? options.Longitude ?? 0),
                    Map       = map,
                    Title     = options.MarkerTitle,
                    Animation = Animation.Drop
                });
            }

            LazyLoadHelper.ExecuteOnceWhenShown(container, () =>
            {
                GEvent.Trigger(map, "resize");
                map.SetCenter(center); // in case it wasn't visible (e.g. in dialog)
            });
        }
Exemplo n.º 8
0
    public void FixedUpdate()
    {
        Fix64 deltaTime = GTime.FixedDeltaTime;

        /**************以下是帧同步的核心逻辑*********************/
        AccumilatedTime = AccumilatedTime + deltaTime;

        //如果真实累计的时间超过游戏帧逻辑原本应有的时间,则循环执行逻辑,确保整个逻辑的运算不会因为帧间隔时间的波动而计算出不同的结果
        while (AccumilatedTime > NextGameTime)
        {
            // -----------------------------------
            // 替换帧同步的数据同步
            LocalFrameSynServer.SynFrameData();
            // -----------------------------------

            //运行与游戏相关的具体逻辑
            GEvent.DispatchEvent(GacEvent.UpdateFrameLogic);
            //计算下一个逻辑帧应有的时间
            NextGameTime += FrameLen;
            //游戏逻辑帧自增
            FsData.GameLogicFrame += 1;
        }

        //计算两帧的时间差,用于补间动画(interpolation是从0渐变到1的值,为什么?请查看Vector3.Lerp的用法)
        Interpolation = (AccumilatedTime + FrameLen - NextGameTime) / FrameLen;

        //更新渲染
        GEvent.DispatchEvent(GacEvent.UpdateFrameRender, Interpolation);
        /**************帧同步的核心逻辑完毕*********************/
    }
    public override void SetEventString(GEvent e)
    {
        object[] eArguments = e.Arguments;

        string unitName  = GetName((string)eArguments [0]);
        string enemyName = GetName((string)eArguments [1]);

        string rawName = (eArguments [2] as Weapon).GetWeaponType();

        rawName = rawName.Substring(0, rawName.Length - 4) + "name";

        string weaponName = LanguageManager.instance.getString("Weapons", rawName);

        string[] teams = { GetTeam((string)eArguments [0]), GetTeam((string)eArguments[1]) };

        string message = "";

        if ((int)e.Arguments[4] == 1)
        {
            message = "Unit " + unitName + " attacked unit " + enemyName + " with " + weaponName + ", but missed because it moved out of range";
        }
        else
        {
            message = "Unit " + unitName + " attacked unit " + enemyName + " with " + weaponName + " doing " + eArguments [3] + " damage";
        }

        e.String = EventLog.FormatEventString(teams, e.Timestamp, message);
    }
Exemplo n.º 10
0
    /**
     * Handles all events that should be handled at this turn of the given
     * priority.
     *
     * @param priority
     *      The priority of the events that should be handled.
     */
    public void HandleEvents(int priority)
    {
        // record the current turn
        int curTurn = TurnManager.GetCurrentTurn();

        List <GEvent> current = Events[priority];

        if (current == null)
        {
            return;
        }

        current.Sort();

        // Iterate over all the events of the priority
        while (Events[priority].Count > 0 && Events[priority][0].Turn <= curTurn)
        {
            GEvent e = Events[priority][0];

            // Removes the event that was just handled.
            Events[priority].RemoveAt(0);

            ////Debug.Log("Handling Event of type: " + e.GetType().ToString());

            // Iterate over every interested handler
            foreach (EventHandler h in EventHandlers[e.GetEventType()])
            {
                // Send the event to be handled by the handler
                h.ProcessEvent(e);
            }
        }
    }
    public override void SetEventString(GEvent e)
    {
        object[] eArguments = e.Arguments;

        string unitName  = GetName((string)eArguments [0]);
        string enemyName = GetName((string)eArguments [1]);
        string rawName   = ((AttackController)GuidList.GetGameObject((string)e.Arguments [0]).GetComponent <AttackController>()).GetWeapon((string)e.Arguments [2]).GetWeaponType();

        rawName = rawName.Substring(0, rawName.Length - 4) + "name";

        string weaponName = LanguageManager.instance.getString("Weapons", rawName);

        string[] teams = { GetTeam((string)eArguments [0]) };

        string message = "Unit " + unitName + " targeted unit " + enemyName + " with " + weaponName + " and " + e.Arguments[3] + " shots.";

        string firerer = (string)eArguments [0];
        string firing  = (string)eArguments [2];
        int    shots   = (int)eArguments [3];
        Weapon w       = ((AttackController)GuidList.GetGameObject(firerer).GetComponent <AttackController>()).GetWeapon(firing);

        if (w.GetCurAmmo() != 0)
        {
            e.String = EventLog.FormatEventString(teams, e.Timestamp, message);
        }
        else
        {
            e.String = "Unit " + unitName + " tried targeting unit " + enemyName + " with " + weaponName + " and " + e.Arguments[3] + " shots and failed.";
            e.String = EventLog.FormatEventString(teams, e.Timestamp, e.String);
        }
    }
Exemplo n.º 12
0
    public override void HandleEvent(GEvent e)
    {
        //Player joining code

        ////Debug.Log ("User Join event handled");
        User NewUser = new User((PermissionLevel)e.Arguments [0], (MilitaryBranch)e.Arguments [1], (int)e.Arguments [2], (string)e.Arguments [3], (string)e.Arguments [4]);

        if (NewUser == null)
        {
            //Debug.Log("User is null.");
        }
        else
        {
            //Debug.Log("Attempting to add user " + NewUser.GetUsername() + " to team " + NewUser.TeamNumber);
        }
        Team team = Team.GetTeam((int)e.Arguments [2]);

        if (team == null)
        {
            //Debug.Log("Team is null.");
        }
        else
        {
            //Debug.Log(team.GetTeamName());
            team.AddUser(NewUser);
        }

        ////Debug.Log (Team.GetTeam ((int)e.Arguments [2]).GetUsers ().ToArray().ToString());
        ////Debug.Log (Team.GetUser((string)e.Arguments [3], (int)e.Arguments [2]).GetUsername());
        ////Debug.Log (Team.GetTeam ((int)e.Arguments [2]).GetUsers ().Count);
        ////Debug.Log (team.GetUsers ().ToArray().ToString());
        ////Debug.Log (team.GetUsers ().Count);
    }
Exemplo n.º 13
0
        public static bool Load(UnityModManager.ModEntry modEntry)
        {
            #region InitBase

            var harmony = HarmonyInstance.Create(modEntry.Info.Id);
            harmony.PatchAll(Assembly.GetExecutingAssembly());

            Logger = modEntry.Logger;

            modEntry.OnToggle = OnToggle;
            modEntry.OnGUI    = OnGUI;

            #endregion

            dataPath = Assembly.GetExecutingAssembly().Location;
            dataPath = Path.Combine(dataPath.Substring(0, dataPath.LastIndexOf('\\')), "Event_Date.txt");

            if (File.Exists(dataPath))
            {
                Logger.Log(dataPath);
                DateFile.EventMethodManager.RegisterEventBase(typeof(EventExtentionHandle));
            }

            GEvent.AddOneShot(eEvents.LoadedSavedAndBaseData, (args) =>
            {
                LoadDataText(dataPath, ref DateFile.instance.eventDate);
                Logger.Log($"{DateFile.instance.eventDate[50000][0]},{string.Join(",",DateFile.instance.eventDate[50000].SelectMany(t=>t.Value))}");
                Logger.Log($"{DateFile.instance.eventDate[900100004][0]},{string.Join(",",DateFile.instance.eventDate[900100004].SelectMany(t=>t.Value))}");
                Logger.Log($"{DateFile.instance.eventDate[500000001][0]},{string.Join(",",DateFile.instance.eventDate[500000001].SelectMany(t=>t.Value))}");
                Logger.Log($"{DateFile.instance.eventDate[500000002][0]},{string.Join(",",DateFile.instance.eventDate[500000002].SelectMany(t=>t.Value))}");
            });

            return(true);
        }
Exemplo n.º 14
0
        private int DrawTreeTimeline(GPEditor.TimelineWindow.TreeNode node, int level)
        {
            if (object.Equals(node, null) || string.IsNullOrEmpty(node.name))
            {
                return(level);
            }
            treeIndex2++;
            EditorGUILayout.BeginHorizontal();
            GEvent evt = node.evt;

            if (evt == curEvent)
            {
                GUI.contentColor = Color.green;
            }
            else
            {
                GUI.contentColor = Color.white;
            }
            GEventStyle tStyle           = evt.mStyle;
            FrameRange  validRange       = evt.GetMaxFrameRange();
            FrameRange  rang             = tStyle.range;
            float       sliderStartFrame = rang.Start;
            float       sliderEndFrame   = rang.End;

            EditorGUI.BeginChangeCheck();
            float allW   = position.width - 150f;
            float evtW   = allW * (float)validRange.Length / evt.root.Length;
            float startX = allW * (float)validRange.Start / evt.root.Length;

            GUILayout.Space(startX);
            if (GUILayout.Button(tStyle.Attr.name, GUILayout.Width(60f)))
            {
                SetSelect(node);
            }
            GUILayout.Label(validRange.Start.ToString(), GUILayout.Width(30f));
            EditorGUILayout.MinMaxSlider(ref sliderStartFrame, ref sliderEndFrame, validRange.Start, validRange.End, GUILayout.Width(evtW));
            GUILayout.Label(validRange.End.ToString(), GUILayout.Width(30f));
            if (EditorGUI.EndChangeCheck())
            {
                rang.Start        = (int)sliderStartFrame;
                rang.End          = (int)sliderEndFrame;
                tStyle.range      = rang;
                rootNode.isChange = true;
                evt.OnStyleChange();
                SetSelect(node);
            }
            EditorGUILayout.EndHorizontal();
            EventType eType = Event.current.type;

            if (node.Length == 0)
            {
                return(level);
            }
            for (int i = 0; i < node.childs.Count; i++)
            {
                DrawTreeTimeline(node.childs[i], level + 1);
            }
            return(level);
        }
Exemplo n.º 15
0
    public override void HandleEvent(GEvent e)
    {
        // weather change code

        int weatherIndex = (int)e.Arguments[0];

        GlobalSettings.SetCurrentWeatherIndex(weatherIndex);
    }
Exemplo n.º 16
0
 public void SetEvent(GEvent tl)
 {
     this.evt = tl;
     for (int i = 0; i < this.childs.Count; i++)
     {
         this.childs[i].SetEvent(tl.GetEvents()[i]);
     }
 }
Exemplo n.º 17
0
    void GetEvent(string e)
    {
        MemoryStream    m    = new MemoryStream(Convert.FromBase64String(e));
        BinaryFormatter b    = new BinaryFormatter();
        GEvent          test = (GEvent)b.Deserialize(m);

        EventManager.Instance.AddEvent(test);
    }
    public override void HandleEvent(GEvent e)
    {
        object[] args = e.Arguments;

        GameObject go = GuidList.GetGameObject((string)args[0]) as GameObject;
        Controller c  = go.GetComponent((string)args[1]) as Controller;

        c.SetValue((string)args[2], args[3]);
    }
Exemplo n.º 19
0
        public void Start()
        {
            if (_cleanPeriod > 0)
            {
                StartSchedule(_cleanPeriod);
            }

            GEvent.Attach(TRY_UNLOAD, OnTryUnload, null);
        }
Exemplo n.º 20
0
 // Use this for initialization
 void Start()
 {
     msgContent.text = "";
     localIP.text    = string.Format("本机IP:{0}", NetUtils.GetSelfIP4Address());
     btnStop.gameObject.SetActive(false);
     AddMsg(localIP.text + ":start up....");
     AddMsg("当前网络类型:" + Application.internetReachability.ToString());
     GEvent.Add(eEvent.AddMsg, OnAddMsgEvent);
 }
Exemplo n.º 21
0
        protected GUIContainer()
            : base()
        {
            components=	new FList<GUIComponent>();
            focusedComp=	null;

            bEComponents=	false;

            e_components=	null;
        }
Exemplo n.º 22
0
    public override void SetEventString(GEvent e)
    {
        object[] eArguments = e.Arguments;

        string[] teams = Team.GetTeamNames().ToArray();

        string message = "Player " + eArguments [0] + " has left the game";

        e.String = EventLog.FormatEventString(teams, e.Timestamp, message);
    }
Exemplo n.º 23
0
    public override void SetEventString(GEvent e)
    {
        object[] eArguments = e.Arguments;

        string[] teams = Team.GetTeamNames().ToArray();

        string message = string.Format("{3} joined the game as a(n) {0}", eArguments);

        e.String = EventLog.FormatEventString(teams, e.Timestamp, message);
    }
Exemplo n.º 24
0
    public override void SetEventString(GEvent e)
    {
        object[] eArguments = e.Arguments;

        string[] teams = Team.GetTeamNames().ToArray();

        string message = "Weather changed to " + Weather.GetWeatherType((int)eArguments [0]);

        e.String = EventLog.FormatEventString(teams, e.Timestamp, message);
    }
    public override void HandleEvent(GEvent e)
    {
        //Call EmbarkerController.EmbarkEventHelper(string TargetGuid, string EmbarkerGuid);
        String SmallerUnitGuid = (string)e.Arguments [0];
        String SuperUnitGuid   = (string)e.Arguments [1];

        EmbarkerController smaller = GuidList.GetGameObject(SmallerUnitGuid).GetComponent <EmbarkerController>();

        smaller.EmbarkEventHelper(SuperUnitGuid, SmallerUnitGuid);
    }
Exemplo n.º 26
0
        static void Main(string[] args)
        {
            // 코드 생성
            GEntry entry = new GEntry();

            GVariable var = new GVariable("valueA");
            GDefine   def = new GDefine(var);

            entry.Append(def);

            GEvent main     = new GEvent(new GCommand("this", "Loaded", typeof(void), GCommand.CommandType.Event));
            GSet   setValue = new GSet(var, new GNumberConst(5));

            main.Append(setValue);

            GIf ifCheck = new GIf(new GCompare(var, GCompare.ConditionType.GREATER_THEN, new GNumberConst(3)));

            ifCheck.Append(
                new GVoidCall(
                    new GCommand("Console", "WriteLine", typeof(void), GCommand.CommandType.Call),
                    new GObject[] { new GStringCat(new GStringConst("A"), new GConvertNumberToString(new GNumberConst(5))) }
                    )
                );

            main.Append(ifCheck);
            entry.Append(main);

            // 생성된 코드 컴파일
            string source     = entry.ToSource();
            string resultFile = Path.GetTempFileName();

            GCompiler        compile = new GCompiler(source);
            GCompilerResults result  = compile.Build(resultFile);

            Console.WriteLine(result.Source);

            // 코드 컴파일 결과 분석
            if (result.IsSuccess)
            {
                // 컴파일 성공
                // 컴파일된 시나리오 실행
                Console.WriteLine("컴파일 성공");
            }
            else
            {
                // 컴파일 실패
                // 컴파일 오류 출력
                foreach (CompilerError error in result.Results.Errors)
                {
                    Console.WriteLine("컴파일 오류 : " + error.Line + " - " + error.ErrorNumber + ":" + error.ErrorText);
                }
            }

            Console.ReadLine();
        }
Exemplo n.º 27
0
    public override void HandleEvent(GEvent e)
    {
        String SmallerUnitGuid = Convert.ToString(e.Arguments [0]);
        //Debug.Log ("YO IM HERE: " + SmallerUnitGuid);
        Point              p       = (Point)e.Arguments [1];
        Vector3            pos     = new Vector3(p.x, p.y, p.z);
        string             parent  = Convert.ToString(e.Arguments [2]);
        EmbarkerController smaller = (EmbarkerController)GuidList.GetGameObject(SmallerUnitGuid).GetComponent <EmbarkerController>();

        smaller.LaunchEventHelper(SmallerUnitGuid, pos, parent);
    }
Exemplo n.º 28
0
 /// <summary>
 /// 从对象池里获取GEvent
 /// </summary>
 /// <param name="type"></param>
 /// <param name="data"></param>
 /// <returns></returns>
 public static GEvent CreateEvent(string type, object data = null)
 {
     GEvent evt = _pool.GetObject() as GEvent;//使用对象池,避免频繁实例,触发GCloc.
     if (evt == null)
     {
         Log.info("事件管理器[EventManager] 当前事件个数:" + _pool.ToString());
     }
     evt.type = type;
     evt.data = data;
     return evt;
 }
Exemplo n.º 29
0
    public void SendEvent(GEvent e)
    {
        MemoryStream    m = new MemoryStream();
        BinaryFormatter b = new BinaryFormatter();

        b.Serialize(m, e);
        string test = Convert.ToBase64String(m.GetBuffer());

        networkView.RPC("GetEvent", RPCMode.Server, test);
        //Debug.Log ("Sent event of type " + e.EventType.ToString () + " with timestamp " + e.Timestamp.ToString () + " and " + e.Arguments.Length + " argument(s)");
    }
Exemplo n.º 30
0
    public override void SetEventString(GEvent e)
    {
        object[] eArguments = e.Arguments;
        string   unitName   = GetName(Convert.ToString(eArguments[0]));
        string   superName  = GetName(Convert.ToString(eArguments [2]));

        string[] teams = { GetTeam(Convert.ToString(eArguments [0])) };

        string message = "Unit " + unitName + " unembarked off of unit " + superName;

        e.String = EventLog.FormatEventString(teams, e.Timestamp, message);
    }
    public override void SetEventString(GEvent e)
    {
        object[] eArguments = e.Arguments;

        string unitName = GetName((string)eArguments [0]) + " " + eArguments [0];

        string[] teams = { GetTeam((string)eArguments [0]) };

        string message = "Admin has modified statistics of unit " + unitName;

        e.String = EventLog.FormatEventString(teams, e.Timestamp, message);
    }
Exemplo n.º 32
0
        public GUIButton(GUISprite sprite)
            : base(sprite)
        {
            pText=	"BUTTON";
            pHoverTexture=	pTexture;
            pPressedTexture=	pTexture;
            pDisabledTexture=	pTexture;
            pHoverColor=	new Color(255, 128, 0);
            pPressedColor=	new Color(0, 128, 255);
            if(pSprite!= null)
            {
                pTexBounds=	pSprite.textureBounds;
                pHoverTexBounds=	pSprite.textureBounds;
                pPressedTexBounds=	pSprite.textureBounds;
                pDisabledTexBounds=	pSprite.textureBounds;
            }
            else
            {
                pTexBounds=	new Rectangle(0f, 0f, 1f, 1f);
                pHoverTexBounds=	new Rectangle(0f, 0f, 1f, 1f);
                pPressedTexBounds=	new Rectangle(0f, 0f, 1f, 1f);
                pDisabledTexBounds=	new Rectangle(0f, 0f, 1f, 1f);
            }

            bEText=	false;
            bETexHover=	false;
            bETexPressed=	false;
            bETexDisabled=	false;
            bEFgColor=	false;
            bEHoverColor=	false;
            bEPressedColor=	false;
            bEHoverTexBounds=	false;
            bEPressedTexBounds=	false;
            bEDisabledTexBounds=	false;

            e_text=	null;
            e_texHover=	null;
            e_texPressed=	null;
            e_texDisabled=	null;
            e_fgColor=	null;
            e_hoverColor=	null;
            e_pressedColor=	null;
            e_hoverTexBounds=	null;
            e_pressedTexBounds=	null;
            e_disabledTexBounds=	null;
        }