//还没有处理装备满了的情况 public bool AddEquip(Equip equip) { if (equip == null) { return(false); } int index = -1; for (int i = 0; i < equipBag.Length; i++) { if (equipBag[i] == null) { index = i; equipBag[i] = equip; break; } } if (index != -1) { EventManager.ExecuteEvent(EventType.EquipUpdate, index); return(true); } else { WndTips.ShowTips("背包已满,装备获取失败!"); return(false); } }
public void OnClickRefresh() { if (playerModel.SetMoney(-refreshCost)) { RefreshShopData(); } else { WndTips.ShowTips("您的金币不足以刷新商店"); } }
void OnClickLoadGame(GameObject go) { if (SaveAndLoad.hasSaveFile) { LoadGame(); } else { WndTips.ShowTips("您暂时没有存档,请点击开始游戏"); } OnButtonClick(go); }
protected override void OnFightStart(dynamic dy) { WndTips.ShowTips("我方所有角色闪避率增加10%"); var roles = FightManager.instance.playerRoles; foreach (var role in roles) { if (role != null) { role.missValue += 0.1f; } } }
//获得新装备 public bool AddEquip(Equip equip) { Equip curEquip = equips[equip.equipType]; if (curEquip != null) { //curEquip.UnLoad(this); if (curEquip.level > equip.level) { WndTips.ShowTips("不可替换为低等级的装备!"); return(false); } else { AudioManager.instance.PlayEffect(ConstConfig.UpEquip); EquipModel equipModel = ModelManager.Get <EquipModel>("EquipModel"); curEquip.UnLoad(this); equipModel.AddEquip(curEquip); equips[equip.equipType] = equip; equip.Load(this); OnUpdateEquip?.Invoke(); return(true); } } else if (equip.level > cost && isLevelEffect == true) { WndTips.ShowTips("装备等级不能低于角色品质."); return(false); } else { AudioManager.instance.PlayEffect(ConstConfig.UpEquip); equips[equip.equipType] = equip; equip.Load(this); OnUpdateEquip?.Invoke(); return(true); } //return curEquip; }
void OnClickBuy(object ob = null) { PlayerModel playerModel = ModelManager.Get("PlayerModel") as PlayerModel; int emptyIndex = playerModel.GetEmptyPreIndex(); if (emptyIndex == -1 && !playerModel.CanRoleUpLevel(roleId, 1, 2)) { WndTips.ShowTips("您的备战区已满,不能再获得角色"); } else { (ModelManager.Get("RoleShopModel") as RoleShopModel).OnBuyRole(index); } }
//-----------------------------------------------------------------------------------羁绊 //-----------------------------------------------------------------------------------羁绊 /// <summary> /// 准备队列增加角色,(交换战斗队列与准备队列的角色时不走该接口 /// </summary> /// <param name="role">角色</param> /// <param name="idx">角色即将所在准备队列中的索引</param> /// <param name="orIdx">角色在战斗队列中的索引</param> public bool AddRolePre(RoleBase role) { //判断准备队列里有多少个角色 int count = 0; for (int i = 0; i < preRoles.Length; i++) { if (preRoles[i] != null) { count++; } } //小于最大的角色数量 if (count < Max_Pre_Role_Count) { //找个空位置给他 for (int i = 0; i < preRoles.Length; i++) { if (preRoles[i] == null) { preRoles[i] = role; EventManager.ExecuteEvent(EventType.PreRoleUpdate, i); TryRoleUpLevel(role.GetRoleId(), role.GetLevel()); break; } } return(true); } else //角色满了 { //先判断是否可以合成 bool res = TryRoleUpLevel(role.GetRoleId(), role.GetLevel(), 2); if (!res) { WndTips.ShowTips("玩家准备区域拥有的角色达到最大数量"); } return(res); } }
public void TryUpPeopleLevel() { //先判等级 if (peopleLevel >= MaxPeopleLevel) { WndTips.ShowTips("人口已达最大限度,不可继续升级!"); return; } bool can = SetMoney(-4 * peopleLevel); if (can) { UpdateLevel(); } else { WndTips.ShowTips("余额不足,不可升级人口!"); } }
public void OnBuyRole(int index) { int id = roles[index]; int cost = ConfigRoleManager.Instance().allDatas[id].cost; int price = cost - zhekou; if (playerModel.SetMoney(-price)) { roles[index] = 0; //买了后 id 设置为0 playerModel.AddRolePre(id); EventManager.ExecuteEvent(EventType.ShopDataUpdate); } else { WndTips.ShowTips("您的余额不足以购买该角色!"); } }
void OnOverTime() { WndTips.ShowTips("所有角色伤害提升500%!\n战斗速度提升1.5倍!"); Time.timeScale = 1.5f; AudioManager.instance.BgAudioSource.pitch = 1.5f; foreach (RoleBase role in playerRoles) { if (role != null) { role.attackValueParam += overTimeBL; role.skillParam += overTimeBL; } } foreach (RoleBase role in aiRoles) { if (role != null) { role.attackValueParam += overTimeBL; role.skillParam += overTimeBL; } } }
/// <summary> /// 交换2个队列中的角色数据 /// </summary> /// <param name="role">具体角色</param> /// <param name="fightIndex">即将落户的战斗队列索引</param> /// <param name="preIndex">准备队列索引</param> public bool ExChangeRolesBetPreAndFight(int fightIndex, int preIndex) { RoleBase fightRole = fightRoles[fightIndex]; if (fightRole == null) { int count = GetFightRoleCount(); if (count >= peopleLevel) { WndTips.ShowTips("战斗队列角色已达上限,不可再上阵角色!"); return(false); } } RoleBase preRole = preRoles[preIndex]; RemoveFightRole(fightIndex, EnumType.RoleUpdateType.FightToPre); //减少属性并更新羁绊 SetPreRole(fightRole, preIndex); //pre 来自fight AddFightRole(preRole, fightIndex); //判断该角色是否需要获取羁绊属性,更新羁绊 return(true); }