Пример #1
0
        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);
                        }
                    }
                }
            }
        }
Пример #2
0
 public PlanetRegion(Planet p)
 {
     planet     = p;
     RegionSize = Random.Range(2, 11);
     RegionType = (RegionTypes)Random.Range(0, 6);
     RegionName = "<Unexplored " + RegionType.ToString();
 }
Пример #3
0
        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 static async Task WaitForSelectRegion(RegionTypes regionTypes, Territory territory)
        {
            AgainstInfo.IsWaitForSelectRegion = true;
            AgainstInfo.SelectRegion          = null;
            RowCommand.SetRegionSelectable(regionTypes, territory);
            await Task.Run(async() =>
            {
                while (Info.AgainstInfo.SelectRegion == null)
                {
                    StateInfo.TaskManager.Token.ThrowIfCancellationRequested();
                    if (AgainstInfo.isAIControl)
                    {
                        await Task.Delay(1000);
                        List <SingleRowInfo> rows = AgainstInfo.cardSet.singleRowInfos.Where(row => row.CanBeSelected).ToList();
                        int rowRank = AiCommand.GetRandom(0, rows.Count());
                        AgainstInfo.SelectRegion = rows[rowRank];//设置部署区域
                    }
                    await Task.Delay(1000);
                }
            });

            Network.NetCommand.AsyncInfo(NetAcyncType.SelectRegion);
            RowCommand.SetRegionSelectable(RegionTypes.None);
            AgainstInfo.IsWaitForSelectRegion = false;
        }
Пример #5
0
        public void Add(RegionTypes type, int range, Color color)
        {
            var data = new RegionData();

            data.Type  = type;
            data.Range = range;
            data.Color = color;
            dataList.Add(data);
        }
        /// <summary>
        /// Get region types for specified locale.
        /// </summary>
        /// <param name="locale">Locale.</param>
        /// <returns>Region types for specified locale.</returns>
        protected virtual RegionTypeList GetRegionTypes(ILocale locale)
        {
            RegionTypeList regionTypes = null;

            if (RegionTypes.ContainsKey(locale))
            {
                regionTypes = (RegionTypeList)(RegionTypes[locale]);
            }
            return(regionTypes);
        }
 public static void SetRegionSelectable(RegionTypes region, Territory territory = Territory.All)
 {
     if (region == RegionTypes.None)
     {
         AgainstInfo.cardSet[RegionTypes.Battle].singleRowInfos.ForEach(row => row.SetRegionSelectable(false));
     }
     else
     {
         AgainstInfo.cardSet[region][(Orientation)territory].singleRowInfos.ForEach(row => row.SetRegionSelectable(true));
     }
 }
Пример #8
0
 public static List <Card> GetOpCardList(RegionTypes type)
 {
     if (GlobalBattleInfo.IsMyTurn)
     {
         return(GetUpCardList(type));
     }
     else
     {
         return(GetDownCardList(type));
     }
 }
 /// <summary>
 /// Refresh cached data.
 /// </summary>
 /// <param name="userContext">User context.</param>
 protected override void RefreshCache(IUserContext userContext)
 {
     lock (RegionTypes)
     {
         RegionTypes.Clear();
     }
     lock (RegionCategories)
     {
         RegionCategories.Clear();
     }
 }
        /// <summary>
        /// Get region types for specified locale.
        /// </summary>
        /// <param name="locale">Locale.</param>
        /// <returns>Region types for specified locale.</returns>
        protected override RegionTypeList GetRegionTypes(ILocale locale)
        {
            RegionTypeList regionTypes = null;

            lock (RegionTypes)
            {
                if (RegionTypes.ContainsKey(locale))
                {
                    regionTypes = (RegionTypeList)(RegionTypes[locale]);
                }
            }
            return(regionTypes);
        }
Пример #11
0
        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 static async Task SelectRegion(RegionTypes regionType = RegionTypes.Battle, Territory territory = Territory.All) => await Command.StateCommand.WaitForSelectRegion(regionType, territory);
