private void BehitEffectEndEventHandler(EffectBase effect, BattleCard target, float total_time)
        {
            effect.EffectEnd -= BehitEffectEndEventHandler;
            EffectManager.Instance.DestroyEffect(effect);

            target.OnHit(m_SkillOwner, m_BehitMap[target]);
        }
Exemplo n.º 2
0
        public override void Update()
        {
            //全部被攻击者动画播放完以后可以可以进行一下次攻击
            bool can_next = false;

            if (m_CurAttackCard != null)
            {
                Dictionary <BattleCard, BeHitBag> .KeyCollection key_col = m_CurActionBag.behitMap.Keys;
                bool end = true;
                foreach (BattleCard card in key_col)
                {
                    if (card.InBehitAction == true)
                    {
                        end = false;
                        break;
                    }
                }
                if (end)
                {
                    m_CurAttackCard = null;
                    m_CurActionBag  = null;
                    can_next        = true;
                }
            }
            else
            {
                can_next = true;
            }

            if (can_next)
            {
                ExecuteOneAttack();
            }
        }
        public void OnCardPosChanged(int srcPos, int tgtPos)
        {
            if (srcPos < 0 || srcPos > 5)
            {
                return;
            }
            if (tgtPos < 0 || tgtPos > 5)
            {
                return;
            }
            if (srcPos == tgtPos)
            {
                return;
            }

            BattleSlot srcSlot = m_BattleSlotArray[BattleCardType.E_BATTLE_CARD_TYPE_SELF][srcPos];
            BattleCard srcCard = m_BattleSlotArray[BattleCardType.E_BATTLE_CARD_TYPE_SELF][srcPos].Battle_Card;
            BattleSlot tgtSlot = m_BattleSlotArray[BattleCardType.E_BATTLE_CARD_TYPE_SELF][tgtPos];
            BattleCard tgtCard = m_BattleSlotArray[BattleCardType.E_BATTLE_CARD_TYPE_SELF][tgtPos].Battle_Card;

            srcCard.OnChangeSlot(tgtSlot);
            tgtSlot.OnChangeCard(srcCard);

            if (tgtCard != null)
            {
                tgtCard.OnChangeSlot(srcSlot);
                srcSlot.OnChangeCard(tgtCard);
            }
            else
            {
                srcSlot.OnChangeCard(null);
            }
        }
Exemplo n.º 4
0
        public void SetCard(BattleCard cd)
        {
            m_BattleCard = cd;
            int name_id = TableManager.GetCardByID(cd.Card_Data.CardTempId).Appearance;

            m_SlotName.text = LanguageManger.GetWords(TableManager.GetAppearanceByID(name_id).Name);
        }
Exemplo n.º 5
0
        private void ProjectileEffectEndEventHandler(EffectBase effect, BattleCard target, float total_time)
        {
            effect.EffectEnd -= ProjectileEffectEndEventHandler;
            EffectManager.Instance.DestroyEffect(effect);

            PlayBehitEffect(target);
        }
        public virtual bool Init(CardStateMachine machine)
        {
            m_StateMachine = machine;
            m_BattleCard   = machine.Owner;

            return(true);
        }
