protected override void OnHide(object userData) { base.OnHide(userData); m_EtcJoystick.onMoveStart.RemoveListener(MoveStartEvent); m_EtcJoystick.onMove.RemoveListener(MoveEvent); m_JoyNameType = JoyNameType.AttackJoy; }
protected override void OnUpdate(float elapseSeconds, float realElapseSeconds) { base.OnUpdate(elapseSeconds, realElapseSeconds); if (m_JoyNameType == JoyNameType.AttackJoy || m_JoyNameType == JoyNameType.IdleJoy) { GetNerMonstar(); if (nearMonstar == null) { m_JoyNameType = JoyNameType.IdleJoy; m_SpineItem.SetSpinePlayAnim(m_JoyNameType, transform.eulerAngles.y, 0.5f); isGameSuccess = true; return; } //转向就近敌方单位 m_CharacterController.transform.LookAt(nearMonstar.transform.position); m_SpineItem.SetSpinePlayAnim(m_JoyNameType, transform.eulerAngles.y, 0.5f); //等待一秒发射子弹 if (waitTime > 0f) { waitTime -= Time.deltaTime; } else { UIMapManager.Instance.BulletManager.CreateBullet(this, m_CharacterController.transform.position, nearMonstar.transform.position, 0.5f, CampType.Player, m_ArrowPlayerData.Attack); waitTime = 1f; } } else { waitTime = 1f; m_SpineItem.SetSpinePlayAnim(m_JoyNameType, transform.eulerAngles.y, 0.5f); } }
protected void OnInit(object userData) { isGameSuccess = false; m_ArrowPlayerData = userData as ArrowPlayerData; m_EtcJoystick = FindObjectOfType <ETCJoystick>(); if (!m_CharacterController) { m_CharacterController = GetComponentInChildren <CharacterController>(); } m_JoyNameType = JoyNameType.MoveJoy; m_EtcJoystick.onMoveStart.AddListener(MoveStartEvent); m_EtcJoystick.onMove.AddListener(MoveEvent); m_EtcJoystick.onMoveEnd.AddListener(MoveEndEvent); m_SpineItem = GetComponentInChildren <SpineItem>(); m_Weapon = gameObject.AddComponent <Weapon>(); //生成Hp UIHpBarManager.m_UIHpBarManager.ShowHPBar(this, m_ArrowPlayerData.HP, m_ArrowPlayerData.HPRatio); }
/// <summary> /// 玩家 /// </summary> /// <param name="attack"></param> /// <param name="angular"></param> public void SetSpinePlayAnim(JoyNameType joyType, float angular, float speed = 1f) { m_IsRotation = false; if (angular > -45f && angular <= 45f) { SetSpinePlayAnim(joyType == JoyNameType.IdleJoy ? SpineAnimType.back_idle : (joyType == JoyNameType.AttackJoy ? SpineAnimType.back_attack : SpineAnimType.back_move)); } else if (angular > 45f && angular <= 135f) { SetSpinePlayAnim(joyType == JoyNameType.IdleJoy ? SpineAnimType.side_idle : (joyType == JoyNameType.AttackJoy ? SpineAnimType.side_attack : SpineAnimType.side_move)); } else if ((angular > 135f && angular <= 180f) || (angular > -180f && angular <= -135)) { SetSpinePlayAnim(joyType == JoyNameType.IdleJoy ? SpineAnimType.front_idle : (joyType == JoyNameType.AttackJoy ? SpineAnimType.front_attack : SpineAnimType.front_move)); } else if (angular > -135f && angular <= -45f) { m_IsRotation = true; SetSpinePlayAnim(joyType == JoyNameType.IdleJoy ? SpineAnimType.side_idle : (joyType == JoyNameType.AttackJoy ? SpineAnimType.side_attack : SpineAnimType.side_move)); } m_SkeletonAnimation.transform.localEulerAngles = m_IsRotation?new Vector3(-50, 180, 0): new Vector3(50, 0, 0); m_SkeletonAnimation.timeScale = speed; }
void MoveEndEvent() { m_JoyNameType = JoyNameType.AttackJoy; m_SpineItem.SetSpinePlayAnim(m_JoyNameType, transform.eulerAngles.y, 0.5f); }
void MoveStartEvent() { m_JoyNameType = JoyNameType.MoveJoy; m_SpineItem.SetSpinePlayAnim(m_JoyNameType, transform.eulerAngles.y, 0.5f); }