Пример #13
0
        public static bool IsPointInRegionType(RegionTypes type, int mouseX, int mouseY, Point pos, int range, bool forleft)
        {
            if (type == RegionTypes.None)
                return false;

            int size = BattleManager.Instance.MemMap.CardSize;
            int targetX = pos.X + size / 2;
            int targetY = pos.Y + size / 2;
            MemMapPoint mousePoint = BattleManager.Instance.MemMap.GetMouseCell(mouseX, mouseY);
            if (type == RegionTypes.Circle)
            {
                if (MathTool.GetDistance(mousePoint.X + size / 2, mousePoint.Y + size / 2, targetX, targetY) > range * size / 10)
                    return false;
            }
            else if (type == RegionTypes.Cross)
            {
                if (!((mousePoint.X == pos.X && Math.Abs(mousePoint.Y - pos.Y) <= range * size / 10) || (mousePoint.Y == pos.Y && Math.Abs(mousePoint.X - pos.X) <= range * size / 10)))
                    return false;
            }
            else if (type == RegionTypes.Grid)
            {
                if (mousePoint.Y != pos.Y || mousePoint.X != pos.X)
                    return false;
            }
            else if (type == RegionTypes.Row)
            {
                if (mousePoint.Y != pos.Y || Math.Abs(mousePoint.X - pos.X) > range * size / 10)
                    return false;
            }
            else if (type == RegionTypes.RowForward)
            {
                if (mousePoint.Y != pos.Y )
                    return false;
                if (forleft)
                {
                    if (pos.X - mousePoint.X > range * size / 10 || pos.X <= mousePoint.X)
                        return false;
                }
                else
                {
                    if (mousePoint.X  - pos.X > range * size / 10 || pos.X >= mousePoint.X)
                        return false;
                }
            }
            else if (type == RegionTypes.Column)
            {
                if (mousePoint.X != pos.X || Math.Abs(mousePoint.Y - pos.Y) > range * size / 10)
                    return false;
            }
            return true;
        }
Пример #14
0
        public static bool IsPointInRegionType(RegionTypes type, int mouseX, int mouseY, Point pos, int range, bool forleft)
        {
            if (type == RegionTypes.None)
            {
                return(false);
            }

            int         size       = BattleManager.Instance.MemMap.CardSize;
            int         targetX    = pos.X + size / 2;
            int         targetY    = pos.Y + size / 2;
            MemMapPoint mousePoint = BattleManager.Instance.MemMap.GetMouseCell(mouseX, mouseY);

            if (type == RegionTypes.Circle)
            {
                if (MathTool.GetDistance(mousePoint.X + size / 2, mousePoint.Y + size / 2, targetX, targetY) > range * size / 10)
                {
                    return(false);
                }
            }
            else if (type == RegionTypes.Cross)
            {
                if (!((mousePoint.X == pos.X && Math.Abs(mousePoint.Y - pos.Y) <= range * size / 10) || (mousePoint.Y == pos.Y && Math.Abs(mousePoint.X - pos.X) <= range * size / 10)))
                {
                    return(false);
                }
            }
            else if (type == RegionTypes.Grid)
            {
                if (mousePoint.Y != pos.Y || mousePoint.X != pos.X)
                {
                    return(false);
                }
            }
            else if (type == RegionTypes.Row)
            {
                if (mousePoint.Y != pos.Y || Math.Abs(mousePoint.X - pos.X) > range * size / 10)
                {
                    return(false);
                }
            }
            else if (type == RegionTypes.RowForward)
            {
                if (mousePoint.Y != pos.Y)
                {
                    return(false);
                }
                if (forleft)
                {
                    if (pos.X - mousePoint.X > range * size / 10 || pos.X <= mousePoint.X)
                    {
                        return(false);
                    }
                }
                else
                {
                    if (mousePoint.X - pos.X > range * size / 10 || pos.X >= mousePoint.X)
                    {
                        return(false);
                    }
                }
            }
            else if (type == RegionTypes.Column)
            {
                if (mousePoint.X != pos.X || Math.Abs(mousePoint.Y - pos.Y) > range * size / 10)
                {
                    return(false);
                }
            }
            else if (type == RegionTypes.MultiColumn)
            {
                if (Math.Abs(mousePoint.X - pos.X) > range * size / 10)
                {
                    return(false);
                }
            }
            return(true);
        }
Пример #15
0
 internal void Update(SpellConfig spellConfig)
 {
     Type = BattleTargetManager.GetRegionType(spellConfig.Target[2]);
     range = spellConfig.Range;
     CheckColor(spellConfig.Target[1]);
 }
Пример #16
0
 public static List <Card> GetDownCardList(RegionTypes type)
 {
     return(GlobalCardList[(int)type + (GlobalBattleInfo.IsPlayer1 ? 0 : 9)]);
 }