示例#1
0
    private GameObject setInfo(roleInfo pInfo, int orderUIID)
    {
        //加载图片
        string    fileName = csPicPath + pInfo.picName;
        Texture2D texture1 = (Texture2D)Resources.Load(csPicPath + pInfo.picName) as Texture2D;

        //创建UI
        UnityEngine.Object infoObj = Resources.Load("Prefab/UI/" + csRoleInfo);
        GameObject         tmpObj  = GameObject.Instantiate(infoObj, viewPortLst) as GameObject;
        //Image tmpImage = tmpObj.GetComponent<Image>();
        //tmpImage.sprite = Sprite.Create(texture1, new Rect(0, 0, texture1.width, texture1.height), new Vector2(0.5f, 0.5f));

        //hp显示及背景默认隐藏
        roleInfoUI tmpInfoUI = tmpObj.GetComponent <roleInfoUI>();

        tmpInfoUI.hpSlider.value = pInfo.hp * 100.0f / pInfo.maxHp;
        tmpInfoUI.backImage.gameObject.SetActive(false);
        tmpInfoUI.picIcon.sprite = Sprite.Create(texture1, new Rect(0, 0, texture1.width, texture1.height), new Vector2(0.5f, 0.5f));
        tmpInfoUI.roleID         = pInfo.roleID;
        pInfo.infoUI             = tmpInfoUI;
        // uiRole.Add(pInfo);
        //int order = uiRole.Count - 1;
        tmpInfoUI.orderUIID = orderUIID;

        //点击事件绑定
        Button tmpBtn = tmpObj.GetComponent <Button>();

        tmpBtn.onClick.AddListener(delegate()
        {
            this.OnClick(orderUIID);
        });
        return(tmpObj);
    }
示例#2
0
    private void initData()
    {
        uiRole = new List <roleInfo>();
        int nCount = 0;

        gameDataMgr.bossTag tmpTag = gameDataMgr.gameData().m_bossTag;
        for (int i = 0; i < tmpTag.bossUse.Length; i++)
        {
            if (tmpTag.bossUse[i] == true)
            {
                roleInfo tmpInfo = new roleInfo();

                tmpInfo.hp = gameDataMgr.gameData().m_roleData.bosshp[i];

                RoleProTable.rolePro tmpPro = RoleProTable.GetFromRoleID(i);
                tmpInfo.maxHp  = tmpPro.MaxHp;
                tmpInfo.roleID = tmpPro.ID;

                ShopItemTable.shopElements tmpEle = ShopItemTable.Get(i);
                //RoleInfoTable.roleElements tmpEle = RoleInfoTable.Get(i+1);
                tmpInfo.picName = tmpEle.Pic;

                uiRole.Add(tmpInfo);
                nCount++;
            }
        }

        //OKBtnClick
        btnOK.onClick.AddListener(delegate()
        {
            this.OKBtnClick();
        });
    }
示例#3
0
 void OnGUI()
 {
     for (int i = 0; i < roleInfoTableManager.instance.Size(); i++)
     {
         roleInfo info = roleInfoTableManager.instance.GetByIndex(i);
         GUILayout.Label(info.ID + info.name + info.resModel);
     }
 }
示例#4
0
 public static roleInfo getInstance()
 {
     if (_instance == null)
     {
         if (_instance == null)
         {
             _instance = new roleInfo();
         }
     }
     return(_instance);
 }
示例#5
0
        public List <roleInfo> GetRoleList()
        {
            List <roleInfo> l   = new List <roleInfo>();
            string          sql = "select * from t_admin_role order by id asc";

            try
            {
                using (DataTable dt = helper.GetDataTable(sql))
                {
                    Dictionary <int, adminLimit> dic = new _AdminLimit().getLimitDic();
                    foreach (DataRow r in dt.Rows)
                    {
                        roleInfo ad = new roleInfo
                        {
                            id       = Convert.ToInt16(r["id"]),
                            roleName = r["roleName"].ToString(),
                            limits   = r["limits"].ToString()
                        };
                        string[] arr       = ad.limits.Split(',');
                        string   limitInfo = "全部";
                        if (ad.limits != "*")
                        {
                            limitInfo = "";
                            foreach (string item in arr)
                            {
                                if (item.Length > 0)
                                {
                                    if (dic.ContainsKey(Convert.ToInt16(item)))
                                    {
                                        if (dic[Convert.ToInt16(item)].pId > 0)
                                        {
                                            limitInfo += dic[Convert.ToInt16(item)].typeName + "-" + dic[Convert.ToInt16(item)].limitName + " , ";
                                        }
                                    }
                                }
                            }
                        }
                        ad.limitInfo = limitInfo;
                        l.Add(ad);
                    }
                }
            }
            catch
            {
            }
            return(l);
        }
        //Add role in DB
        public void AddRole(RoleInfos role)
        {
            using (StationeryModel context = new StationeryModel())
            {
                roleInfo r = new roleInfo();
                r.roleID      = role.RoleId;
                r.roleName    = role.RoleName;
                r.description = role.Description;
                context.roleInfoes.Add(r);
                foreach (var ps in role.Permissions)
                {
                    rolePermission rp = new rolePermission();
                    rp.roleID       = role.RoleId;
                    rp.permissionID = ps.permissionID;

                    context.rolePermissions.Add(rp);
                }
                context.SaveChanges();
            }
        }
