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; //Запускаем по игроку шарик ISpell arrow = CurrentUnit.Spells.FirstOrDefault(p => p.GetType() == typeof(SP_EasyMobArrow)) as SP_EasyMobArrow; if (arrow == null) { arrow = CurrentUnit.Spells.FirstOrDefault(p => p.GetType() == typeof(SP_EasyMobArrowFifeBall)) as SP_EasyMobArrowFifeBall; } if (arrow == null) { arrow = CurrentUnit.Spells.FirstOrDefault(p => p.GetType() == typeof(SP_EasyMobArrowStun)) as SP_EasyMobArrowStun; } if (arrow == null) { arrow = CurrentUnit.Spells.FirstOrDefault(p => p.GetType() == typeof(SP_HunterBoss)) as SP_HunterBoss; } arrow.UseSpall(CurrentMap, null, CurrentUnit, CurrentUnit.Angel); muveSpell.UseSpall(CurrentMap, null, CurrentUnit, _call.Angel); } else { StopAI(); } } } else { ///Нету куда ходить ///Подождем может освободится место _firstTimer = new DispatcherTimer() { Interval = TimeSpan.FromSeconds(1) }; _firstTimer.Tick += _firstTimer_Tick; _firstTimer.Start(); } } } }
private void Gamepad() { if (_inputType == EInput.Joist1) { _gamepadeState = GamePad.GetState(Microsoft.Xna.Framework.PlayerIndex.One); } else if (_inputType == EInput.Joist2) { _gamepadeState = GamePad.GetState(Microsoft.Xna.Framework.PlayerIndex.Two); } else if (_inputType == EInput.Joist3) { _gamepadeState = GamePad.GetState(Microsoft.Xna.Framework.PlayerIndex.Three); } else if (_inputType == EInput.Joist4) { _gamepadeState = GamePad.GetState(Microsoft.Xna.Framework.PlayerIndex.Four); } if (_gamepadeState.IsConnected) { if (Player != null) { if (Bay.Visibility == Visibility.Collapsed) { if (_gamepadeState.ThumbSticks.Left.X > 0.5) { ///Right _player.UseSpall(0, EAngel.Right); } else if (_gamepadeState.ThumbSticks.Left.Y > 0.5) { ///Top _player.UseSpall(0, EAngel.Top); } else if (_gamepadeState.ThumbSticks.Left.X < -0.5) { ///Left _player.UseSpall(0, EAngel.Left); } else if (_gamepadeState.ThumbSticks.Left.Y < -0.5) { ///Bottom _player.UseSpall(0, EAngel.Bottom); } if (_gamepadeState.IsButtonDown(Buttons.A)) { _player.UseSpall(2, 1); } if (_gamepadeState.IsButtonDown(Buttons.X)) { _player.UseSpall(1, 1); } if (_gamepadeState.IsButtonDown(Buttons.B)) { _player.UseSpall(3, 1); } if (_gamepadeState.IsButtonDown(Buttons.Y)) { _player.UseSpall(4, 1); } if (_gamepadeState.IsButtonDown(Buttons.RightShoulder)) { ///Юзаем ап спела UpSpell(); } if (_gamepadeState.IsButtonDown(Buttons.LeftShoulder)) { ///Юзаем смену мест предметам ItemChengPosition(); } if (_gamepadeState.DPad.Left == ButtonState.Pressed) { _player.UseItemSpall(0, null); } if (_gamepadeState.DPad.Up == ButtonState.Pressed) { _player.UseItemSpall(1, null); } if (_gamepadeState.DPad.Right == ButtonState.Pressed) { _player.UseItemSpall(2, null); } if (_gamepadeState.DPad.Down == ButtonState.Pressed) { _player.UseItemSpall(3, null); } if (_gamepadeState.Triggers.Right > 0.5) { ///Юзаем спел с самым маленьким кулдауном if (_player.Spells.Count > 0 && !_player.Dead) { ISpell minCdSpell = _player.Spells.FirstOrDefault(p => p.SpellDescriptionInfo.MinCd); if (minCdSpell != null) { minCdSpell.UseSpall(_player.CurrentMap, null, _player, null); } } } if (_gamepadeState.Triggers.Left > 0.5) { _player.UseItemSpall(0, null); } // if (_gamepadeState.IsButtonDown(Buttons.Start)) // StaticVaribl.MainPage.Start2PlayrGame(null, null); if (_gamepadeState.IsButtonDown(Buttons.Back)) { Bay.Show(_player); } if (_player.AllowUpSpell && _player.UpPoint > 0) { if (_gamepadeState.ThumbSticks.Right.X > 0.5) { ///Left _player.UseSpall(3, 1); } else if (_gamepadeState.ThumbSticks.Right.Y > 0.5) { ///Top _player.UseSpall(4, 1); } else if (_gamepadeState.ThumbSticks.Right.X < -0.5) { ///Right _player.UseSpall(1, 1); } else if (_gamepadeState.ThumbSticks.Right.Y < -0.5) { ///Bottom _player.UseSpall(2, 1); } } } else if (Bay.CurrentPlayer == _player) { if (_gamepadeState.IsButtonDown(Buttons.A)) { Bay.BuyItem(); } if (_gamepadeState.ThumbSticks.Left.Y > 0.5) { Bay.IndexLeft(); } if (_gamepadeState.ThumbSticks.Left.Y < -0.5) { Bay.IndexRight(); } if (_gamepadeState.IsButtonDown(Buttons.Back)) { Bay.Close(); } } } } }