Ejemplo n.º 1
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.º 2
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);
        }
    }
Ejemplo n.º 3
0
    /// <summary>
    /// 创建角色确认按钮
    /// </summary>
    public void OnConfirmBtnClick(string name)
    {
        //判断名字是否合法
        if (CheckRoleName(name))
        {
            Debug.LogWarning("创建角色成功!!!!!");

            //根据角色基础属性,构建一个角色对象出来
            RoleBasicInfo roleBasic = ConfigManager.GetInstance().GetRoleBasicInfo(_view.currentType);
            if (roleBasic != null)
            {
                Player player = new Player(roleBasic, name);
                player.roleWeapon = ENUM_Weapon.Knife;
                PlayerConfig config = ConfigManager.GetInstance().GetPlayerConfig();
                if (config == null)
                {
                    config = new PlayerConfig();
                }
                config.players.Add(player);
                ConfigManager.GetInstance().SetPlayerConfig(config);
                string s = JsonConvert.SerializeObject(config);
                Debug.LogWarning(s);
                //写入本地数据表
                System.IO.File.WriteAllText(Application.dataPath + "/Resources/Config/PlayerConfig.txt", s);
            }
            else
            {
                Debug.LogError("无此职业的基础属性!!!");
            }
        }
        else
        {
            Debug.LogError("名字不合法或重复!!!");
            _view.pop.SetActive(true);
        }
    }