Esempio n. 1
0
    private void applyAccelerate(bool acc)
    {
        if (!m_pFSM.isHero)
        {
            return;
        }

        cmd_creature_set_wing_state data;

        data.nEncounterFlag = 0;
        if (acc)
        {
            data.nType = WING_STATE_TYPE.WING_STATE_ACCELERATION;
        }
        else
        {
            data.nType = WING_STATE_TYPE.WING_STATE_NORMAL_FLIGHT;
        }


        IntPtrHelper helper  = new IntPtrHelper();
        int          len     = Marshal.SizeOf(data);
        IntPtr       ptr     = helper.toPtr <cmd_creature_set_wing_state>(ref data);
        int          eventID = (int)EntityLogicDef.ENTITY_CMD_SET_WING_STATE;

        GameLogicAPI.onEntityEvent(m_pFSM.entityID, eventID, len, "", ptr, len);
    }
Esempio n. 2
0
    public void StopAutoMove(bool userStop = true)
    {
        if (!isAutoMoving)
        {
            return;
        }


        isAutoMoving = false;

        if (m_autoMoveNavModeFollow)
        {
            SoldierCamera.MainInstance <SoldierCamera>().exitNavMode(CameraNavMode.Follow);
            m_autoMoveNavModeFollow = false;
        }

        if (m_pFSM.showLog)
        {
            Trace.Log("StopAutoMove");
        }

        if (userStop)
        {
            cmd_creature_operation_type type = new cmd_creature_operation_type();
            type.nType = 0;
            IntPtrHelper helper = new IntPtrHelper();
            IntPtr       ptr    = helper.toPtr <cmd_creature_operation_type>(ref type);
            int          len    = Marshal.SizeOf(type);
            GameLogicAPI.onEntityEvent(m_pFSM.entityID, (int)EntityLogicDef.ENTITY_CMD_OPERATION_TYPE, len, "", ptr, len);
        }
        enableAutoMoveEffect(false);
    }
Esempio n. 3
0
    public void OnTalentPagePointsInfo(int nPageIndex, string szPointsData, string szTalentId, string szTalentPageName, int nAttackPoints, int nTrickPoints, int nHelpPoints)
    {
        // 请求保存当前页数据
        TalentPageInfo talentPageInfo = new TalentPageInfo();

        talentPageInfo.szTalentPageName  = szTalentPageName;
        talentPageInfo.nAttackPointAll   = nAttackPoints;
        talentPageInfo.nTrickPointAll    = nTrickPoints;
        talentPageInfo.nHelpPointAll     = nHelpPoints;
        this.dTalentPageInfo[nPageIndex] = talentPageInfo;

        cmd_TalentPage_Points_Single cmdSinglePoint = new cmd_TalentPage_Points_Single();

        cmdSinglePoint.nCurPageIndex = nPageIndex;
        string[] sTalentIdArray = ((string)(szTalentId)).Split(';');
        int      nArrayLen      = sTalentIdArray.Length - 1;

        cmdSinglePoint.nTalentId     = new int[nArrayLen];
        cmdSinglePoint.nTalentPoints = new int[nArrayLen];
        for (int i = 0; i < nArrayLen; i++)
        {
            cmdSinglePoint.nTalentId[i]     = int.Parse(sTalentIdArray[i]);
            cmdSinglePoint.nTalentPoints[i] = int.Parse(szPointsData[i].ToString());;
        }
        cmdSinglePoint.nTalentNum       = (byte)nArrayLen;
        cmdSinglePoint.szTalentPageName = szTalentPageName;
        IntPtrHelper helper = new IntPtrHelper();
        IntPtr       ptr    = helper.toPtr <cmd_TalentPage_Points_Single>(ref cmdSinglePoint);
        int          len    = Marshal.SizeOf(cmdSinglePoint);

        GameLogicAPI.onEntityEvent(EntityFactory.MainHeroID, (int)EntityLogicDef.ENTITY_CMD_SAVE_TALENT_PAGE_SINGLE, len, "", ptr, len);
    }
Esempio n. 4
0
        // 当点击确定按钮时向逻辑层请求升星
        public void onClickUpStarButton()
        {
            IntPtrHelper helper = new IntPtrHelper();
            IntPtr       ptr    = helper.toPtr <int>(ref nHeroID);
            int          nLen   = Marshal.SizeOf(nHeroID);

            GameLogicAPI.onEntityEvent(EntityFactory.MainHeroID, (int)EntityLogicDef.ENTITY_CMD_REQ_UPGRADE_STAR, nLen, "", ptr, nLen);
        }
Esempio n. 5
0
    /// <summary>
    /// 显示层发送View命令到逻辑层
    /// </summary>
    /// <typeparam name="T"></typeparam>
    /// <param name="event_id"></param>
    /// <param name="data"></param>
    /// <example>
    /// gameview_create_player data = new gameview_create_player();
    /// ViewEventHelper.Instance.SendCommand<gameview_create_player>(EntityLogicDef.GVIEWCMD_USER_CREATE_PLAYER, ref data);
    /// </example>
    public void SendCommand <T>(GameLogic.GameLogicDef event_id, ref T data) where T : struct
    {
        IntPtrHelper helper   = new IntPtrHelper();
        int          data_len = System.Runtime.InteropServices.Marshal.SizeOf(data);

        IntPtr ptr = helper.toPtr <T>(ref data);

        GameLogicAPI.onGameViewEvent((int)event_id, data_len, "", ptr, data_len);
    }
Esempio n. 6
0
        public UIMsgCmdData create <T>(WndMsgID msg_id, ref T data, int nParam = 0, string strParam = "") where T : struct
        {
            IntPtrHelper helper   = new IntPtrHelper();
            int          data_len = System.Runtime.InteropServices.Marshal.SizeOf(data);

            IntPtr ptr = helper.toPtr <T>(ref data);

            return(create(msg_id, nParam, strParam, ptr, data_len));
        }
