Example #1
0
    private void OnLoadUI(string uiName, UnityEngine.Object obj)
    {
        PendingViewInfo info = default(PendingViewInfo);

        for (int i = _waitingForLoadView.Count - 1; i >= 0; i--)
        {
            var pendingViewInfo = _waitingForLoadView[i];
            if (pendingViewInfo.UiName.Equals(uiName))
            {
                info = pendingViewInfo;
                _waitingForLoadView.RemoveAt(i);
                break;
            }
        }
        if (!info.Equals(default(PendingViewInfo)) && info.UiName.Equals(uiName))
        {
            GameObject go = UnityEngine.Object.Instantiate(obj) as GameObject;
            go.transform.parent = Main.SP.UIParent;
            var v = Activator.CreateInstance(info.UiType) as View;
            _views.Add(v);
            v.name = uiName;
            v.Init(go);
            v.Show(info.Param);
            FireEvent((int)UIEventList.OnShowUI, this, EventGroup.NewArg <EventSingleArgs <View>, View>(v));
        }
    }
Example #2
0
 public void CancelSkill()
 {
     this.so.EventGroup.FireEvent((int)Event.Cancelskill, so, EventGroup.NewArg <EventSingleArgs <string>, string>(RunningSkill.SourceData.path));
     RunningSkill.Cancel();
     Pool.SP.Recycle(RunningSkill);
     RunningSkill = null;
 }
Example #3
0
    private void HideUI(object sender, EventMsg e)
    {
        var v = e as EventSingleArgs <View>;

        v.value.OnHide();
        FireEvent((int)UIEventList.OnHideUI, this, EventGroup.NewArg <EventSingleArgs <View>, View>(v.value));
    }
Example #4
0
        public void SendCommand(LockFrameCommand cmd)
        {
#if LocalDebug
            cmd.Execute();
            return;
#endif
            NetDataWriter w = new NetDataWriter(true);
            cmd.Serialize(w);
            EventDispatcher.FireEvent(UIEventList.SendNetMsg.ToInt(), this, EventGroup.NewArg <EventSingleArgs <NetDataWriter>, NetDataWriter>(w));
        }
Example #5
0
        public void SwitchScene(IScene battleScene)
        {
            if (CurrentScene != null)
            {
                CurrentScene.Destroy();
            }
            CurrentScene = battleScene;
            CurrentScene.Init();
            var arg = EventGroup.NewArg <EventSingleArgs <IScene> >();

            arg.value = battleScene;
            EventGroup.FireEvent((int)SceneManagerEvent.OnSwitchScene, this, arg);
        }
Example #6
0
        private void ReleaseSkill(string path, RuntimeData srd)
        {
            var skill = GetSkill(path);

            if (srd.receiver != null && skill.ForceFaceToTarget)
            {
                so.Forward = (srd.receiver.Position - so.Position).Normalize();
            }
            RunningSkill = Pool.SP.Get(typeof(RuntimeSkill)) as RuntimeSkill;
            RunningSkill.Init(skill, srd);
            RunningSkill.FinishAction = OnFinish;
            this.so.EventGroup.FireEvent((int)Event.Startskill, so, EventGroup.NewArg <EventSingleArgs <string>, string>(path));
        }
Example #7
0
 public void AddComponent(SceneObjectBaseComponent t)
 {
     for (int i = 0; i < _components.Count; i++)
     {
         if (_components[i].GetType() == t.GetType())
         {
             return;
         }
     }
     t.SceneObject = this;
     _components.Add(t);
     _components.Sort((a, b) => a.ExecuteOrder - b.ExecuteOrder);
     t.OnAdd();
     FireEvent((int)SceneObject.SceneObjectEvent.OnAddComponent, this, EventGroup.NewArg <EventSingleArgs <SceneObjectBaseComponent>, SceneObjectBaseComponent>(t));
 }
