Beispiel #1
0
    public static CharacterBase Create(int staticId, string name = null, int level = 1, Vector3 pos = default)
    {
        var  staticData = MainStaticDataCenter.instance.roleBaseTable.findItemWithId(staticId.ToString());
        uint uid        = GetUniqueId();

        if (uid > 0)
        {
            if (name == null)
            {
                name = CreateName.GetRandomSurnnameName((int)uid);
            }

            CharacterBase chBase = new CharacterBase();
            chBase.uid        = uid;
            chBase.staticData = staticData;

            chBase.items  = new HashSet <uint>();
            chBase.equips = new HashSet <uint>();
            chBase.skills = new List <SkillData>();
            // 默认添加空手为武器
            chBase.equips.Add(1);

            // 设置名字和等级
            chBase.charName = name;
            chBase.Level    = level;
            chBase.position = pos;

            // 初始化满血
            chBase.HP    = 1;
            chBase.SP    = 1;
            chBase.MaxHP = 1;
            chBase.MaxSP = 1;

            chBase.UpdateAttribute();

            Debug.LogError(name + " " + chBase.HP + "/" + chBase.MaxHP);
            return(chBase);
        }
        else
        {
            return(null);
        }
    }
Beispiel #2
0
 public void RandomName()
 {
     inputName.text = CreateName.GetRandomSurnnameName((int)(Time.time * 1000));
 }