void UpdatePosition(Vector3 holderPos) { Vector3 dir = holderPos.normalized; float len = holderPos.sqrMagnitude; if (len > m_nSqrRadius) { len = m_nRadius; holderPos = dir * len; } if (EntityManager.instance.curEntity != null) { Transform et = EntityManager.instance.curEntity; Animator animator = et.gameObject.GetComponentInChildren <Animator>(); animator.SetFloat("curDirX", dir.x); animator.SetFloat("curDirY", dir.y); animator.SetFloat("curDirZ", dir.z); animator.SetFloat("speed", 5); EntityAnimator eanimator = et.gameObject.GetComponentInChildren <EntityAnimator>(); eanimator.Play(EAnimationType.Move, 1.0f); } //DataBuffer buf = new DataBuffer(); //buf.WriteFloat(dir.x); //buf.WriteFloat(dir.y); //buf.WriteFloat(dir.z); //GameEvtArg arg = new GameEvtArg(buf); //m_EvtCtx.FireEvent(this, GameEventType.EVT_INPUT_JOYSTICK_DIR_CHANGED, arg); m_rectTransform.anchoredPosition = holderPos; }
public override void OnStartState() { base.OnStartState(); if (entityview == null) { Goto(timeOutState); } m_animator = entityview.animator; if (m_animator != null) { m_animator.Play(m_animType, m_animationSpeed); } }
void OnHandleInput(object sender, EventArgs arg) { GameEvtArg garg = arg as GameEvtArg; if (garg != null && garg.m_buf != null) { int i = garg.m_buf.ReadByte(); EntityAnimator animator = curEntity.gameObject.GetComponent <EntityAnimator>(); if (animator == null) { return; } switch (i) { case 0: { animator.Play(EAnimationType.LPunch, 1); } break; case 1: { animator.Play(EAnimationType.RPunch, 1); } break; case 2: { animator.Play(EAnimationType.LPunchMove, 1); } break; case 3: { animator.Play(EAnimationType.RPunchMove, 1); } break; case 4: { animator.Play(EAnimationType.LKick, 1); } break; case 5: { animator.Play(EAnimationType.RKick, 1); } break; } } }