private void onSpriteLeaveZone(GameEvent e) { Variant data = e.data; foreach (uint iid in data["iidary"]._arr) { if (!_monInfos.ContainsKey(iid)) { continue; } _monInfos.Remove(iid); if (_monWaitCreateInfos.ContainsKey(iid)) { _monWaitCreateInfos.Remove(iid); } if (!_mons.ContainsKey(iid)) { continue; } LGAvatarMonster ct = _mons[iid]; _mons.Remove(iid); ct.dispose(); } }
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._monInfos.ContainsKey(key); if (!flag) { this._monInfos.Remove(key); bool flag2 = this._monWaitCreateInfos.ContainsKey(key); if (flag2) { this._monWaitCreateInfos.Remove(key); } bool flag3 = !this._mons.ContainsKey(key); if (!flag3) { LGAvatarMonster lGAvatarMonster = this._mons[key]; this._mons.Remove(key); lGAvatarMonster.dispose(); } } } } }
public LGAvatarMonster getNearMon(int range = 1000) { bool flag = this._mons == null || this._mons.Values == null; LGAvatarMonster result; if (flag) { result = null; } else { LGAvatarMonster lGAvatarMonster = null; float num = 1000f; Vector3 unityPos = this.lgMainPlayer.unityPos; float x = unityPos.x; float z = unityPos.z; foreach (LGAvatarMonster current in this._mons.Values) { bool flag2 = current.IsDie(); if (!flag2) { bool flag3 = current.IsCollect(); if (!flag3) { Vector3 unityPos2 = current.unityPos; float num2 = Math.Abs(unityPos2.x - x) + Math.Abs(unityPos2.y - z); bool flag4 = num2 > (float)range; if (!flag4) { bool flag5 = lGAvatarMonster == null && !current.IsDie(); if (flag5) { lGAvatarMonster = current; num = num2; } else { bool flag6 = num > num2 && !current.IsDie(); if (flag6) { lGAvatarMonster = current; num = num2; } } } } } } result = lGAvatarMonster; } return(result); }
public void createMon(Variant m) { int monid = m["mid"]._int; uint iid = m["iid"]._uint; // debug.Log("!!createMon!! monid:" + monid + " " + iid + " " + debug.count); Variant b = MonsterConfig.instance.conf; Variant mconf = b["monsters"][monid + ""]; if (mconf == null) { GameTools.PrintError(" mon[ " + monid + " ] no conf ERR!"); return; } m["x"] = m["x"] / GameConstant.PIXEL_TRANS_UNITYPOS; m["y"] = m["y"] / GameConstant.PIXEL_TRANS_UNITYPOS; LGAvatarMonster ct = new LGAvatarMonster(this.g_mgr); _mons[iid] = ct; //if( info.ContainsKey( "owner_cid" ) ) //{ // GameTools.PrintNotice("mon todo owner_cid!"); //} //if( info.ContainsKey("moving") ) //{ // GameTools.PrintNotice("mon todo moving!"); //} //if( info.ContainsKey( "atking" ) ) //{ // GameTools.PrintNotice("mon todo atking!"); //} //if( info.ContainsKey( "states" ) ) //{ // GameTools.PrintNotice("mon todo states!"); //} ct.initData(m); ct.init(); this.g_mgr.g_processM.addRender(ct); // GameRoomMgr.getInstance().onMonsterEnterView(ct.grAvatar); }
private void onRespawn(GameEvent e) { Variant data = e.data; bool flag = !data.ContainsKey("iid"); if (!flag) { uint @uint = data["iid"]._uint; bool flag2 = !this._mons.ContainsKey(@uint); if (!flag2) { LGAvatarMonster lGAvatarMonster = this._mons[@uint]; lGAvatarMonster.Respawn(data); } } }
//public void on_attchange(Variant msgData) //{ // uint iid = msgData["iid"]._uint; // if( !_mons.ContainsKey( iid ) ) return; // LGAvatarMonster ct = _mons[ iid ]; // ct.onAttchange( msgData ); //} public LGAvatarMonster getNearMon(int range = 1000) { if (_mons == null || _mons.Values == null) { return(null); } LGAvatarMonster charMon = null; float curdis = 1000f; Vector3 vec = lgMainPlayer.unityPos; float x = vec.x; float y = vec.z; foreach (LGAvatarMonster ct in _mons.Values) { if (ct.IsDie()) { continue; } if (ct.IsCollect()) { continue; } Vector3 vecmon = ct.unityPos; float dis = Math.Abs(vecmon.x - x) + Math.Abs(vecmon.y - y); if (dis > range) { continue; } if (charMon == null && !ct.IsDie()) { charMon = ct; curdis = dis; } // else if (Math.Abs((charMon.x - x) * (charMon.x - x)) + Math.Abs((charMon.y - y) * (charMon.y - y)) > Math.Abs((ct.x - x) * (ct.x - x)) + Math.Abs((ct.y - y) * (ct.y - y))) else if (curdis > dis && !ct.IsDie()) { charMon = ct; curdis = dis; } } return(charMon); }
private void onRespawn(GameEvent e) { Variant info = e.data; if (!info.ContainsKey("iid")) { return; } uint iid = info["iid"]._uint; if (!_mons.ContainsKey(iid)) { return; } LGAvatarMonster mon = _mons[iid]; mon.Respawn(info); }
public void createMon(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(" mon[ " + @int + " ] no conf ERR!"); } else { m["x"] = m["x"] / 53.333f; m["y"] = m["y"] / 53.333f; LGAvatarMonster lGAvatarMonster = new LGAvatarMonster(this.g_mgr); this._mons[@uint] = lGAvatarMonster; lGAvatarMonster.initData(m); lGAvatarMonster.init(); this.g_mgr.g_processM.addRender(lGAvatarMonster, false); } }
public void onSelectMonster(LGAvatarMonster lga) { }