Пример #1
0
    public void Init()
    {
#if CWSDK
        CWSdkPubmeth.GetSdk.Init();
#endif

        GameObject plan   = GameObject.Find("Plane");
        Vector3    length = plan.GetComponent <MeshFilter>().mesh.bounds.size;
        xlength = length.x * plan.transform.lossyScale.x;
        ylength = length.z * plan.transform.lossyScale.z;
        Debug.Log($"地图的尺寸为  x:{xlength}  y:{ylength}");


        m_main  = GameObject.Find("Main Camera").GetComponent <Camera>();
        npcroot = GameObject.Find("NPC_Root");
        UIMgr.Instance.Init(GameObject.Find("UIRoot"), GameObject.Find("HUD"));


        player_info info = new player_info();
        info.ID      = 0;
        info.m_name  = "tony";
        info.m_level = 9;
        info.m_pos   = Vector3.zero;
        info.m_res   = "Teddy";
        info.m_HP    = 2000;
        info.m_MP    = 1000;
        info.m_hpMax = 2000;
        info.m_mpMax = 2000;

        //===技能解析读取   已取出单独解析
        //info.skillList =

        m_plyer = new HostPlayer(info);
        m_plyer.CreateObj(MonsterType.Null);
        JoyStickMgr.Instance.SetJoyArg(m_main, m_plyer);
        JoyStickMgr.Instance.JoyActive = true;

        CreateIns();

        MsgCenter.Instance.AddListener("AutoMove", (notify) =>
        {
            this.AutoMoveByInsId((int)notify.data[0], (Vector3)notify.data[1]);
        });

        MsgCenter.Instance.AddListener("AddBuff", (notify) =>
        {
            int insid    = (int)notify.data[0];
            int buffid   = (int)notify.data[1];
            ObjectBase p = m_insDic[insid];
            if (p is PlayerObj)
            {
                BuffSystem.Instance.AddBuff(p as PlayerObj, buffid);
            }
        });

        MsgCenter.Instance.AddListener("ReMoveBuff", (notify) =>
        {
        });
    }
Пример #2
0
    /// <summary>
    /// 初始化的方法
    /// </summary>
    public void Init()
    {
        //找到地图
        GameObject plan = GameObject.Find("Plane");
        //获得地图的尺寸
        Vector3 length = plan.GetComponent <MeshFilter>().mesh.bounds.size;

        xLength = length.x * plan.transform.localScale.x;
        yLength = length.z * plan.transform.localScale.z;
        Debug.Log($"地图的尺寸为 x:{xLength}   y:{yLength}");

        camera = GameObject.Find("Main Camera").GetComponent <Camera>();
        npc    = GameObject.Find("NPC_Root");
        UIMgr.Instance.Init(GameObject.Find("UIRoot"), GameObject.Find("HUD"));
        //给玩家赋值属性
        PlayerDate info = new PlayerDate();

        info.ID    = 1;            //ID
        info.name  = "Teddy";      //名字
        info.level = 99;           //等级
        info.pos   = Vector3.zero; //位置
        info.hp    = 2000;         //当前血量
        info.mp    = 1500;         //当前法力值
        info.MaxHp = 2000;         //最大血量
        info.MaxMp = 2000;         //最大法力值
        //把玩家的属性传到玩家自己的脚本身上
        player = new HostPlayer(info);
        //创建对应的角色
        player.CreateObj(RoleType.Null);
        JoyStickMgr.Instance.SetJoyArg(camera, player);
        JoyStickMgr.Instance.JoyActive = true;
        CreaeIns();
        //监听事件---移动
        MsgCenter.Instance.AddListener("AutoMove", (notify) =>
        {
            this.AutoMoveByInsId((int)notify.data[0], (Vector3)notify.data[1]);
        });
        //监听事件---Buff
        MsgCenter.Instance.AddListener("AddBuff", (notify) =>
        {
        });
    }