Example #1
0
        //-------------------------------------------------------------------------------------------------------
        private void MoveDir()
        {
            if (m_Owner == null)
            {
                return;
            }

            Vector3 pos = m_Owner.GetPos();

            Engine.IRenderSystem rs = Engine.RareEngine.Instance().GetRenderSystem();
            if (rs == null)
            {
                return;
            }
            m_curScene = rs.GetActiveScene();
            if (m_curScene == null)
            {
                return;
            }

            // 先设置人物旋转
            Quaternion rotate = new Quaternion();

            rotate.eulerAngles = new Vector3(0, m_param.m_dir, 0);

            Matrix4x4 mat = new Matrix4x4();

            mat.SetTRS(Vector3.zero, rotate, Vector3.one);
            m_dir = mat.GetColumn(2);

            if (!m_bIgnoreMoveAction)
            {
                m_Owner.PlayAction(m_param.strRunAct, 0, m_param.m_speed);
            }

            stEntityBeginMove move = new stEntityBeginMove();

            move.uid = m_Owner.GetUID();
            Engine.Utility.EventEngine.Instance().DispatchEvent((int)GameEventID.ENTITYSYSTEM_ENTITYBEGINMOVE, move);

            if (!m_bMoving)
            {
                Engine.Utility.Log.Error("MoveDir----------- {0}-------------------------------------", m_param.m_dir);

                m_vLastPos    = pos;
                m_lastSyncPos = m_vLastPos;

                m_bMoving = true;
                if (!m_bIgnoreMoveAction)
                {
                    m_Owner.PlayAction(m_param.strRunAct, 0, m_param.m_speed);
                }

                //Engine.Utility.TimerAxis.Instance().KillTimer(0, this);
                //Engine.Utility.TimerAxis.Instance().SetTimer(0, 33, this, TimerAxis.INFINITY_CALL, "EntityMove");
                m_LastTime = Engine.Utility.TimeHelper.GetTickCount();
            }
        }
Example #2
0
        //-------------------------------------------------------------------------------------------------------
        private void CloseTerrainPos(ref Vector3 curPos)
        {
            Engine.IRenderSystem rs = Engine.RareEngine.Instance().GetRenderSystem();
            if (rs == null)
            {
                return;
            }

            // 再计算移动速度
            m_curScene = rs.GetActiveScene();
            if (m_curScene == null)
            {
                return;
            }

            //和周围墙做碰撞修正
            // 计算得到新位置,还需要做一次碰撞检测,看是否可以行走
            //Ray rayLine = new Ray(m_vLastPos, pos - m_vLastPos);
            //Engine.ColliderInfo colliderInfo = new Engine.ColliderInfo();
            //float fDis = Vector3.Distance(pos, m_vLastPos);
            //if (m_curScene.GetColliderInfo(ref rayLine, ref colliderInfo))
            //{
            //    //Engine.Utility.Log.Trace("Dis:{0}", colliderInfo.distance);
            //    if (colliderInfo.distance < 1.5f) // 应当是玩家的半径
            //    {
            //        //                     if (colliderInfo.distance < fDis)
            //        //                     {
            //        //                         pos = m_vLastPos + Vector3.Normalize(m_vSpeed) * colliderInfo.distance;
            //        //                     }
            //        //                     else
            //        //                     {
            //        //            m_jumpSpeed =  Vector3.up * _jumpUp;
            //        //             m_vSpeed = m_jumpSpeed ;
            //        m_vSpeed = m_vSpeed - Vector3.Dot(m_vSpeed, colliderInfo.normal) * colliderInfo.normal;
            //        pos = m_vLastPos + m_vSpeed * Time.deltaTime;
            //        /*                    }*/
            //    }
            //}

            Engine.TerrainInfo info;
            if (m_curScene.GetTerrainInfo(ref curPos, out info))
            {
                //斜坡速度衰减.... 去掉
                //Vector3 right = Vector3.Cross(info.normal, m_dir);
                //Vector3 speed = Vector3.Cross(right, info.normal);
                //float cos = Vector3.Dot(m_dir, speed);

                //m_fSpeedTerrainFact = cos;
            }

            curPos.y = info.pos.y;
        }