Esempio n. 7
0
        // 进入战场后请求基本数据
        public void OnTabClick()
        {
            IntPtrHelper helper        = new IntPtrHelper();
            int          nIsOneRequest = Convert.ToInt16(isOneRequest);
            IntPtr       ptr           = helper.toPtr <int>(ref nIsOneRequest);
            int          len           = Marshal.SizeOf(nIsOneRequest);

            GameLogicAPI.onEntityEvent(EntityFactory.MainHeroID, (int)EntityLogicDef.ENTITY_CMD_PLAYER_BASE_INFO, len, "", ptr, len);
        }
Esempio n. 8
0
        private void notifyTabWndStatus()
        {
            // 发向逻辑层是否判断战绩界面是否打开
            int          nIsOpen = Convert.ToInt16(LogicDataCenter.recordTableDataManager.IsWarRecordTableVisible);
            IntPtrHelper helper  = new IntPtrHelper();
            IntPtr       ptr     = helper.toPtr <int>(ref nIsOpen);
            int          len     = Marshal.SizeOf(nIsOpen);

            GameLogicAPI.onEntityEvent(EntityFactory.MainHeroID, (int)EntityLogicDef.ENTITY_CMD_PALYER_TAB_ISOPEN, len, "", ptr, len);
            view.showRecordTable();
        }
Esempio n. 9
0
    /**
     *   英雄技能相关
     */
    public void onSkillUpgradeButtonClick(int _nClickSlotID)
    {
        cmd_creature_upgrade_spell data = new cmd_creature_upgrade_spell();

        data.nSlotIndex = _nClickSlotID;

        IntPtrHelper helper = new IntPtrHelper();
        IntPtr       ptr    = helper.toPtr <cmd_creature_upgrade_spell>(ref data);
        int          len    = Marshal.SizeOf(data);

        GameLogicAPI.onEntityEvent(EntityFactory.MainHeroID, (int)EntityLogicDef.ENTITY_CMD_UPGRADE_SPELL, len, "", ptr, len);
    }
Esempio n. 10
0
        public void OnConfirmSubButtonClick()
        {
            cmd_Actor_Name_Fix cmdInfo = new cmd_Actor_Name_Fix();

            cmdInfo.szNewName = LogicDataCenter.playerSystemDataManager.sFixActorName;
            cmdInfo.nCostType = m_nCostType;
            IntPtrHelper helper = new IntPtrHelper();
            IntPtr       ptr    = helper.toPtr <cmd_Actor_Name_Fix>(ref cmdInfo);
            int          len    = Marshal.SizeOf(cmdInfo);

            GameLogicAPI.onEntityEvent(EntityFactory.MainHeroID, (int)EntityLogicDef.ENTITY_CMD_ACTOR_NAME_FIX, len, "", ptr, len);
        }
Esempio n. 11
0
        public void RequestAllHero(int actorID)
        {
            cmd_Request_Hero_Info cmdInfo = new cmd_Request_Hero_Info();

            cmdInfo.nActorID = (uint)actorID;
            cmdInfo.bFake    = bFake == true ? 1 : 0;
            IntPtrHelper helper = new IntPtrHelper();
            IntPtr       ptr    = helper.toPtr <cmd_Request_Hero_Info>(ref cmdInfo);
            int          len    = Marshal.SizeOf(cmdInfo);

            GameLogicAPI.onEntityEvent(EntityFactory.MainHeroID, (int)EntityLogicDef.ENTITY_CMD_REQ_HERO_INFO, len, "", ptr, len);
        }
Esempio n. 12
0
 public void onRevokeBtn()
 {
     if (bCanBuyOrSell)
     {
         cmd_war_revocation_operation data = new cmd_war_revocation_operation();
         data.uUID = (uint)EntityFactory.MainHeroID;
         IntPtrHelper helper = new IntPtrHelper();
         IntPtr       ptr    = helper.toPtr <cmd_war_revocation_operation>(ref data);
         int          len    = Marshal.SizeOf(data);
         GameLogicAPI.onEntityEvent(EntityFactory.MainHeroID, (int)EntityLogicDef.ENTITY_CMD_WAR_REVOCATION_OPERATION, len, "", ptr, len);
     }
 }
Esempio n. 13
0
    public void onPurchasedSlotDrop(int _nOrigDragSlotID, int _nTargetDropSlotID)
    {
        cmd_war_personexchangeslot data = new cmd_war_personexchangeslot();

        data.nSrcSlotIndex    = _nOrigDragSlotID;
        data.nTargetSlotIndex = _nTargetDropSlotID;

        IntPtrHelper helper = new IntPtrHelper();
        IntPtr       ptr    = helper.toPtr <cmd_war_personexchangeslot>(ref data);
        int          len    = Marshal.SizeOf(data);

        GameLogicAPI.onEntityEvent(EntityFactory.MainHeroID, (int)EntityLogicDef.ENTITY_CMD_WAR_EXCHANGE_SLOT, len, "", ptr, len);
    }
Esempio n. 14
0
    public void OnTalentPagePointsDelete(int nPageIndex)
    {
        this.dTalentPageInfo.Remove(nPageIndex);
        cmd_Entity_Talent_Page_Detele cmdPointDelete = new cmd_Entity_Talent_Page_Detele();

        cmdPointDelete.nCurTalentPage = nPageIndex;

        IntPtrHelper helper = new IntPtrHelper();

        IntPtr ptr = helper.toPtr <cmd_Entity_Talent_Page_Detele>(ref cmdPointDelete);
        int    len = Marshal.SizeOf(cmdPointDelete);

        GameLogicAPI.onEntityEvent(EntityFactory.MainHeroID, (int)EntityLogicDef.ENTITY_CMD_BEGIN_TALENT_PAGE_DELETE, len, "", ptr, len);
    }
Esempio n. 15
0
        internal void onBtnSellClick(int _nGoodsID, int _nSlotIndex)
        {
            if (WarMobaGoodsDataManager.Instance.CanBuyOrSell && _nGoodsID > 0 && _nSlotIndex != -1)
            {
                cmd_war_personsellgoods data = new cmd_war_personsellgoods();
                data.nGoodID    = _nGoodsID;
                data.nSlotIndex = _nSlotIndex;

                IntPtrHelper helper = new IntPtrHelper();
                IntPtr       ptr    = helper.toPtr <cmd_war_personsellgoods>(ref data);
                int          len    = Marshal.SizeOf(data);
                GameLogicAPI.onEntityEvent(EntityFactory.MainHeroID, (int)EntityLogicDef.ENTITY_CMD_WAR_SELL_GOOD, len, "", ptr, len);
            }
        }