Exemplo n.º 7
0
        public override bool Play(BattleCard target)
        {
            m_TargetCard = target;

            if (m_EffectLib == null)
            {
                Debug.LogError("Can't play effect! " + m_EffectName);
                if (EffectEnd != null)
                {
                    EffectEnd(this, m_TargetCard, 0f);
                }
                return(false);
            }

            GameObject go          = GameObject.Instantiate(m_EffectLib) as GameObject;
            Vector3    _localScale = go.transform.localScale * m_StartPos.localScale.x;

            go.transform.parent = m_StartPos.parent;
            Vector3 pos = new Vector3(0.0f, 0.0f, -30.0f);

            pos.x = m_StartPos.localPosition.x;
            pos.y = m_StartPos.localPosition.y;
            go.transform.localPosition = pos;
            go.transform.localScale    = _localScale;//new Vector3(512.0f, 512.0f, 0.0f);

            //计算旋转方向
            Vector3 direct = m_DirectionPoint - m_StartPos.transform.localPosition;

            if (direct.x != 0f || direct.y != 0f)
            {
                direct.z        = 0f;
                go.transform.up = direct;
            }

            //如果速度不为0,则特效需要飞行,添加iTween事件
            if (m_MoveSpeed > 0f)
            {
                go.AddComponent <iTweenHandler>().ProjectileFlyCompleteHandler = ProjectileFlyCompleteHandler;

                Hashtable args = new Hashtable();
                args.Add("time", m_MoveSpeed);
                args.Add("x", m_StartPos.position.x);
                args.Add("y", m_StartPos.position.y);
                args.Add("looptype", iTween.LoopType.none);
                args.Add("easetype", iTween.EaseType.linear);
                args.Add("oncompletetarget", go);
                args.Add("oncompleteparams", go);
                args.Add("oncomplete", "OnProjectileFlyComplete");
                iTween.MoveTo(go, args);
            }

            DestroyParticle dp = go.AddComponent <DestroyParticle>();

            dp.particleCompleteDelegate += AnimationCompleteHandler;
            dp.DestroyTime = 1000f;

            m_EffectObj = go;
            return(true);
        }
        private void AttackEffectUpdateEventHandler(EffectBase effect, BattleCard target, float total_time, float cur_time)
        {
            effect.EffectUpdate -= AttackEffectUpdateEventHandler;

            m_IsAttackEffectEnd = true;

            PlayBehitEffect();
        }
Exemplo n.º 9
0
        private void SkillEndEventHandler(EffectBase effect, BattleCard target, float total_time)
        {
            m_AttackEffect.EffectEnd -= SkillEndEventHandler;

            EventManager.Instance.Fire(EventDefine.BATTLE_CARD_ATTACK_END, m_SkillOwner.BattleCardObj);

            if (m_TargetList.Count > 0)
            {
                target.OnHit(m_SkillOwner, m_BehitMap[target]);
            }
        }
Exemplo n.º 10
0
        public override void OnEnter()
        {
            m_TurnCounter     = 0;
            m_StepCounter     = 0;
            m_BattleRoundData = m_Manager.GetBattlePlayer().GetBattleRoundData();
            //m_BattleActionBagList = m_Manager.GetBattlePlayer().BattleReportReader(m_BattleRoundData);
            m_CurAttackCard = null;
            m_CurActionBag  = null;
            Obj_MyselfPlayer.GetMe().reviveCount = 0;

            BattleCardManager.Instance.MakeCardInBattling();
        }
 public CardStateMachine(BattleCard owner)
 {
     m_Owner = owner;
     m_StateList[CardStateType.E_CARD_STATE_ATTACK]    = new CardStateAttack();
     m_StateList[CardStateType.E_CARD_STATE_BEHIT]     = new CardStateBehit();
     m_StateList[CardStateType.E_CARD_STATE_DEAD]      = new CardStateDead();
     m_StateList[CardStateType.E_CARD_STATE_FORWARD]   = new CardStateForward();
     m_StateList[CardStateType.E_CARD_STATE_IN_BATTLE] = new CardStateInBattle();
     m_StateList[CardStateType.E_CARD_STATE_NORMAL]    = new CardStateNormal();
     m_StateList[CardStateType.E_CARD_STATE_PREPARE]   = new CardStatePrepare();
     m_StateList[CardStateType.E_CARD_STATE_WAITING]   = new CardStateWaiting();
 }