Example #3
0
        private object SetPos(object param)
        {
            if (m_Owner != null)
            {
                Vector3 pos             = (Vector3)param;
                Engine.IRenderSystem rs = Engine.RareEngine.Instance().GetRenderSystem();
                if (rs == null)
                {
                    return(null);
                }
                // 取下地表高度
                // 再计算移动速度
                Engine.IScene curScene = rs.GetActiveScene();
                if (curScene == null)
                {
                    return(null);
                }
                Engine.TerrainInfo info;
                if (curScene.GetTerrainInfo(ref pos, out info))
                {
                    //if (pos.y < info.pos.y)
                    {
                        pos.y = info.pos.y;// +0.08f; // 往上提一个距离
                    }
                }

                //if (pos.y <= 10f)
                //{
                //    if (!EntitySystem.m_ClientGlobal.IsMainPlayer(m_Owner))
                //    {
                //        Vector3 mainPos = EntitySystem.m_ClientGlobal.MainPlayer.GetPos();
                //        pos.y = mainPos.y;
                //    }
                //}


                //if (EntitySystem.m_ClientGlobal.IsMainPlayer(m_Owner))
                //{
                //    Engine.Utility.Log.LogGroup("XXF", "Entity.SetPos ({0},{1})", pos.x,-pos.z);
                //}

                m_Owner.SetPos(ref pos);
            }
            else
            {
                Engine.Utility.Log.LogGroup("XXF", "Entity.SetPos m_Owner is null");
            }

            return(null);
        }
Example #4
0
        public override void FireEvent()
        {
            if (!AffectedObject)
            {
                return;
            }

            if (!Application.isPlaying && Application.isEditor)
            {
            }
            else
            {
                table.MapDataBase data = GameTableManager.Instance.GetTableItem <table.MapDataBase>(sceneID);
                if (data == null)
                {
                    return;
                }
                table.ResourceDataBase resDB = GameTableManager.Instance.GetTableItem <table.ResourceDataBase>(data.dwResPath);
                if (resDB == null)
                {
                    return;
                }

                Engine.IRenderSystem rs = Engine.RareEngine.Instance().GetRenderSystem();
                if (rs != null)
                {
                    string        str   = resDB.strPath;
                    Engine.IScene scene = rs.EnterScene(ref str, SequencerManager.Instance());
                    if (scene != null)
                    {
                        ///¼ÓÔس¡¾°
                        SequencerManager.Instance().Pause();

                        scene.StartLoad(Vector3.one);

                        //±£´æÏÂmapid
                        Client.IMapSystem map = Client.ClientGlobal.Instance().GetMapSystem();
                        SequencerManager.Instance().m_MapID = map.GetMapID();
                    }
                }
            }
        }
