Example #1
0
        public void Init(int left, int right, int rlevel)
        {
            PeopleConfig peopleConfig = ConfigData.GetPeopleConfig(right);
            if (left == 0)
            {
                switch (peopleConfig.Method)
                {
                    case "common": LeftPlayer = new HumanPlayer(true); break;
                    case "rand": LeftPlayer = new RandomPlayer(right, true, true); break;
                    default: LeftPlayer = new AIPlayer(right, peopleConfig.Method, true, rlevel, true); break;
                }
            }
            else //观看比赛
            {
                LeftPlayer = new AIPlayer(left, ConfigData.GetPeopleConfig(left).Emethod, true, rlevel, false);
            }

            switch (peopleConfig.Emethod)
            {
                case "common": RightPlayer = new HumanPlayer(false); RightPlayer.PeopleId = right; break;
                case "rand": RightPlayer = new RandomPlayer(right, false, false); break;
                case "mirror": RightPlayer = new MirrorPlayer(right, LeftPlayer.Cards, false); break;
                default: RightPlayer = new AIPlayer(right, peopleConfig.Emethod, false, rlevel, false); break;
            }

            LeftPlayer.InitialMonster = peopleConfig.LeftMon;
            RightPlayer.InitialMonster = peopleConfig.RightMon;
        }
Example #2
0
        public void InitUnit(Player player)
        {
            int x = player.IsLeft ? 0 : ColumnCount - 1;
            int y = RowCount / 2;

            foreach (var unitInfo in bMap.Info)
            {
                var id = World.WorldInfoManager.GetCardFakeId();
                var heroData = new Monster(unitInfo.UnitId);
                var level = ConfigData.GetLevelExpConfig(player.Level).TowerLevel;
                LiveMonster lm = new LiveMonster(id, level, heroData, new Point((x + (player.IsLeft ? unitInfo.X : (-unitInfo.X))) * CardSize, (y + unitInfo.Y) * CardSize), player.IsLeft);
                BattleManager.Instance.MonsterQueue.Add(lm);
            }

            if (player.InitialMonster != null && player.InitialMonster.Length >= 3)
            {
                for (int i = 0; i < player.InitialMonster.Length; i+=3)
                {
                    int mid = player.InitialMonster[i];
                    int xoff = player.InitialMonster[i+1];
                    int yoff = player.InitialMonster[i+2];

                    var id = World.WorldInfoManager.GetCardFakeId();
                    var level = ConfigData.GetLevelExpConfig(player.Level).TowerLevel;
                    var mon = new Monster(mid);
                    mon.UpgradeToLevel(level);
                    var pos = new Point((x + xoff)*CardSize, yoff*CardSize);
                    LiveMonster lm = new LiveMonster(id, level, mon, pos, player.IsLeft);
                    BattleManager.Instance.MonsterQueue.Add(lm);
                }
            }
        }
Example #3
0
        public void Init(Player p)
        {
            bitmapButton1.ImageNormal = PicLoader.Read("ButtonBitmap", "ButtonBack2.PNG");

            player = p;
            cardList = player.CardsDesk;//hold住cardlist

            cards = new CardSlot[GameConstants.BattleInitialCardCount];
            InstallCards();
        }
Example #4
0
        internal static void OnInit(Player player)
        {
            var cds = player.CardsDesk.GetAllCard();
            for (int i = 0; i < cds.Length; i++)
            {
                var card = cds[i];
                if (card.Card.Star>3)//把3费以上卡都换掉
                {
                    player.CardManager.GetNextCardAt(i + 1);
                }
            }

#if DEBUG
            //int[] cardToGive = new[] { 53000019 };
            //foreach (var cardId in cardToGive)
            //{
            //    player.CardManager.AddCard(new ActiveCard(cardId, 1, 0));
            //}
#endif
        }
Example #5
0
 public void Clear()
 {
     LeftPlayer = null;
     RightPlayer = null;
 }