Exemplo n.º 12
0
        //处理斗转星移,如果卡牌使用斗转星移技能,目标是自己,给自己加斗转的Buff,走正常逻辑,读表,没有子弹和受击动画;
        //如果卡牌使用斗转星移技能,目标是别人,则使用特殊的表现,走非正常逻辑,bullet_dzxy,behit_dzxy
        //正常逻辑返回true,非正常逻辑返回false
        private bool HandleSkill_DZXY(int skill_step, BattleCard target)
        {
            switch (skill_step)
            {
            case 1:
                if ((m_SkillTab.Effect == 50024 || m_SkillTab.Effect == 60024) && m_TargetList.Count > 0 && m_TargetList[0] != m_SkillOwner)
                {
                    PlayProjectileEffect();
                    return(false);
                }
                break;

            case 2:
                if ((m_SkillTab.Effect == 50024 || m_SkillTab.Effect == 60024) && m_TargetList.Count > 0 && m_TargetList[0] != m_SkillOwner)
                {
                    foreach (BattleCard battle_card in m_TargetList)
                    {
                        EffectBase effect = EffectManager.Instance.CreateEffect(this, BattleEffectType.E_BATTLE_EFFECT_TYPE_PARTICLE, "bullet_dzxy", "");
                        effect.Load();
                        effect.EffectEnd     += ProjectileEffectEndEventHandler;
                        effect.StartPos       = m_SkillOwner.BattleCardObj.transform;
                        effect.EndPos         = battle_card.BattleCardObj.transform;
                        effect.MoveSpeed      = 0.5f;
                        effect.DirectionPoint = battle_card.BattleCardObj.transform.localPosition;

                        effect.Play(battle_card);    //播放最后调用
                    }
                    return(false);
                }

                break;

            case 3:
                if ((m_SkillTab.Effect == 50024 || m_SkillTab.Effect == 60024) && m_TargetList.Count > 0 && m_TargetList[0] != m_SkillOwner)
                {
                    EffectBase behit_effect = EffectManager.Instance.CreateEffect(this, BattleEffectType.E_BATTLE_EFFECT_TYPE_PARTICLE, "behit_dzxy", "");
                    behit_effect.Load();
                    behit_effect.EffectEnd     += BehitEffectEndEventHandler;
                    behit_effect.StartPos       = behit_effect.EndPos = target.BattleCardObj.transform;
                    behit_effect.MoveSpeed      = 0f;
                    behit_effect.DirectionPoint = CalculateEffectDirection();

                    target.AnimateBeHit(m_BehitMap[target]);
                    target.ShowHitValue(m_BehitMap[target], this, false);

                    behit_effect.Play(target);    //播放最后调用
                    return(false);
                }
                break;
            }

            return(true);
        }
Exemplo n.º 13
0
        private void AttackEffectEndEventHandler(EffectBase effect, BattleCard target, float total_time)
        {
            effect.EffectEnd -= AttackEffectEndEventHandler;
            EffectManager.Instance.DestroyEffect(effect);

            if (!m_IsAttackEffectEnd)
            {
                PlayProjectileEffect();
            }
            m_IsAttackEffectEnd = true;
            EventManager.Instance.Fire(EventDefine.BATTLE_CARD_ATTACK_END, m_SkillOwner.BattleCardObj);
        }
Exemplo n.º 14
0
        private void ProjectileEffectUpdateEventHandler(EffectBase effect, BattleCard target, float total_time, float cur_time)
        {
            float x        = target.BattleCardObj.transform.localPosition.x - m_SkillOwner.BattleCardObj.transform.localPosition.x;
            float y        = target.BattleCardObj.transform.localPosition.y - m_SkillOwner.BattleCardObj.transform.localPosition.y;
            float distance = (float)System.Math.Sqrt(x * x + y * y);

            if (distance <= cur_time / total_time * 870f)
            {
                effect.EffectUpdate -= ProjectileEffectUpdateEventHandler;
                EffectManager.Instance.DestroyEffect(effect);
                PlayBehitEffect(target);
            }
        }
