예제 #1
0
        private void StartMuve()
        {
            if (CurrentUnit != null)
            {
                if (CurrentUnit.Dead)
                {
                    StopAI();
                }

                if (!Stoped)
                {
                    if (!Rotation)
                    {
                        ///Выбираем рандомный угол, проверяем или он пустой и перемещпемся туда
                        _call = UnitGenerator.RandonCell(CurrentUnit,
                                                         CurrentMap, false, false, Hunt);
                    }
                    else
                    {
                        Rotation = false;
                    }

                    if (_call != null && !_call.Using && !CurrentUnit.UnitFrozen)
                    {
                        if (_call.Used && _call.IUnits.Any(p =>
                                                           p.GroupType != CurrentUnit.GroupType))
                        {///Колонка занята врагом нужно атаковать его
                            SP_AttackEasyMob attackEasyMob = CurrentUnit.Spells.FirstOrDefault(p => p.GetType() == typeof(SP_AttackEasyMob)) as SP_AttackEasyMob;
                            if (attackEasyMob != null)
                            {
                                attackEasyMob.CompletedUseSpell += _attackEasyMob_CompletedUseSpell;
                                attackEasyMob.UseSpall(CurrentMap, null, CurrentUnit, _call);
                            }
                            else
                            {
                                StopAI();
                            }
                        }
                        else
                        {
                            ///Если колонка не занята перейти туда
                            SP_Move muveSpell = CurrentUnit.Spells.FirstOrDefault(p => p.GetType() == typeof(SP_Move)) as SP_Move;
                            if (muveSpell != null)
                            {
                                muveSpell.CompletedUseSpell += _muveSpell_CompletedUseSpell;

                                //Запускаем по игроку шарик
                                SP_EasyMobArrowFifeBall arrow = CurrentUnit.Spells.FirstOrDefault(p => p.GetType() == typeof(SP_EasyMobArrowFifeBall)) as SP_EasyMobArrowFifeBall;
                                arrow.UseSpall(CurrentMap, null, CurrentUnit, null);

                                muveSpell.UseSpall(CurrentMap, null, CurrentUnit, _call.Angel);
                            }
                            else
                            {
                                StopAI();
                            }
                        }
                    }
                    else
                    {   ///Нету куда ходить
                        ///Подождем может освободится место
                        _firstTimer = new DispatcherTimer()
                        {
                            Interval = TimeSpan.FromSeconds(1)
                        };
                        _firstTimer.Tick += _firstTimer_Tick;
                        _firstTimer.Start();
                    }
                }
            }
        }
예제 #2
0
        private void StartMuve()
        {
            if (CurrentUnit != null)
            {
                if (CurrentUnit.Dead)
                {
                    StopAI();
                }

                if (!Stoped)
                {
                    if (!Rotation)
                    {
                        ///Выбираем рандомный угол, проверяем или он пустой и перемещпемся туда
                        _call = UnitGenerator.RandonCell(CurrentUnit,
                                                         CurrentMap, true, false, Hunt);
                    }
                    else
                    {
                        Rotation = false;
                    }

                    if (_call != null && !_call.Using && !CurrentUnit.UnitFrozen)
                    {
                        if (_call.Used && _call.IUnits.Any(p =>
                                                           p.GroupType != CurrentUnit.GroupType))
                        {///Колонка занята врагом нужно атаковать его
                            SP_AttackEasyMob attackEasyMob = CurrentUnit.Spells.FirstOrDefault(p => p.GetType() == typeof(SP_AttackEasyMob)) as SP_AttackEasyMob;
                            if (attackEasyMob != null)
                            {
                                attackEasyMob.CompletedUseSpell += _attackEasyMob_CompletedUseSpell;
                                attackEasyMob.UseSpall(CurrentMap, null, CurrentUnit, _call);
                            }
                            else
                            {
                                StopAI();
                            }
                        }
                        else
                        {
                            ///Если колонка не занята перейти туда
                            SP_Move muveSpell = CurrentUnit.Spells.FirstOrDefault(p => p.GetType() == typeof(SP_Move)) as SP_Move;
                            if (muveSpell != null)
                            {
                                muveSpell.CompletedUseSpell += _muveSpell_CompletedUseSpell;

                                ///Проверим есть ли на горезонте игрок, чтобы на него напаcть
                                //if (UnitGenerator.CheckLine(CurrentUnit.PositionX, CurrentUnit.PositionY, CurrentUnit))
                                //{
                                //    Rotation = true;
                                //    _call.Angel = CurrentUnit.Angel;
                                //    (CurrentUnit.GameObject.View as IGameControl).ChengAngel(_call.Angel);
                                //}

                                muveSpell.UseSpall(CurrentMap, null, CurrentUnit, _call.Angel);
                            }
                            else
                            {
                                StopAI();
                            }
                        }
                    }
                    else
                    {   ///Нету куда ходить
                        ///Подождем может освободится место
                        _firstTimer = new DispatcherTimer()
                        {
                            Interval = TimeSpan.FromSeconds(1)
                        };
                        _firstTimer.Tick += _firstTimer_Tick;
                        _firstTimer.Start();
                    }
                }
            }
        }