/// <summary> /// 摇杆的场景指示器也只能主角自己有,并且是操作完成才发送指令 /// </summary> private void OnSkillEvent(int index, eJoyStickEvent jsEvent, Vector2 m_delta, bool bCancel) { m_curSkillIndex = index; m_curSkillJoyStick = jsEvent; CCreature master = CCreatureMgr.GetMaster(); CSkillInfo sInfo = m_master.GetSkillByIndex(index); //if (sInfo == null || !sInfo.IsCanUse()) //{ // Debug.Log(index + " 不可用" + jsEvent); // return; //} if (jsEvent == eJoyStickEvent.Drag) { m_curSkillDir = new Vector3(m_delta.x, 0, m_delta.y); m_curSkillDir.Normalize(); } if (jsEvent == eJoyStickEvent.Down) { m_bSkillCancel = false; skillInfo = sInfo.m_skillInfo; m_ui.m_cancelBtn.SetActiveNew(true); m_ui.SetColor(index, SKLL_BLUE); m_skillChose.gameObject.SetActiveNew(true); m_skillCenter.gameObject.SetActiveNew(true); m_skillDistance.gameObject.SetActiveNew(true); m_skillSectorDir.gameObject.SetActiveNew(false); m_skillDir.gameObject.SetActiveNew(false); m_skillPos.gameObject.SetActiveNew(false); m_skillDistance.localScale = new Vector3(skillInfo.distance, 0.01f, skillInfo.distance) * 2; } // 自己 if (skillInfo.selectTargetType == (int)eSelectTargetType.Self) { m_curSkillDir = master.GetDir().ToVector3(); } // 扇形方向 else if (skillInfo.selectTargetType == (int)eSelectTargetType.SectorDir) { if (jsEvent == eJoyStickEvent.Down) { m_curSkillDir = master.GetDir().ToVector3(); m_skillSectorDir.gameObject.SetActiveNew(true); m_skillSectorDir.localScale = new Vector3(skillInfo.distance, 0.01f, skillInfo.distance); } else if (jsEvent == eJoyStickEvent.Drag) { } m_skillCenter.rotation = Quaternion.LookRotation(m_curSkillDir); // 只用控制中心点的方向 } // 直线方向 else if (skillInfo.selectTargetType == (int)eSelectTargetType.Dir) { if (jsEvent == eJoyStickEvent.Down) { int tUid = master.GetTarget(skillInfo.distance); if (tUid == 0) { m_curSkillDir = master.GetDir().ToVector3(); } else { CCreature cc = CCreatureMgr.Get(tUid); if (cc != null) { m_curSkillDir = (cc.GetPos() - master.GetPos()).ToVector3().normalized; } } m_skillDir.gameObject.SetActiveNew(true); m_skillDir.localScale = new Vector3(skillInfo.distance, 0.01f, skillInfo.distance); } else if (jsEvent == eJoyStickEvent.Drag) { } m_skillCenter.rotation = Quaternion.LookRotation(m_curSkillDir); // 只用控制中心点的方向 } // 位置 else if (skillInfo.selectTargetType == (int)eSelectTargetType.Pos) { if (jsEvent == eJoyStickEvent.Down) { int tUid = master.GetTarget(skillInfo.distance); if (tUid == 0) { m_curSkilPos = m_master.GetPos().ToVector3(); } else { CCreature cc = CCreatureMgr.Get(tUid); if (cc != null) { m_curSkilPos = cc.GetPos().ToVector3(); } } m_skillPos.gameObject.SetActiveNew(true); m_skillPos.position = m_curSkilPos; m_skillPos.localScale = new Vector3(skillInfo.length, 0.001f, skillInfo.length); } else if (jsEvent == eJoyStickEvent.Drag) { Vector3 atkOffset = m_curSkillDir * m_delta.magnitude * skillInfo.distance; m_curSkilPos = m_master.m_vCreature.GetEnt().GetPos() + atkOffset; m_skillPos.position = m_curSkilPos; } } if (jsEvent == eJoyStickEvent.Up) { // 发送技能 if (!m_bSkillCancel) { m_bSkillCancel = true; //Debug.Log("发送技能:" + skillInfo.id + "dir:" + m_curSkillDir + " pos:" + m_curSkilPos); CmdFspSendSkill cmd = new CmdFspSendSkill(); cmd.m_casterUid = (int)m_master.GetUid(); cmd.m_skillIndex = m_curSkillIndex; cmd.m_dir = (new Vector2(m_curSkillDir.x, m_curSkillDir.z)).ToVector2d(); cmd.m_endPos = (new Vector2(m_curSkilPos.x, m_curSkilPos.z)).ToVector2d(); master.SendFspCmd(cmd); OnSkillSpeak(index); } // 还原指示器 CancelSkill(); m_skillChose.gameObject.SetActiveNew(false); } }