Esempio n. 1
0
        public void UpdateSlot(ActiveCard[] pCards)
        {
            realCardNum = 0;
            for (int i = 0; i < 10; i++)
            {
                if (cards[i].ACard.Id != pCards[i].Id)
                    cards[i].SetSlotCard(pCards[i]);
                if (pCards[i].CardId > 0)
                {
                    realCardNum++;
                }
            }

            if (realCardNum <= 6)
            {
                for (int i = 0; i < pCards.Length; i++)
                {
                    cards[i].Size.Width = 120;
                    cards[i].Location.X = 120*i+4*i+4;
                }
            }
            else
            {
                for (int i = 0; i < pCards.Length; i++)
                {
                    cards[i].Size.Width = (754 - (realCardNum + 1) * 4 - 120) / (realCardNum-1);
                    cards[i].Location.X = cards[i].Size.Width * i+4*i+4;
                }
            }
            Invalidate();
        }
Esempio n. 2
0
        public override bool Equals(object obj)
        {
            if (obj == null)
            {
                return(false);
            }
            if (GetType() != obj.GetType())
            {
                return(false);
            }
            ActiveCard rec = (ActiveCard)obj;

            if (rec.Card == Card)
            {
                return(true);
            }
            if (rec.CardId != CardId)
            {
                return(false);
            }
            if (rec.Level != Level) //todo 还有其他可能性,暂时只有这个
            {
                return(false);
            }
            return(true);
        }
Esempio n. 3
0
 public override void SetData(ActiveCard card1)
 {
     card = card1.Card;
     if (card1.Level > 1)
     {
         monster.UpgradeToLevel(card1.Level);
     }
 }
Esempio n. 4
0
 private void SetCard(int id, ActiveCard card)
 {
     int count = GetCardNumber();
     if (id < count)
     {
         cards[id] = card;
     }
     if (self.CardsDesk != null)
         self.CardsDesk.UpdateSlot(cards);
 }
Esempio n. 5
0
        public ActiveCard GetCopy()
        {
            DeckCard dc = new DeckCard(Card.BaseId, Card.Level, Card.Exp);
            var      ac = new ActiveCard(dc);

            ac.MpCostChange = MpCostChange;
            ac.LpCostChange = LpCostChange;
            ac.PpCostChange = PpCostChange;
            ac.Lp2Mp        = Lp2Mp;
            return(ac);
        }
Esempio n. 6
0
 public void UpdateSlot(ActiveCard[] pCards)
 {
     for (int i = 0; i < cards.Length; i++)
     {
         cards[i] = ActiveCards.NoneCard;
     }
     for (int i = 0; i < Math.Min(pCards.Length, cards.Length); i++)
     {
         if (cards[i].Id != pCards[i].Id)
             cards[i] = pCards[i];
     }
     Invalidate();
 }
Esempio n. 7
0
        public ActiveCard ReplaceCard(ActiveCard card)
        {
            if (LeftCount <= 0)
            {
                return(NoneCard);
            }

            var targetIndex = index + MathTool.GetRandom(LeftCount);
            var target      = cards[targetIndex];

            cards[targetIndex] = card;
            return(target);
        }
Esempio n. 8
0
        public static bool UseFightItem(ItemConsumerConfig itemConfig)
        {
            var player = BattleManager.Instance.PlayerManager.LeftPlayer;
            if (itemConfig.GainLp > 0)
            {
                player.AddLp(itemConfig.GainLp);
            }
            if (itemConfig.GainPp > 0)
            {
                player.AddPp(itemConfig.GainPp);
            }
            if (itemConfig.GainMp > 0)
            {
                player.AddMp(itemConfig.GainMp);
            }

            if (itemConfig.DirectDamage > 0)
            {
                player.DirectDamage += itemConfig.DirectDamage;
            }

            if (itemConfig.FightRandomCardType > 0)
            {
                int cardId = 0;
                switch (itemConfig.FightRandomCardType)
                {
                    case 1: cardId = MonsterBook.GetRandMonsterId(); break;
                    case 2: cardId = WeaponBook.GetRandWeaponId(); break;
                    case 3: cardId = SpellBook.GetRandSpellId(); break;
                }
                var card = new ActiveCard(new DeckCard(cardId, 1, 0));
                player.CardManager.AddCard(card);
            }
            if (!string.IsNullOrEmpty(itemConfig.HolyWord))
            {
                player.AddHolyWord(itemConfig.HolyWord);
            }
            if (itemConfig.AttrAddAfterSummon != null)
            {
                player.AddMonsterAddon(itemConfig.AttrAddAfterSummon);
            }
            if (itemConfig.AddTowerHp > 0)
            {
                player.AddTowerHp(itemConfig.AddTowerHp);
            }
            return true;
        }