Exemplo n.º 15
0
        //受击动画-
        private void PlayBehitEffect(BattleCard target)
        {
            EffectBase behit_effect = m_BehitEffect.Duplicate();

            behit_effect.EffectEnd     += BehitEffectEndEventHandler;
            behit_effect.StartPos       = behit_effect.EndPos = target.BattleCardObj.transform;
            behit_effect.MoveSpeed      = 0f;
            behit_effect.DirectionPoint = CalculateEffectDirection();

            target.AnimateBeHit(m_BehitMap[target]);
            target.ShowHitValue(m_BehitMap[target], this, false);

            behit_effect.Play(target);//播放最后调用
        }
        public BattleCard FindCardByGUID(long guid)
        {
            List <BattleCard> card_list   = m_BattleCardList[BattleCardType.E_BATTLE_CARD_TYPE_SELF];
            BattleCard        battle_card = card_list.Find(delegate(BattleCard cd) { return(cd.Card_Data.CardGuid == guid); });

            if (battle_card != null)
            {
                return(battle_card);
            }

            card_list   = m_BattleCardList[BattleCardType.E_BATTLE_CARD_TYPE_OTHER];
            battle_card = card_list.Find(delegate(BattleCard cd) { return(cd.Card_Data.CardGuid == guid); });
            if (battle_card != null)
            {
                return(battle_card);
            }

            return(null);
        }
Exemplo n.º 17
0
        public BuffBase CreateBuff(BattleCard owner, int id, int bf_value)
        {
            BuffBase buff_base = new BuffGeneric(owner, id, bf_value);

            if (!buff_base.Init())
            {
                Debug.LogError("CreateBuff");
                return(null);
            }

            if (!buff_base.LoadBuff())
            {
                Debug.LogError("CreateBuff");
                return(null);
            }
            buff_base.UseBuff();
            m_BuffList.Add(buff_base);
            return(buff_base);
        }
        public BattleCard FindCardBySlotIndex(int index)
        {
            List <BattleCard> card_list   = m_BattleCardList[BattleCardType.E_BATTLE_CARD_TYPE_SELF];
            BattleCard        battle_card = card_list.Find(delegate(BattleCard cd) { return(cd.Battle_Slot.SlotIndex == index); });

            if (battle_card != null)
            {
                return(battle_card);
            }

            card_list   = m_BattleCardList[BattleCardType.E_BATTLE_CARD_TYPE_OTHER];
            battle_card = card_list.Find(delegate(BattleCard cd) { return(cd.Battle_Slot.SlotIndex == index); });
            if (battle_card != null)
            {
                return(battle_card);
            }

            return(null);
        }
        public BattleCard CreateCard(TroopMember member)
        {
            BattleCard battle_card = new BattleCard(member);

            if (!battle_card.Init())
            {
                Debug.LogError("CreateCard");
                return(null);
            }
            if (!battle_card.PreLoad())
            {
                Debug.LogError("CreateCard");
                return(null);
            }
            battle_card.ChangeState(CardStateType.E_CARD_STATE_PREPARE);
            m_BattleCardList[battle_card.Card_Type].Add(battle_card);

            return(battle_card);
        }
Exemplo n.º 20
0
        //受击动画-
        private void PlayBehitEffect(BattleCard target)
        {
            //处理斗转星移
            if (!HandleSkill_DZXY(3, target))
            {
                return;
            }

            EffectBase behit_effect = m_BehitEffect.Duplicate();

            behit_effect.EffectEnd     += BehitEffectEndEventHandler;
            behit_effect.StartPos       = behit_effect.EndPos = target.BattleCardObj.transform;
            behit_effect.MoveSpeed      = 0f;
            behit_effect.DirectionPoint = target.BattleCardObj.transform.localPosition;//CalculateEffectDirection();

            target.AnimateBeHit(m_BehitMap[target]);
            target.ShowHitValue(m_BehitMap[target], this, false);

            behit_effect.Play(target);//播放最后调用
        }
Exemplo n.º 21
0
        public SkillBase CreateSkill(BattleCard owner, int skillid, SkillType type)
        {
            SkillBase skill_base = null;

            switch (type)
            {
            case SkillType.E_SKILL_TYPE_DIRECT:
                skill_base = new SkillDirect(owner, skillid);
                break;

            case SkillType.E_SKILL_TYPE_PROJECTILE:
                skill_base = new SkillProjectile(owner, skillid);
                break;

            case SkillType.E_SKILL_TYPE_STRETCH:
                skill_base = new SkillStretch(owner, skillid);
                break;

            case SkillType.E_SKILL_TYPE_COMBINE:
                skill_base = new SkillCombine(owner, skillid);
                break;

            default:
                break;
            }

            if (skill_base != null)
            {
                skill_base.Init();
                m_SkillList.Add(skill_base);
            }
            else
            {
                Debug.LogError("CreateSkill() failed! skill id = " + skillid);
            }

            return(skill_base);
        }
