public void Load() { if (string.IsNullOrEmpty(npcPrefabName)) { npcObjPrefab = null; } if (npcObjPrefab == null) { if (!string.IsNullOrEmpty(npcPrefabName)) { npcObjPrefab = Resources.Load <GameObject>(npcPrefabDirectoryPath + "/" + npcPrefabName); } } if (NPCObj == null && npcObjPrefab != null) { NPCObj = GameObject.Instantiate <GameObject>(npcObjPrefab); NPCObj.transform.position = NPCLocation; NPCObj.transform.eulerAngles = NPCAngle; NPCObj.name = NPCName; NPCDataInfoMono npcDaatInfoMono = NPCObj.AddComponent <NPCDataInfoMono>(); npcDaatInfoMono.NPCDataInfo = this; } if (NPCSprite == null) { if (!string.IsNullOrEmpty(npcSpriteID)) { NPCSprite = SpriteManager.GetSrpite(npcSpriteID); } } }
public bool DoSetTargetNPCWithClick(NPCObj npc, bool waitTargetSet) { var pj = this.Client.Mem.Link.PJInfo; // calculo el angulo XZ var z = Convert.ToSingle(npc.Coord.Z - pj.Data.Coords.Z); var x = Convert.ToSingle(npc.Coord.X - pj.Data.Coords.X); var angleXZ = Convert.ToSingle(Math.Atan(x / z) * 180 / Math.PI); if (z < 0) { angleXZ += 180; } // invierto el ángulo para poner la camara atrás angleXZ += 180; if (angleXZ > 360) { angleXZ -= 360; } // Calculo en ángulo Y var npcY = new float[] { npc.CoordBottom.Y, npc.CoordHead.Y }.Average(); var y = Convert.ToSingle(npcY - pj.Data.Coords.Y); var h = npc.DistAlPJ; var angleY = Convert.ToSingle(Math.Asin(y / h) * 180 / Math.PI); // Seteo la cámara var prevDist = pj.Data.CamDist; var prevAngleY = pj.Data.CamAngleY; var prevAngleXZ = pj.Data.CamAngleXZ; pj.SetCamDist(npc.DistAlPJ + 2); pj.SetCamAngleY(-angleY); pj.SetCamAngleXZ(angleXZ); pj.SetBloquearMovimiento(true); Thread.Sleep(50); var win = this.Client.Manager.GetWindowRect(); this.Client.Manager.MouseDown(win.Width / 2, win.Height / 2); Thread.Sleep(50); pj.SetBloquearMovimiento(false); // restauro la camara pj.SetCamDist(prevDist); pj.SetCamAngleY(prevAngleY); pj.SetCamAngleXZ(prevAngleXZ); var start = DateTime.Now; while (waitTargetSet && start.AddSeconds(3) > DateTime.Now && this.Client.Mem.Link.PJInfo.Data.TargetId != npc.Id) { Thread.Sleep(500); } return(this.Client.Mem.Link.PJInfo.Data.TargetId == npc.Id); }
public NPCObj getNpcFromDB(string id) { NPCObj npc = null; IDataReader reader = getDataByString(id); while (reader.Read()) { NPCObj entity = new NPCObj(reader[0].ToString(), reader[1].ToString(), reader[2].ToString(), reader[3].ToString() ); npc = entity; } reader.Close(); if (npc == null) { return(null); } reader = getDialogs(npc._id); while (reader.Read()) { npc._Dialogs.Add(reader[0].ToString()); } reader.Close(); reader = getQuests(npc._id); while (reader.Read()) { npc._AvailableQuests.Add(reader[0].ToString()); } reader.Close(); return(npc); }