public bool canAttackOp(SceneCardBase card, EnGameOp gameOp) { bool ret = false; if (m_opCard != null) { if (gameOp == m_curOp) // 如果当前处于这个操作状态 { if (gameOp == EnGameOp.eOpNormalAttack) // 如果当前处于攻击 { ret = canNormalAttack(card, gameOp); } else if (gameOp == EnGameOp.eOpFaShu || gameOp == EnGameOp.eOpSkillAttackTarget) // 当前处于法术牌攻击 { ret = canFaShuAttack(card, gameOp); } else if (gameOp == EnGameOp.eOpZhanHouAttack) // 当前处于战吼牌攻击 { ret = canZhanHouAttack(card, gameOp); } } } return(ret); }
override public void onOneCardEnterHandleEntry(IDispatchObject card_) { SceneCardBase _card = card_ as SceneCardBase; _card.trackAniControl.createAndAddGridElem(); base.onOneCardEnterHandleEntry(card_); }
override public void initDieItemData(SceneCardBase dieCard, stRetRemoveBattleCardUserCmd msg) { base.initDieItemData(dieCard, msg); m_card = dieCard; m_dieEffectId = 14; // 普通死亡 }
// 尝试清理当前拖放卡牌 public void tryClearDragItem(SceneCardBase curDragItem_) { if(UtilApi.isAddressEqual(m_curDragItem, curDragItem_)) { setCurDragItem(null); } }
// 尝试清理当前拖放卡牌 public void tryClearDragItem(SceneCardBase curDragItem_) { if (UtilApi.isAddressEqual(m_curDragItem, curDragItem_)) { setCurDragItem(null); } }
protected SceneCardBase m_whiteCard; // 这个卡牌就是当要出手的时候,就加入列表中,好计算位置 public OutSceneCardList(SceneDZData data, EnDZPlayer playerSide) : base(data, playerSide) { m_whiteCard = Ctx.m_instance.m_sceneCardMgr.createCardById(SceneDZCV.WHITE_CARDID, playerSide, CardArea.CARDCELLTYPE_HAND, CardType.CARDTYPE_ATTEND, m_sceneDZData); Ctx.m_instance.m_sceneCardMgr.delObject(m_whiteCard); // 白色卡牌就不加入列表中了 m_whiteCard.gameObject().SetActive(false); }
// 移除一张卡牌,不释放资源,这个接口仅仅是客户端自己释放资源使用 public void removeOneCardByItem(SceneCardItem sceneItem) { if ((int)CardArea.CARDCELLTYPE_SKILL == sceneItem.svrCard.pos.dwLocation) { m_sceneSkillCard = null; } else if ((int)CardArea.CARDCELLTYPE_EQUIP == sceneItem.svrCard.pos.dwLocation) { m_sceneEquipCard = null; } else if ((int)CardArea.CARDCELLTYPE_COMMON == sceneItem.svrCard.pos.dwLocation) { m_outSceneCardList.removeCardIByItem(sceneItem); m_outSceneCardList.updateSceneCardPos(); } else if ((int)CardArea.CARDCELLTYPE_HAND == sceneItem.svrCard.pos.dwLocation) { if (m_inSceneCardList.removeCardIByItem(sceneItem)) { m_inSceneCardList.updateSceneCardPos(); } else // 可能是战吼或者法术有攻击目标的 { SceneCardBase srcCard = m_outSceneCardList.removeAndRetCardByItem(sceneItem); // 如果是法术或者战吼有攻击目标的卡牌,虽然在出牌区,但是是客户端自己移动过去的 if (srcCard != null && srcCard.canClientMove2OutArea()) { // 更新手牌索引 m_inSceneCardList.updateCardIndex(); } } } }
virtual protected void updateSceneCardPosInternal(CardArea area, bool bUpdateIdx = true) { int idx = 0; SceneCardBase cardItem = null; WayPtItem pt = null; PosType posType = PosType.eHandDown; if (CardArea.CARDCELLTYPE_HAND == area) { posType = PosType.eHandDown; } else if (CardArea.CARDCELLTYPE_COMMON == area) { posType = PosType.eOutDown; } getCardPos(); while (idx < m_sceneCardList.Count()) { cardItem = m_sceneCardList[idx]; if (bUpdateIdx) { cardItem.curIndex = (ushort)idx; } pt = cardItem.trackAniControl.wayPtList.getAndAddPosInfo(posType); pt.pos = m_posList[idx]; cardItem.trackAniControl.moveToDestPos(posType); ++idx; } }
public void addSceneCardByItem(SceneCardItem sceneItem) { if (CardArea.CARDCELLTYPE_HERO == sceneItem.cardArea) { m_centerHero = Ctx.m_instance.m_sceneCardMgr.createCard(sceneItem, m_sceneDZData) as HeroCard; m_centerHero.setPlayerCareer((EnPlayerCareer)Ctx.m_instance.m_dataPlayer.m_dzData.m_playerArr[(int)m_playerSide].m_heroOccupation); // 设置 hero 动画结束后的处理 m_centerHero.heroAniEndDisp = m_sceneDZData.heroAniEndDisp; } else if (CardArea.CARDCELLTYPE_SKILL == sceneItem.cardArea) { m_sceneSkillCard = Ctx.m_instance.m_sceneCardMgr.createCard(sceneItem, m_sceneDZData); } else if (CardArea.CARDCELLTYPE_EQUIP == sceneItem.cardArea) { m_sceneEquipCard = Ctx.m_instance.m_sceneCardMgr.createCard(sceneItem, m_sceneDZData); } else if (CardArea.CARDCELLTYPE_HAND == sceneItem.cardArea) { if (Ctx.m_instance.m_dataPlayer.m_dzData.m_playerArr[(int)m_playerSide].m_recStartCardNum >= Ctx.m_instance.m_dataPlayer.m_dzData.m_playerArr[(int)m_playerSide].getStartCardNum()) // 判断接收的数据是否是 startCardList 列表中的数据 { m_inSceneCardList.addCardByIdAndItem(sceneItem.svrCard.dwObjectID, sceneItem); } else { m_inSceneCardList.setCardDataByIdx(Ctx.m_instance.m_dataPlayer.m_dzData.m_playerArr[(int)m_playerSide].m_recStartCardNum, sceneItem); ++Ctx.m_instance.m_dataPlayer.m_dzData.m_playerArr[(int)m_playerSide].m_recStartCardNum; } } else if (CardArea.CARDCELLTYPE_COMMON == sceneItem.cardArea) // 只有对方出牌的时候才会走这里 { changeEnemySceneCardArea(sceneItem); } }
// 尝试结束,可能当前观察的卡牌不是要结束的卡牌 public void tryStopWatch(SceneCardBase card_) { if (UtilApi.isAddressEqual(m_watchCard, card_)) { stopWatch(); } }
// 根据服务器索引添加一个卡牌,不是根据卡牌列表索引 public void addCardByServerPos(SceneCardBase card) { int idx = 0; // 检查是否是最后一个 if (0 == m_sceneCardList.Count()) // 如果列表中没有,直接加入 { m_sceneCardList.Add(card as SceneCardBase); } else if (m_sceneCardList[m_sceneCardList.Count() - 1].curIndex < card.curIndex) // 如果是最后一个 { m_sceneCardList.Add(card as SceneCardBase); } else { foreach (var cardItem in m_sceneCardList.list) { if (cardItem.curIndex >= card.curIndex) { m_sceneCardList.Insert(idx, card as SceneCardBase); break; } ++idx; } } }
public TrackAniControl(SceneCardBase rhv) : base(rhv) { m_numAniParal = new NumAniParallel(); m_numAniParal.setAniSeqEndDisp(onMoveEndHandle); m_wayPtList = new WayPtList(); initPosInfo(); }
public void quitMoveOp() { m_curOp = EnGameOp.eOpNone; m_opCard = null; // 退出操作后,需要开启手牌区域卡牌拖动操作 m_sceneDZData.m_sceneDZAreaArr[(int)EnDZPlayer.ePlayerSelf].enableAllInCardDragExceptOne(null); }
// 通过服务器数据创建 public SceneCardBase createCard(SceneCardItem sceneItem, SceneDZData sceneDZData) { SceneCardBase ret = null; ret = createCardById(sceneItem.svrCard.dwObjectID, sceneItem.playerSide, sceneItem.cardArea, (CardType)sceneItem.m_cardTableItem.m_type, sceneDZData); ret.sceneCardItem = sceneItem; return(ret); }
protected void createCard() { if (m_outCard == null) { m_outCard = Ctx.m_instance.m_sceneCardMgr.createCardById(m_cardId, EnDZPlayer.ePlayerSelf, CardArea.CARDCELLTYPE_COMMON, CardType.CARDTYPE_ATTEND, m_sceneDZData); Ctx.m_instance.m_sceneCardMgr.remove(m_outCard); } }
public void enterMoveOp(SceneCardBase card) { // 进入操作后,需要禁止手牌区域卡牌拖动操作 m_sceneDZData.m_sceneDZAreaArr[(int)EnDZPlayer.ePlayerSelf].disableAllInCardDragExceptOne(card as SceneCardBase); m_curOp = EnGameOp.eOpMoveIn2Out; m_opCard = card; }
// 通过客户端的数据移除一张卡牌 override public void removeCard(SceneCardBase card) { // 关闭拖拽功能 if (card.ioControl != null) // Enemy Hand 手牌没有拖动 { card.ioControl.disableDrag(); } base.removeCard(card); }
// 提供全部释放的接口 public void removeAndDestroyAll(SceneCardBase card) { int idx = m_sceneEntityList.Count; for (; idx >= 0; --idx) { m_sceneEntityList[idx].dispose(); } }
// Enemy 卡牌改变位置 virtual public void changeEnemySceneCardArea(SceneCardItem sceneItem_) { SceneCardBase srcCard = Ctx.m_instance.m_sceneCardMgr.createCard(sceneItem_, m_sceneDZData); srcCard.convOutModel(); m_outSceneCardList.addCard(srcCard, sceneItem_.svrCard.pos.y); m_outSceneCardList.updateSceneCardPos(); srcCard.effectControl.updateStateEffect(); }
protected SceneStateFSM m_hurtStateFSM; // 被击流程状态机 public BehaviorControl(SceneCardBase rhv) : base(rhv) { m_attStateFSM = new SceneStateFSM(m_card); m_attStateFSM.Start(); m_hurtStateFSM = new SceneStateFSM(m_card); m_hurtStateFSM.Start(); }
override public void psstRetRemoveBattleCardUserCmd(stRetRemoveBattleCardUserCmd msg, int side, SceneCardItem sceneItem) { m_msg = msg; m_side = side; m_sceneItem = sceneItem; m_card = Ctx.m_instance.m_sceneCardMgr.getCardByThisId(m_msg.dwThisID); m_card.setSvrDispose(); // 设置服务器死亡标志 }
protected void onDieEndHandle(IDispatchObject dispObj) { // 删除死亡对象 Ctx.m_instance.m_logSys.fightLog(string.Format("[Fight] 真正删除一个卡牌 {0}", m_card.getDesc())); //m_sceneDZData.m_sceneDZAreaArr[m_side].removeAndDestroyOneCardByItem(m_sceneItem); m_card.dispose(); m_card = null; m_OneAttackAndHurtEndDisp.dispatchEvent(this); }
// 这个说明攻击操作完成 public void endAttackOp() { m_curOp = EnGameOp.eOpNone; m_opCard = null; m_sceneDZData.m_attackArrow.stopArrow(); clearAttackTargetFlags(); // 退出操作后,需要开启手牌区域卡牌拖动操作 m_sceneDZData.m_sceneDZAreaArr[(int)EnDZPlayer.ePlayerSelf].enableAllInCardDragExceptOne(null); }
protected void createCard(SceneCardItem sceneItem, SceneDZData sceneDZData) { if (m_showCard == null) { m_showCard = Ctx.m_instance.m_sceneCardMgr.createCard(sceneItem, sceneDZData); Ctx.m_instance.m_sceneCardMgr.remove(m_showCard); m_sceneCardItem = new SceneCardItem(); } }
override public void enableAllCardDragExceptOne(SceneCardBase card) { foreach (SceneCardBase cardItem in m_sceneCardList.list) { if (!cardItem.Equals(card)) // 如果内存地址相等 { cardItem.ioControl.enableDrag(); } } }
// 将 Out 区域中的第一个牌退回到 handle 中 public void putHandFromOut() { SceneCardBase card = m_outSceneCardList.removeNoDestroyAndRet() as SceneCardBase; if (card != null) { card.trackAniControl.retFormOutAreaToHandleArea(); m_outSceneCardList.updateSceneCardPos(); } }
// 生成攻击数据,普通攻击 def 是有值的,技能攻击没有值 protected void startAtt(SceneCardBase att, SceneCardBase def, EAttackType attackType, stNotifyBattleCardPropertyUserCmd msg) { if (att != null) { Ctx.m_instance.m_logSys.fightLog(string.Format("[Fight] 攻击者详细信息 {0}", att.getDesc())); // 攻击 AttackItemBase attItem = null; attItem = att.fightData.attackData.createItem(attackType); attItem.initItemData(att, def, msg); } }
// 技能攻击攻击者不会伤血 m_damage = 0 override public void initItemData(SceneCardBase att, SceneCardBase def, stNotifyBattleCardPropertyUserCmd msg) { base.initItemData(att, def, msg); skillId = msg.dwMagicType; foreach(var item in msg.defList) { m_hurtIdList.Add(item.qwThisID); } m_attThisId = att.sceneCardItem.svrCard.qwThisID; }
// 技能攻击攻击者不会伤血 m_damage = 0 override public void initItemData(SceneCardBase att, SceneCardBase def, stNotifyBattleCardPropertyUserCmd msg) { base.initItemData(att, def, msg); skillId = msg.dwMagicType; foreach (var item in msg.defList) { m_hurtIdList.Add(item.qwThisID); } m_attThisId = att.sceneCardItem.svrCard.qwThisID; }
public SceneCardBase getCardByIdx(int idx = 0) { SceneCardBase card = null; if (idx < m_sceneCardList.Count()) { card = m_sceneCardList[idx]; } return(card); }
// 通过客户端的卡牌数据添加卡牌 virtual public void addCard(SceneCardBase card, int idx = -1) { if (idx == -1) { m_sceneCardList.Add(card); } else { m_sceneCardList.Insert(idx, card); } }
override public void addCard(SceneCardBase card, int idx = -1) { base.addCard(card, idx); #if !DEBUG_NOTNET card.sceneCardItem.cardArea = CardArea.CARDCELLTYPE_COMMON; #endif // 添加进来的卡牌是不能移动的 card.ioControl.disableDrag(); card.updateOutCardScaleInfo(m_sceneDZData.m_placeHolderGo.m_cardCenterGOArr[(int)m_playerSide, (int)CardArea.CARDCELLTYPE_COMMON].transform); // 缩放按照配置运行 }
public void onSelfStartCardEnterHandEntry(IDispatchObject card_) { SceneCardBase _card = card_ as SceneCardBase; _card.trackAniControl.createAndAddGridElem(); --m_initCardCount; if (0 == m_initCardCount) { updateSceneCardPos(); } }
protected MList<LinkEffect> m_linkEffectList; // 保存所有添加的连接特效 public EffectControl(SceneCardBase rhv) : base(rhv) { m_frameEffectId = 4; // 默认是手牌特效 4 m_linkEffectList = new MList<LinkEffect>(); m_stateEffectList = new MList<LinkEffect>((int)StateID.CARD_STATE_MAX); int idx = 0; for(idx = 0; idx < (int)StateID.CARD_STATE_MAX; ++idx) { m_stateEffectList.Add(null); } }
// 检查之前的攻击状态 public void checkPreAttackOp(EnGameOp op, SceneCardBase card) { if (EnGameOp.eOpZhanHouAttack == m_curOp) // 如果是战吼 { // 需要将其回退回去 m_sceneDZData.m_sceneDZAreaArr[(int)EnDZPlayer.ePlayerSelf].putHandFromOutByCard(m_opCard); } else if(EnGameOp.eOpFaShu == m_curOp) // 法术 { if (card.sceneCardItem.m_cardTableItem.m_bNeedFaShuTarget > 0) // 如果有攻击目标 { m_sceneDZData.m_sceneDZAreaArr[(int)EnDZPlayer.ePlayerSelf].cancelFashuOp(m_opCard); } } }
override public void initItemData(SceneCardBase att, SceneCardBase def, stNotifyBattleCardPropertyUserCmd msg) { base.initItemData(att, def, msg); // 普通被击伤血是对方的伤血值,不是血量的减少 m_bDamage = att.sceneCardItem.svrCard.damage > 0; if (m_bDamage) { m_damage = (int)att.sceneCardItem.svrCard.damage; } Ctx.m_instance.m_logSys.fightLog(string.Format("[Fight] 被击者掉血 {0}", m_damage)); m_hurtEffectId = 7; // 普通被击,根据攻击力播放不同的特效,并且播放掉血特效 }
override public void initItemData(SceneCardBase att, SceneCardBase def, stNotifyBattleCardPropertyUserCmd msg) { base.initItemData(att, def, msg); // 播放 Fly 数字,攻击者和被击者都有可能伤血,播放掉血数字 // 普通攻击者掉血是被击者的伤血量 m_bDamage = def.sceneCardItem.svrCard.damage > 0; if (m_bDamage) // 攻击力可能为 0 { m_damage = (int)def.sceneCardItem.svrCard.damage; } Ctx.m_instance.m_logSys.fightLog(string.Format("[Fight] 攻击者掉血 {0}", m_damage)); m_hurterId = def.sceneCardItem.svrCard.qwThisID; m_attackEffectId = 0; // 普通攻击没有攻击特效 }
override public void initItemData(SceneCardBase att, SceneCardBase def, stNotifyBattleCardPropertyUserCmd msg) { base.initItemData(att, def, msg); m_svrCard = def.sceneCardItem.svrCard; // 保存这次被击的属性,可能这个会被后面的给改掉 skillId = msg.dwMagicType; this.delayTime = m_skillTableItem.m_effectMoveTime; // 技能被击伤血是血量值差 m_bDamage = hasDamageHp(msg.m_origDefObject, def.sceneCardItem.svrCard); if (m_bDamage) { m_damage = (int)(msg.m_origDefObject.hp - def.sceneCardItem.svrCard.hp); } Ctx.m_instance.m_logSys.fightLog(string.Format("[Fight] 被击者掉血 {0}", m_damage)); }
// 进入攻击操作 public void enterAttackOp(EnGameOp op, SceneCardBase card) { // 进入操作后,需要禁止手牌区域卡牌拖动操作 m_sceneDZData.m_sceneDZAreaArr[(int)EnDZPlayer.ePlayerSelf].disableAllInCardDragExceptOne(card as SceneCardBase); // 如果不是自己的回合,直接返回 if (!Ctx.m_instance.m_dataPlayer.m_dzData.bSelfSide()) { return; } // 进入某一个状态的时候,要查看之前的状态是否需要需要处理 checkPreAttackOp(op, m_opCard); m_curOp = op; m_opCard = card; // 开始拖动箭头 m_sceneDZData.m_attackArrow.startArrow(); addAttackTargetFlags(); }
override public void initItemData(SceneCardBase att, SceneCardBase def, stNotifyBattleCardPropertyUserCmd msg) { base.initItemData(att, def, msg); m_card = def; m_svrCard = def.sceneCardItem.svrCard; // 保存这次被击的属性,可能这个会被后面的给改掉 Ctx.m_instance.m_logSys.fightLog(string.Format("[Fight] 被击者被击前属性值 {0}", msg.m_origDefObject.log())); Ctx.m_instance.m_logSys.fightLog(string.Format("[Fight] 被击者被击后属性值 {0}", def.sceneCardItem.svrCard.log())); // 回血统一接口 m_bAddHp = hasAddHp(msg.m_origDefObject, def.sceneCardItem.svrCard); m_addHp = (int)(def.sceneCardItem.svrCard.hp - msg.m_origDefObject.hp); if(m_bAddHp) { Ctx.m_instance.m_logSys.fightLog(string.Format("[Fight] 被击者加血 {0}", m_addHp)); } updateStateChange(msg.m_origDefObject.state, def.sceneCardItem.svrCard.state); }
override public void enableAllInCardDragExceptOne(SceneCardBase card) { m_inSceneCardList.enableAllCardDragExceptOne(card); }
public Inplace2DestedFS(FSM fsm, SceneCardBase card) : base(fsm) { }
// 攻击者攻击被击者 protected void attackTo(SceneCardBase att, SceneCardBase def, EAttackType attackType, stNotifyBattleCardPropertyUserCmd msg) { if (att != null && def != null) { Ctx.m_instance.m_logSys.fightLog(string.Format("[Fight] 被击者详细信息 {0}", def.getDesc())); // 受伤 HurtItemBase hurtItem = null; hurtItem = def.fightData.hurtData.createItem((EHurtType)attackType); hurtItem.initItemData(att, def, msg); def.fightData.hurtData.allHurtExecEndDisp.addEventHandle(onOneAttackAndHurtEndHandle); m_hurtList.Add(def.fightData.hurtData); } }
// 开始观察卡牌 public void startWatch(SceneCardBase card_) { m_watchCard = card_; startTimer(); }
public SelfMagicAniControl(SceneCardBase rhv) : base(rhv) { m_scaleGridElement = new ScaleGridElement(); m_scaleGridElement.setMovedEntity(this); }
override public void execAttack(SceneCardBase card) { Ctx.m_instance.m_logSys.fightLog(string.Format("[Fight] 开始执行技能攻击 {0}", m_card.getDesc())); card.behaviorControl.execAttack(this); }
// 将当前卡牌结束观察 public void stopWatch() { if (m_watchStage == WatchStage.eStartTimer) { stopTimer(); } m_watchCard = null; if (m_showCard != null) { m_showCard.hide(); } }
public Dest2InplaceStartFS(FSM fsm, SceneCardBase card) : base(fsm) { }
public SceneStateFSM(SceneCardBase card) : base(card) { }