void UpdateMoveEvent(float deltaTime)
    {
        // move event to avoid crash
        if (moveOprEvent != null)
        {
            moveOprEvent.OnUpdate(deltaTime);
            if (moveOprEvent.IsFinish())
            {
                moveOprEvent = null;
            }
        }

        if (gasMoveEvent != null)
        {
            gasMoveEvent.OnUpdate(deltaTime);
            if (gasMoveEvent.IsFinish())
            {
                gasMoveEvent = null;
            }
        }

        if (skillMoveEvent != null)
        {
            skillMoveEvent.OnUpdate(deltaTime);
            if (skillMoveEvent.IsFinish())
            {
                skillMoveEvent = null;
            }
        }
    }
Esempio n. 2
0
    public override void  OnMsg(int msgID, object args)
    {
        if (msgID == (int)Const_Util.UNIT_MSG.START_JUMP)
        {
            if (jumpOprEvent != null && !jumpOprEvent.IsFinish())
            {
                return;
            }
            jumpOprEvent = new SeqEvent();
            Vector3       originScale = cobj.GetRenderObjTr().localScale;
            Vector3       destScale   = originScale * 1.34f;
            ParallelEvent jumpUpPara  = new ParallelEvent();
            ScaleEvent    scaleTo     = new ScaleEvent(cobj.GetRenderObjTr(), originScale, destScale, 0.4f);
            jumpUpPara.AddEvent(scaleTo);
            SeqEvent   upEvent     = new SeqEvent();
            TimerEvent upTimeDelay = new TimerEvent(0.1f);
            upEvent.AddEvent(upTimeDelay);
            OneTimerEvent scaletoFunc = new OneTimerEvent(JumpEnough);
            upEvent.AddEvent(scaletoFunc);
            jumpUpPara.AddEvent(upEvent);

            TimerEvent timeDelay = new TimerEvent(0.8f);

            SeqEvent   downEvent     = new SeqEvent();
            TimerEvent downTimeDelay = new TimerEvent(0.1f);
            downEvent.AddEvent(downTimeDelay);
            OneTimerEvent scalebackReset = new OneTimerEvent(JumpReset);
            downEvent.AddEvent(scalebackReset);
            ParallelEvent jumpDownPara = new ParallelEvent();
            jumpDownPara.AddEvent(downEvent);
            ScaleEvent scaleBack = new ScaleEvent(cobj.GetRenderObjTr(), destScale, originScale, 0.4f);
            jumpDownPara.AddEvent(scaleBack);

            jumpOprEvent.AddEvent(jumpUpPara);
            jumpOprEvent.AddEvent(timeDelay);
            jumpOprEvent.AddEvent(jumpDownPara);

            jumpOprEvent.Begin();
        }
    }
    public override void OnBroadcastEvent(int eventID, int targetObjID, object args = null)
    {
        if (!isActive)
        {
            return;
        }

        if (eventID == (int)Const_Util.BATTLE_EVENT.CHG_DIR)
        {
            unitHangNode.localPosition = hangNodeOriginPos;
            if (colliderCD > Const_Util.FLT_EPSILON)
            {
                return;
            }
            if (moveOprEvent != null && !moveOprEvent.IsFinish())
            {
                moveOprEvent.Destroy();
                moveOprEvent = null;
            }
            moveOprEvent = new SeqEvent();
            MoveToEvent moveTo = new MoveToEvent(cobj.GetRenderObjTr(), new Vector3((float)args, cobj.GetRenderObjTr().localPosition.y, 0), 0.1f);
            moveOprEvent.AddEvent(moveTo);
            moveOprEvent.Begin();
        }
        else if (eventID == (int)Const_Util.BATTLE_EVENT.MOVE_SPEED_RATE)
        {
            if (!IsHero())
            {
                SetMoveSpeed((float)args * baseMoveSpeed);
            }
        }
        else if (eventID == (int)Const_Util.BATTLE_EVENT.JUMP)
        {
            if (colliderCD > Const_Util.FLT_EPSILON)
            {
                return;
            }
            SendMsg((int)Const_Util.UNIT_MSG.START_JUMP, null);
        }
    }
Esempio n. 4
0
    public override void OnUpdate(float deltaTime)
    {
        if (mLockMoveTimer > 0)
        {
            mLockMoveTimer = mLockMoveTimer - Time.deltaTime;
            if (mLockMoveTimer <= 0)
            {
                mLockMoveTimer = 0;
            }
        }

        if (randomSkillSprEvent != null)
        {
            randomSkillSprEvent.OnUpdate(deltaTime);
            if (randomSkillSprEvent.IsFinish())
            {
                randomSkillSprEvent = null;
            }
        }

        if (Input.GetMouseButtonDown(0) || (Input.touchCount > 0 && Input.GetTouch(0).phase == TouchPhase.Began))
        {
            //            #if IPHONE || ANDROID
            //            if (EventSystem.current.IsPointerOverGameObject(Input.GetTouch(0).fingerId))
            //            #else
            //            if (EventSystem.current.IsPointerOverGameObject())
            //            #endif
            //                Debug.Log("当前触摸在UI上");
            //
            //            else
            //                Debug.Log("当前没有触摸在UI上");
        }
        float gasValue = BattleInstance.instance.GetHeroCarFloatAttr(BattleInstance.instance.MyPlayerIdx, (int)Const_Util.UNIT_ATTR.NITROGEN_CUR);

        if (Mathf.Abs(gasValue - nitrogenValue) > 1)
        {
            nitrogenValue = gasValue;
            int showGas = Mathf.RoundToInt(nitrogenValue);
            if (showGas < 0)
            {
                showGas = 0;
            }
            nitrogenTxtCom.text = showGas.ToString();
            float gasMaxValue = BattleInstance.instance.GetHeroCarFloatAttr(BattleInstance.instance.MyPlayerIdx, (int)Const_Util.UNIT_ATTR.NITROGEN_MAX);
            nitrogenImgCom.fillAmount = nitrogenValue / gasMaxValue;
        }

//        int showGas = Mathf.RoundToInt(nitrogenValue);
        string strDistance = String.Format("{0:F}", BattleInstance.instance.GetHeroCarFloatAttr(TestConfig.RoleHeroPlayerIdx, (int)Const_Util.UNIT_ATTR.MOVE_DISTANCE));

        moveDistanceTextCom.text = strDistance;
    }