Esempio n. 16
0
        public void onAllSlotMouseEvent(int nSlotId, int nSlotType, int nMouseEventType)
        {
            cmd_entity_mouse_enter_slot data = new cmd_entity_mouse_enter_slot();

            data.nEnterSlot = nMouseEventType;
            data.nSlotType  = nSlotType;
            data.nSlotIndex = nSlotId;

            IntPtrHelper helper = new IntPtrHelper();
            IntPtr       ptr    = helper.toPtr <cmd_entity_mouse_enter_slot>(ref data);
            int          len    = Marshal.SizeOf(data);

            GameLogicAPI.onEntityEvent(EntityFactory.MainHeroID, (int)EntityLogicDef.ENTITY_CMD_MOUSE_ENTER_SLOT, len, "", ptr, len);
        }
Esempio n. 17
0
    /// <summary>
    /// 发送EntityEvent命令到逻辑层
    /// </summary>
    /// <typeparam name="T"></typeparam>
    /// <param name="entity_id"></param>
    /// <param name="event_id"></param>
    /// <param name="data"></param>
    public void SendCommand <T>(int entity_id, GameLogic.EntityLogicDef event_id, ref T data) where T : struct
    {
        if (entity_id == 0)
        {
            return;
        }

        IntPtrHelper helper   = new IntPtrHelper();
        int          data_len = System.Runtime.InteropServices.Marshal.SizeOf(data);

        IntPtr ptr = helper.toPtr <T>(ref data);

        GameLogicAPI.onEntityEvent(entity_id, (int)event_id, data_len, "", ptr, data_len);
    }
Esempio n. 18
0
    // 当召唤师技能改变之后回调
    public void OnSummonerEveryButtonClick(int nSkillFirst, int nSkillSecond)
    {
        cmd_SmSillInfo_Return cmdInfo = new cmd_SmSillInfo_Return();

        cmdInfo.nAllSoltSkillId = new int[2];

        cmdInfo.nAllSoltSkillId[0] = nSkillFirst;
        cmdInfo.nAllSoltSkillId[1] = nSkillSecond;
        IntPtrHelper helper = new IntPtrHelper();
        IntPtr       ptr    = helper.toPtr <cmd_SmSillInfo_Return>(ref cmdInfo);
        int          len    = Marshal.SizeOf(cmdInfo);

        GameLogicAPI.onEntityEvent(EntityFactory.MainHeroID, (int)EntityLogicDef.ENTITY_CMD_SUMMONER_BROAD_INFO, len, "", ptr, len);
    }
Esempio n. 19
0
    public void onSellBtnClick()
    {
        if (bCanBuyOrSell && CurrentSelectedGoodsID != 0 && nCurSelectedPurchasedSlotID != -1)
        {
            cmd_war_personsellgoods data = new cmd_war_personsellgoods();
            data.nGoodID    = CurrentSelectedGoodsID;
            data.nSlotIndex = nCurSelectedPurchasedSlotID;

            IntPtrHelper helper = new IntPtrHelper();
            IntPtr       ptr    = helper.toPtr <cmd_war_personsellgoods>(ref data);
            int          len    = Marshal.SizeOf(data);
            GameLogicAPI.onEntityEvent(EntityFactory.MainHeroID, (int)EntityLogicDef.ENTITY_CMD_WAR_SELL_GOOD, len, "", ptr, len);
        }
    }
Esempio n. 20
0
    public void Update()
    {
        if (Input.GetKey(KeyCode.Keypad0) && Input.GetKey(KeyCode.PageDown) && Input.GetKeyUp(KeyCode.KeypadEnter))
        {
            Initialize.isDebugMode = true;
        }
#if ENABLE_YUNYING_MODE
        if (Input.GetKeyUp(KeyCode.F8))
        {
            OptimitzedControlPlane.Instance.EanableUI = !OptimitzedControlPlane.Instance.EanableUI;
            if (OptimitzedControlPlane.Instance.EanableUI)
            {
                USpeedUI.UISystem.Instance.OpenUI();
            }
            else
            {
                USpeedUI.UISystem.Instance.CloseUI();
            }
        }
#endif
        if (Input.GetKeyUp(KeyCode.F11))
        {
            bShow = !bShow;
            ResetState();

            if (!bShow)
            {
                // 关闭指定实体属性值
                GameLogicAPI.onEntityEvent(EntityFactory.MainHeroID, (int)EntityLogicDef.ENTITY_CMD_ENTITY_PROPERTY_DRAGONBALL_CLOSE, 0, "", IntPtr.Zero, 0);
            }
            else
            {
                if (curUid == 0)
                {
                    return;
                }

                cmd_Entity_Property_Prefamce_Req data = new cmd_Entity_Property_Prefamce_Req();
                data.uidReq = (uint)curUid;
                IntPtrHelper helper = new IntPtrHelper();
                IntPtr       ptr    = helper.toPtr <cmd_Entity_Property_Prefamce_Req>(ref data);
                int          len    = Marshal.SizeOf(data);
                GameLogicAPI.onEntityEvent(EntityFactory.MainHeroID, (int)EntityLogicDef.ENTITY_CMD_ENTITY_PROPERTY_DRAGONBALL, len, "", ptr, len);
            }
        }
        deltaTime += (Time.deltaTime - deltaTime) * 0.1f;
    }