Example #5
0
        private void OnCreateRenderObj(Engine.IRenderObj obj, object param)
        {
            if (m_EntityView == null)
            {
                return;
            }

            if (m_EntityView.GetNode() == null)
            {
                Engine.Utility.Log.Error("OnCreateRenderObj  m_EntityView.GetNode() is null");
                return;
            }
            int nID        = GetProp((int)EntityProp.BaseID);
            var table_data = GameTableManager.Instance.GetTableItem <table.ItemDataBase>((uint)nID);

            if (table_data != null)
            {
                m_EntityView.GetNode().SetScale(UnityEngine.Vector3.one * table_data.scale * 0.01f);
            }

            if (nID == 60001)
            {
                UnityEngine.Vector3 pos = GetPos();
                pos.y += 0.05f;
                SendMessage(EntityMessage.EntityCommand_SetPos, (object)pos);
            }
            // 根据全局配置设置阴影
            //int nShadowLevel = EntitySystem.m_ClientGlobal.gameOption.GetInt("Render", "shadow", 1);
            //m_EntityView.SetShadowLevel(nShadowLevel);


            Engine.IRenderSystem rs = Engine.RareEngine.Instance().GetRenderSystem();
            if (rs == null)
            {
                return;
            }
            // 取下地表高度
            // 再计算移动速度
            Engine.IScene curScene = rs.GetActiveScene();
            if (curScene == null)
            {
                return;
            }
            Material mat = curScene.GetBoxMat();

            if (mat != null)
            {
                if (m_EntityView.GetMaterial() == null)
                {
                    return;
                }
                Texture tex = m_EntityView.GetMaterial().mainTexture;
                mat.mainTexture = tex;
                m_EntityView.ApplySharedMaterial(mat);
            }


            Vector3 currPos = GetPos();

            SetPos(ref currPos);

            Client.stCreateEntity createEntity = new Client.stCreateEntity();
            createEntity.uid = GetUID();
            Engine.Utility.EventEngine.Instance().DispatchEvent((int)GameEventID.ENTITYSYSTEM_CREATEENTITY, createEntity);
            //             if (!m_sendPickMsg && CanAutoPick())
            //             {
            //                 m_sendPickMsg = true;
            //                 Engine.Utility.EventEngine.Instance().DispatchEvent((int)Client.GameEventID.ROBOTCOMBAT_PICKUPITEM, new Client.stPickUpItem() { itemid = GetID(), state = 0 });
            //             }
        }
Example #6
0
    //正常播放完成
    public void PlaybackFinished(WellFired.USSequencer sequencer)
    {
        m_IsPlay = false;

        if (m_SequencerCamera != null)
        {
            GameObject obj    = GameObject.Find("MainCamera");
            Camera     camera = obj.GetComponent <Camera>();
            if (camera != m_SequencerCamera)
            {
                camera.enabled = true;
            }
        }
        m_SequencerCamera = null;
        m_SequencerData   = null;


        // 取消回调
        if (sequencer != null)
        {
            sequencer.PlaybackFinished -= this.PlaybackFinished;
            sequencer.BeforeUpdate     -= this.BeforeUpdate;
        }

        try
        {
            //显示npc
            Client.IEntitySystem es = Client.ClientGlobal.Instance().GetEntitySystem();
            if (es != null)
            {
                es.ShowEntity(true);
            }

            //删除剧情gameobject
            if (m_SequencerGameObject != null)
            {
                GameObject.Destroy(m_SequencerGameObject);
                m_SequencerGameObject = null;
            }
            Debug.Log("清理剧情对象");

            //清理剧情对象
            ClearSequencerTempObject();

            //打开声音
            Client.ClientGlobal.Instance().MuteGameSound(false);
        }
        catch
        {
            goto Exit0;
        }
Exit0:
        //隐藏提示
        TipsManager.Instance.EnableTips(true);

        //DataManager.Manager<UIPanelManager>().ShowStoryCachePanel();
        Debug.Log("剧情结束显示UI");
        RoleStateBarManager.ShowHeadStatus();
        //剧情结束隐藏黑边
        DataManager.Manager <UIPanelManager>().HideStory();
        Debug.Log("剧情结束隐藏黑边");
        Engine.Utility.EventEngine.Instance().DispatchEvent((int)Client.GameEventID.STORY_PLAY_OVER, null);

        //却换到原场景
        Engine.IRenderSystem rs = Engine.RareEngine.Instance().GetRenderSystem();
        if (m_MapID != 0)
        {
            // 剧情播放完毕加载原场景
            table.MapDataBase data = GameTableManager.Instance.GetTableItem <table.MapDataBase>(m_MapID);
            if (data == null)
            {
                return;
            }
            table.ResourceDataBase resDB = GameTableManager.Instance.GetTableItem <table.ResourceDataBase>(data.dwResPath);
            if (resDB == null)
            {
                return;
            }

            if (rs != null)
            {
                string        str   = resDB.strPath;
                Engine.IScene scene = rs.EnterScene(ref str, SequencerManager.Instance());
                if (scene != null)
                {
                    ///加载场景
                    SequencerManager.Instance().Pause();

                    scene.StartLoad(Vector3.one);
                }
            }
            m_MapID = 0;
        }
    }