private void StartStoryboard(IUnit unit, int xNew, int yNew) { string animationType = "(Canvas.Left)"; double mouvePos = 0; ///Новая позиция double newPos = 0; if (unit.Angel == EAngel.Left || unit.Angel == EAngel.Right) { animationType = "(Canvas.Left)"; mouvePos = Canvas.GetLeft(unit.GameObject.View); newPos = xNew; } else { animationType = "(Canvas.Top)"; mouvePos = Canvas.GetTop(unit.GameObject.View); newPos = yNew; } _storyboard = new Storyboard(); var animation = new DoubleAnimation { From = mouvePos, To = newPos * 50, Duration = TimeSpan.FromSeconds(1 * unit.Speed) }; _storyboard.Children.Add(animation); Storyboard.SetTargetProperty(animation, animationType); Storyboard.SetTarget(_storyboard, unit.GameObject.View); _storyboard.Completed += storyboard_Completed; _storyboard.Begin(); ///Спрайты движения IAnimationControl muveAnimation = _unit.GameObject.View as IAnimationControl; if (muveAnimation != null) { muveAnimation.StartMuveAnimation(unit.Speed); } ///Таймер половины перемещения юнита ///Необходим чтобы поставить новую ячейку useD _firstTimer = new Storyboard() { Duration = TimeSpan.FromSeconds((1 * unit.Speed) / 2) }; _firstTimer.Completed += _firstTimer_Completed; _firstTimer.Begin(); if (Paused) { Pause(); } }
public void UseSpall(Map map, Game_Object_In_Call obj, IUnit unit, object property) { bool upSpell = UnitGenerator.UpPlayerSpell(unit, this); _unit = unit; if (unit.UnitFrozen == false && !_culdaunBool && LevelCast != 0 && !upSpell && !unit.Silenced && !unit.Hexed && !Paused) { if (unit.Mana >= ManaCost) ///Проверка есть ли мана на каст { ///Флаг кулдауна _culdaunBool = true; ///Отнимаем нужное количество unit.Mana -= ManaCost; ///Тут кординаты ячеек в которых действует тучка List <Point> callsPoint = new List <Point>(); ///Получаем ячейки которые находятся перед героем int xNew = unit.PositionX; int yNew = unit.PositionY; if (unit.Angel == EAngel.Left) { xNew = xNew - 1; callsPoint.Add(new Point(xNew, yNew)); callsPoint.Add(new Point(xNew, yNew + 2)); callsPoint.Add(new Point(xNew, yNew - 2)); } else if (unit.Angel == EAngel.Right) { xNew = xNew + 1; callsPoint.Add(new Point(xNew, yNew)); callsPoint.Add(new Point(xNew, yNew + 2)); callsPoint.Add(new Point(xNew, yNew - 2)); } else if (unit.Angel == EAngel.Top) { yNew = yNew - 1; callsPoint.Add(new Point(xNew, yNew)); callsPoint.Add(new Point(xNew + 2, yNew)); callsPoint.Add(new Point(xNew - 2, yNew)); } else if (unit.Angel == EAngel.Bottom) { yNew = yNew + 1; callsPoint.Add(new Point(xNew, yNew)); callsPoint.Add(new Point(xNew + 2, yNew)); callsPoint.Add(new Point(xNew - 2, yNew)); } ///Кординаты ячеек есть ///теперь спауним тучку foreach (var item in callsPoint) { Map_Cell call = map.Calls.FirstOrDefault(p => p.IndexLeft == item.X && p.IndexTop == item.Y); if (call != null && !call.Block) { ///Создаем визуальный объект тучка UC_Jinx_Flame_Chompers acidSpray = new UC_Jinx_Flame_Chompers(); acidSpray.ChengAngel(unit.Angel); Bullet bullAcidSpray = new Bullet() { Name = "Jinx_Flame_Chompers" }; bullAcidSpray.GameObject = new Game_Object_In_Call() { EnumCallType = EnumCallType.Bullet, View = acidSpray }; bullAcidSpray.UnitUsed = unit; bullAcidSpray.PositionX = (int)item.X; bullAcidSpray.PositionY = (int)item.Y; bullAcidSpray.Speed = Speed; bullAcidSpray.IsRoket = true; ///Магический урон зависит от прокача стрел ///bullArrow.DemageMagic = 5 * (int)property; if (LevelCast == 1) { bullAcidSpray.DemageMagic = 15; bullAcidSpray.StunDuration = 2; } else if (LevelCast == 2) { bullAcidSpray.DemageMagic = 25; bullAcidSpray.StunDuration = 2; } else if (LevelCast == 3) { bullAcidSpray.DemageMagic = 35; bullAcidSpray.StunDuration = 3; } bullAcidSpray.CurrentMap = map; bullAcidSpray.Angel = unit.Angel; bullAcidSpray.Range = _unit.Range; bullAcidSpray.Duration = Duration; bullAcidSpray.Spells.Add(new SPB_Jinx_Flame_Chompers() { Name = "Jinx_Flame_Chompers" }); ///И его же добавим в масив всех объектов map.GameObjectInCall.Add(bullAcidSpray.GameObject); Canvas.SetLeft(bullAcidSpray.GameObject.View, bullAcidSpray.PositionX * 50); Canvas.SetTop(bullAcidSpray.GameObject.View, bullAcidSpray.PositionY * 50); ///Отображение map.MapCanvas.Children.Add(bullAcidSpray.GameObject.View); _animationControl = (bullAcidSpray.GameObject.View as IAnimationControl); _animationControl.StartMuveAnimation(0); bullAcidSpray.UseSpall("Jinx_Flame_Chompers"); } } if (StartUseSpell != null) { StartUseSpell(this, null); } ///Таймер кулдауна заклинания _firstTimer = new Storyboard() { Duration = TimeSpan.FromSeconds(Culdaun) }; _firstTimer.Completed += _firstTimer_Completed; _firstTimer.Begin(); if (Paused) { Pause(); } UnitGenerator.UpdatePlayerView(unit); } } if (unit.UnitFrozen == false && ///Проверка не в стане ли юнит !Paused) { Map_Cell unitCall = map.Calls.FirstOrDefault(p => p.IndexLeft == unit.PositionX && p.IndexTop == unit.PositionY); ///Может тучка была кинута, тогда можно атаковать if (unitCall.Bullet.Any(p => p.Name == "SP_Alchemist_AcidSpray" && p.UnitUsed == unit) && !CuldaunBoolAttack) { Point attackCallPoint = UnitGenerator.AngelCallPoint(unit.Angel, unit.PositionX, unit.PositionY); Map_Cell attackCallCall = map.Calls.FirstOrDefault(p => p.IndexLeft == attackCallPoint.X && p.IndexTop == attackCallPoint.Y); ///Если на против юнита есть ячейка куда атаковать if (attackCallCall != null && !attackCallCall.Block && attackCallCall.IUnits.Any()) { ///Флаг кулдауна CuldaunBoolAttack = true; Bullet bullet = new Bullet() { UnitUsed = unit, DemagePhys = unit.Demage }; UnitGenerator.MKB_Bush(bullet, unit); UnitGenerator.AddDamage(attackCallCall, bullet); (unit.GameObject.View as IGameControl).ShowAttack(unit.Angel, unit.AttackSpeed); _secondTimer = new Storyboard() { Duration = TimeSpan.FromSeconds(unit.AttackSpeed) }; _secondTimer.Completed += _secondTimer_Completed; _secondTimer.Begin(); if (Paused) { Pause(); } } } } }
private void AttackUnits(Map map, IUnit unit, bool attackCount) { ///Кординаты ячеек есть ///теперь спауним атаку foreach (var item in _callsPointl) { Map_Cell call = map.Calls.FirstOrDefault(p => p.IndexLeft == item.X && p.IndexTop == item.Y); if (call != null && !call.Block) { ///Создаем визуальный объект атака UC_Mirana_Starstorm dualBreath = new UC_Mirana_Starstorm(); dualBreath.ChengAngel(unit.Angel); _bullDualBreath = new Bullet() { Name = "SP_Mirana_Starstorm" }; _bullDualBreath.GameObject = new Game_Object_In_Call() { EnumCallType = EnumCallType.Bullet, View = dualBreath }; _bullDualBreath.UnitUsed = unit; _bullDualBreath.PositionX = (int)item.X; _bullDualBreath.PositionY = (int)item.Y; _bullDualBreath.Speed = Speed; ///Магический урон зависит от прокача стрел //bullArrow.DemageMagic = 5 * (int)property; if (LevelCast == 1) { _bullDualBreath.DemageMagic = 16; } else if (LevelCast == 2) { _bullDualBreath.DemageMagic = 26; } else if (LevelCast == 3) { _bullDualBreath.DemageMagic = 36; } if (!attackCount) { _bullDualBreath.DemageMagic = _bullDualBreath.DemageMagic / 2; } _bullDualBreath.CurrentMap = map; _bullDualBreath.Angel = unit.Angel; _bullDualBreath.Range = _unit.Range; _bullDualBreath.Duration = Duration; //_bullDualBreath.SpeedSlow = 0.5; ///И его же добавим в масив всех объектов //map.GameObjectInCall.Add(_bullDualBreath.GameObject); Canvas.SetLeft(_bullDualBreath.GameObject.View, _bullDualBreath.PositionX * 50); Canvas.SetTop(_bullDualBreath.GameObject.View, _bullDualBreath.PositionY * 50); ///Отображение map.MapCanvas.Children.Add(_bullDualBreath.GameObject.View); _attackView.Add(dualBreath); _animationControl = (_bullDualBreath.GameObject.View as IAnimationControl); _animationControl.StartMuveAnimation(0); UnitGenerator.AddDamage(call, _bullDualBreath); } } }
public void UseSpall(Map map, Game_Object_In_Call obj, IUnit unit, object property) { bool upSpell = UnitGenerator.UpPlayerSpell(unit, this); _unit = unit; if (unit.UnitFrozen == false && !_culdaunBool && LevelCast != 0 && !upSpell && !unit.Silenced && !unit.Hexed && !Paused) { if (unit.Mana >= ManaCost) ///Проверка есть ли мана на каст { ///Флаг кулдауна _culdaunBool = true; ///Отнимаем нужное количество unit.Mana -= ManaCost; _map = map; ///Тут кординаты ячеек в которых действует тучка _callsPointl = new List <Point>(); ///Получаем ячейки которые находятся перед героем ///использывавшим тучку ///Сначала добавляем ячеку с героем int xNew = unit.PositionX; int yNew = unit.PositionY; if (unit.Angel == EAngel.Left) { for (int i = 0; i <= _size; i++) { xNew = xNew - 1; Map_Cell call = map.Calls.FirstOrDefault(p => p.IndexLeft == xNew && p.IndexTop == yNew); if (call == null || call != null && call.Block) { break; } _callsPointl.Add(new Point(xNew, yNew)); if (_size == i) { _callsPointl.Add(new Point(xNew, yNew + 1)); _callsPointl.Add(new Point(xNew, yNew - 1)); } } } else if (unit.Angel == EAngel.Right) { for (int i = 0; i <= _size; i++) { xNew = xNew + 1; Map_Cell call = map.Calls.FirstOrDefault(p => p.IndexLeft == xNew && p.IndexTop == yNew); if (call == null || call != null && call.Block) { break; } _callsPointl.Add(new Point(xNew, yNew)); if (_size == i) { _callsPointl.Add(new Point(xNew, yNew + 1)); _callsPointl.Add(new Point(xNew, yNew - 1)); } } } else if (unit.Angel == EAngel.Top) { for (int i = 0; i <= _size; i++) { yNew = yNew - 1; Map_Cell call = map.Calls.FirstOrDefault(p => p.IndexLeft == xNew && p.IndexTop == yNew); if (call == null || call != null && call.Block) { break; } _callsPointl.Add(new Point(xNew, yNew)); if (_size == i) { _callsPointl.Add(new Point(xNew + 1, yNew)); _callsPointl.Add(new Point(xNew - 1, yNew)); } } } else if (unit.Angel == EAngel.Bottom) { for (int i = 0; i <= _size; i++) { yNew = yNew + 1; Map_Cell call = map.Calls.FirstOrDefault(p => p.IndexLeft == xNew && p.IndexTop == yNew); if (call == null || call != null && call.Block) { break; } _callsPointl.Add(new Point(xNew, yNew)); if (_size == i) { _callsPointl.Add(new Point(xNew + 1, yNew)); _callsPointl.Add(new Point(xNew - 1, yNew)); } } } if (!_callsPointl.Any()) { (unit.GameObject.View as IGameControl).GetDemage("Miss"); } _attackView = new List <UC_Jakiro_DualBreath>(); ///Кординаты ячеек есть ///теперь спауним атаку foreach (var item in _callsPointl) { Map_Cell call = map.Calls.FirstOrDefault(p => p.IndexLeft == item.X && p.IndexTop == item.Y); if (call != null && !call.Block) { ///Создаем визуальный объект атака UC_Jakiro_DualBreath dualBreath = new UC_Jakiro_DualBreath(); dualBreath.ChengAngel(unit.Angel); _bullDualBreath = new Bullet() { Name = "SP_Jakiro_DualBreath" }; _bullDualBreath.GameObject = new Game_Object_In_Call() { EnumCallType = EnumCallType.Bullet, View = dualBreath }; _bullDualBreath.UnitUsed = unit; _bullDualBreath.PositionX = (int)item.X; _bullDualBreath.PositionY = (int)item.Y; _bullDualBreath.Speed = Speed; ///Магический урон зависит от прокача стрел //bullArrow.DemageMagic = 5 * (int)property; if (LevelCast == 1) { _bullDualBreath.DemageMagic = 16; } else if (LevelCast == 2) { _bullDualBreath.DemageMagic = 26; } else if (LevelCast == 3) { _bullDualBreath.DemageMagic = 36; } // _bullDualBreath.DemageMagic += unit.Demage/2; _bullDualBreath.CurrentMap = map; _bullDualBreath.Angel = unit.Angel; _bullDualBreath.Range = _unit.Range; _bullDualBreath.Duration = Duration; _bullDualBreath.SpeedSlow = 0.5; ///И его же добавим в масив всех объектов //map.GameObjectInCall.Add(_bullDualBreath.GameObject); Canvas.SetLeft(_bullDualBreath.GameObject.View, _bullDualBreath.PositionX * 50); Canvas.SetTop(_bullDualBreath.GameObject.View, _bullDualBreath.PositionY * 50); ///Отображение map.MapCanvas.Children.Add(_bullDualBreath.GameObject.View); _attackView.Add(dualBreath); _animationControl = (_bullDualBreath.GameObject.View as IAnimationControl); _animationControl.StartMuveAnimation(0); UnitGenerator.AddDamage(call, _bullDualBreath); _removeFire = false; } } ///Таймер второго дыхания, замедляющего _secondTimer = new Storyboard() { Duration = TimeSpan.FromSeconds(0.4) }; _secondTimer.Completed += _secondTimer_Completed; _secondTimer.Begin(); if (StartUseSpell != null) { StartUseSpell(this, null); } ///Таймер кулдауна заклинания _firstTimer = new Storyboard() { Duration = TimeSpan.FromSeconds(Culdaun) }; _firstTimer.Completed += _firstTimer_Completed; _firstTimer.Begin(); if (Paused) { Pause(); } UnitGenerator.UpdatePlayerView(unit); } } }
public void UseSpall(Map map, Game_Object_In_Call obj, IUnit unit, object property) { bool upSpell = UnitGenerator.UpPlayerSpell(unit, this); _unit = unit; if (unit.UnitFrozen == false && !_culdaunBool && LevelCast != 0 && !upSpell && !unit.Silenced && !unit.Hexed && !Paused) { if (unit.Mana >= ManaCost) ///Проверка есть ли мана на каст { ///Флаг кулдауна _culdaunBool = true; ///Отнимаем нужное количество unit.Mana -= ManaCost; ///Тут кординаты ячеек в которых действует тучка List <Point> callsPoint = new List <Point>(); ///Получаем ячейки которые находятся перед героем ///использывавшим тучку int xNew = unit.PositionX; int yNew = unit.PositionY; if (unit.Angel == EAngel.Left) { // xNew = xNew - 1; for (int i = 0; i <= _size; i++) { xNew = xNew - 1; callsPoint.Add(new Point(xNew, yNew)); if (i == 0 || i == _size) { callsPoint.Add(new Point(xNew, yNew + 1)); callsPoint.Add(new Point(xNew, yNew - 1)); } else { callsPoint.Add(new Point(xNew, yNew + 1)); callsPoint.Add(new Point(xNew, yNew + 2)); callsPoint.Add(new Point(xNew, yNew - 1)); callsPoint.Add(new Point(xNew, yNew - 2)); } } } else if (unit.Angel == EAngel.Right) { // xNew = xNew + 1; for (int i = 0; i <= _size; i++) { xNew = xNew + 1; callsPoint.Add(new Point(xNew, yNew)); if (i == 0 || i == _size) { callsPoint.Add(new Point(xNew, yNew + 1)); callsPoint.Add(new Point(xNew, yNew - 1)); } else { callsPoint.Add(new Point(xNew, yNew)); callsPoint.Add(new Point(xNew, yNew + 1)); callsPoint.Add(new Point(xNew, yNew + 2)); callsPoint.Add(new Point(xNew, yNew - 1)); callsPoint.Add(new Point(xNew, yNew - 2)); } } } else if (unit.Angel == EAngel.Top) { // yNew = yNew - 1; for (int i = 0; i <= _size; i++) { yNew = yNew - 1; callsPoint.Add(new Point(xNew, yNew)); if (i == 0 || i == _size) { callsPoint.Add(new Point(xNew + 1, yNew)); callsPoint.Add(new Point(xNew - 1, yNew)); } else { callsPoint.Add(new Point(xNew + 1, yNew)); callsPoint.Add(new Point(xNew + 2, yNew)); callsPoint.Add(new Point(xNew - 1, yNew)); callsPoint.Add(new Point(xNew - 2, yNew)); } } } else if (unit.Angel == EAngel.Bottom) { // yNew = yNew + 1; for (int i = 0; i <= _size; i++) { yNew = yNew + 1; callsPoint.Add(new Point(xNew, yNew)); if (i == 0 || i == _size) { callsPoint.Add(new Point(xNew + 1, yNew)); callsPoint.Add(new Point(xNew - 1, yNew)); } else { callsPoint.Add(new Point(xNew + 1, yNew)); callsPoint.Add(new Point(xNew + 2, yNew)); callsPoint.Add(new Point(xNew - 1, yNew)); callsPoint.Add(new Point(xNew - 2, yNew)); } } } ///Кординаты ячеек есть ///теперь спауним шрапнель foreach (var item in callsPoint) { Map_Cell call = map.Calls.FirstOrDefault(p => p.IndexLeft == item.X && p.IndexTop == item.Y); if (call != null && !call.Block) { ///Создаем визуальный объект шрапнель UC_Sniper_Shrapnel acidSpray = new UC_Sniper_Shrapnel(); acidSpray.ChengAngel(unit.Angel); Bullet bullAcidSpray = new Bullet() { Name = "SP_Alchemist_AcidSpray" }; bullAcidSpray.GameObject = new Game_Object_In_Call() { EnumCallType = EnumCallType.Bullet, View = acidSpray }; bullAcidSpray.UnitUsed = unit; bullAcidSpray.PositionX = (int)item.X; bullAcidSpray.PositionY = (int)item.Y; bullAcidSpray.Speed = Speed; if (LevelCast == 1) { bullAcidSpray.SpeedSlow = 0.2; bullAcidSpray.DemageMagic = 6; } else if (LevelCast == 2) { bullAcidSpray.SpeedSlow = 0.3; bullAcidSpray.DemageMagic = 8; } else if (LevelCast == 3) { bullAcidSpray.SpeedSlow = 0.35; bullAcidSpray.DemageMagic = 10; } bullAcidSpray.CurrentMap = map; bullAcidSpray.Angel = unit.Angel; bullAcidSpray.Range = _unit.Range; bullAcidSpray.Duration = Duration; bullAcidSpray.Spells.Add(new SPB_Sniper_Shrapnel() { Name = "SniperShrapnel" }); ///И его же добавим в масив всех объектов map.GameObjectInCall.Add(bullAcidSpray.GameObject); Canvas.SetLeft(bullAcidSpray.GameObject.View, bullAcidSpray.PositionX * 50); Canvas.SetTop(bullAcidSpray.GameObject.View, bullAcidSpray.PositionY * 50); ///Отображение map.MapCanvas.Children.Add(bullAcidSpray.GameObject.View); _animationControl = (bullAcidSpray.GameObject.View as IAnimationControl); _animationControl.StartMuveAnimation(0); bullAcidSpray.UseSpall("SniperShrapnel"); } } if (StartUseSpell != null) { StartUseSpell(this, null); } ///Таймер кулдауна заклинания _firstTimer = new Storyboard() { Duration = TimeSpan.FromSeconds(Culdaun) }; _firstTimer.Completed += _firstTimer_Completed; _firstTimer.Begin(); if (Paused) { Pause(); } UnitGenerator.UpdatePlayerView(unit); } } }