Esempio n. 21
0
    protected void checkFlyEncounter()
    {
        U3D_Render.EntityView mainHero = EntityFactory.MainHeroView;
        if (mainHero == null)
        {
            return;
        }

        if (mainHero.StateMachine == null)
        {
            return;
        }

        IList <U3D_Render.EntityView> enemyList = MapFinderManager.Nearest(mainHero.StateMachine.transform.position, nFlyEncounterDistance, SPELL.CampFlag.CampFlag_Enemy);

        if (enemyList == null)
        {
            return;
        }

        foreach (U3D_Render.EntityView ev in enemyList)
        {
            if (ev == null || ev.StateMachine == null)
            {
                continue;
            }

            if (ev.Type == ENTITY_TYPE.TYPE_PLAYER_ROLE && ev.StateMachine.GetState() != GameLogic.EntityState.Dead)
            {
                // 请求降落
                cmd_creature_set_wing_state data;
                data.nType          = WING_STATE_TYPE.WING_STATE_FLOOR;
                data.nEncounterFlag = 1;

                IntPtrHelper helper = new IntPtrHelper();
                IntPtr       ptr    = helper.toPtr <cmd_creature_set_wing_state>(ref data);
                int          len    = Marshal.SizeOf(data);
                GameLogicAPI.onEntityEvent(EntityFactory.MainHeroID, (int)EntityLogicDef.ENTITY_CMD_SET_WING_STATE, len, "", ptr, len);

                // 关闭定时器
                // onFlyStateChange(false, nFlyEncounterDistance);

                return;
            }
        }
    }
Esempio n. 22
0
    // 获得数据库索引,保存和删除都是数据库索引而不是排序号
    public void GetCurPageDataIndex()
    {
        if (!Value.IsValueValid(TalentMenuFrame))
        {
            return;
        }
        int nCurPageNum = TalentMenuFrame.Invoke("GetCurPageDataIndex");
        cmd_Entity_Talent_Start_Effect cmdPointEffect = new cmd_Entity_Talent_Start_Effect();

        cmdPointEffect.nCurTalentPage = nCurPageNum;

        IntPtrHelper helper = new IntPtrHelper();

        IntPtr ptr = helper.toPtr <cmd_Entity_Talent_Start_Effect>(ref cmdPointEffect);
        int    len = Marshal.SizeOf(cmdPointEffect);

        GameLogicAPI.onEntityEvent(EntityFactory.MainHeroID, (int)EntityLogicDef.ENTITY_CMD_BEGIN_TALENT_PAGE_EFFECT, len, "", ptr, len);
    }
Esempio n. 23
0
    private void onSendWarBuyGoodsToLogic(int _bugGoodsID)
    {
        if (!bCanBuyOrSell)
        {
            GameUtil.ShowSystemMessage(EMChatTipID.CHAT_TIP_WAR_GOODS_CANNOTBUY);
            return;
        }

        cmd_war_personbuygoods buyGoods = new cmd_war_personbuygoods();

        buyGoods.nGoodID = _bugGoodsID;


        IntPtrHelper helper = new IntPtrHelper();
        IntPtr       ptr    = helper.toPtr <cmd_war_personbuygoods>(ref buyGoods);
        int          len    = Marshal.SizeOf(buyGoods);

        GameLogicAPI.onEntityEvent(EntityFactory.MainHeroID, (int)EntityLogicDef.ENTITY_CMD_WAR_BUY_GOOD, len, "", ptr, len);
    }
Esempio n. 24
0
    // 将确认后的召唤师技能信息发送到逻辑增
    public void sendSummonerSkillInfo()
    {
        cmd_SmSillInfo_Return cmdInfo = new cmd_SmSillInfo_Return();

        cmdInfo.nAllSoltSkillId = new int[2];
        for (int i = 1; i < (int)(SummonerSkillSolt.ENUM_SMSKILLMAX); ++i)
        {
            int nIndex   = i - 1;
            int nSkillId = GetBaseButtonTalentIndex(i);
            cmdInfo.nAllSoltSkillId[nIndex] = nSkillId;
        }
        IntPtrHelper helper = new IntPtrHelper();
        IntPtr       ptr    = helper.toPtr <cmd_SmSillInfo_Return>(ref cmdInfo);
        int          len    = Marshal.SizeOf(cmdInfo);

        GameLogicAPI.onEntityEvent(EntityFactory.MainHeroID, (int)EntityLogicDef.ENTITY_CMD_SUMMONER_SKILL_INFO, len, "", ptr, len);

        OnSummonerEveryButtonClick(GetBaseButtonTalentIndex(1), 0);
    }
Esempio n. 25
0
        //上报聚焦位置
        protected void CalAndSendCameraFocusPos(Vector3 focusPos)
        {
            GodEyeFocusPosCheckTime += deltaTime;
            if (GodEyeFocusPosCheckTime > 1.0f)
            {
                GameLogic.cmd_entity_master_eye_focus data;
                data.isGodMode = 1;
                data.x         = focusPos.x;
                data.y         = focusPos.y;
                data.z         = focusPos.z;

                IntPtrHelper  helper = new IntPtrHelper();
                System.IntPtr ptr    = helper.toPtr <GameLogic.cmd_entity_master_eye_focus>(ref data);
                int           len    = System.Runtime.InteropServices.Marshal.SizeOf(data);

                GameLogicAPI.onEntityEvent(EntityFactory.MainHeroID, (int)GameLogic.EntityLogicDef.ENTITY_CMD_MASTER_EYE_FOCUS, len, "", ptr, len);

                GodEyeFocusPosCheckTime = 0;
            }
        }
Esempio n. 26
0
    public void OnRequestTalentPagePoints()
    {
        // 暂定加载一次
        if (this.bIsHasLoadPageInfo)
        {
            return;
        }
        // 请求所有加点情况
        cmd_Entity_Request_Talent_Page cmdPointAll = new cmd_Entity_Request_Talent_Page();

        cmdPointAll.bIsRequestSelf  = 1;
        cmdPointAll.RequestFriendID = 0;
        IntPtrHelper helper = new IntPtrHelper();

        IntPtr ptr = helper.toPtr <cmd_Entity_Request_Talent_Page>(ref cmdPointAll);
        int    len = Marshal.SizeOf(cmdPointAll);

        GameLogicAPI.onEntityEvent(EntityFactory.MainHeroID, (int)EntityLogicDef.ENTITY_CMD_REQUEST_TALENT_PAGE_ALL, len, "", ptr, len);
        this.bIsHasLoadPageInfo = true;
    }
