/// <summary> /// 技能释放 /// </summary> public override void OnUse(PlayerCard from, PlayerCard target) { int skillDamage = this.GetCalculatedDamage(); target.GetDamage(skillDamage);//造成伤害 from.currentEnergy -= this.skillEnergyCost;//消耗能量 LogsSystem.Instance.Print(string.Format("{0}对{1}释放了技能{2},造成伤害{3}点。", from.cardName, target.cardName, this.skillName, skillDamage), LogLevel.GAMEDETAIL); //附加状态 if (appendStateList != null && appendStateList.Count != 0) { foreach (StateSkill state in appendStateList) { target.AppendState(state); } } }
/// <summary> /// 根据技能来源(技能释放者)计算伤害 /// </summary> public virtual int GetCalculatedDamage(PlayerCard from) { return this.GetCalculatedDamage(); }
/// <summary> /// 添加卡片到房间 /// </summary> public void AddPlayerCard(PlayerCard card) { characterCard.Add(card.cardUUID, card); card.SetOwnerData(this.gameRoom, (int)this.position); }
/// <summary> /// 技能被使用是调用函数 /// 必须实现 /// </summary> public abstract void OnUse(PlayerCard from, PlayerCard target);
/// <summary> /// 根据卡片ID创建卡片数据 /// </summary> private static PlayerCard CreatePlayerCardByID(int cardID) { CharacterCard character = CardManager.Instance.GetCharacterCloneByID(cardID); PlayerCard playerCard = new PlayerCard(); playerCard.cardUUID = character.cardUUID; playerCard.cardId = character.cardId; playerCard.cardName = character.cardName; playerCard.cardRarity = character.cardRarity; playerCard.baseHealth = character.baseHealth; playerCard.baseEnergy = character.baseEnergy; playerCard.baseAttack = character.baseAttack; playerCard.baseSpeed = character.baseSpeed; playerCard.growHealth = character.growHealth; playerCard.growEnergy = character.growEnergy; playerCard.growAttack = character.growAttack; playerCard.growSpeed = character.growSpeed; return playerCard; }
public EquipmentCard weapon; //武器 #endregion Fields #region Constructors public PlayerEquipment(PlayerCard playerCard) { this.playerCard = playerCard; }
/// <summary> /// 设置状态基本信息 /// </summary> public void SetStateInfo(PlayerCard stateOwnerCard) { this.stateOwnerCard = stateOwnerCard; }
public override void OnUse(PlayerCard from, PlayerCard target) { target.AddState(this); }
public override void OnUse(PlayerCard from, PlayerCard target) { this.stateOwnerCard = target; target.AddState(this); }
/// <summary> /// 根据玩家的UUID和UID /// 发送玩家拥有的卡片(仅在此时创建卡片的UUID) /// </summary> public GameData SendPlayerOwnCard(GamePlayerOwnCardData requestData, GameRoom room) { int uid = requestData.operatePlayerUid; string UUID = requestData.operatePlayerUUID; GameRoom.PlayerPosition position = (GameRoom.PlayerPosition)requestData.operatePlayerPosition; if (CheckUUID(UUID)) { string command; List<PlayerCard> playerCardList = new List<PlayerCard>(); CardManager cardManager = CardManager.Instance; //获取背包信息 requestData.cardInv = new List<CardInfo>(); command = string.Format("SELECT * FROM cardinventory WHERE CardOwnerId = '{0}'", uid); DataSet cardInventory = MySQLHelper.GetDataSet(MySQLHelper.Conn, CommandType.Text, command, null); foreach (DataRow row in cardInventory.Tables[0].Rows) { try { int cardID = Convert.ToInt32(row["CardId"]); CharacterCard standardCharacterCard = cardManager.GetCharacterCloneByID(cardID); PlayerCard playerCard = new PlayerCard(); //卡片通用 playerCard.cardUUID = System.Guid.NewGuid().ToString();//创建卡片的UUID作为唯一标识 playerCard.cardId = cardID; playerCard.cardName = standardCharacterCard.cardName; playerCard.cardRarity = standardCharacterCard.cardRarity; //角色卡通用 playerCard.baseHealth = standardCharacterCard.baseHealth; playerCard.baseEnergy = standardCharacterCard.baseEnergy; playerCard.baseAttack = standardCharacterCard.baseAttack; playerCard.baseSpeed = standardCharacterCard.baseSpeed; playerCard.growHealth = standardCharacterCard.growHealth; playerCard.growEnergy = standardCharacterCard.growEnergy; playerCard.growAttack = standardCharacterCard.growAttack; playerCard.growSpeed = standardCharacterCard.growSpeed; //游戏卡个性化 playerCard.cardOwnerId = Convert.ToInt32(row["CardOwnerId"]); playerCard.cardLevel = Convert.ToInt32(row["CardLevel"]); playerCard.specialHealth = Convert.ToInt32(row["SpecialHealth"]); playerCard.specialEnergy = Convert.ToInt32(row["SpecialEnergy"]); playerCard.specialAttack = Convert.ToInt32(row["SpecialAttack"]); playerCard.specialSpeed = Convert.ToInt32(row["SpecialSpeed"]); playerCard.InitHealthAndEnergy(); //设置卡片拥有技能 int[] skillIdArray = IntArray.StringToIntArray(row["CardOwnSkill"].ToString());//获取卡片技能的ID列表 SkillManager skillManager = TcpServer.Instance.GetSkillManager(); foreach (int skillId in skillIdArray) { Skill skill = skillManager.GetSkillById(skillId);//从技能管理器中获取该技能的克隆 playerCard.AddSkill(skill); } CardInfo cardInfo = playerCard.GetCardInfo(); requestData.cardInv.Add(cardInfo);//添加到列表 playerCardList.Add(playerCard);//添加卡片 } catch (Exception ex) { LogsSystem.Instance.Print(ex.ToString(), LogLevel.WARN); } } //将数据加载到本地内存 room.SetCardInv(playerCardList, position); //封装返回数据 GameData returnData = new GameData(); returnData.operateCode = OperateCode.PlayerOwnCard; returnData.roomID = room.roomID; returnData.returnCode = ReturnCode.Success; returnData.operateData = JsonCoding<GamePlayerOwnCardData>.encode(requestData); return returnData; } else { return Offline(); } }
/// <summary> /// 向客户端发送状态修改操作的请求 /// </summary> public void SendStateOperate(StateSkill skill, PlayerCard operateCard, int operateType, int operatePosition, GameRoom gameRoom) { OperateStateData detail = new OperateStateData(); detail.skillID = skill.skillID; detail.stateOperate = operateType; detail.ownerCardUUID = operateCard.cardUUID; detail.appendData = skill.GenerateSkillAppendData();//将技能生成的数据附加值传递 switch (operateCard.GetCardOwnerPosition()) { case 0://A { detail.operatePlayerPosition = 0; detail.operatePlayerUid = gameRoom.playerSocketA.playerInfo.playerUid; detail.operatePlayerUUID = gameRoom.playerSocketA.playerInfo.playerUUID; break; } case 1://B { detail.operatePlayerPosition = 1; detail.operatePlayerUid = gameRoom.playerSocketB.playerInfo.playerUid; detail.operatePlayerUUID = gameRoom.playerSocketB.playerInfo.playerUUID; break; } default: { LogsSystem.Instance.Print("错误:卡片拥有者的位置出现错误:" + operateCard.GetCardOwnerPosition(), LogLevel.WARN); break; } } GameData data = new GameData(); data.returnCode = ReturnCode.Success; data.roomID = gameRoom.roomID; data.operateCode = OperateCode.OperateState; data.operateData = JsonCoding<OperateStateData>.encode(detail); gameRoom.SendOperateToAllPlayer(data); }