// C_Skill public void HandleSkill(Player player, C_Skill skillPacket) { if (player == null) { return; } ObjectInfo info = player.Info; if (info.PosInfo.State != CreatureState.Idle) { return; } // TODO : 스킬 사용가능한지 검증 // 통과 info.PosInfo.State = CreatureState.Skill; S_Skill skill = new S_Skill() { Info = new SkillInfo() }; skill.ObjectId = info.ObjectId; skill.Info.SkillId = skillPacket.Info.SkillId; // 유저가 보내준 스킬 Broadcast(player.CellPos, skill); Data.Skill skillData = null; if (DataManager.SkillDict.TryGetValue(skill.Info.SkillId, out skillData) == false) { return; } // 스킬 종류에 따른 로직 switch (skillData.skillType) { case SkillType.SkillAuto: // 평타 // 데미지 판정 Vector2Int skillPos = player.GetFrontCellPos(info.PosInfo.MoveDir); GameObject target = Map.Find(skillPos); if (target != null) { this.Push(target.OnDamaged, player, player.Info.StatInfo.Attack); } break; case SkillType.SkillProjectile: // 투사체 SpawnProjectile(player, skillData); break; case SkillType.SkillNone: break; default: return; } }
public void EnterGame(GameObject gameObject, bool randomPos) { if (gameObject == null) { return; } if (randomPos) { Vector2Int respawnPos; while (true) { respawnPos.x = _rand.Next(Map.MinX, Map.MaxX + 1); respawnPos.y = _rand.Next(Map.MinY, Map.MaxY + 1); if (Map.Find(respawnPos) == null) { gameObject.CellPos = respawnPos; break; } } } GameObjectType type = ObjectManager.GetObjectTypeById(gameObject.Id); if (type == GameObjectType.Player) { Player player = gameObject as Player; _players.Add(gameObject.Id, player); player.Room = this; player.RefreshAdditionalStat(); Map.ApplyMove(player, new Vector2Int(player.CellPos.x, player.CellPos.y)); GetZone(player.CellPos).Players.Add(player); // 본인한테 정보 전송 { S_EnterGame enterPacket = new S_EnterGame(); enterPacket.Player = player.Info; player.Session.Send(enterPacket); player.Vision.Update(); } } else if (type == GameObjectType.Monster) { Monster monster = gameObject as Monster; _monster.Add(gameObject.Id, monster); monster.Room = this; GetZone(monster.CellPos).Monsters.Add(monster); Map.ApplyMove(monster, new Vector2Int(monster.CellPos.x, monster.CellPos.y)); monster.Update(); } else if (type == GameObjectType.Projectile) { Projectile projectile = gameObject as Projectile; _Projectiles.Add(gameObject.Id, projectile); projectile.Room = this; GetZone(projectile.CellPos).Projectiles.Add(projectile); projectile.Update(); } // 타인한테 정보 전송 { S_Spawn spawnPacket = new S_Spawn(); spawnPacket.Objects.Add(gameObject.Info); Broadcast(gameObject.CellPos, spawnPacket); } }
public void HandleSkill(Player player, C_Skill skillPacket) { if (player == null) { return; } ObjectInfo info = player.Info; if (info.PosInfo.State != CreatureState.Idle) { return; } // TODO : 스킬 사용 가능 여부 체크 info.PosInfo.State = CreatureState.Skill; S_Skill skill = new S_Skill() { Info = new SkillInfo() }; skill.ObjectId = info.ObjectId; skill.Info.SkillId = skillPacket.Info.SkillId; Broadcast(player.CellPos, skill); Data.Skill skillData = null; if (DataManager.SkillDict.TryGetValue(skillPacket.Info.SkillId, out skillData) == false) { return; } switch (skillData.skillType) { case SkillType.SkillAuto: { Vector2Int skillPos = player.GetFrontCellPos(info.PosInfo.MoveDir); GameObject target = Map.Find(skillPos); if (target != null) { Console.WriteLine("Hit GameObject !"); } } break; case SkillType.SkillProjectile: { Arrow arrow = ObjectManager.Instance.Add <Arrow>(); if (arrow == null) { return; } arrow.Owner = player; arrow.Data = skillData; arrow.PosInfo.State = CreatureState.Moving; arrow.PosInfo.MoveDir = player.PosInfo.MoveDir; arrow.PosInfo.PosX = player.PosInfo.PosX; arrow.PosInfo.PosY = player.PosInfo.PosY; arrow.Speed = skillData.projectile.speed; Push(EnterGame, arrow, false); } break; } }