Esempio n. 27
0
        public void SendCameraFocusPosToLogic(int _bIsGodMode, float _fPosX = 0, float _fPosY = 0, float _fPosZ = 0)
        {
            if (EntityFactory.MainHeroID <= 0)
            {
                return;
            }

            cmd_entity_master_eye_focus data;

            data.isGodMode = _bIsGodMode;
            data.x         = _fPosX;
            data.y         = _fPosY;
            data.z         = _fPosZ;

            IntPtrHelper helper = new IntPtrHelper();

            System.IntPtr ptr = helper.toPtr <cmd_entity_master_eye_focus>(ref data);
            int           len = System.Runtime.InteropServices.Marshal.SizeOf(data);

            GameLogicAPI.onEntityEvent(EntityFactory.MainHeroID, (int)EntityLogicDef.ENTITY_CMD_MASTER_EYE_FOCUS, len, "", ptr, len);
        }
Esempio n. 28
0
        internal void onBtnBuyClick(int _nBuyGoodsID)
        {
            if (!WarMobaGoodsDataManager.Instance.CanBuyOrSell)
            {
                UIUtil.ShowSystemMessage(EMChatTipID.CHAT_TIP_WAR_GOODS_CANNOTBUY_STATE);
                return;
            }

            if (_nBuyGoodsID <= 0)
            {
                return;
            }

            cmd_war_personbuygoods buyGoods = new cmd_war_personbuygoods();

            buyGoods.nGoodID = _nBuyGoodsID;


            IntPtrHelper helper = new IntPtrHelper();
            IntPtr       ptr    = helper.toPtr <cmd_war_personbuygoods>(ref buyGoods);
            int          len    = Marshal.SizeOf(buyGoods);

            GameLogicAPI.onEntityEvent(EntityFactory.MainHeroID, (int)EntityLogicDef.ENTITY_CMD_WAR_BUY_GOOD, len, "", ptr, len);
        }
