// 이동 정보 패킷 획득 함수 public void OnReceiveSkillPacket(PacketId id, byte[] data) { SkillPacket packet = new SkillPacket(data); SkillData skill = packet.GetPacket(); Debug.Log(skill + " 수신완료(스킬)."); // 수신 후 사용 예 // navAgent(moving.index).destinaion(new Vector3(moving.destX, moving.destY, moving.dextZ); }
// 스킬 정보를 상대에게 전송하는 함수 public void SendLocalSkillInfo(SkillData data) { // 패킷 붙힘. SkillPacket packet = new SkillPacket(data); // UDP 전송 networkManager.SendUnreliable <SkillData>(packet); Debug.Log("전송 " + data); }
internal void HandlePacket(SkillPacket packet, PacketSession peerSession) { Character findOne; if (!_characters.TryGetValue(packet.AttackeeObjectId, out findOne)) { return; } var newEffect = new Effect(findOne); _coro.AddEntry(newEffect.Update); _drawObjects.Add(newEffect); }
// 스킬 사용 정보 패킷 획득 함수 public void OnReceiveSkillPacket(PacketId id, byte[] data) { SkillPacket packet = new SkillPacket(data); SkillData skill = packet.GetPacket(); // Debug.Log(skill + " 수신완료(스킬)."); Vector3 pos = new Vector3(skill.posX, skill.posY, skill.posZ); Vector3 dir = new Vector3(skill.dirX, skill.dirY, skill.dirZ); Debug.Log((useCnt++) + " 스킬 사용한 놈 : " + skill.campNumber + " 캠프의 " + skill.index); // 2020 02 01상대 단말의 로컬 캐릭터가 스킬 사용했다는 정보를 내 단말에서 수신 한것이므로, 내 단말의 상대 캐릭터가 스킬사용했다고 해줘야함. GameManager.instance.ApplyFire(skill.campNumber, skill.isRobot, skill.index, pos, dir); }
public void Handle(SkillPacket packet, PacketSession peerSession) { // 한 대 맞으면 즉사한다. var attackeeObject = _context.RemoveGameObject(packet.AttackeeObjectId); if (attackeeObject == null) { return; } _context.BroadcastPacket(packet); // 1s 뒤에 해당 객체 삭제 패킷을 전달 const int despawnDelay = 1000; Task.Delay(despawnDelay).ContinueWith(_ => _context.BroadcastPacket(attackeeObject.ToDespawnPacket())); }
/// <summary> /// 스킬 정보를 상대방에게 전송하는 코드 /// </summary> /// <param name="isRobot">로봇이 사용한 공격인가?</param> /// <param name="index">로봇/영웅의 번호</param> /// <param name="dir">방향</param> public void SendLocalSkillInfo(int campNum, bool isRobot, int index, Vector3 pos, Vector3 dir) { // 이동정보 데이터 생성 후 정보 입력 SkillData skillData = new SkillData(); skillData.campNumber = campNum; skillData.isRobot = isRobot; skillData.index = index; skillData.posX = pos.x; skillData.posY = pos.y; skillData.posZ = pos.z; skillData.dirX = dir.x; skillData.dirY = dir.y; skillData.dirZ = dir.z; // Debug.Log("전송 " + skillData); // 생성자로 데이터에 패킷을 연결 SkillPacket packet = new SkillPacket(skillData); // UDP 전송 //networkManager.SendUnreliable<SkillData>(packet); networkManager.SendReliable <SkillData>(packet); }
public static void Game_Log_Req(InPacket lea, Client gc) { //int re = SearchBytes(lea.Content, new byte[] { 0x0 }); string[] data = lea.ReadString(0x100 /*re*/).Split(new[] { (char)0x20 }, StringSplitOptions.None); int encryptKey = int.Parse(data[1]); string username = data[2]; string password = data[4]; int selectCharacter = lea.ReadByte(); IPAddress hostid = lea.ReadIPAddress(); gc.SetAccount(new Account(gc)); try { gc.Account.Load(username); //var pe = new PasswordEncrypt(encryptKey); //string encryptPassword = pe.encrypt(gc.Account.Password, gc.RetryLoginCount > 0 ? password.ToCharArray() : null); if (password.Equals(gc.Account.Password)) { gc.Dispose(); Log.Error("Login Fail!"); } else { gc.Account.Characters = new List <Character>(); foreach (dynamic datum in new Datums("Characters").PopulateWith("id", "accountId = '{0}' ORDER BY position ASC", gc.Account.ID)) { Character character = new Character(datum.id, gc); character.Load(false); character.IP = hostid; gc.Account.Characters.Add(character); } gc.SetCharacter(gc.Account.Characters[selectCharacter]); } Log.Inform("Password = {0}", password); //Log.Inform("encryptKey = {0}", encryptKey); //Log.Inform("encryptPassword = {0}", encryptPassword); } catch (NoAccountException) { gc.Dispose(); Log.Error("Login Fail!"); } Character chr = gc.Character; chr.CharacterID = gc.CharacterID; MapFactory.AllCharacters.Add(chr); StatusPacket.UpdateHpMp(gc, 0, 0, 0, 0); GamePacket.FW_DISCOUNTFACTION(gc); StatusPacket.getStatusInfo(gc); InventoryPacket.getCharacterEquip(gc); SkillPacket.getSkillInfo(gc, chr.Skills.getSkills()); QuestPacket.getQuestInfo(gc, chr.Quests.getQuests()); GamePacket.getQuickSlot(gc, chr.Keymap); StoragePacket.getStoreInfo(gc); StoragePacket.getStoreMoney(gc); MapPacket.enterMapStart(gc); InventoryPacket.getInvenCash(gc); CashShopPacket.MgameCash(gc); CashShopPacket.GuiHonCash(gc); InventoryPacket.getInvenEquip(gc); InventoryPacket.getInvenEquip1(gc); InventoryPacket.getInvenEquip2(gc); InventoryPacket.getInvenSpend3(gc); InventoryPacket.getInvenOther4(gc); InventoryPacket.getInvenPet5(gc); }
public static void SkillLevelUp_Req(InPacket lea, Client gc) { byte Type = lea.ReadByte(); byte Slot = lea.ReadByte(); var chr = gc.Character; if (chr.SkillBonus < 1) { return; } List <Skill> s = chr.Skills.getSkills(); Skill sl = null; foreach (Skill skill in s) { if (skill.Type == Type && skill.Slot == Slot) { sl = skill; break; } } if (sl == null || (sl.SkillID == 1 && sl.SkillLevel + 1 > 5) || (sl.SkillID == 2 && sl.SkillLevel + 1 > 10) || (sl.SkillID == 3 && sl.SkillLevel + 1 > 20) || (sl.SkillID == 4 && sl.SkillLevel + 1 > 20) || sl.SkillLevel + 1 > 20) { return; } chr.SkillBonus--; sl.SkillLevel++; if (sl.SkillID == 10101 || sl.SkillID == 10201 || sl.SkillID == 10301 || sl.SkillID == 10401 || sl.SkillID == 10501 || sl.SkillID == 10102 || sl.SkillID == 10202 || sl.SkillID == 10302 || sl.SkillID == 10402 || sl.SkillID == 10502) { if (chr.Items[InventoryType.ItemType.Equip, (byte)InventoryType.EquipType.Weapon] != null) { int ItemID = chr.Items[InventoryType.ItemType.Equip, (byte)InventoryType.EquipType.Weapon].ItemID; int MaxAttack = 5; int Attack = 3; int MaxMagic = 4; int Magic = 4; MaxAttack += ((chr.Str - 3) * 2 + chr.Str / 5); MaxAttack += ((chr.Dex - 3) * 2 + chr.Dex / 5); Attack += ((chr.Dex - 3) * 1 + chr.Dex / 5); MaxMagic += ((chr.Int - 3) * 2 + chr.Int / 5); Magic += ((chr.Int - 3) * 2 + chr.Int / 5); // 技能攻擊力+、魔攻力+ if (InventoryType.Is劍(ItemID) && sl.SkillID == 10101) { chr.MaxAttack -= (short)(MaxAttack * 0.02 * (sl.SkillLevel - 1)); chr.Attack -= (short)(Attack * 0.02 * (sl.SkillLevel - 1)); chr.MaxAttack += (short)(MaxAttack * 0.02 * sl.SkillLevel); chr.Attack += (short)(Attack * 0.02 * sl.SkillLevel); } if (InventoryType.Is刀(ItemID) && sl.SkillID == 10102) { chr.MaxAttack -= (short)(MaxAttack * 0.03 * (sl.SkillLevel - 1)); chr.Attack -= (short)(Attack * 0.03 * (sl.SkillLevel - 1)); chr.MaxAttack += (short)(MaxAttack * 0.03 * sl.SkillLevel); chr.Attack += (short)(Attack * 0.03 * sl.SkillLevel); } if (InventoryType.Is手套(ItemID) && sl.SkillID == 10201) { chr.MaxAttack -= (short)(MaxAttack * 0.02 * (sl.SkillLevel - 1)); chr.Attack -= (short)(Attack * 0.02 * (sl.SkillLevel - 1)); chr.MaxAttack += (short)(MaxAttack * 0.02 * sl.SkillLevel); chr.Attack += (short)(Attack * 0.02 * sl.SkillLevel); } if (InventoryType.Is爪(ItemID) && sl.SkillID == 10202) { chr.MaxAttack -= (short)(MaxAttack * 0.03 * (sl.SkillLevel - 1)); chr.Attack -= (short)(Attack * 0.03 * (sl.SkillLevel - 1)); chr.MaxAttack += (short)(MaxAttack * 0.03 * sl.SkillLevel); chr.Attack += (short)(Attack * 0.03 * sl.SkillLevel); } if (InventoryType.Is扇(ItemID) && sl.SkillID == 10301) { chr.MaxMagic -= (short)(MaxMagic * 0.02 * (sl.SkillLevel - 1)); chr.Magic -= (short)(Magic * 0.02 * (sl.SkillLevel - 1)); chr.MaxMagic += (short)(MaxMagic * 0.02 * sl.SkillLevel); chr.Magic += (short)(Magic * 0.02 * sl.SkillLevel); } if (InventoryType.Is杖(ItemID) && sl.SkillID == 10302) { chr.MaxMagic -= (short)(MaxMagic * 0.03 * (sl.SkillLevel - 1)); chr.Magic -= (short)(Magic * 0.03 * (sl.SkillLevel - 1)); chr.MaxMagic += (short)(MaxMagic * 0.03 * sl.SkillLevel); chr.Magic += (short)(Magic * 0.03 * sl.SkillLevel); } if (InventoryType.Is斧(ItemID) && sl.SkillID == 10401) { chr.MaxAttack -= (short)(MaxAttack * 0.02 * (sl.SkillLevel - 1)); chr.Attack -= (short)(Attack * 0.02 * (sl.SkillLevel - 1)); chr.MaxAttack += (short)(MaxAttack * 0.02 * sl.SkillLevel); chr.Attack += (short)(Attack * 0.02 * sl.SkillLevel); } if (InventoryType.Is輪(ItemID) && sl.SkillID == 10402) { chr.MaxAttack -= (short)(MaxAttack * 0.03 * (sl.SkillLevel - 1)); chr.Attack -= (short)(Attack * 0.03 * (sl.SkillLevel - 1)); chr.MaxAttack += (short)(MaxAttack * 0.03 * sl.SkillLevel); chr.Attack += (short)(Attack * 0.03 * sl.SkillLevel); } //if (Skill.ContainsKey(10501) && InventoryType.Is(chr.Items[InventoryType.ItemType.Equip, (byte)InventoryType.EquipType.Weapon].ItemID)) //{ //} //if (Skill.ContainsKey(10502) && InventoryType.Is(chr.Items[InventoryType.ItemType.Equip, (byte)InventoryType.EquipType.Weapon].ItemID)) //{ //} StatusPacket.UpdateStat(gc); } } SkillPacket.updateSkillLevel(gc, chr.SkillBonus, Type, Slot, sl.SkillLevel); }