Esempio n. 1
0
 private void Start()
 {
     if (gameObject.layer != Layer.Unit)
     {
         Debug.LogError(string.Format("Unit {0} is not in Unit layer.", gameObject.name));
     }
     //注册单位
     lock (GameDB.unitPool)
         attributes.ID = Gamef.UnitBirth(this);
     attributes.Init(this);
     //if (unit.data.IsCaster)
     //{
     //    //将技能施法者设置为自己, 初始化技能
     //    for (int i = 0; i < 4; i++)
     //    {
     //        skillTable.skills[i].Init(unitInfo, unit.data.skills[i]);
     //    }
     //    skillTable.CurrentIndex = 0;
     //}
     //测试用
     if (attributes.name == UnitName.Player)
     {
         GameCtrl.Instance.PlayerChara = this;
         StartCoroutine(DisplayProperity());
     }
     // 如果该单位是施法单位,则初始化技能表
     if (attributes.data.IsCaster)
     {
         skillTable.Init(this);
     }
 }
Esempio n. 2
0
    /// <summary>
    /// 外部可以通过该接口对单位进行初始化。
    /// </summary>
    /// <param name="ID">单位ID</param>
    public void InitAttributes(int ID)
    {
        if (isInitAttr)
        {
            return;
        }
        isInitAttr = true;
        //注册单位
        lock (GameDB.unitPool)
            attributes.ID = Gamef.UnitBirth(this, ID);

        attributes.Init(this);
        // 如果该单位是施法单位,则初始化技能表
        if (attributes.data.IsCaster)
        {
            skillTable.Init(this);
        }
    }