Exemple #1
0
    public void MoveTo(GameObject TargetObj, ActionCallBack.MoveFinishCallBack CallBack = null, bool bUseOffset = true, bool bPlayAnim = true, float speed = MOVETOTAGETTIME, int iVal = 0, bool lookTarget = true)
    {
        if (null == TargetObj)
        {
            return;
        }

        MoveTo(TargetObj.transform.position, CallBack, bUseOffset, bPlayAnim, MOVETOTAGETTIME, iVal, lookTarget);
    }
Exemple #2
0
    public void MoveTo(Vector3 TargetPos, ActionCallBack.MoveFinishCallBack CallBack = null, bool bUseOffset = true, bool bPlayAnim = true, float moveTime = MOVETOTAGETTIME, int iVal = 0, bool lookTarget = true)
    {
        // one position to another is 0.5f
        float distance = Vector3.Distance(TargetPos, ActorObj.transform.position);

        if (distance < GlobalValue.MoveMinGap || Mathf.Approximately(distance, GlobalValue.MoveMinGap))
        {
            if (CallBack != null)
            {
                CallBack(iVal);
            }
            return;
        }
        if (bPlayAnim)
        {
            SetAnimationParam(GlobalValue.FMove, AnimatorParamType.APT_Float, distance);
        }
//			PlayEntityAction( GlobalValue.ActionName , GlobalValue.Action_Run);
        ActionCallBack callback = ActorObj.GetComponent <ActionCallBack>();

        callback.m_MoveFinishCallBack = CallBack;
        Hashtable args = new Hashtable();

        args.Add("easeType", iTween.EaseType.linear);
        args.Add("time", moveTime);
        args.Add("delay", 0.0f);
        if (lookTarget)
        {
            args.Add("looktarget", TargetPos);
            m_EntityObj.transform.LookAt(TargetPos);
        }
        args.Add("loopType", "none");
        //args.Add("onstart", "MoveStartCallBack");
        //args.Add("onstarttarget", m_EntityObj);
        args.Add("oncomplete", "ActionMoveFinishCallBack");
        args.Add("oncompleteparams", iVal);
        args.Add("oncompletetarget", m_EntityObj);
        args.Add("onupdate", "MoveUpdateCallBack");
        //args.Add("onupdatetarget", m_EntityObj);
        args.Add("onupdateparams", true);
        if (bUseOffset)
        {
            Vector3 shortPos = (TargetPos - m_EntityObj.transform.position).normalized;
            args.Add("position", TargetPos - shortPos * 0.5f);
        }
        else
        {
            args.Add("position", TargetPos);
        }

        iTween.MoveTo(m_EntityObj, args);
    }