public void Equip(Position position, EquipmentCard equip) { switch (position) { case Position.Weapon: { if (this.weapon == null) { //角色没有装备 this.weapon = equip; equip.OnEquiped(playerCard); } else { //角色已经有装备了 this.weapon.OnUnequiped(); this.weapon = equip; equip.OnEquiped(playerCard); } break; } case Position.Armor: { if (this.armor == null) { //角色没有装备 this.armor = equip; equip.OnEquiped(playerCard); } else { //角色已经有装备了 this.armor.OnUnequiped(); this.armor = equip; equip.OnEquiped(playerCard); } break; } case Position.Jewelry: { EquipmentCard jewelry = equip; equip.OnEquiped(playerCard); //如果两个首饰槽都有装备了。覆盖稀有度小的。稀有度一样则随机覆盖 if (this.jewelry1 != null && this.jewelry2 != null) { if (this.jewelry1.cardRarity != this.jewelry2.cardRarity) { //替换稀有度低的 if (this.jewelry1.cardRarity > this.jewelry2.cardRarity) { this.jewelry1 = jewelry; } else { this.jewelry2 = jewelry; } } else { //随机替换 System.Random random = new System.Random(); float randVal = (float)random.Next(0, 1000) / 1000; if (randVal < 0.5f) { this.jewelry1 = jewelry; } else { this.jewelry2 = jewelry; } } } else { if (this.jewelry1 == null) { this.jewelry1 = jewelry; } else if (this.jewelry2 == null) { this.jewelry2 = jewelry; } } break; } default: { LogsSystem.Instance.Print("不合法的装备位置"); break; } } }
/// <summary> /// 装备装备卡 /// </summary> public void Equip(int postion, EquipmentCard equip) { this.Equip((Position)postion, equip); }