public void CheckSpellEffect(bool isLeft, LiveMonster target, Point mouse) { if (spellInfo.SpellConfig.Effect != null) { Player p1 = isLeft ? BattleManager.Instance.PlayerManager.LeftPlayer : BattleManager.Instance.PlayerManager.RightPlayer; Player p2 = !isLeft ? BattleManager.Instance.PlayerManager.LeftPlayer : BattleManager.Instance.PlayerManager.RightPlayer; spellInfo.SpellConfig.Effect(spellInfo, BattleManager.Instance.MemMap, p1, p2, target, mouse, Level); if (!string.IsNullOrEmpty(spellInfo.SpellConfig.AreaEffect)) { //播放特效 RegionTypes rt = BattleTargetManager.GetRegionType(spellInfo.SpellConfig.Target[2]); var cardSize = BattleManager.Instance.MemMap.CardSize; foreach (var memMapPoint in BattleManager.Instance.MemMap.Cells) { var pointData = memMapPoint.ToPoint(); if (BattleLocationManager.IsPointInRegionType(rt, mouse.X, mouse.Y, pointData, spellInfo.SpellConfig.Range, isLeft)) { var effectData = new ActiveEffect(EffectBook.GetEffect(spellInfo.SpellConfig.AreaEffect), pointData + new Size(cardSize / 2, cardSize / 2), false); BattleManager.Instance.EffectQueue.Add(effectData); } } } } }
public MonsterCollection GetRangeMonsterGhost(bool isLeft, string target, string shape, int range, Point mouse) { List <IMonster> monsters = new List <IMonster>(); RegionTypes rt = BattleTargetManager.GetRegionType(shape[0]); foreach (var mon in BattleManager.Instance.MonsterQueue.Enumerator) { if (!mon.IsGhost) { continue; } if ((BattleTargetManager.IsSpellEnemyMonster(target[0]) && isLeft != mon.Owner.IsLeft) || (BattleTargetManager.IsSpellFriendMonster(target[0]) && isLeft == mon.Owner.IsLeft)) { if (!BattleLocationManager.IsPointInRegionType(rt, mouse.X, mouse.Y, mon.Position, range, isLeft)) { continue; } monsters.Add(mon); } } return(new MonsterCollection(monsters, mouse)); }
public Color GetMonsterColor(LiveMonster lm, int mouseX, int mouseY) { if (!Active) { return(Color.White); } foreach (var regionData in dataList) { if (regionData.Color == Color.Red && lm.IsLeft) { continue; } if (regionData.Color == Color.Green && !lm.IsLeft) { continue; } if (!BattleLocationManager.IsPointInRegionType(regionData.Type, mouseX, mouseY, lm.Position, regionData.Range, true)) { //magicregion永远为leftplayer服务 continue; } return(regionData.Color); } return(Color.White); }
private void Remove(LiveMonster mon) { mon.OwnerPlayer.State.CheckMonsterEvent(false, mon); if (BattleManager.Instance.MemMap.GetMouseCell(mon.Position.X, mon.Position.Y).Owner == -mon.Id) { BattleLocationManager.ClearCellOwner(mon.Position.X, mon.Position.Y); } monsters.Remove(mon); }
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(); } }
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); }
public void UpdateCellOwner(Point mouse, int ownerId) { if (ownerId == 0) { BattleLocationManager.ClearCellOwner(mouse.X, mouse.Y); } else { BattleLocationManager.UpdateCellOwner(mouse.X, mouse.Y, ownerId); } }
public void SetToPosition(string type, int step) { if (Avatar.MonsterConfig.IsBuilding) { BattleManager.Instance.FlowWordQueue.Add(new FlowWord("抵抗", Position, 0, "Gold", 26, 0, 0, 1, 15), false); return; } Point dest = MonsterPositionHelper.GetAvailPoint(Position, type, IsLeft, step); if (dest.X != Position.X || dest.Y != Position.Y) { BattleLocationManager.SetToPosition(this, dest); } }
public void Add(LiveMonster mon) { mon.OwnerPlayer.State.CheckMonsterEvent(true, mon); monsters.Add(mon); BattleLocationManager.UpdateCellOwner(mon.Position.X, mon.Position.Y, mon.Id); mon.OnInit(); if (mon.IsLeft) { LeftCount++; } else { RightCount++; } }
private void SendAreaEffect(Point pos) { //播放特效 RegionTypes rt = BattleTargetManager.GetRegionType(SkillInfo.SkillConfig.Target[2]); var cardSize = BattleManager.Instance.MemMap.CardSize; foreach (var memMapPoint in BattleManager.Instance.MemMap.Cells) { var pointData = memMapPoint.ToPoint(); if (BattleLocationManager.IsPointInRegionType(rt, pos.X, pos.Y, pointData, SkillInfo.SkillConfig.Range, Self.IsLeft)) { var effectData = new ActiveEffect(EffectBook.GetEffect(SkillInfo.SkillConfig.EffectArea), pointData + new Size(cardSize / 2, cardSize / 2), false); BattleManager.Instance.EffectQueue.Add(effectData); } } }
public void SetTile(Point point, int dis, int tile) { foreach (var memMapPoint in Cells) { if (BattleLocationManager.IsPointInRegionType(RegionTypes.Circle, point.X, point.Y, memMapPoint.ToPoint(), dis, true))//地形和方向无关,随便填一个 { memMapPoint.Tile = tile; } } tiles.Clear(); foreach (var memMapPoint in Cells) { tiles[memMapPoint.Tile == 9 ? 0 : memMapPoint.Tile]++; } isDirty = true; }
private static Point GetMonsterPoint(int mid, bool isLeft) { int size = BattleManager.Instance.MemMap.CardSize; var sideCell = BattleManager.Instance.MemMap.ColumnCount / 2; while (true) { int x = isLeft ? MathTool.GetRandom(0, sideCell) : MathTool.GetRandom(sideCell + 1, BattleManager.Instance.MemMap.ColumnCount - 1); int y = MathTool.GetRandom(0, BattleManager.Instance.MemMap.RowCount); x *= size; y *= size; if (BattleLocationManager.IsPlaceCanSummon(mid, x, y, false)) { return(new Point(x, y)); } } }
private static List <Point> GetPointInner(Point pos, string type, bool isLeft) { List <Point> posLis = new List <Point>(); int size = BattleManager.Instance.MemMap.CardSize; if (type == "side") { posLis.Add(new Point(pos.X, pos.Y - size)); posLis.Add(new Point(pos.X, pos.Y + size)); } if (type == "back") //击退 { if (!isLeft) { posLis.Add(new Point(pos.X + size, pos.Y)); } else { posLis.Add(new Point(pos.X - size, pos.Y)); } } if (type == "come") //拉过来 { if (!isLeft) { posLis.Add(new Point(pos.X - size, pos.Y)); } else { posLis.Add(new Point(pos.X + size, pos.Y)); } } if (type == "around") //随机 { posLis.Add(new Point(pos.X, pos.Y - size)); posLis.Add(new Point(pos.X, pos.Y + size)); posLis.Add(new Point(pos.X - size, pos.Y)); posLis.Add(new Point(pos.X + size, pos.Y)); } if (type == "rand") //随机 { posLis.Add(BattleLocationManager.GetRandomPoint()); } return(posLis); }
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(); } }
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); }
private static Point GetAvailPoint(Point pos, string type, bool isLeft) { List <Point> posList = GetPointInner(pos, type, isLeft); List <Point> availPoints = new List <Point>(); foreach (var point in posList) { if (BattleLocationManager.IsPlaceCanMove(point.X, point.Y)) { availPoints.Add(point); } } if (availPoints.Count > 0) { return(availPoints[MathTool.GetRandom(availPoints.Count)]); } return(new Point(-1)); }
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); }
internal void Draw(Graphics g) { if (cardId == 0) { return; } int size = BattleManager.Instance.MemMap.CardSize; SolidBrush fillBrush = new SolidBrush(Color.FromArgb(60, Color.Red)); foreach (MemMapPoint memMapPoint in BattleManager.Instance.MemMap.Cells) { if (!BattleLocationManager.IsPlaceCanSummon(cardId, memMapPoint.X, memMapPoint.Y, true)) { g.FillRectangle(fillBrush, memMapPoint.X, memMapPoint.Y, size, size); } } fillBrush.Dispose(); }
private void CheckMove(LiveMonster nearestEnemy) { var moveDis = BattleManager.Instance.MemMap.CardSize; Point aimPos; //决定想去的目标点 bool goX; if (nearestEnemy.Position.X != monster.Position.X) { var x = monster.Position.X + (nearestEnemy.Position.X > monster.Position.X ? moveDis : -moveDis); aimPos = new Point(x, monster.Position.Y); goX = true; } else { var y = monster.Position.Y + (nearestEnemy.Position.Y > monster.Position.Y ? moveDis : -moveDis); aimPos = new Point(monster.Position.X, y); goX = false; } if (!BattleLocationManager.IsPlaceCanMove(aimPos.X, aimPos.Y)) { if (goX)//绕过不可行走区域 { aimPos = MonsterPositionHelper.GetAvailPoint(monster.Position, "side", monster.IsLeft, 1); } else//往前走 { aimPos = MonsterPositionHelper.GetAvailPoint(monster.Position, "come", monster.IsLeft, 1); } } if (aimPos.X != monster.Position.X || aimPos.Y != monster.Position.Y) { BattleLocationManager.SetToPosition(monster, aimPos); } if (monster.ReadMov > 10) //会返回一些ats { monster.AddActionRate((float)(monster.ReadMov - 10) / monster.ReadMov); } monster.MovRound++; }
public void Draw(Graphics g, int round, int mouseX, int mouseY) { if (!Active) { return; } int size = BattleManager.Instance.MemMap.CardSize; int roundoff = ((round / 12) % 2) * 1 + 2; foreach (var memMapPoint in BattleManager.Instance.MemMap.Cells) { Color c = Color.Black; foreach (var regionData in dataList) { if (BattleLocationManager.IsPointInRegionType(regionData.Type, mouseX, mouseY, memMapPoint.ToPoint(), regionData.Range, true)) //magicregion永远为leftplayer服务 { if (c == Color.Black) { c = regionData.Color; } else { c = Color.FromArgb(c.R / 2 + regionData.Color.R / 2, c.G / 2 + regionData.Color.G / 2, c.B / 2 + regionData.Color.B / 2); } } if (c != Color.Black) { SolidBrush fillBrush = new SolidBrush(Color.FromArgb(50, c)); Pen borderPen = new Pen(c, 2); g.FillRectangle(fillBrush, memMapPoint.X + roundoff, memMapPoint.Y + roundoff, size - roundoff * 2, size - roundoff * 2); g.DrawRectangle(borderPen, memMapPoint.X + roundoff, memMapPoint.Y + roundoff, size - roundoff * 2, size - roundoff * 2); borderPen.Dispose(); fillBrush.Dispose(); } } } }
public static List <Point> GetAvailPointList(Point pos, string type, bool isLeft, int count) { List <Point> posList = GetPointInner(pos, type, isLeft); List <Point> availPoints = new List <Point>(); foreach (var point in posList) { if (BattleLocationManager.IsPlaceCanMove(point.X, point.Y)) { availPoints.Add(point); } } while (availPoints.Count > count) { availPoints.RemoveAt(MathTool.GetRandom(availPoints.Count)); } return(availPoints); }
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); } }
public Point GetRandomPoint() { return(BattleLocationManager.GetRandomPoint()); }