예제 #1
0
        private void onSpriteLeaveZone(GameEvent e)
        {
            Variant data = e.data;

            using (List <Variant> .Enumerator enumerator = data["iidary"]._arr.GetEnumerator())
            {
                while (enumerator.MoveNext())
                {
                    uint key  = enumerator.Current;
                    bool flag = !this._heroInfos.ContainsKey(key);
                    if (!flag)
                    {
                        this._heroInfos.Remove(key);
                        bool flag2 = this._heroWaitCreateInfos.ContainsKey(key);
                        if (flag2)
                        {
                            this._heroWaitCreateInfos.Remove(key);
                        }
                        bool flag3 = !this._heros.ContainsKey(key);
                        if (!flag3)
                        {
                            LGAvatarHero lGAvatarHero = this._heros[key];
                            this._heros.Remove(key);
                            lGAvatarHero.dispose();
                        }
                    }
                }
            }
        }
예제 #2
0
        public void createHero(Variant m)
        {
            int     @int    = m["mid"]._int;
            uint    @uint   = m["iid"]._uint;
            Variant conf    = MonsterConfig.instance.conf;
            Variant variant = conf["monsters"][string.Concat(@int)];
            bool    flag    = variant == null;

            if (flag)
            {
                GameTools.PrintError(" hero[ " + @int + " ] no conf ERR!");
            }
            else
            {
                LGAvatarHero lGAvatarHero = new LGAvatarHero(this.g_mgr);
                this._heros[@uint] = lGAvatarHero;
                bool flag2 = m["owner_cid"] == ModelBase <PlayerModel> .getInstance().cid;

                if (flag2)
                {
                    lGAvatarHero.addEffect("heroenterworld" + this.herologhtIdx, "hero_enterscence", true);
                }
                lGAvatarHero.initData(m);
                lGAvatarHero.init();
                this.g_mgr.g_processM.addRender(lGAvatarHero, false);
            }
        }
예제 #3
0
        public void createHero(Variant m)
        {
            int  heroid = m["mid"]._int;
            uint iid    = m["iid"]._uint;


            Variant b     = MonsterConfig.instance.conf;
            Variant mconf = b["monsters"][heroid + ""];

            if (mconf == null)
            {
                GameTools.PrintError(" hero[ " + heroid + " ] no conf ERR!");
                return;
            }

            LGAvatarHero ct = new LGAvatarHero(this.g_mgr);

            _heros[iid] = ct;

            if (m["owner_cid"] == PlayerModel.getInstance().cid)
            {
                ct.addEffect("heroenterworld" + herologhtIdx, "hero_enterscence", true);
            }

            ct.initData(m);
            ct.init();



            this.g_mgr.g_processM.addRender(ct);
        }
예제 #4
0
        private void onSpriteLeaveZone(GameEvent e)
        {
            Variant data = e.data;

            foreach (uint iid in data["iidary"]._arr)
            {
                if (!_heroInfos.ContainsKey(iid))
                {
                    continue;
                }
                _heroInfos.Remove(iid);

                if (_heroWaitCreateInfos.ContainsKey(iid))
                {
                    _heroWaitCreateInfos.Remove(iid);
                }


                if (!_heros.ContainsKey(iid))
                {
                    continue;
                }
                LGAvatarHero ct = _heros[iid];
                _heros.Remove(iid);
                ct.dispose();
            }
        }
예제 #5
0
        public LGAvatarHero getNearHero()
        {
            bool         flag = this._heros == null || this._heros.Values == null;
            LGAvatarHero result;

            if (flag)
            {
                result = null;
            }
            else
            {
                LGAvatarHero lGAvatarHero = null;
                float        num          = 1000f;
                int          num2         = this.lgMainPlayer.viewInfo["x"];
                int          num3         = this.lgMainPlayer.viewInfo["y"];
                foreach (LGAvatarHero current in this._heros.Values)
                {
                    bool flag2 = current.IsDie();
                    if (!flag2)
                    {
                        bool flag3 = current.IsCollect();
                        if (!flag3)
                        {
                            float num4  = Math.Abs(current.x - (float)num2) + Math.Abs(current.y - (float)num3);
                            bool  flag4 = num4 > 1000f;
                            if (!flag4)
                            {
                                bool flag5 = lGAvatarHero == null;
                                if (flag5)
                                {
                                    lGAvatarHero = current;
                                    num          = num4;
                                }
                                else
                                {
                                    bool flag6 = num > num4;
                                    if (flag6)
                                    {
                                        lGAvatarHero = current;
                                        num          = num4;
                                    }
                                }
                            }
                        }
                    }
                }
                result = lGAvatarHero;
            }
            return(result);
        }
예제 #6
0
        private void onRespawn(GameEvent e)
        {
            Variant data = e.data;
            bool    flag = !data.ContainsKey("iid");

            if (!flag)
            {
                uint @uint = data["iid"]._uint;
                bool flag2 = !this._heros.ContainsKey(@uint);
                if (!flag2)
                {
                    LGAvatarHero lGAvatarHero = this._heros[@uint];
                    lGAvatarHero.Respawn(data);
                }
            }
        }
예제 #7
0
        private void onRespawn(GameEvent e)
        {
            Variant info = e.data;

            if (!info.ContainsKey("iid"))
            {
                return;
            }
            uint iid = info["iid"]._uint;

            if (!_heros.ContainsKey(iid))
            {
                return;
            }
            LGAvatarHero hero = _heros[iid];

            hero.Respawn(info);
        }
예제 #8
0
        public LGAvatarHero getNearHero()
        {
            if (_heros == null || _heros.Values == null)
            {
                return(null);
            }
            LGAvatarHero charHero = null;
            float        curdis   = 1000f;
            int          x        = lgMainPlayer.viewInfo["x"];
            int          y        = lgMainPlayer.viewInfo["y"];

            foreach (LGAvatarHero ct in _heros.Values)
            {
                if (ct.IsDie())
                {
                    continue;
                }
                if (ct.IsCollect())
                {
                    continue;
                }

                float dis = Math.Abs(ct.x - x) + Math.Abs(ct.y - y);

                if (dis > 1000)
                {
                    continue;
                }

                if (charHero == null)
                {
                    charHero = ct;
                    curdis   = dis;
                }
                //  else if (Math.Abs((charHero.x - x) * (charHero.x - x)) + Math.Abs((charHero.y - y) * (charHero.y - y)) > Math.Abs((ct.x - x) * (ct.x - x)) + Math.Abs((ct.y - y) * (ct.y - y)))
                else if (curdis > dis)
                {
                    charHero = ct;
                    curdis   = dis;
                }
            }
            return(charHero);
        }