Example #8
0
        public override void Execute(SceneObject sender, SceneObject reciever, object data)
        {
            SceneObject so = null;

            if (playTarget == PlayTarget.SENDER)
            {
                so = sender;
            }
            else if (playTarget == PlayTarget.RECEIVER)
            {
                so = reciever;
            }
            so.EventGroup.FireEvent(SceneObject.SceneObjectEvent.Executedisplayaction.ToInt(), sender,
                                    EventGroup.NewArg <EventSingleArgs <DisplayAction>, DisplayAction>(this));
            base.Execute(sender, reciever, data);
        }
Example #9
0
 public override void OnTimeLineFinish(SceneObject sender, SceneObject reciever, object data)
 {
     if (stopCondition == StopCondition.TimelineEnd)
     {
         SceneObject so = null;
         if (playTarget == PlayTarget.SENDER)
         {
             so = sender;
         }
         else if (playTarget == PlayTarget.RECEIVER)
         {
             so = reciever;
         }
         so.EventGroup.FireEvent(SceneObject.SceneObjectEvent.Stopdisplayaction.ToInt(), sender,
                                 EventGroup.NewArg <EventSingleArgs <DisplayAction>, DisplayAction>(this));
     }
 }
Example #10
0
        public T AddComponent <T>() where T : SceneObjectBaseComponent
        {
            for (int i = 0; i < _components.Count; i++)
            {
                if (_components[i] is T)
                {
                    return(null);
                }
            }
            T t = Activator.CreateInstance <T>();

            t.SceneObject = this;
            _components.Add(t);
            _components.Sort((a, b) => a.ExecuteOrder - b.ExecuteOrder);
            t.OnAdd();
            FireEvent((int)SceneObject.SceneObjectEvent.OnAddComponent, this, EventGroup.NewArg <EventSingleArgs <SceneObjectBaseComponent>, SceneObjectBaseComponent>(t));
            return(t);
        }
Example #11
0
    // Use this for initialization
    void Start()
    {
        DonotDestroy();
        Logic.LogicCore.SP.Init();
        u3dSceneManager = new U3DSceneManager();
        Logic.LogicCore.SP.SceneManager.SwitchScene(new HotFixScene());
        EventDispatcher.FireEvent(UIEventList.ShowUI.ToInt(), this, EventGroup.NewArg <EventThreeArgs <string, Type, object>, string, Type, object>("BattleUI.prefab", typeof(UIBattle), null));
        //AssetResources.LoadAsset("skill_1.bytes", (s, o) =>
        //{
        //    var ta = o as TextAsset;
        //    Debug.LogError(ta.text);
        //});
        //   EventDispatcher.FireEvent(UIEventList.ShowUI.ToInt(), this, EventGroup.NewArg<EventThreeArgs<string, Type, object>, string, Type, object>("UIBattle.prefab", typeof(UIBattle), null));
        //EventDispatcher.FireEvent(UIEventList.ShowUI.ToInt(), this, EventGroup.NewArg<EventThreeArgs<string, Type, object>, string, Type, object>("Hud.prefab", typeof(HudView), null));
#if UNITY_ANDROID
        FingerGestures.OnTap += CheckOpenLogWindow;
#endif
    }
Example #12
0
 public void Add(AttributeType at, Operation op, long value)
 {
     if (_attributes.ContainsKey((int)at))
     {
         var attr     = _attributes[(int)at];
         var oldValue = attr.FinalValue;
         attr.Add(op, value);
         EventGroup.FireEvent((int)Event.OnAttributechange, this, EventGroup.NewArg <EventSingleArgs <AttributeMsg>, AttributeMsg>(new AttributeMsg()
         {
             At       = at,
             NewValue = attr.FinalValue,
             OldValue = oldValue
         }));
     }
     else
     {
         Debug.LogError(at + " Key not exsit");
     }
 }