Example #6
0
        internal static void AIProc(Player player)
        {            
            if (player.CardNumber <= 0)
                return;

            if (MathTool.GetRandom(4) != 0)
                return;

            int row = BattleManager.Instance.MemMap.RowCount;
            int size = BattleManager.Instance.MemMap.CardSize;
            bool isLeft = player.IsLeft;
            var rival = (player == BattleManager.Instance.PlayerManager.LeftPlayer) ? BattleManager.Instance.PlayerManager.RightPlayer : BattleManager.Instance.PlayerManager.LeftPlayer;
            
            player.CardsDesk.SetSelectId(MathTool.GetRandom(player.CardNumber) + 1);
            if (player.SelectCardId != 0)
            {
                ActiveCard card = player.CardsDesk.GetSelectCard();
                if (player.CheckUseCard(card, player, rival) != HSErrorTypes.OK)
                {
                    return;
                }

                int tar = -1;
                if (card.CardType == CardTypes.Weapon)
                {
                    for (int i = 0; i <BattleManager.Instance.MonsterQueue.Count; i++)
                    {
                        LiveMonster monster =BattleManager.Instance.MonsterQueue[i];
                        if (!monster.IsGhost && monster.IsLeft == isLeft && monster.Weapon == null && monster.Life > monster.RealMaxHp / 2)
                        {
                            if (!monster.CanAddWeapon())//建筑无法使用武器
                                continue;

                            if (tar == -1 || monster.Avatar.MonsterConfig.Star >BattleManager.Instance.MonsterQueue[tar].Avatar.MonsterConfig.Star)
                                tar = i;
                        }
                    }
                    if (tar == -1)
                        return;
                }
                else if (card.CardType == CardTypes.Spell)
                {
                    SpellConfig spellConfig = ConfigData.GetSpellConfig(card.CardId);
                    if (BattleTargetManager.IsSpellUnitTarget(spellConfig.Target))
                    {
                        for (int i = 0; i <BattleManager.Instance.MonsterQueue.Count; i++)
                        {
                            LiveMonster monster =BattleManager.Instance.MonsterQueue[i];
                            if (!monster.IsGhost && ((monster.IsLeft != isLeft && spellConfig.Target[1] == 'F') || (monster.IsLeft == isLeft && spellConfig.Target[1] != 'F')))
                            {
                                if (tar == -1 || monster.Avatar.MonsterConfig.Star >BattleManager.Instance.MonsterQueue[tar].Avatar.MonsterConfig.Star)
                                    tar = i;
                            }
                        }
                        if (tar == -1)
                            return;
                    }
                }

                if (card.CardType == CardTypes.Monster)
                {
                    Point monPos = GetMonsterPoint(card.CardId, false);
                    player.UseMonster(card, monPos);
                }
                else if (card.CardType == CardTypes.Weapon)
                {
                    var lm =BattleManager.Instance.MonsterQueue[tar];
                    player.UseWeapon(lm, card);
                }
                else if (card.CardType == CardTypes.Spell)
                {
                    SpellConfig spellConfig = ConfigData.GetSpellConfig(card.CardId);
                    Point targetPos = Point.Empty;
                    LiveMonster targetMonster = null;
                    if (BattleTargetManager.IsSpellNullTarget(spellConfig.Target))
                    {
                        targetPos = new Point(isLeft ? MathTool.GetRandom(200, 300) : MathTool.GetRandom(600, 700), MathTool.GetRandom(size * 3 / 10, row * size - size * 3 / 10));
                    }
                    else if (BattleTargetManager.IsSpellUnitTarget(spellConfig.Target))
                    {
                        targetMonster = BattleManager.Instance.MonsterQueue[tar];
                        targetPos = targetMonster.CenterPosition;
                    }

                    player.DoSpell(targetMonster, card, targetPos);
                }
            }
        }
Example #7
0
        private void CheckTrapOnSummon(LiveMonster mon, Player left, Player right)
        {
            foreach (var trap in trapList)
            {
                var effect = ConfigData.GetSpellTrapConfig(trap.Id).EffectSummon;
                if (effect != null)
                {
                    if (MathTool.GetRandom(100) < trap.Rate && effect(left, right, trap, mon, trap.Level))
                    {
                        RemoveTrap(trap.Id);
                        NLog.Debug(string.Format("RemoveTrap Summon id={0} cardId={1}", trap.Id, mon.Id));

                        return;
                    }
                }
            }
        }
Example #8
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;
        }
Example #9
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;
        }