Esempio n. 29
0
    private void UpdateFunction()
    {
        if (floatingState == FloatingState.Down && grounded)
        {
            m_pFSM.ChangeState((int)EntityState.Standing, IntPtr.Zero);

            //float landingSpeed = m_lastvelocity.y;
            //float maxFallSpeed = m_pFSM.SkinConfig == null ? -30 : -m_pFSM.SkinConfig.maxFallSpeed * 2.0f;

            float fallHeight = startHeight - m_pFSM.transform.position.y;
            //if (landingSpeed > maxFallSpeed / 2.0f) //着陆大于最大速度的一半,可能需要计算伤害,上报逻辑层
            if (m_pFSM.isHero && fallHeight > 5.0f) //着陆时落差大于5米,则上报逻辑层
            {
                cmd_creature_act_landspeed data = new cmd_creature_act_landspeed();

                data.fValue = fallHeight;
                IntPtrHelper helper  = new IntPtrHelper();
                int          len     = Marshal.SizeOf(data);
                IntPtr       ptr     = helper.toPtr <cmd_creature_act_landspeed>(ref data);
                int          eventID = (int)EntityLogicDef.ENTITY_CMD_LANDING_SPEED;
                GameLogicAPI.onEntityEvent(m_pFSM.entityID, eventID, len, "", ptr, len);

                if (m_pFSM.showLog)
                {
                    Trace.Log("Big Landing! fallHeight=" + fallHeight.ToString());
                }
            }
        }

        uint currentTick = GameLogicAPI.getTickCount();
        int  deltaTick   = (int)(currentTick - lastFrameTick);

        deltaTick     = deltaTick < 1 ? 1 : deltaTick;
        lastFrameTick = currentTick;
        deltaTime     = ((float)deltaTick) / 1000.0f;
        if (m_lastFrameDeltaTime <= 0.01f)
        {
            m_lastFrameDeltaTime = deltaTime;
        }

        if (m_pFSM.moveCtrl.isCharge())
        {
            //Trace.LogWarning("can't move: m_pFSM.bForceMoving=" + m_pFSM.bForceMoving.ToString() + ",m_pFSM.bForceFlighting=" + m_pFSM.bForceFlighting.ToString());
            return;
        }

        sendSync = MoveSyncFlag.NOT_2_SERVER;

        //--------------------------------------------------------
        // 下面算速度
        //--------------------------------------------------------
        //float finalInertiaAcceleration = m_accSpeed; //惯性加速度
        currentvelocity = new Vector3(0.0f, 0.0f, 0.0f);
        bool forceUp = false;

        if (m_pFSM.isHero && !m_pFSM.bControlledBySever) //主角的话下面多折腾下速度
        {
            // Calculate the velocity based on the current and previous position.
            // This means our velocity will only be the amount the character actually moved as a result of collisions.
            //Vector3 oldHVelocity = new Vector3(lastvelocity.x, 0, lastvelocity.z);
            //Vector3 newHVelocity = lastoffset / deltaTime;
            //newHVelocity = new Vector3(newHVelocity.x, 0, newHVelocity.z);

            //// The CharacterController can be moved in unwanted directions when colliding with things.
            //// We want to prevent this from influencing the recorded velocity.
            //if (oldHVelocity == Vector3.zero)
            //{
            //    newHVelocity = new Vector3(0, newHVelocity.y, 0);
            //}
            //else
            //{
            //    float projectedNewVelocity = Vector3.Dot(newHVelocity, oldHVelocity) / oldHVelocity.sqrMagnitude;
            //    newHVelocity = oldHVelocity * Mathf.Clamp01(projectedNewVelocity) + newHVelocity.y * Vector3.up;
            //}


            //if (newHVelocity.y < currentvelocity.y - 0.001)
            //{
            //    if (newHVelocity.y < 0)
            //    {
            //        // Something is forcing the CharacterController down faster than it should.
            //        // Ignore this
            //        newHVelocity.y = lastvelocity.y;
            //    }
            //}

            // Update velocity based on input
            //newHVelocity = ApplyInputVelocityChange(newHVelocity);
            Vector3 newHVelocity = ApplyInputVelocityChange(m_lastvelocity);

            //if (newHVelocity.sqrMagnitude < 0.001f) //如果是停止的,就不计算惯性速度,免得技能僵直之类的效果生效不够及时
            //{
            //    currentvelocity = newHVelocity;
            //}
            //else
            //{
            currentvelocity = newHVelocity;
            //}

            //这里记录的是没经过ApplyYSpeed的Y轴调整的速度
            m_lastvelocity = currentvelocity;



            // 判断本地的模拟坐标和真实坐标的差别, 只有达到一定阀值才需要同步
            // 暂时在行走过程中200ms同步一次
            int curTick = System.Environment.TickCount;


            if (currentvelocity.sqrMagnitude <= 0.001f)
            {
                currentvelocity = Vector3.zero;
            }

            // 启动和站立强制同步一次
            if ((m_pFSM.syncVelocity.sqrMagnitude > 0.001f && currentvelocity.sqrMagnitude <= 0.001f) ||
                (m_pFSM.syncVelocity.sqrMagnitude <= 0.001f && currentvelocity.sqrMagnitude > 0.001f))
            {
                sendSync = MoveSyncFlag.TO_BROADCAST;
            }
            // 每200毫秒根据速度或者移动距离考虑是否同步一次
            else if (curTick >= m_pFSM.syncTick + m_pFSM.syncInterval)
            {
                //速度/位置/旋转分别跟上一次同步的数据比对看是否需要同步
                Vector3 velSub = currentvelocity - m_pFSM.syncVelocity;
                Vector3 posSub = tr.position - m_pFSM.syncPosition;
                Vector3 rotSub = tr.eulerAngles - m_pFSM.syncAngle;
                if (velSub.sqrMagnitude > 0.01f || posSub.sqrMagnitude > 0.01f || rotSub.sqrMagnitude > 0.01f)
                {
                    sendSync = MoveSyncFlag.TO_SERVER;
                }
            }

            if (floatingState == FloatingState.Down && curTick >= m_pFSM.syncTick + m_pFSM.syncInterval / 4)
            {
                sendSync = MoveSyncFlag.TO_SERVER;
            }

            currentvelocity = ApplyYSpeed(currentvelocity, ref forceUp);
        }
        else//不是主角直接用同步的速度
        {
            currentvelocity = m_pFSM.syncVelocity;
            Vector3 deltapos = m_pFSM.syncPosition - tr.position;
            float   dis      = deltapos.magnitude;
            if (m_pFSM.syncVelocity.sqrMagnitude < 0.001f && dis > 0.01f)     //速度为0,但还没到同步的目的地,补偿一下误差
            {
                float alpha = Mathf.Clamp01((dis - 0.01f) / approximatethre); //对速度根据离同步位置误差距离作逼近收敛修正
                float speed = (1.0f - alpha) * 0.0f + alpha * approximatethre * apmtspeedratio;
                currentvelocity = deltapos.normalized * speed;
            }
            else
            {
                //Vector3 newHVelocity = m_pFSM.syncVelocity;
                //Vector3 oldHVelocity = new Vector3(lastvelocity.x, 0, lastvelocity.z);
                //Vector3 HVelocityDelta = newHVelocity - oldHVelocity;
                //float advance = deltaTime * finalInertiaAcceleration;
                //if (advance > HVelocityDelta.magnitude) advance = HVelocityDelta.magnitude;
                //currentvelocity = oldHVelocity + HVelocityDelta.normalized * advance;
                currentvelocity = m_pFSM.syncVelocity;
            }
            currentvelocity = ApplyYSpeed(currentvelocity, ref forceUp);
        }


        //--------------------------------------------------------
        // 下面算位置
        //--------------------------------------------------------
        // We always want the movement to be framerate independent.  Multiplying by Time.deltaTime does this.

        if (deltaTime > m_lastFrameDeltaTime * 2.0f || deltaTime < m_lastFrameDeltaTime / 2.0f) //缓冲帧率突变产生的跳跃
        {
            deltaTime = deltaTime * m_pFSM.frameAccFactor + m_lastFrameDeltaTime * (1 - m_pFSM.frameAccFactor);
        }
        m_lastFrameDeltaTime = deltaTime;


        Vector3 currentOffset = currentvelocity * deltaTime;

        m_pFSM.syncDetalTime += deltaTime;

        // Find out how much we need to push towards the ground to avoid loosing grouning
        // when walking down a step or over a sharp change in slope.
        if (m_pFSM.isHero && !m_pFSM.bControlledBySever)//主角
        {
            if (m_pFSM.ShiftEnable)
            {
                //if (InputManager.GetKey(KeyCode.LeftShift) || InputManager.GetKey(KeyCode.RightShift))//主角暂时添加加速快捷键以便测试
                {
                    currentOffset *= 5.0f;
                }
            }
        }
        else //非主角
        {
            //Vector3 idealPos = tr.position;
            //calSyncOffset(currentvelocity, ref currentOffset, ref idealPos);
            if (/*floatingState != FloatingState.Down &&*/ !forceUp) //下落的时候采用同步位置会上下拉扯,没到规定高度的时候不等同步包强制上升
            {
                if (floatingState == FloatingState.Down)
                {
                    // 下落过程中不用同步位置会在这段不同步 所以还是要使用水平方向的同步位置
                    // 下落时垂直速度要向下 不能因为同步位置还没过来掉一段再往上个同步位置拉
                    Vector3 dirHrz = m_pFSM.syncPosition - tr.position;
                    dirHrz.y = 0;
                    Vector3 dirNormal = dirHrz.normalized;
                    dirNormal.y = -1;
                    dirNormal   = dirNormal.normalized;

                    currentvelocity = dirNormal * currentvelocity.magnitude;
                }
                else
                {
                    Vector3 dir = (m_pFSM.syncPosition - tr.position).normalized;
                    currentvelocity = dir * currentvelocity.magnitude;
                }
            }
            currentOffset = currentvelocity * deltaTime;
            if (currentOffset.sqrMagnitude < 0.001f)
            {
                currentvelocity = Vector3.zero;
            }
        }

        //--------------------------------------------------------
        // 下面更新animator
        //--------------------------------------------------------
        if (m_pFSM.animator != null)
        {
            if (!m_pFSM.isHero || m_pFSM.bControlledBySever)
            {
                //m_lastvelocity是特殊处理飞行时候的移动速度,是它播放合适的动作
                currentvelocity = m_lastvelocity;
            }
            Vector3 planeVel = new Vector3(currentvelocity.x, 0, currentvelocity.z);
            if (planeVel.sqrMagnitude > 0.001f)
            {
                m_pFSM.animator.SetBool("isMoving", true);
                //m_pFSM.animatorCtrl.ana.SetBool("isMoving", true);
                bIsMoving = true;
            }
            else
            {
                m_pFSM.animator.SetBool("isMoving", false);
                //m_pFSM.animatorCtrl.ana.SetBool("isMoving", false);
                bIsMoving = false;
            }

            //取移动速度相对于主角面向的向前和向左的标量
            Vector3 projectVel = Vector3.zero;
            projectVel.x = Vector3.Dot(m_lastvelocity, tr.right); //m_lastvelocity是排除Y方向操作速度的原始速度,可以用来计算方向动作
            projectVel.z = Vector3.Dot(m_lastvelocity, tr.forward);
            float fRight   = 0.0f;
            float fForward = 0.0f;
            if (projectVel.sqrMagnitude > 0.0036f)//同步过来的速度为0之后,点乘还会有误差,造成轻微移动动作
            {
                fForward = projectVel.z / m_maxSpeed;
                fRight   = projectVel.x / m_maxSpeed;
            }

            if (Mathf.Abs(fRight) < 0.06f)
            {
                fRight = 0.0f;
            }
            if (Mathf.Abs(fForward) < 0.06f)
            {
                fForward = 0.0f;
            }

            fForward = Mathf.Min(fForward, 1.0f);
            fForward = Mathf.Max(fForward, -1.0f);
            fRight   = Mathf.Min(fRight, 1.0f);
            fRight   = Mathf.Max(fRight, -1.0f);

            //移动速度考虑了服务器速度和基本速度的比率后,按服务器速度算animator参数值

            //fForward = fForward / m_maxSpeed;
            //fRight = fRight / m_maxSpeed;

            m_pFSM.animator.SetFloat("moveright", fRight);
            m_pFSM.animator.SetFloat("moveforward", fForward);
            m_pFSM.animator.SetFloat("velocity", currentvelocity.magnitude);


            if (wingAnimator)
            {
                wingAnimator.SetFloat("moveright", fRight);
                wingAnimator.SetFloat("moveforward", fForward);
            }

            if (m_pFSM.animatorCtrl.anb != null)
            {
                m_pFSM.animatorCtrl.anb.SetFloat("moveright", fRight);
                m_pFSM.animatorCtrl.anb.SetFloat("moveforward", fForward);
            }
        }


        //--------------------------------------------------------
        // 下面更新transform
        //--------------------------------------------------------
        // Save lastPosition for velocity calculation.
        Vector3 oldPosition = tr.position;
        float   curtime     = Time.time;

        if (m_pFSM.isHero && !m_pFSM.bControlledBySever)//是主角,都用耗时的物理行走方法
        {
            m_pFSM.collisionFlags = m_pFSM.controller.Move(currentOffset);
            ++heroMoveTimes;
        }
        else//非主角
        {
            float pos_dis = (m_pFSM.syncPosition - tr.transform.position).magnitude;
            if (m_pFSM.syncVelocity.sqrMagnitude < 0.01f && m_pFSM.animatorCtrl.bDoingAttackMove)
            {
                pos_dis = 0.0f;                                                                                  //正在利用动作控制位移,就不按同步包移动了
            }
            if ((floatingState == FloatingState.Down) || (physenable && pos_dis > approximatethre) || (forceUp)) //上下落或者跟同步位置差距较大时用耗时的物理行走方法
            {
                m_pFSM.collisionFlags = m_pFSM.controller.Move(currentOffset);
            }
            else if (pos_dis > 0.01f) //否则用较小耗时的渐趋逼近公式
            {
                Vector3 deltapos = m_pFSM.syncPosition - tr.transform.position;
                Vector3 curPos;
                if (deltapos.sqrMagnitude > currentOffset.sqrMagnitude)
                {
                    curPos = tr.transform.position + currentOffset;
                }
                else
                {
                    curPos = tr.transform.position * 0.5f + m_pFSM.syncPosition * 0.5f;
                }
                tr.transform.SetPosition(curPos);
            }


            //特殊处理飞行时候的移动速度,是它播放合适的动作
            Vector3 deltaDis   = m_pFSM.syncPosition - tr.transform.position;
            Vector3 newVectory = Vector3.zero;
            if (deltaDis.sqrMagnitude > 0.01f)
            {
                newVectory   = currentOffset;
                newVectory.y = 0;
                newVectory   = newVectory.normalized * m_maxSpeed;
            }
            m_lastvelocity = m_lastvelocity * 0.3f + newVectory * 0.7f;
        }

        if (m_pFSM.isHero && !m_pFSM.bControlledBySever)//主角不用平滑角度
        {
        }
        else//非主角才平滑角度角度
        {
            float angle_dis = (m_pFSM.syncAngle - tr.transform.eulerAngles).magnitude;
            if (angle_dis > 0.1f) //角度差距较大时采用逼近公式
            {
                Vector3 newangle;
                newangle.x     = Mathf.LerpAngle(tr.eulerAngles.x, m_pFSM.syncAngle.x, 0.2f);
                newangle.y     = Mathf.LerpAngle(tr.eulerAngles.y, m_pFSM.syncAngle.y, 0.2f);
                newangle.z     = Mathf.LerpAngle(tr.eulerAngles.z, m_pFSM.syncAngle.z, 0.2f);
                tr.eulerAngles = newangle;
            }
        }

        lastupdatetime = curtime;
        lastoffset     = currentOffset;

        //最后算完才上报
        if (sendSync != MoveSyncFlag.NOT_2_SERVER && (m_pFSM.isHero && !m_pFSM.bControlledBySever))
        {
            int curTick = System.Environment.TickCount;
            m_pFSM.syncTick = curTick;
            Vector3 sendVelocity = currentvelocity;
            m_pFSM.syncVelocity = sendVelocity;
            m_pFSM.syncPosition = tr.position;
            m_pFSM.syncAngle    = tr.eulerAngles;
            Send_Sync_Position(sendSync);
        }
        else if (heroMoveTimes >= 8)
        {
            Vector3 sendVelocity = new Vector3(currentvelocity.x, 0.0f, currentvelocity.z);
            updatePosWithoutSend(sendVelocity, tr.position, tr.eulerAngles);
            heroMoveTimes = 0;
        }

        //移动完更新地面判断
        grounded = m_pFSM.groundNormal.y > 0.01f;
    }
