Exemplo n.º 1
0
    private void ChangeSelect(object obj)
    {
        ServantVo vo = (ServantVo)obj;

        if (nowId == vo.id)
        {
            DataManager.Instance.servantModel.SetNow(nowVo.id);
            UpdateNow();
        }
        nowId = vo.id;
        nowVo = vo;
        for (int i = 0; i < barList.Count; i++)
        {
            barList[i].ChangeSelect(nowId);
        }
        UpdateInfo(nowVo);
        if (DataManager.Instance.servantModel.nowServant != nowVo)
        {
            nowServantSelect.SetActive(false);
            btnRemove.gameObject.SetActive(true);
        }
        else
        {
            btnRemove.gameObject.SetActive(false);
            nowServantSelect.SetActive(true);
        }
    }
Exemplo n.º 2
0
    public bool Add(StaticUnitLevelVo vo)
    {
        if (_dataList.Count >= DataManager.Instance.roleVo.maxServantNum)
        {
            return(false);
        }
        ServantVo servantVo = new ServantVo();

        servantVo.unitId = vo.unitId;
        servantVo.level  = 1;
        if (_dataList.Count != 0)
        {
            servantVo.id = _dataList[_dataList.Count - 1].id + 1;
        }
        else
        {
            servantVo.id = 0;
        }
        servantVo.exp         = 0;
        servantVo.maxSkillNum = Random.Range(vo.skillList.Count, 6);
        for (int i = 0; i < vo.skillList.Count; i++)
        {
            AddSkill(servantVo, StaticDataPool.Instance.staticSkillLevelPool.GetStaticDataVo(vo.skillList[i]));
        }
        _dataList.Add(servantVo);
        return(true);
    }
Exemplo n.º 3
0
    private void BtnClick(Button btn)
    {
        switch (btn.name)
        {
        case "btnLevelUp":
            bool result = DataManager.Instance.servantModel.LevelUp(nowVo);
            if (result == false)
            {
                UIManager.Instance.CreateTipPanel("灵魂不足");
            }
            else
            {
                OnUpdate(null);
            }
            break;

        case "btnNowServant":
            nowVo = DataManager.Instance.servantModel.nowServant;
            nowId = nowVo.unitId;
            nowServantSelect.SetActive(true);
            ChangeSelect(nowVo);
            break;

        case "btnRemove":
            UIManager.Instance.CreateConfirmPanel("真的要驱逐" + StaticDataPool.Instance.staticUnitPool.GetStaticDataVo(nowVo.unitId).name + "吗?", OnRemoveConfirm);
            break;
        }
    }
Exemplo n.º 4
0
    public void SetNow(int id)
    {
        ServantVo vo = _dataList.Find(p => p.id == id);

        if (vo != null)
        {
            nowServant = vo;
        }
    }
Exemplo n.º 5
0
    private void UpdateInfo(ServantVo vo)
    {
        StaticUnitVo staticUnitVo = StaticDataPool.Instance.staticUnitPool.GetStaticDataVo(nowVo.unitId);

        image.sprite = ResourceManager.Instance.GetCharactor(staticUnitVo.sprite);
        StaticUnitLevelVo nowLevelVo = StaticDataPool.Instance.staticUnitLevelPool.GetStaticDataVo(nowVo.unitId, nowVo.level);
        int nextLevel;

        if (nowLevelVo.level == 150)
        {
            nextLevel = 150;
            btnLevelUp.gameObject.SetActive(false);
        }
        else
        {
            nextLevel = nowLevelVo.level + 1;
        }
        {
            StaticUnitLevelVo nextVo = StaticDataPool.Instance.staticUnitLevelPool.GetStaticDataVo(nowLevelVo.unitId, nextLevel);
            roleName.text  = nowLevelVo.name;
            data1[0].text  = nowLevelVo.level.ToString();
            data1[1].text  = nextVo.needExp.ToString();
            data1[2].text  = ((int)(nowLevelVo.hp)).ToString();
            data1[3].text  = ((int)(nowLevelVo.mp)).ToString();
            data1[4].text  = ((int)(nowLevelVo.attackSmall)) + "~" + ((int)(nowLevelVo.attackBig));
            data1[5].text  = ((int)(nowLevelVo.magicAttack)).ToString();
            data1[6].text  = ((int)(nowLevelVo.defence)).ToString();
            data1[12].text = ((int)(nowLevelVo.magicDefance)).ToString();
            data1[7].text  = ((int)(nowLevelVo.critNum)).ToString();
            data1[8].text  = ((int)(nowLevelVo.duckNum)).ToString();
            data1[9].text  = (nowLevelVo.critDamage) * 100 + "%";
            data1[10].text = ((int)(nowLevelVo.speed)).ToString();
            data1[11].text = (nowLevelVo.magicRate) * 100 + "%";
            data1[13].text = ((int)(nowLevelVo.defanceRate)).ToString();

            data2[0].text  = nextLevel.ToString();
            data2[1].text  = "";
            data2[2].text  = ((int)(nextVo.hp)).ToString();
            data2[3].text  = ((int)(nextVo.mp)).ToString();
            data2[4].text  = ((int)(nextVo.attackSmall)) + "~" + ((int)(nowLevelVo.attackBig));
            data2[5].text  = ((int)(nextVo.magicAttack)).ToString();
            data2[6].text  = ((int)(nextVo.defence)).ToString();
            data2[12].text = ((int)(nextVo.magicDefance)).ToString();
            data2[7].text  = ((int)(nextVo.critNum)).ToString();
            data2[8].text  = ((int)(nextVo.duckNum)).ToString();
            data2[9].text  = (nextVo.critDamage) * 100 + "%";
            data2[10].text = ((int)(nextVo.speed)).ToString();
            data2[11].text = (nextVo.magicRate) * 100 + "%";
            data2[13].text = ((int)(nextVo.defanceRate)).ToString();
        }
        Tools.ClearChildFromParent(tsSkill);
        for (int i = 0; i < vo.skills.Count; i++)
        {
            GameObject obj = Tools.CreateGameObject("UI/ServantPanel/ServantSkillCell", tsSkill, new Vector3(-840f + 130 * i, -490f, 0), Vector3.one);
            obj.GetComponent <ServantSkillCell>().Create(vo.skills[i]);
        }
    }