Esempio n. 9
0
 internal ActiveCards(DeckCard[] itsCards)
 {
     ActiveCard[] tcards = new ActiveCard[GameConstants.DeckCardCount];
     for (int i = 0; i < GameConstants.DeckCardCount; i++)
     {
         tcards[i] = new ActiveCard(itsCards[i]);
     }
     for (int i = 0; i < 100; i++)
     {
         int x = MathTool.GetRandom(GameConstants.DeckCardCount);
         int y = MathTool.GetRandom(GameConstants.DeckCardCount);
         ActiveCard temp = tcards[x];
         tcards[x] = tcards[y];
         tcards[y] = temp;
     }
     cards = new List<ActiveCard>(tcards);
     index = 0;
 }
Esempio n. 10
0
 public ActiveCards(DeckCard[] itsCards)
 {
     ActiveCard[] tcards = new ActiveCard[GameConstants.DeckCardCount];
     for (int i = 0; i < GameConstants.DeckCardCount; i++)
     {
         tcards[i] = new ActiveCard(itsCards[i]);
     }
     for (int i = 0; i < 100; i++)
     {
         int        x    = MathTool.GetRandom(GameConstants.DeckCardCount);
         int        y    = MathTool.GetRandom(GameConstants.DeckCardCount);
         ActiveCard temp = tcards[x];
         tcards[x] = tcards[y];
         tcards[y] = temp;
     }
     cards = new List <ActiveCard>(tcards);
     index = 0;
 }
Esempio n. 11
0
 public void AddCard(ActiveCard card)
 {
     var spikeManager = self.SpikeManager;
     card.MpCostChange = spikeManager.MpCost;
     card.LpCostChange = spikeManager.LpCost;
     card.PpCostChange = spikeManager.PpCost;
     card.Lp2Mp = spikeManager.HasSpike("lp2mp");
     int count = GetCardNumber();
     if (count < GameConstants.CardSlotMaxCount)
     {
         cards[count] = card;
     }
     if (spikeManager.HasSpike("copycard") && count < GameConstants.CardSlotMaxCount-1)
     {
         cards[count+1] = card.GetCopy();
     }
     if (self.CardsDesk != null)
         self.CardsDesk.UpdateSlot(cards);
 }
Esempio n. 12
0
 private void OnVRegionClick(int info, int x, int y, MouseButtons button)
 {
     if (info > 0)
     {
         HeroSkillConfig heroSkillConfig = ConfigDatas.ConfigData.GetHeroSkillConfig(info);
         LevelExpConfig levelConfig = ConfigData.GetLevelExpConfig(UserProfile.Profile.InfoBasic.Level);
         leftSelectCard = new ActiveCard(heroSkillConfig.CardId, (byte)levelConfig.HeroSkillLevel, 0);
         panelState.Invalidate();
     }
 }