Exemplo n.º 22
0
        public BattleSlot(int index)
        {
            m_SlotIndex  = index;
            m_BattleCard = null;
            if (0 <= index && index <= 5)
            {
                m_HpBar      = BattleUI.Instacne.selfSlotHp[index];
                m_SlotBg     = BattleUI.Instacne.selfSlotBgs[index];
                m_SlotName   = BattleUI.Instacne.selfSlotNames[index];
                m_SlotBorder = BattleUI.Instacne.selfSlotSprites[index];
            }
            else if (6 <= index && index <= 11)
            {
                m_HpBar      = BattleUI.Instacne.otherSlotHp[index - 6];
                m_SlotBg     = BattleUI.Instacne.otherSlotBgs[index - 6];
                m_SlotName   = BattleUI.Instacne.otherSlotNames[index - 6];
                m_SlotBorder = BattleUI.Instacne.otherSlotSprites[index - 6];
            }

            m_HpBar.gameObject.AddComponent <BattleHpBar>();
            SetHpBarVisible(false);
            SetSlotFrameVisible(false);
            m_HpBar.sliderValue = 1.0f;
        }
Exemplo n.º 23
0
        //受击--
        public void OnHit(BattleCard attacker, BeHitBag bag)
        {
            Debug.LogWarning("OnHit(), SlotIndex: " + m_BattleSlot.SlotIndex + ", TotalHP: " + m_CardData.TotalHp + ", CurHp: " + bag.curHp + ", attackHp: " + bag.behitValue);
            m_CurrentHp = bag.curHp;

            m_InBehitAction = false;

            if (m_CurrentHp <= 0)
            {
                OnDead();
                return;
            }

            UpdateBuff(bag.behitBuffs);

            //如果卡牌身上有反击BUFF,在受击时给攻击者造成伤害--
            foreach (BuffBase bf in m_BuffList)
            {
                if (bf.TabBfEffect.BuffType == (int)BattleBuffType.E_BATTLE_BUFF_TYPE_FAN_SHANG)
                {
                    bf.ShowBuffValue(attacker.BattleCardObj);
                }
            }
        }
Exemplo n.º 24
0
 private void ExcuteOnCommand()
 {
     if (m_BattleActionBagList.ContainsKey(m_TurnCounter))
     {
         if (m_StepCounter < m_BattleActionBagList[m_TurnCounter].Count)
         {
             ActionBag action_bag = m_BattleActionBagList[m_TurnCounter][m_StepCounter];
             m_CurAttackCard = action_bag.attackCard;
             m_CurActionBag  = action_bag;
             action_bag.attackCard.DoAttack(action_bag);
             m_StepCounter++;
         }
         else
         {
             m_StepCounter = 0;
             m_TurnCounter++;
             ExcuteOnCommand();
         }
     }
     else
     {
         m_Manager.ChangProcedure(BattleProcedureType.E_BATTLE_PROCEDURE_SHOW_TROPHY);
     }
 }
Exemplo n.º 25
0
 public SkillDirect(BattleCard owner, int id)
 {
     m_SkillOwner = owner;
     m_SkillId    = id;
     m_SkillType  = SkillType.E_SKILL_TYPE_DIRECT;
 }
Exemplo n.º 26
0
 public SkillStretch(BattleCard owner, int id)
 {
     m_SkillOwner = owner;
     m_SkillId    = id;
     m_SkillType  = SkillType.E_SKILL_TYPE_STRETCH;
 }