Exemplo n.º 6
0
 public void AddSkill(ServantVo vo, StaticSkillLevelVo skillVo)
 {
     if (vo.skills.Count < vo.maxSkillNum)
     {
         SkillVo newSkill = new SkillVo();
         newSkill.id    = skillVo.skillId;
         newSkill.level = skillVo.level;
         vo.skills.Add(newSkill);
     }
 }
Exemplo n.º 7
0
 private void Start()
 {
     GameRoot.Instance.evt.AddListener(GameEventDefine.UPDATE_SERVANT, OnUpdate);
     btnLevelUp.onClick.AddListener(delegate() { BtnClick(btnLevelUp); });
     btnNowServant.onClick.AddListener(delegate() { BtnClick(btnNowServant); });
     btnRemove.onClick.AddListener(delegate() { BtnClick(btnRemove); });
     nowVo = DataManager.Instance.servantModel.nowServant;
     nowId = nowVo.id;
     OnUpdate(null);
 }
Exemplo n.º 8
0
    private void OnRemoveConfirm(object obj)
    {
        DataManager.Instance.servantModel.Remove(nowVo);
        StaticUnitVo staticUnitVo = StaticDataPool.Instance.staticUnitPool.GetStaticDataVo(nowVo.unitId);

        UIManager.Instance.CreateTipPanel("你驱逐了" + staticUnitVo.name);
        nowVo = DataManager.Instance.servantModel.nowServant;
        nowId = nowVo.id;
        OnUpdate(null);
    }
Exemplo n.º 9
0
    public void Create(ServantVo servantVo, CallBackFunctionWithObject callback)
    {
        this.servantVo = servantVo;
        this.callback  = callback;
        StaticUnitLevelVo staticUnitLevelVo = StaticDataPool.Instance.staticUnitLevelPool.GetStaticDataVo(servantVo.unitId, servantVo.level);
        StaticUnitVo      staticUnitVo      = StaticDataPool.Instance.staticUnitPool.GetStaticDataVo(servantVo.unitId);

        textName.text = staticUnitVo.name;
        desc.text     = staticUnitVo.desc;
        level.text    = "Lv." + servantVo.level;
    }
Exemplo n.º 10
0
 public bool Remove(ServantVo vo)
 {
     if (nowServant != vo)
     {
         _dataList.Remove(vo);
         return(true);
     }
     else
     {
         return(false);
     }
 }
Exemplo n.º 11
0
    public void Create()
    {
        servantVo = DataManager.Instance.servantModel.nowServant;
        StaticUnitLevelVo staticUnitVo = StaticDataPool.Instance.staticUnitLevelPool.GetStaticDataVo(servantVo.unitId, servantVo.level);

        Create(staticUnitVo);
        skillList.Clear();
        for (int i = 0; i < servantVo.skills.Count; i++)
        {
            skillList.Add(StaticDataPool.Instance.staticSkillLevelPool.GetStaticDataVo(servantVo.skills[i].id, servantVo.skills[i].level));
        }
        unitName = staticUnitVo.name;
    }
Exemplo n.º 12
0
    public bool LevelUp(ServantVo vo)
    {
        StaticUnitLevelVo staticUnitVo = StaticDataPool.Instance.staticUnitLevelPool.GetStaticDataVo(vo.unitId, vo.level + 1);

        if (DataManager.Instance.roleVo.exp > staticUnitVo.needExp)
        {
            DataManager.Instance.roleVo.exp = DataManager.Instance.roleVo.exp - staticUnitVo.needExp;
            vo.level++;
            GameRoot.Instance.evt.CallEvent(GameEventDefine.ROLE_INFO, null);

            //todo
            return(true);
        }
        return(false);
    }
Exemplo n.º 13
0
    public void Load(string str)
    {
        string[] arr    = str.Split('|');
        string   nowArr = arr[0];

        for (int i = 1; i < arr.Length; i++)
        {
            if (arr[i] != "")
            {
                ServantVo vo = new ServantVo();
                vo.Update(arr[i]);
                _dataList.Add(vo);
            }
        }
        for (int i = 0; i < nowArr.Length; i++)
        {
            nowServant = _dataList.Find(p => p.id == int.Parse(arr[0]));
        }
    }