Esempio n. 13
0
        private void panelBattle_MouseClick(object sender, MouseEventArgs e)
        {
            if (BattleManager.Instance.PlayerManager.LeftPlayer == null)
                return;

            if (isGamePaused)
                return;

            int cardSize = BattleManager.Instance.MemMap.CardSize;
            if (e.Button == MouseButtons.Left)
            {
                if (leftSelectCard != null && (myCursor.Name == "summon" || myCursor.Name == "equip" || myCursor.Name == "cast" || myCursor.Name == "sidekick"))
                {
                    int result;
                    if ((result = BattleManager.Instance.PlayerManager.LeftPlayer.CheckUseCard(leftSelectCard, BattleManager.Instance.PlayerManager.LeftPlayer, BattleManager.Instance.PlayerManager.RightPlayer)) != HSErrorTypes.OK)
                    {
                        BattleManager.Instance.FlowWordQueue.Add(new FlowErrInfo(result, new Point(mouseX, mouseY), 0, 0), false);
                        return;
                    }

                    LiveMonster lm = BattleLocationManager.GetPlaceMonster(mouseX, mouseY);
                    if (myCursor.Name == "summon" && lm == null)
                    {
                        var pos = new Point(mouseX/cardSize*cardSize, mouseY/cardSize*cardSize);
                        BattleManager.Instance.PlayerManager.LeftPlayer.UseMonster(leftSelectCard, pos);
                    }
                    else if (myCursor.Name == "equip" && lm != null)
                    {
                        BattleManager.Instance.PlayerManager.LeftPlayer.UseWeapon(lm, leftSelectCard);
                    }
                    else if (myCursor.Name == "sidekick" && lm != null)
                    {
                        BattleManager.Instance.PlayerManager.LeftPlayer.UseSideKick(lm, leftSelectCard);
                    }
                    else if (myCursor.Name == "cast")
                    {
                        BattleManager.Instance.PlayerManager.LeftPlayer.DoSpell(lm, leftSelectCard, e.Location);
                    }

                    var cardData = CardConfigManager.GetCardConfig(leftSelectCard.CardId);
                    UserProfile.Profile.OnUseCard(cardData.Star, 0, cardData.TypeSub);

                    cardsArray1.DisSelectCard();
                }
            }
            else if (e.Button == MouseButtons.Right)
            {
                leftSelectCard = null;
                cardsArray1.DisSelectCard();
            }
        }
Esempio n. 14
0
        private bool CheckTrapOnUseCard(ActiveCard selectCard, Player left, Player right)
        {
            foreach (var trap in trapList)
            {
                var effect = ConfigData.GetSpellTrapConfig(trap.Id).EffectUse;
                if (effect != null)
                {
                    if (MathTool.GetRandom(100) < trap.Rate && effect(left, right, trap, selectCard.CardId, selectCard.Id, (int)selectCard.CardType))
                    {
                        RemoveTrap(trap.Id);
                        NLog.Debug(string.Format("RemoveTrap UseCard id={0} cardId={1}", trap.Id, selectCard.CardId));

                        return true;
                    }
                }
            }

            return false;
        }
Esempio n. 15
0
 public void AddCard(int cardId, int level)
 {
     ActiveCard card = new ActiveCard(cardId, (byte)level, 0);
     AddCard(card);
 }
Esempio n. 16
0
        public void UseSideKick(LiveMonster lm, ActiveCard card)
        {
            if (!CheckUseCard(card))
            {
                return;
            }

            try
            {
                Monster mon = new Monster(card.CardId);
                mon.UpgradeToLevel(card.Level);
                BattleManager.Instance.BattleInfo.GetPlayer(IsLeft).MonsterAdd++;

                var tWeapon = new SideKickWeapon(lm, card.Level, mon);
                lm.AddWeapon(tWeapon);
            }
            catch (Exception e)
            {
                NLog.Warn(e);
                BattleManager.Instance.FlowWordQueue.Add(new FlowWord("未知错误", lm.Position, 0, "Red", 26, 0, 0, 2, 15), false);
                return;
            }

            CardManager.DeleteCardAt(SelectId);
        }
Esempio n. 17
0
        public void DoSpell(LiveMonster target, ActiveCard card, Point location)
        {
            if (!CheckUseCard(card))
            {
                return;
            }

            try
            {
                Spell spell = new Spell(card.CardId);
                spell.Addon = SpellEffectAddon;
                spell.UpgradeToLevel(card.Level);
                BattleManager.Instance.BattleInfo.GetPlayer(IsLeft).SpellAdd++;

                SpellAssistant.CheckSpellEffect(spell, IsLeft, target, location);

                if (SpikeManager.HasSpike("mirrorspell"))
                {
                    var rival = IsLeft ? BattleManager.Instance.PlayerManager.RightPlayer : BattleManager.Instance.PlayerManager.LeftPlayer;
                    rival.AddCard(null, card.CardId, card.Level);
                }
            }
            catch (Exception e)
            {
                NLog.Warn(e);
                BattleManager.Instance.FlowWordQueue.Add(new FlowWord("未知错误", location, 0, "Red", 26, 0, 0, 2, 15),false);
                return;
            }
            
            CardManager.DeleteCardAt(SelectId);
        }
