Ejemplo n.º 1
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();
            }
        }
Ejemplo n.º 2
0
        private void CheckCursor()
        {
            string cursorname = "default";

            magicRegion.Active = false;
            if (leftSelectCard != null)
            {
                if (leftSelectCard.CardType == CardTypes.Monster)
                {
                    if (BattleLocationManager.IsPlaceCanSummon(leftSelectCard.CardId, mouseX, mouseY, true))
                    {
                        cursorname         = "summon";
                        magicRegion.Active = true;
                    }
                    else
                    {
                        var placeMon = BattleLocationManager.GetPlaceMonster(mouseX, mouseY);
                        if (placeMon != null && placeMon.IsLeft && !placeMon.Avatar.MonsterConfig.IsBuilding)
                        {
                            if (MonsterBook.HasTag(leftSelectCard.CardId, "sidekicker") ||
                                MonsterBook.HasTag(placeMon.CardId, "sidekickee") ||
                                BattleManager.Instance.PlayerManager.LeftPlayer.SpikeManager.HasSpike("sidekickall"))
                            {
                                cursorname = "sidekick";
                            }
                        }
                    }
                }
                else if (leftSelectCard.CardType == CardTypes.Weapon)
                {
                    LiveMonster lm = BattleLocationManager.GetPlaceMonster(mouseX, mouseY);
                    if (lm != null && lm.CanAddWeapon() && lm.IsLeft)
                    {
                        cursorname = "equip";
                    }
                }
                else if (leftSelectCard.CardType == CardTypes.Spell)
                {
                    if (mouseX > 0)
                    {
                        SpellConfig spellConfig = ConfigData.GetSpellConfig(leftSelectCard.CardId);
                        if (BattleLocationManager.IsPlaceCanCast(mouseX, mouseY, spellConfig.Target))
                        {
                            magicRegion.Active = true;
                            cursorname         = "cast";
                        }
                        else
                        {
                            cursorname = "nocast";
                        }
                    }
                }
            }
            myCursor.ChangeCursor(cursorname);
        }
Ejemplo n.º 3
0
        public override bool CheckFly(ref NLPointF position, ref int angle)
        {
            if (parent == null || !parent.IsAlive)
            {
                return(false);
            }

            if (FlyProc(targetPos, ref position, ref angle) == FlyCheckType.EndPoint)
            {
                var mon = BattleLocationManager.GetPlaceMonster(targetPos.X, targetPos.Y);
                if (mon != null)
                {
                    parent.HitTarget(mon, false);
                    BattleManager.Instance.EffectQueue.Add(new ActiveEffect(EffectBook.GetEffect(config.EffName), mon, false));
                }
                return(false);
            }
            return(true);
        }
Ejemplo n.º 4
0
        public override bool CheckFly(ref NLPointF position, ref int angle)
        {
            var type = FlyProc(targetPos, ref position, ref angle);

            if (type == FlyCheckType.EndPoint)
            {
                return(false);
            }
            if (type == FlyCheckType.ToCheck)
            {
                var mon = BattleLocationManager.GetPlaceMonster((int)position.X, (int)position.Y);
                if (mon != null && mon.IsLeft != owner.IsLeft)
                {
                    mon.OnMagicDamage(null, spell.Damage, spell.Attr);
                    return(false);
                }
            }
            return(true);
        }
Ejemplo n.º 5
0
        private void panelBattle_Paint(object sender, PaintEventArgs e)
        {
            Bitmap   bmp = new Bitmap(panelBattle.Width, panelBattle.Height);
            Graphics g   = Graphics.FromImage(bmp);

            try
            {
                if (showGround)
                {
                    BattleManager.Instance.Draw(g, magicRegion, visualRegion, mouseX, mouseY, isMouseIn);

                    LiveMonster target = BattleLocationManager.GetPlaceMonster(mouseX, mouseY);
                    if (target != null && isMouseIn && !magicRegion.Active)
                    {
                        target.LiveMonsterToolTip.DrawCardToolTips(g);
                    }
#if !DEBUG
                    if (IsGamePaused)
                    {
                        Font font = new Font("微软雅黑", 30 * 1.33f, FontStyle.Bold, GraphicsUnit.Pixel);
                        g.DrawString("游戏暂停", font, Brushes.OrangeRed, 370, 170);
                        font.Dispose();
                    }
#endif
                }
            }
            catch (Exception err)
            {
                NarlonLib.Log.NLog.Error("panelBattle_Paint" + err);
            }

            e.Graphics.DrawImageUnscaled(bmp, 0, 0);
            g.Dispose();
            bmp.Dispose();

            if (fpsList.Count >= 10)//fps显示
            {
                int  fps     = (int)Math.Round((fpsList.Count - 1) * 1000 / fpsList[fpsList.Count - 1].Subtract(fpsList[0]).TotalMilliseconds);
                Font fontFps = new Font("黑体", 9 * 1.33f, FontStyle.Regular, GraphicsUnit.Pixel);
                e.Graphics.DrawString(string.Format("fps {0}", fps), fontFps, Brushes.White, 3, 3);
                fontFps.Dispose();
            }
        }
Ejemplo n.º 6
0
        public void SetRowUnitPosition(int y, bool isLeft, string type)
        {
            for (int i = 1; i < ColumnCount - 1; i++)
            {
                LiveMonster lm = BattleLocationManager.GetPlaceMonster(i * CardSize, y);
                if (lm == null)
                {
                    continue;
                }

                if (lm.IsGhost || isLeft && lm.IsLeft)
                {
                    continue;
                }

                if (lm.IsHero)
                {
                    continue;
                }

                lm.SetToPosition(type, 1);
            }
        }