Example #13
0
 public void Start <T>() where T : State, IPool
 {
     if (this.State != null)
     {
         if (this.State is T)
         {
             return;
         }
         else
         {
             this.State.Stop();
             SceneObject.EventGroup.FireEvent((int)Event.StopState, this, EventGroup.NewArg <EventSingleArgs <State>, State>(this.State));
         }
     }
     this.State             = Pool.SP.Get <T>() as State;
     this.State.SceneObject = SceneObject;
     this.State.Start();
     SceneObject.EventGroup.FireEvent((int)Event.ExecuteState, this, EventGroup.NewArg <EventSingleArgs <State>, State>(this.State));
 }
Example #14
0
        public void SetBase(AttributeType at, long value)
        {
            CharacterAttribute attr;

            if (_attributes.TryGetValue((int)at, out attr))
            {
                var oldValue = attr.FinalValue;
                _attributes[(int)at].SetBase(value);
                EventGroup.FireEvent((int)Event.OnAttributechange, this, EventGroup.NewArg <EventSingleArgs <AttributeMsg>, AttributeMsg>(new AttributeMsg()
                {
                    At       = at,
                    NewValue = attr.FinalValue,
                    OldValue = oldValue
                }));
            }
            else
            {
                attr = New(at, value);
            }
        }
Example #15
0
 public void RemoveComponent <T>() where T :  SceneObjectBaseComponent
 {
     for (int i = 0; i < _components.Count; i++)
     {
         if (_components[i] is T)
         {
             FireEvent((int)SceneObject.SceneObjectEvent.OnRemoveComponent, this, EventGroup.NewArg <EventSingleArgs <SceneObjectBaseComponent>, SceneObjectBaseComponent>((T)_components[i]));
             _components[i].OnRemove();
             _components.RemoveAt(i);
         }
     }
 }
Example #16
0
 internal void OnFinish()
 {
     so.EventGroup.FireEvent((int)Event.Endskill, so, EventGroup.NewArg <EventSingleArgs <string>, string>(RunningSkill.SourceData.path));
     Pool.SP.Recycle(RunningSkill);
     RunningSkill = null;
 }
Example #17
0
 void Awake()
 {
     this.OnMoveStart    = (() => { LogicCore.SP.EventGroup.FireEvent((int)LogicCore.LogicCoreEvent.OnJoystickStart, this, null); });
     this.OnMove         = ((v) => { LogicCore.SP.EventGroup.FireEvent((int)LogicCore.LogicCoreEvent.OnJoystickMove, this, EventGroup.NewArg <EventSingleArgs <Vector2>, Vector2>(v)); });
     this.OnMoveEnd      = (() => { LogicCore.SP.EventGroup.FireEvent((int)LogicCore.LogicCoreEvent.OnJoystickEnd, this, null); });
     cachedRectTransform = transform as RectTransform;
 }
Example #18
0
        public override void Execute(SceneObject sender, SceneObject reciever, object data)
        {
            base.Execute(sender, reciever, data);
            var character = reciever;

            if (character == null)
            {
            }
            else
            {
                var damage = Damage.value * FixedMath.One;
                sender.EventGroup.FireEvent(SceneObject.SceneObjectEvent.OnBeforeAttackOther.ToInt(), sender, EventGroup.NewArg <EventTwoArgs <SceneObject, long>, SceneObject, long>(reciever, damage));
                reciever.EventGroup.FireEvent(SceneObject.SceneObjectEvent.OnBeforeBeAttacked.ToInt(), sender, EventGroup.NewArg <EventSingleArgs <long>, long>(damage));
                character.Hp = character.Hp.Sub(damage);
                sender.EventGroup.FireEvent(SceneObject.SceneObjectEvent.OnAfterAttackOther.ToInt(), sender, EventGroup.NewArg <EventTwoArgs <SceneObject, long>, SceneObject, long>(reciever, damage));
                reciever.EventGroup.FireEvent(SceneObject.SceneObjectEvent.OnAfterBeAttacked.ToInt(), sender, EventGroup.NewArg <EventSingleArgs <long>, long>(damage));
            }
        }