示例#7
0
    //加载显示UI
    public void showUI(int roleID, Action <int> pEvent)
    {
        calBackEvent = pEvent;

        initData();
        int nCount = uiRole.Count;
        //int nCount = pData.mRoleData.Count;
        int nRowMax = 3;
        int nLine   = Mathf.CeilToInt((float)nCount / (float)nRowMax);

        float         csPosX    = 160.0f;
        float         csPosY    = 124.0f;
        float         allHeight = csPosY * nLine;
        RectTransform tmpTrans  = viewPortLst.GetComponent <RectTransform>();

        tmpTrans.sizeDelta = new Vector2(csPosX * 3, allHeight);

        for (int i = 1; i <= nCount; i++)
        {
            int      orderUIID = i - 1;
            roleInfo tmpPro    = uiRole[orderUIID];
            //roleProperty tmpPro = pData.mRoleData[i - 1];
            if (tmpPro.roleID == roleID)   //设置默认选中的UIID
            {
                oldRoleIndex = orderUIID;
            }
            //设置信息
            GameObject tmpObj = setInfo(tmpPro, orderUIID);

            //调整位置
            RectTransform tmp     = tmpObj.GetComponent <RectTransform>();
            int           orderY  = orderUIID / nRowMax;
            int           orderX  = orderUIID - nRowMax * orderY;
            float         tmpPosX = csPosX * orderX;
            float         tmpPosY = csPosY * orderY;

            tmp.anchoredPosition3D = new Vector3(tmpPosX, tmpPosY, 0);
        }
        setSel(oldRoleIndex, true);
        this.gameObject.SetActive(true);
    }
示例#8
0
    void OnGUI()
    {
        GUILayout.BeginHorizontal();
        if (GUILayout.Button("Load File New"))
        {
            AIDataMgr.instance.LoadNewData();
        }
        if (GUILayout.Button("重新加载AI配置表"))
        {
            LoadAiTable();
        }
        if (GUILayout.Button("ClearAllAI", GUILayout.Width(100)))
        {
            AIMgr.instance.DestroyAllAIs();
        }
        if (GUILayout.Button("DebugWindow", GUILayout.Width(100)))
        {
            AIDebugWindow.Open();
        }

        GUILayout.EndHorizontal();

        AIMgr.DisableAiAttack = EditorGUILayout.Toggle("关闭AI攻击", AIMgr.DisableAiAttack);
        createCamp            = (EAiCamp)EditorGUILayout.EnumPopup("创建阵营", createCamp);
        createAsAI            = EditorGUILayout.Toggle("asAi", createAsAI);
        GUILayout.BeginHorizontal();
        aiModelName = AIFUIUtility.DrawTextField(aiModelName, "AI资源名");
        aiDataId    = EditorGUILayout.IntField("AI数据ID", aiDataId);
        GUILayout.EndHorizontal();
        GUILayout.BeginHorizontal();
        if (GUILayout.Button("Create"))
        {
            CreateAI(aiModelName, aiDataId, createCamp, createAsAI);
        }

        if (GUILayout.Button("CreateEnemy"))
        {
            CreateAI(aiModelName, aiDataId, EAiCamp.Enemy, true);
        }
        GUILayout.EndHorizontal();
        GUILayout.Label("创建列表");
        GUILayout.BeginScrollView(scrollPos);
        for (int i = 0; i < roleInfoTableManager.instance.Size(); i++)
        {
            roleInfo info = roleInfoTableManager.instance.GetByIndex(i);
            GUILayout.BeginHorizontal();
            GUILayout.Label(info.ID + "/" + info.AiDataId + "/" + info.name, GUILayout.Width(200));
            if (GUILayout.Button("创建为主角"))
            {
                CreateAI(info.resModel, info.AiDataId, EAiCamp.MainPlayer, false);
            }
            if (GUILayout.Button("创建为友方"))
            {
                CreateAI(info.resModel, info.AiDataId, EAiCamp.Friend, true);
            }
            if (GUILayout.Button("创建为敌方"))
            {
                CreateAI(info.resModel, info.AiDataId, EAiCamp.Enemy, true);
            }
            GUILayout.EndHorizontal();
        }
        GUILayout.EndScrollView();
    }