Ejemplo n.º 1
0
 public RoleBasicInfo GetRoleBasicInfo(ENUM_Role roleType)
 {
     for (int i = 0; i < RoleBasicInfos.Count; i++)
     {
         if (RoleBasicInfos[i].roleType == roleType)
         {
             return(RoleBasicInfos[i]);
         }
     }
     return(null);
 }
Ejemplo n.º 2
0
 public RoleBasicInfo(string name, string model, string icon, ENUM_Role roleType, int wise, int power, float speed, int hp, int mp)
 {
     this.name     = name;
     this.model    = model;
     this.icon     = icon;
     this.roleType = roleType;
     this.wise     = wise;
     this.power    = power;
     this.speed    = speed;
     this.hp       = hp;
     this.mp       = mp;
 }
Ejemplo n.º 3
0
 public Player(RoleBasicInfo basicInfo, string name)
 {
     this.name     = name;
     this.roleType = basicInfo.roleType;
     this.hp       = basicInfo.hp;
     this.mp       = basicInfo.mp;
     this.speed    = basicInfo.speed;
     this.level    = 1;
     this.exp      = 0;
     this.icon     = basicInfo.icon;
     this.model    = basicInfo.model;
     this.wise     = basicInfo.wise;
     this.power    = basicInfo.power;
 }
Ejemplo n.º 4
0
    public override void Initialize(string s)
    {
        m_RootUI = UnityTool.FindGameObject(s);

        tips = UnityTool.FindChildGameObject(m_RootUI, "Tips");
        item = UnityTool.FindChildGameObject(m_RootUI, "CreateRoleItemBtn");

        pop = UnityTool.FindChildGameObject(m_RootUI, "Pop");

        GoBackBtn  = UITool.GetUIComponent <Button>(m_RootUI, "GoBackBtn");
        RepeatBtn  = UITool.GetUIComponent <Button>(m_RootUI, "RepeatBtn");
        ConfirmBtn = UITool.GetUIComponent <Button>(m_RootUI, "ConfirmBtn");
        CancelBtn  = UITool.GetUIComponent <Button>(m_RootUI, "CancelBtn");

        showRole = UITool.GetUIComponent <Image>(m_RootUI, "ShowRole");

        input = UITool.GetUIComponent <InputField>(m_RootUI, "InputField");

        content = UITool.GetUIComponent <Transform>(m_RootUI, "CreateContent");

        pop.SetActive(false);



        //根据基础信息生成可以创建的角色
        List <RoleBasicInfo> roleBasicInfoList = _model.GetRoleBasicInfoConfig();

        for (int i = 0; i < roleBasicInfoList.Count; i++)
        {
            int        k     = i;
            GameObject clone = GameObject.Instantiate(item, content, false);
            clone.GetComponentInChildren <Text>().text = roleBasicInfoList[k].name;
            clone.GetComponent <Button>().onClick.AddListener(() =>
            {
                tips.SetActive(true);
                showRole.sprite = Resources.Load <Sprite>("RoleShow/" + roleBasicInfoList[k].model);
                currentType     = roleBasicInfoList[k].roleType;
            });
        }

        currentType = roleBasicInfoList[0].roleType;

        GoBackBtn.onClick.AddListener(() => { _ctrl.SwitchChooseRolePanel(); });

        RepeatBtn.onClick.AddListener(() => { _ctrl.OnRepeatBtnClick(input.text); });

        ConfirmBtn.onClick.AddListener(() => { _ctrl.OnConfirmBtnClick(input.text); });

        CancelBtn.onClick.AddListener(() => { _ctrl.OnCancelBtnClick(); });
    }
Ejemplo n.º 5
0
    /// <summary>
    /// 读取角色基础属性
    /// </summary>
    private void InitRoleBasicInfoConfig()
    {
        string s = AssetFactory.LoadConfig("RoleBasicInfoConfig");

        string[] arr = s.Split('&');
        for (int i = 1; i < arr.Length; i++)
        {
            string[]      array    = arr[i].Split('|');
            string        name     = array[0].Trim();
            string        model    = array[1].Trim();
            string        icon     = array[2].Trim();
            ENUM_Role     roleType = (ENUM_Role)int.Parse(array[3].Trim());
            int           wise     = int.Parse(array[4].Trim());
            int           power    = int.Parse(array[5].Trim());
            float         speed    = float.Parse(array[6].Trim());
            int           hp       = int.Parse(array[7].Trim());
            int           mp       = int.Parse(array[8].Trim());
            RoleBasicInfo role     = new RoleBasicInfo(name, model, icon, roleType, wise, power, speed, hp, mp);
            RoleBasicInfos.Add(role);
        }
    }