Esempio n. 1
0
        internal bool Update(out BattleAttackVO _vo)
        {
            if (parent.state == UnitState.CD)
            {
                parent.Ready(time);
            }

            bool b = DoAction(out _vo);

            if (b)
            {
                time += sds.GetAttackGap();
            }

            return(b);
        }
Esempio n. 2
0
        private bool DoAction(out BattleAttackVO _vo)
        {
            Dictionary <KeyValuePair <int, int>, int> recDic = null;

            if (sds.GetAttackDamageAdd() > 0)
            {
                recDic = lastTargetDic;

                lastTargetDic = new Dictionary <KeyValuePair <int, int>, int>();
            }

            List <int> result = BattlePublicTools.GetTurrentAttackTargetList(battleCore, parent.isMine, sds, pos);

            if (result != null)
            {
                Turrent[] oppTurrent = parent.isMine ? battleCore.oTurrent : battleCore.mTurrent;

                List <KeyValuePair <int, int> > damageDataList = new List <KeyValuePair <int, int> >();

                for (int i = 0; i < result.Count; i++)
                {
                    int targetPos = result[i];

                    if (targetPos < 0)
                    {
                        if (sds.GetAttackDamageAdd() > 0)
                        {
                            if (!lastTargetDic.ContainsKey(new KeyValuePair <int, int>(-1, -1)))
                            {
                                int lastTargetTime;

                                if (recDic.TryGetValue(new KeyValuePair <int, int>(-1, -1), out lastTargetTime))
                                {
                                    lastTargetDic.Add(new KeyValuePair <int, int>(-1, -1), lastTargetTime);
                                }
                                else
                                {
                                    lastTargetDic.Add(new KeyValuePair <int, int>(-1, -1), time);
                                }
                            }
                        }

                        int damage = DamageBase();

                        damageDataList.Add(new KeyValuePair <int, int>(-1, damage));
                    }
                    else
                    {
                        Turrent targetTurrent = oppTurrent[targetPos];

                        if (sds.GetAttackDamageAdd() > 0)
                        {
                            if (!lastTargetDic.ContainsKey(new KeyValuePair <int, int>(targetTurrent.parent.uid, targetTurrent.pos)))
                            {
                                int lastTargetTime;

                                if (recDic.TryGetValue(new KeyValuePair <int, int>(targetTurrent.parent.uid, targetTurrent.pos), out lastTargetTime))
                                {
                                    lastTargetDic.Add(new KeyValuePair <int, int>(targetTurrent.parent.uid, targetTurrent.pos), lastTargetTime);
                                }
                                else
                                {
                                    lastTargetDic.Add(new KeyValuePair <int, int>(targetTurrent.parent.uid, targetTurrent.pos), time);
                                }
                            }
                        }

                        int damage = DamageTurrent(targetTurrent);

                        damageDataList.Add(new KeyValuePair <int, int>(targetPos, damage));
                    }
                }

                _vo = new BattleAttackVO(parent.isMine, pos, damageDataList);

                return(true);
            }
            else
            {
                _vo = new BattleAttackVO();

                return(false);
            }
        }