Esempio n. 18
0
        public bool CheckUseCard(ActiveCard selectCard)
        {
            AddMp(-selectCard.Mp);
            AddLp(-selectCard.Lp);
            AddPp(-selectCard.Pp);

            var rival = IsLeft ? BattleManager.Instance.PlayerManager.RightPlayer : BattleManager.Instance.PlayerManager.LeftPlayer;
            if (rival.CheckTrapOnUseCard(selectCard, rival, this))
            {
                return false;
            }

            SpikeManager.OnUseCard(selectCard.CardType);

            return true;
        }
Esempio n. 19
0
        public void UseMonster(ActiveCard card, Point location)
        {
            if (!CheckUseCard(card))
            {
                return;
            }

            try
            {
                var mon = new Monster(card.CardId);
                mon.UpgradeToLevel(card.Level);
                BattleManager.Instance.BattleInfo.GetPlayer(IsLeft).MonsterAdd++;

                LiveMonster newMon = new LiveMonster(card.Id, card.Level, mon, location, IsLeft);
                BattleManager.Instance.MonsterQueue.Add(newMon);

                var addon = GetAllMonsterAddonAndClear();//这个属性目前可以来自药水
                if (addon.Length > 0)
                {
                    foreach (var add in addon)
                        newMon.AddBasicData(add[0], add[1]);
                }

                var rival = IsLeft ? BattleManager.Instance.PlayerManager.RightPlayer : BattleManager.Instance.PlayerManager.LeftPlayer;
                rival.CheckTrapOnSummon(newMon, rival, this);
            }
            catch (Exception e)
            {
                NLog.Warn(e);
                BattleManager.Instance.FlowWordQueue.Add(new FlowWord("未知错误", location, 0, "Red", 26, 0, 0, 2, 15), false);
                return;
            }

            CardManager.DeleteCardAt(SelectId);
        }
Esempio n. 20
0
        public int CheckUseCard(ActiveCard selectCard, Player left, Player right)
        {
            if (Mp < selectCard.Mp)
            {
                return HSErrorTypes.BattleLackMp;
            }

            if (Lp < selectCard.Lp)
            {
                return HSErrorTypes.BattleLackLp;
            }

            if (Pp < selectCard.Pp)
            {
                return HSErrorTypes.BattleLackPp;
            }

            return HSErrorTypes.OK;
        }
Esempio n. 21
0
 private void cardsArray1_SelectionChange(object sender, EventArgs e)
 {
     leftSelectCard = cardsArray1.GetSelectCard();
     if (leftSelectCard != null && leftSelectCard.CardType == CardTypes.Monster)
         visualRegion.Update(leftSelectCard.CardId);
     else
         visualRegion.Update(0);
     panelState.Invalidate();
 }
Esempio n. 22
0
 public override void SetData(ActiveCard card)
 {            
 }
Esempio n. 23
0
 public ActiveCard GetCopy()
 {
     DeckCard dc = new DeckCard(Card.BaseId, Card.Level, Card.Exp);
     var ac = new ActiveCard(dc);
     ac.MpCostChange = MpCostChange;
     ac.LpCostChange = LpCostChange;
     ac.PpCostChange = PpCostChange;
     ac.Lp2Mp = Lp2Mp;
     return ac;
 }
Esempio n. 24
0
 public void SetSlotCard(ActiveCard tcard)
 {
     ACard = tcard;
     Card = CardAssistant.GetCard(tcard.CardId);
     Card.SetData(ACard);
 }
Esempio n. 25
0
 public void WeaponReturn()
 {
     if (Weapon is TrueWeapon)
     {
         ActiveCard card = new ActiveCard(new DeckCard(Weapon.CardId, (byte)Weapon.Level, 0));
         OwnerPlayer.CardManager.AddCard(card);
         DeleteWeapon();
     }
 }
Esempio n. 26
0
 public abstract void SetData(ActiveCard dc);