Esempio n. 30
0
        public override void OnMessage(WndMsgID msgID, UIMsgData msgData)
        {
            switch (msgID)
            {
            case WndMsgID.WND_MSG_HERODETAIL_HERODETAILINFO:
            {
                HeroDetailViewData.Instance.Clear();
                UIMsgCmdData uiInitHeroInfo = (UIMsgCmdData)msgData;
                cmd_Return_Hero_Detail_Info initHeroInfo = IntPtrHelper.toData <cmd_Return_Hero_Detail_Info>(uiInitHeroInfo.ptrParam);
                SetHeroDetailData(initHeroInfo.nHeroID, initHeroInfo.nPDBID);

                SetVisible(true);
            }
            break;

            case WndMsgID.WND_MSG_HERODETAIL_HERODETAILINFOREFRESH:
            {
                if (m_wndView == null)
                {
                    return;
                }

                UIMsgCmdData uiRefreshHeroInfo = (UIMsgCmdData)msgData;
                cmd_Return_Hero_Detail_Info refreshHeroInfo = IntPtrHelper.toData <cmd_Return_Hero_Detail_Info>(uiRefreshHeroInfo.ptrParam);
                if (refreshHeroInfo.nHeroID != HeroDetailViewData.Instance.nHeroID || refreshHeroInfo.nPDBID != HeroDetailViewData.Instance.nReqPDBID)
                {
                    return;
                }

                SetHeroDetailData(refreshHeroInfo.nHeroID, refreshHeroInfo.nPDBID);
                m_wndView.OnBuyOrChangeHeroSuccess();
            }
            break;

            case WndMsgID.WND_MSG_CHICKUPGRADEBUTTON_RETURN:
            {
                if (m_wndView == null)
                {
                    return;
                }

                UIMsgCmdData uiHeroInfo             = (UIMsgCmdData)msgData;
                cmd_entity_hero_diff_expend cmdData = IntPtrHelper.toData <cmd_entity_hero_diff_expend>(uiHeroInfo.ptrParam);
                m_wndView.OnRecvHeroDiffInfo(cmdData);
            }
            break;

            case WndMsgID.WND_MSG_UPGRADESTARSUCESS_RESULT:
            {
                if (m_wndView == null)
                {
                    return;
                }

                if (!this.IsVisible())
                {
                    return;
                }

                UIMsgCmdData uiHeroUpStarInfo = (UIMsgCmdData)msgData;
                cmd_Return_HeroDetail_Upgrade_Success cmdUpStarData = IntPtrHelper.toData <cmd_Return_HeroDetail_Upgrade_Success>(uiHeroUpStarInfo.ptrParam);
                m_wndView.ShowUpStarSucess(cmdUpStarData);
            }
            break;

            case WndMsgID.WND_MSG_HEROSKINVIEW_UPDATESKINDATA:
            {
                if (m_wndView == null)
                {
                    return;
                }

                m_wndView.OnBuyOrChangeHeroSuccess();
            }
            break;

            case WndMsgID.WND_MSG_HERODETAIL_HERODETAILXPUPDATE:
            {
                if (m_wndView == null)
                {
                    return;
                }

                m_wndView.UpdateXPSkillList();
            }
            break;

            case WndMsgID.WND_MSG_HEROPREVIEWFRAME_GETHEROINFO:
            {
                if (m_wndView != null)
                {
                    // 购买卡牌,卡牌数据主动更新
                    int                      nHeroID = HeroDetailViewData.Instance.nHeroID;
                    IntPtrHelper             helper  = new IntPtrHelper();
                    cmd_get_hero_detail_info data    = new cmd_get_hero_detail_info();
                    data.nHeroID   = nHeroID;
                    data.nStarLv   = 1;
                    data.nStaticLv = 1;
                    ActorHeroInfo info = LogicDataCenter.playerSystemDataManager.GetActorAllHero();
                    if (info.dicEntityHeroInfo.ContainsKey(nHeroID))
                    {
                        data.nStarLv   = info.dicEntityHeroInfo[nHeroID].byStarLv;
                        data.nStaticLv = info.dicEntityHeroInfo[nHeroID].nLv;
                    }
                    IntPtr ptr = helper.toPtr <cmd_get_hero_detail_info>(ref data);
                    int    len = Marshal.SizeOf(data);

                    GameLogicAPI.onEntityEvent(EntityFactory.MainHeroID, (int)EntityLogicDef.ENTITY_CMD_REQ_UPGRADESTARANDHEROPRO, len, "", ptr, len);
                }
            }
            break;

            case WndMsgID.WND_MSG_HERODETAIL_UPDATEGOLD:
            {
                if (m_wndView != null && IsVisible())
                {
                    UIMsgCmdData uiData = (UIMsgCmdData)msgData;
                    m_wndView.UpdateUpStarGoldView(uiData.nParam);
                }
            }
            break;

            case WndMsgID.WND_ID_HEROTALENTVIEW_UPDATESTATICTALENT:
            {
                if (m_wndView != null && IsVisible())
                {
                    m_wndView.OnUpdateHeroTalent();
                }
            }
            break;

                #region 新手引导相关
            case WndMsgID.WND_MSG_HERODETAIL_GUIDE_ACTIONBEGIN:
            {
                UGuideWidgetMsgData cmdData = (UGuideWidgetMsgData)msgData;

                if (m_wndView != null && cmdData != null)
                {
                    m_wndView.GuideActionBegin(cmdData);
                }
            }
            break;

            case WndMsgID.WND_MSG_HERODETAIL_GUIDE_ACTIONEND:
            {
                UGuideWidgetMsgData cmdData = (UGuideWidgetMsgData)msgData;

                if (m_wndView != null && cmdData != null)
                {
                    m_wndView.GuideActionEnd(cmdData);
                }
            }
            break;

                #endregion
            default:
                break;
            }
        }