using UnityEngine; public enum enCharacterType { CHAR_TYPE_NONE = 0, CHAR_TYPE_MYPLAYER = 1, CHAR_TYPE_ATTENDANT = 2, CHAR_TYPE_ENEMY = 3, CHAR_TYPE_BOSS = 4, CHAR_TYPE_BUILD = 5, CHAR_TYPE_CONVOY = 6, CHAR_TYPE_ENEMY_PLAYER = 7, CHAR_TYPE_ENEMY_ATTENDANT = 8, CHAR_TYPE_TRAP = 9, } namespace G { public class NormalAtkBase : MonoBehaviour { protected EntityCha m_unit; protected EntityCha m_target; protected Transform m_transform; protected int m_weaponType; protected AnimationState m_tmpAttack; protected Transform m_efSwing1; protected Transform m_efSwingEx1; protected Transform m_efSwing2; protected Transform m_efThrust; protected Transform m_efPlash; protected Transform m_efpunch; protected Transform m_efRotFog; protected Transform[] m_aryStepfog = new Transform[4]; protected Transform[] m_aryChongfog = new Transform[4]; protected Transform[] m_aryThrustfog = new Transform[4]; protected Ef_swing1 m_swingScript; protected Ef_swing1 m_swingEx1Script; protected Ef_swing1 m_swingScript2; protected Ef_swing1 m_thrustScript; protected Bullet_punch m_punchScript; public Ef_splash m_splashScript; public Ef_rotfog m_rotfogScript; protected string[] ANIM_NAME = new string[5] { "attack1", "attack2", "attack3", "attack4", "attack5" }; protected string[] EX_ANIM_NAME = new string[5] { "1t", "2t", "3t", "4t", string.Empty }; private int m_step = -1; protected int m_totalStep = 5; private int m_curStepFogCount; private int m_curThrustFogCount; public enCharacterType m_chaType; public int myStep { set { m_step = value; } } public NormalAtkBase() { m_weaponType = 0; } public void Reset() { m_step = -1; } public bool IsStepEnd() { return m_step >= m_totalStep - 1; } private void Awake() { m_transform = base.transform; m_unit = GetComponent(); } public void LoadEffect(string swingName) { //m_efSwing1 = PrefabManager.Instance().Spawn("ef_swing"); //m_efSwing1.parent = m_transform; //m_efSwingEx1 = PrefabManager.Instance().Spawn("ef_swing_ex1"); //m_efSwingEx1.parent = m_transform; //m_efSwing2 = PrefabManager.Instance().Spawn("ef_swing1"); //m_efSwing2.parent = m_transform; //m_efSwing2.localScale = new Vector3(1.3f, 1.7f, 1.7f); //m_efThrust = PrefabManager.Instance().Spawn("ef_thrust"); //m_efThrust.parent = m_transform; //m_efThrust.localPosition = new Vector3(0f, 0.05f, 0.08f); //m_efThrust.localRotation = m_transform.rotation; //m_efpunch = PrefabManager.Instance().Spawn("ef_punch"); //m_efPlash = PrefabManager.Instance().Spawn("ef_splash"); //m_efRotFog = PrefabManager.Instance().Spawn("ef_rotfog"); //for (int i = 0; i < 3; i++) //{ // m_aryStepfog[i] = PrefabManager.Instance().Spawn("ef_stepfog", Vector3.one * 4f, base.transform.root.rotation); // m_aryThrustfog[i] = PrefabManager.Instance().Spawn("ef_thrustfog", Vector3.one * 4f, Quaternion.identity); // m_aryChongfog[i] = PrefabManager.Instance().Spawn("ef_stepfog_3", Vector3.one * 4f, base.transform.root.rotation); //} //Texture texture = Resources.Load("Png/Effect/" + swingName) as Texture; //m_swingScript = m_efSwing1.GetComponent(); //m_swingScript.m_attker = m_transform; //m_swingScript.SetTexture(texture); //m_swingScript2 = m_efSwing2.GetComponent(); //m_swingScript2.m_attker = m_transform; //m_swingScript2.SetTexture(texture); //m_swingEx1Script = m_efSwingEx1.GetComponent(); //m_swingEx1Script.m_attker = m_transform; //m_thrustScript = m_efThrust.GetComponent(); //m_thrustScript.m_attker = m_transform; //m_splashScript = m_efPlash.GetComponent(); //m_splashScript.cha1 = m_transform; //m_splashScript.m_attker = m_transform; //m_punchScript = m_efpunch.GetComponent(); //m_punchScript.m_attker = m_transform; //m_rotfogScript = m_efRotFog.GetComponent(); } public float DoAtk(EntityCha target) { float result = 0f; if (target == null || m_unit == null) { return result; } m_target = target; m_unit.SetAtkCollision(false); Vector3 lhs = m_target.position - m_unit.position; lhs.y = 0f; lhs.Normalize(); float magnitude = lhs.magnitude; Vector3 curDir = m_unit.forward; if (curDir != Vector3.zero) { float num = Vector3.Dot(lhs, curDir); if (magnitude > 0.2f) { if (num < 0.5f) { m_unit.SetAtkCollision(true); m_unit.SetCurActionState(enStat.STAT_ACTION_MOVE); return 0f; } } else if (num < -0.2f) { m_unit.SetAtkCollision(true); m_unit.SetCurActionState(enStat.STAT_ACTION_MOVE); return 0f; } } m_step = (m_step + 1) % m_totalStep; int num2 = Random.Range(0, 4); if (num2 < 2) { //HeroSounds.Instance.NormalAtkWhoopSound((EntityPlayer)m_unit, num2); } return UpdateStep(m_step); } protected virtual float UpdateStep(int nStep) { return 0f; } public virtual void CancelAtk() { m_unit.SetAtkCollision(true); } public void OnFog(int _kind) { switch (_kind) { case 3: break; case 0: m_aryStepfog[m_curStepFogCount].gameObject.SetActive(true); m_aryStepfog[m_curStepFogCount].position = m_transform.position; m_aryStepfog[m_curStepFogCount].rotation = m_transform.rotation; m_curStepFogCount = (m_curStepFogCount + 1) % 3; break; case 1: m_aryThrustfog[m_curThrustFogCount].gameObject.SetActive(true); m_aryThrustfog[m_curThrustFogCount].position = m_transform.position + m_transform.forward * 0.2f + Vector3.up * 0.15f; m_aryThrustfog[m_curThrustFogCount].up = m_transform.forward; m_aryThrustfog[m_curThrustFogCount].Rotate(m_transform.forward, Random.Range(0, 360)); m_curThrustFogCount = (m_curThrustFogCount + 1) % 3; break; case 2: m_aryThrustfog[m_curThrustFogCount].gameObject.SetActive(true); //m_aryThrustfog[m_curThrustFogCount].position = m_unit.m_bip01.position + m_unit.m_bip01.forward * 0.2f + Vector3.up * 0.15f; //m_aryThrustfog[m_curThrustFogCount].up = m_unit.m_bip01.forward; //m_aryThrustfog[m_curThrustFogCount].RotateAround(m_unit.m_bip01.forward, Random.Range(0, 360)); m_curThrustFogCount = (m_curThrustFogCount + 1) % 3; break; case 4: m_aryChongfog[m_curStepFogCount].gameObject.SetActive(true); m_aryChongfog[m_curStepFogCount].position = m_transform.position; m_aryChongfog[m_curStepFogCount].rotation = m_transform.rotation; m_curStepFogCount = (m_curStepFogCount + 1) % 3; break; } } } }