Example #19
0
 public void Hide()
 {
     FireEvent((int)UIEventList.HideUI, this, EventGroup.NewArg <EventSingleArgs <View>, View>(this));
     OnHide();
 }
Example #20
0
    void OnGUI()
    {
        return;

        var bs = LogicCore.SP.SceneManager.CurrentScene as BattleScene;

        GUILayout.BeginHorizontal();
        if (ShowShortCut && bs != null)
        {
            GUILayout.BeginVertical();
            GUILayout.Label(LogicCore.SP.LockFrameMgr.LocalFrameCount + "  " +
                            LogicCore.SP.LockFrameMgr.ServerFrameCount);
            if (GUILayout.Button("NewMainPlayer", GUILayout.Width(150), GUILayout.Height(70)))
            {
                LogicCore.SP.LockFrameMgr.SendCommand(new CreateMainPlayerCommand());
            }
            if (GUILayout.Button("NewP"))
            {
                LogicCore.SP.LockFrameMgr.SendCommand(new CreatePlayerCommand());
            }
            if (GUILayout.Button("NewNpc"))
            {
                //if (MainPlayer.SP != null)
                //{
                //    LogicCore.SP.LockFrameMgr.SendCommand(new CreateNpcCommand() { NpcId = 1001, Sender = MainPlayer.SP.Id});
                //}
                //else
                //    LogicCore.SP.LockFrameMgr.SendCommand(new CreateNpcCommand() {NpcId = 1001});
            }

            if (GUILayout.Button("CreateBarack1"))
            {
                //var mp = bs.GetObject<MainPlayer>();
                // var mapItem = LogicCore.SP.SceneManager.CurrentScene.MapConfig.MapDic[MapItemId] as MapBuildingItem;
                //LogicCore.SP.LockFrameMgr.SendCommand(new CreateBuildingCommand {BuildingId = 1002, Sender = mp.Id});
            }
            if (GUILayout.Button("CreateBarack2"))
            {
                //var mp = bs.GetObject<MainPlayer>();
                //if (mp != null)
                //    LogicCore.SP.LockFrameMgr.SendCommand(new CreateBuildingCommand
                //    {
                //        BuildingId = 1002,
                //        Sender = mp.Id
                //    });
                //else
                //{
                //    LogicCore.SP.LockFrameMgr.SendCommand(new CreateBuildingCommand {BuildingId = 1002});
                //}
            }
            if (GUILayout.Button("SaveLog"))
            {
                NetDataWriter w = new NetDataWriter();
                w.Put((short)1);
                EventDispatcher.FireEvent(UIEventList.SendNetMsg.ToInt(), this,
                                          EventGroup.NewArg <EventSingleArgs <NetDataWriter>, NetDataWriter>(w));
            }
#if UNITY_ANDROID
            if (GUILayout.Button("OpenLogWindow", GUILayout.Width(150), GUILayout.Height(70)))
            {
                _showLogWindow = !_showLogWindow;
            }
#endif
            GUILayout.EndVertical();
        }
#if UNITY_ANDROID
        if (_showLogWindow)
        {
            _offset = GUILayout.BeginScrollView(_offset, GUILayout.Width(400), GUILayout.Height(500));
            for (int i = 0; i < log.Count; i++)
            {
                GUILayout.Label(log[log.Count - i - 1]);
            }
            GUILayout.EndScrollView();
        }
#endif
        GUILayout.EndHorizontal();
        //if (GUI.Button(new Rect(0, 0, 300, 50), "GC"))
        //{
        //    System.GC.Collect();
        //    Resources.UnloadUnusedAssets();
        //}
        //if (GUI.Button(new Rect(0, 50, 300, 50), "Unload"))
        //{
        //    Resource.UnloadBundles();
        //}
    }
Example #21
0
    public void OnNetworkReceive(NetPeer peer, NetDataReader reader)
    {
        var msgId = reader.GetShort();

        EventDispatcher.FireEvent(msgId, this, EventGroup.NewArg <EventSingleArgs <NetDataReader>, NetDataReader>(reader));
    }