Exemplo n.º 27
0
        //播放 废弃--
        public void ExecuteOneAttack()
        {
            if (m_BattleRoundData == null)
            {
                Debug.Log("Execute(), m_BattleRoundData == null");
                return;
            }

            Debug.Log("DoPlayOneStep(), turnCount = " + m_TurnCounter + ", stepCount = " + m_StepCounter);

            if (m_TurnCounter < m_BattleRoundData.battleRound.battleTurns.Count)
            {
                if (m_StepCounter < m_BattleRoundData.battleRound.battleTurns[m_TurnCounter].battleSteps.Count)
                {
                    BattleStep tStep = m_BattleRoundData.battleRound.battleTurns[m_TurnCounter].battleSteps[m_StepCounter];

                    BattleCard tAttackcard = null;
                    AttackBag  attack_bag  = new AttackBag();
                    if (tStep.attacks.Count > 0)
                    {
                        StepAction tAttack = tStep.attacks[0];
                        tAttackcard = BattleCardManager.Instance.FindCardBySlotIndex(tAttack.slotIndex);
                        if (tAttackcard != null)
                        {
                            Debug.Log("Attack, slotindex: " + tAttack.slotIndex + ", CardID: " + tAttackcard.Card_Data.CardTempId + ", SkillID: " + tAttack.skillID);
                            attack_bag.skillID  = tAttack.skillID;
                            attack_bag.curHp    = tAttack.curHp;
                            attack_bag.loverIdx = tAttack.hetiIndex;
                            if (tAttack.buff != null && tAttack.buff.Count != 0)
                            {
                                foreach (BuffInfo info in tAttack.buff)
                                {
                                    attack_bag.attackBuffs.Add(info);
                                }
                            }
                        }
                        else
                        {
                            Debug.LogError("DoPlayOneStep(), can not find attack card! " + tAttack.slotIndex);
                            m_StepCounter++;
                            return;
                        }
                    }
                    else
                    {
                        Debug.LogError("DoPlayOneStep(), no attack card !");
                        m_StepCounter++;
                        return;
                    }

                    if (tStep.attacks.Count > 1)
                    {
                        Debug.LogError("DoPlayOneStep(), attack card more then one ! " + tStep.attacks.Count);
                    }

                    Dictionary <BattleCard, BeHitBag> behit_map = new Dictionary <BattleCard, BeHitBag>();
                    foreach (StepAction tBeAtt in tStep.behits)
                    {
                        BeHitBag   behit_bag    = new BeHitBag();
                        BattleCard tDefenceCard = BattleCardManager.Instance.FindCardBySlotIndex(tBeAtt.slotIndex);
                        if (tDefenceCard != null)
                        {
                            Debug.Log("Behit, slotindex: " + tBeAtt.slotIndex + ", CardID: " + tDefenceCard.Card_Data.CardTempId + ", attackHp: " + tBeAtt.attackHp);
                            behit_bag.behitValue = tBeAtt.attackHp;
                            behit_bag.curHp      = tBeAtt.curHp;
                            behit_bag.isCrit     = tBeAtt.isStorm;
                            if (tBeAtt.buff != null && tBeAtt.buff.Count != 0)
                            {
                                foreach (BuffInfo info in tBeAtt.buff)
                                {
                                    behit_bag.behitBuffs.Add(info);
                                }
                            }
                            behit_map.Add(tDefenceCard, behit_bag);
                        }
                    }

                    //send bag
                    ActionBag action_bag = new ActionBag();
                    action_bag.attackBag = attack_bag;
                    action_bag.behitMap  = behit_map;
                    m_CurAttackCard      = tAttackcard;
                    m_CurActionBag       = action_bag;
                    tAttackcard.DoAttack(action_bag);

                    m_StepCounter++;
                }
                else
                {
                    m_StepCounter = 0;
                    m_TurnCounter++;
                    ExecuteOneAttack();
                }
            }
            else
            {
                m_Manager.ChangProcedure(BattleProcedureType.E_BATTLE_PROCEDURE_SHOW_TROPHY);
            }
        }
Exemplo n.º 28
0
 public void OnChangeCard(BattleCard bcard)
 {
     m_BattleCard = bcard;
 }
Exemplo n.º 29
0
 public SkillCombine(BattleCard owner, int id)
 {
     m_SkillOwner = owner;
     m_SkillId    = id;
     m_SkillType  = SkillType.E_SKILL_TYPE_COMBINE;
 }
Exemplo n.º 30
0
 public virtual bool Play(BattleCard target)
 {
     return(false);
 }