Пример #1
0
        public void UseSpall(Map map, Game_Object_In_Call obj, IUnit unit, object property)
        {
            _bullet      = property as Bullet;
            _bullet.Name = "SPB_Jakiro_Ice_Path";

            _map     = map;
            _unit    = _bullet.UnitUsed;
            Duration = _bullet.Duration;
            ///Ячейка где действует тучка
            _oldCall = map.Calls.Single(p => p.IndexLeft == _bullet.PositionX &&
                                        p.IndexTop == _bullet.PositionY);
            _oldCall.Bullet.Add(_bullet);

            for (int i = 0; i < _oldCall.IUnits.Count; i++)
            {
                var item = _oldCall.IUnits[i];
                if (item != null && item.GroupType != _unit.GroupType)
                {
                    UnitGenerator.AddStuneTwo(_oldCall, _bullet, _bullet.StunDuration, 4);
                }
            }

            ///Таймер время жизни тучки
            _firstTimer = new Storyboard()
            {
                Duration = TimeSpan.FromSeconds(1)
            };
            _firstTimer.Completed += _firstTimer_Completed;
            _firstTimer.Begin();

            if (Paused)
            {
                Pause();
            }
        }
Пример #2
0
        public void UseSpall(Map map, Game_Object_In_Call obj, IUnit unit, object property)
        {
            _bullet            = property as Bullet;
            _bullet.BuffDemage = true;
            _map     = map;
            _unit    = _bullet.UnitUsed;
            Duration = _bullet.Duration;
            ///Ячейка где действует шрапнель
            _oldCall = map.Calls.Single(p => p.IndexLeft == _bullet.PositionX &&
                                        p.IndexTop == _bullet.PositionY);
            _oldCall.Bullet.Add(_bullet);

            ///Таймер время жизни шрапнели
            _firstTimer = new Storyboard()
            {
                Duration = TimeSpan.FromSeconds(1)
            };
            _firstTimer.Completed += _firstTimer_Completed;
            _firstTimer.Begin();

            if (Paused)
            {
                Pause();
            }
        }
Пример #3
0
    protected bool CheckCollision(Vector2Int m_pos)
    {
        Map  map = GlobalStorage.Instance.CurrentMap;
        bool map_out_of_bounds = !map.IsValidCoords(m_pos);

        if (map_out_of_bounds)
        {
            OnMapOutOfBounds.Invoke(this);
            return(false);
        }
        else
        {
            Map_Cell cell       = map.GetCell(m_pos);
            object   col_object = cell.Object;

            if (col_object != null)
            {
                if ((col_object is SnakeNode) &&
                    (col_object as SnakeNode).Owner == this &&
                    (M_HeadPosition != m_pos))
                {
                    OnCollideWithSelf.Invoke(this);
                    return(false);
                }
                else
                {
                    OnCollision.Invoke(this, col_object);
                }
            }
        }

        return(true);
    }
Пример #4
0
        void _secondTimer_Completed(object sender, object e)
        {
            if (!_removeFire)
            {
                _removeFire = true;
                foreach (var item in _attackView)
                {
                    item.ChengeFire();
                }

                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)
                    {
                        foreach (var item2 in call.IUnits)
                        {
                            if (item2 != _unit)
                            {
                                Buff buff = item2.Buffs.FirstOrDefault(p => p.Name == "Dual Breath");
                                if (buff != null)
                                {
                                    buff.Duration = 2;
                                }
                                else
                                {
                                    Buff alchBuff = new Buff()
                                    {
                                        SpeedSlow = _bullDualBreath.SpeedSlow,
                                        Duration  = 2,
                                        Name      = "Dual Breath"
                                    };
                                    item2.Buffs.Add(alchBuff);
                                }
                            }
                        }
                    }
                }
                _secondTimer.Begin();
            }
            else
            {
                if (_secondTimer != null)
                {
                    _secondTimer.Completed -= _secondTimer_Completed;
                    _secondTimer            = null;
                }

                foreach (var item in _attackView)
                {
                    _map.MapCanvas.Children.Remove(item);
                }
            }
        }
Пример #5
0
 public void assignJob(Map_Cell cell, string job, int cellNumber)
 {
     jobTarget        = cell;
     State            = job;
     astardestination = jobTarget.assignPosition(gameObject);
     destinationPoint = getClosetPoint(astardestination);
     if (job.Equals("ClaimGround"))
     {
         jobTarget.Claimer = true;
     }
 }
Пример #6
0
 void MineCell(Map_Cell cell)
 {
     if (attackCount >= attackLimit)
     {
         cell.Attack(mineSpeed);
         attackCount = 0;
     }
     else
     {
         attackCount++;
     }
 }
Пример #7
0
 void ClaimCell(Map_Cell cell)
 {
     if (claimCount >= claimLimit)
     {
         cell.ChangeCell(2);
         claimCount = 0;
     }
     else
     {
         claimCount++;
     }
 }
Пример #8
0
 public void StopAI()
 {
     Stoped      = true;
     _call       = null;
     CurrentUnit = null;
     CurrentMap  = null;
     if (_firstTimer != null)
     {
         _firstTimer.Stop();
         _firstTimer = null;
     }
 }
Пример #9
0
        void _firstTimer_Completed(object sender, object e)
        {
            _firstTimer.Completed -= _firstTimer_Completed;
            _firstTimer            = null;

            Map_Cell oldCall = _map.Calls.Single(p => p.IndexLeft == _bullet.PositionX &&
                                                 p.IndexTop == _bullet.PositionY);

            oldCall.Bullet.Remove(_bullet);
            /////Сначала проверяем старую ячейку на попадение
            //Exept();
            _bullet.PositionX = _xNew;
            _bullet.PositionY = _yNew;
            Exept();



            ///Проверяем или молния попала
            if (_bullet.Exept == true)
            {
                _hitCount--;
            }

            Map_Cell newCall = _map.Calls.FirstOrDefault(p => p.IndexLeft == _bullet.PositionX &&
                                                         p.IndexTop == _bullet.PositionY);

            /// Если есть аганим
            if (Name == "SP_Nature_Wrath" && UnitGenerator.HasAghanim(_unit) &&
                _bullet.RemoveUnit != null)
            {
                CreateTrent(newCall, _bullet.RemoveUnit);
            }

            if (_hitCount == 0 || newCall == null ||
                ///Или новая ячейка блок
                newCall != null && newCall.Block)
            {
                (_bullet.GameObject.View as IGameControl).Remove(_map.MapCanvas);
                ///Было попадение, анимация исчезновения стрелы
                //_bullet.GameObject.View.Visibility = Visibility.Collapsed;
                ///Было попадение стрела исчезает
                ///Удаляем из масива всех объектов
                _map.GameObjectInCall.Remove(_bullet.GameObject);
                _exept = true;

                //_map.MapCanvas.Children.Remove(_bullet.GameObject.View);
            }
            else
            {
                newCall.Bullet.Add(_bullet);
            }
        }
Пример #10
0
        public void UseSpall(Map map, Game_Object_In_Call obj, IUnit unit, object property)
        {
            _bullet = property as Bullet;
            _map    = map;
            _unit   = unit;

            Map_Cell oldCall = map.Calls.Single(p => p.IndexLeft == _bullet.PositionX &&
                                                p.IndexTop == _bullet.PositionY);

            oldCall.Bullet.Add(_bullet);

            BulletMuve(_bullet);
        }
Пример #11
0
        void _firstTimer_Completed(object sender, object e)
        {
            _power++;
            _firstTimer.Completed -= _firstTimer_Completed;
            _firstTimer            = null;

            if (_power == 2 ||
                _power == 4 ||
                _power == 6 ||
                _power == 8)
            {
                _bullet.DemageMagic += _bullet.BonusDemage;
                _bullet.Speed       -= 0.06;
            }

            Map_Cell oldCall = _map.Calls.Single(p => p.IndexLeft == _bullet.PositionX &&
                                                 p.IndexTop == _bullet.PositionY);

            oldCall.Bullet.Remove(_bullet);
            /////Сначала проверяем старую ячейку на попадение
            //Exept();
            _bullet.PositionX = _xNew;
            _bullet.PositionY = _yNew;
            Exept();

            Map_Cell newCall = _map.Calls.FirstOrDefault(p => p.IndexLeft == _bullet.PositionX &&
                                                         p.IndexTop == _bullet.PositionY);

            if (_bullet.Exept == true)
            {
                if (newCall != null && !newCall.Block)
                {
                    UnitGenerator.AddStune(newCall, _bullet, _bullet.StunDuration);
                }

                (_bullet.GameObject.View as IGameControl).Remove(_map.MapCanvas);
                ///Было попадение, анимация исчезновения стрелы
                //_bullet.GameObject.View.Visibility = Visibility.Collapsed;
                ///Было попадение стрела исчезает
                ///Удаляем из масива всех объектов
                _map.GameObjectInCall.Remove(_bullet.GameObject);

                BoomMethod(_bullet.PositionX, _bullet.PositionY);
                //_map.MapCanvas.Children.Remove(_bullet.GameObject.View);
            }
            else
            {
                newCall.Bullet.Add(_bullet);
            }
        }
Пример #12
0
    Map_Cell getClosestCell(Vector3 hitPosition)
    {
        Map_Cell bestTarget  = null;
        float    closestDist = Mathf.Infinity;

        foreach (Map_Cell cell in mapCells)
        {
            float dist = Vector3.Distance(cell.position, hitPosition);
            if (dist < closestDist)
            {
                closestDist = dist;
                bestTarget  = cell;
            }
        }
        //Debug.Log (bestTarget.name);
        return(bestTarget);
    }
Пример #13
0
        void _firstTimer_Completed(object sender, object e)
        {
            _firstTimer.Completed -= _firstTimer_Completed;
            _firstTimer            = null;

            Map_Cell oldCall = _map.Calls.Single(p => p.IndexLeft == _bullet.PositionX &&
                                                 p.IndexTop == _bullet.PositionY);

            oldCall.Bullet.Remove(_bullet);
            /////Сначала проверяем старую ячейку на попадение
            //Exept();
            _bullet.PositionX = _xNew;
            _bullet.PositionY = _yNew;
            Exept();

            Map_Cell newCall = _map.Calls.FirstOrDefault(p => p.IndexLeft == _bullet.PositionX &&
                                                         p.IndexTop == _bullet.PositionY);

            if (_bullet.Exept == true)
            {
                if (_bullet.SproutHealth > 0 &&
                    newCall != null &&
                    newCall.IUnits.Count(p => p.UnitType != EUnitType.Grass) > 0)// Значет нужно создать куст
                {
                    CreateSprout(newCall);
                }

                if (newCall != null && !newCall.Block)
                {
                    UnitGenerator.AddStune(newCall, _bullet, _bullet.StunDuration);
                }

                (_bullet.GameObject.View as IGameControl).Remove(_map.MapCanvas);
                ///Было попадение, анимация исчезновения стрелы
                //_bullet.GameObject.View.Visibility = Visibility.Collapsed;
                ///Было попадение стрела исчезает
                ///Удаляем из масива всех объектов
                _map.GameObjectInCall.Remove(_bullet.GameObject);
                //_map.MapCanvas.Children.Remove(_bullet.GameObject.View);
            }
            else
            {
                newCall.Bullet.Add(_bullet);
            }
        }
Пример #14
0
        void _firstTimer_Completed(object sender, object e)
        {
            _firstTimer.Completed -= _firstTimer_Completed;
            _firstTimer            = null;

            Map_Cell oldCall = _map.Calls.Single(p => p.IndexLeft == _bullet.PositionX &&
                                                 p.IndexTop == _bullet.PositionY);

            oldCall.Bullet.Remove(_bullet);
            /////Сначала проверяем старую ячейку на попадение
            //Exept();
            _bullet.PositionX = _xNew;
            _bullet.PositionY = _yNew;
            Map_Cell newCall = _map.Calls.FirstOrDefault(p => p.IndexLeft == _bullet.PositionX &&
                                                         p.IndexTop == _bullet.PositionY);

            Exept();
            if (_bullet.Exept && newCall != null && !newCall.Block &&
                !newCall.IUnits.Any(p => p.GameObject.EnumCallType == EnumCallType.UnitBlock))
            {
                BoomMethod(_bullet.PositionX, _bullet.PositionY);
                _boomTrue = true;
            }
            else if (_bullet.Exept)
            {
                BoomMethod(oldCall.IndexLeft, oldCall.IndexTop);
                _boomTrue = true;
            }


            if (_bullet.Exept == true)
            {
                (_bullet.GameObject.View as IGameControl).Remove(_map.MapCanvas);
                ///Было попадение, анимация исчезновения стрелы
                //_bullet.GameObject.View.Visibility = Visibility.Collapsed;
                ///Было попадение стрела исчезает
                ///Удаляем из масива всех объектов
                _map.GameObjectInCall.Remove(_bullet.GameObject);
                //_map.MapCanvas.Children.Remove(_bullet.GameObject.View);
            }
            else
            {
                newCall.Bullet.Add(_bullet);
            }
        }
Пример #15
0
        /// <summary>
        /// Анимация перемещения закончена
        /// </summary>
        void storyboard_Completed(object sender, object e)
        {
            _storyboard.Completed -= storyboard_Completed;
            _storyboard            = null;

            if (_bullet.Exept == true ||
                _bullet.Range == 0)
            {
                #region Эти 2 метода находятся в пуле
                ///Было попадение, анимация исчезновения стрелы
                //_bullet.GameObject.View.Visibility = Visibility.Collapsed;
                //_map.MapCanvas.Children.Remove(_bullet.GameObject.View);

                (_bullet.GameObject.View as IGameControl).Remove(_map.MapCanvas);
                #endregion
                ///Было попадение стрела исчезает
                ///Удаляем из масива всех объектов
                _map.GameObjectInCall.Remove(_bullet.GameObject);


                if (_map.Calls.Any(p => p.IndexLeft == _bullet.PositionX &&
                                   p.IndexTop == _bullet.PositionY))
                {
                    Map_Cell newCall = _map.Calls.Single(p => p.IndexLeft == _bullet.PositionX &&
                                                         p.IndexTop == _bullet.PositionY);
                    if (!_isBoom)
                    {
                        BoomMethod(_bullet.PositionX, _bullet.PositionY);
                    }
                    newCall.Bullet.Remove(_bullet);
                }
            }
            else
            {
                _bullet.Range--;
                ///Стрела летит дальше попадения не было
                BulletMuve(_bullet);
            }

            if (E_TestEvent != null)
            {
                E_TestEvent("Storyboard_Completed", null);
            }
        }
Пример #16
0
        private void CreateSprout(Map_Cell newCall)
        {
            int posX = _bullet.PositionX;
            int posY = _bullet.PositionY;

            CalculatePos(_bullet, ref posX, ref posY);


            Map_Cell sproutCall = _map.Calls.FirstOrDefault(p => p.IndexLeft == posX &&
                                                            p.IndexTop == posY);

            if (sproutCall != null && sproutCall.IUnits.Count <= 1)
            {
                Unit unit = UnitGenerator.GrassBlock(posX, posY);
                unit.NGold = 0;

                _map.CreateObjectUnitInCall(sproutCall, unit);
            }
        }
Пример #17
0
    public bool ReleaseCell(int x, int y)
    {
        Map_Cell cell = GetCell(x, y);

        if ((cell != null) &&
            (fOccupyCellsCount > 0) &&
            (cell.fIsBusy))
        {
            fOccupyCellsCount--;
            fCellsPool[cell.fPoolIndex]            = fCellsPool[fOccupyCellsCount];
            fCellsPool[cell.fPoolIndex].fPoolIndex = cell.fPoolIndex;
            cell.fPoolIndex = fOccupyCellsCount;
            cell.Object     = null;
            cell.fIsBusy    = false;
            fFreeCellsCount++;
            return(true);
        }

        return(false);
    }
Пример #18
0
    public bool OccupyCell(int x, int y, object occupy_object)
    {
        Map_Cell cell = GetCell(x, y);

        if ((cell != null) &&
            (fFreeCellsCount > 0) &&
            (!cell.fIsBusy))
        {
            cell.Object  = occupy_object;
            cell.fIsBusy = true;
            int temp_index = fCellsPool[fOccupyCellsCount].fPoolIndex;
            fCellsPool[fOccupyCellsCount].fPoolIndex = cell.fPoolIndex;
            fCellsPool[cell.fPoolIndex]   = fCellsPool[fOccupyCellsCount];
            cell.fPoolIndex               = temp_index;
            fCellsPool[fOccupyCellsCount] = cell;
            fOccupyCellsCount++;
            fFreeCellsCount--;
            return(true);
        }

        return(false);
    }
Пример #19
0
 Map_Cell findSuitableMine(Map_Cell s)
 {
     if (mc.mapCells [(int)s.gridPosition.y - 1, (int)s.gridPosition.x].Walkable)
     {
         return(mc.mapCells [(int)s.gridPosition.y - 1, (int)s.gridPosition.x]);
     }
     else if (mc.mapCells [(int)s.gridPosition.y + 1, (int)s.gridPosition.x].Walkable)
     {
         return(mc.mapCells [(int)s.gridPosition.y + 1, (int)s.gridPosition.x]);
     }
     else if (mc.mapCells [(int)s.gridPosition.y, (int)s.gridPosition.x - 1].Walkable)
     {
         return(mc.mapCells [(int)s.gridPosition.y, (int)s.gridPosition.x - 1]);
     }
     else if (mc.mapCells [(int)s.gridPosition.y, (int)s.gridPosition.x + 1].Walkable)
     {
         return(mc.mapCells [(int)s.gridPosition.y, (int)s.gridPosition.x + 1]);
     }
     else
     {
         return(null);
     }
 }
Пример #20
0
        private void CreateTrent(Map_Cell newCall, IUnit target)
        {
            if (newCall == null)
            {
                return;
            }

            Unit trent = UnitGenerator.M_Trent(_bullet.PositionX, _bullet.PositionY, _map, _unit as Player);

            _map.CreateObjectUnitInCall(newCall, trent);

            trent.Health += target.MaxHealth / 3;
            trent.Demage += _bullet.TrentDamage;
            trent.Arrmor += _bullet.TrentArmor;

            trent.AI.Farm = true;
            trent.AI.Hunt = true;
            trent.LifeTime(_bullet.LifeTime);

            trent.AI.StartAI();

            _bullet.RemoveUnit = null;
        }
Пример #21
0
        public void UseSpall(Map map, Game_Object_In_Call obj, IUnit unit, object property)
        {
            _unit   = unit;
            _map    = map;
            _player = _unit as Player;

            if (unit.UnitFrozen == false &&
                !_culdaunBool && LevelCast != 0 &&
                !unit.Hexed)
            {
                if (unit.Mana >= ManaCost)
                ///Проверка есть ли мана на каст
                {
                    ///Флаг кулдауна
                    _culdaunBool = true;
                    ///Отнимаем нужное количество
                    unit.Mana -= ManaCost;

                    _size = 100;
                    if (LevelCast == 1)
                    {
                        _culdaun = 20;
                    }
                    else if (LevelCast == 2)
                    {
                        _culdaun = 12;
                    }

                    if (_player != null)
                    {
                        (_player.GameObject.View as UC_Player).ShowEffect(3, true);
                    }

                    ///Выбираем клетку куда прыгнуть
                    ///Тут кординаты ячеек в которых действует тучка
                    _callsPoints = 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;

                            _callsPoints.Add(new Point(xNew, yNew));
                        }
                    }
                    else if (unit.Angel == EAngel.Right)
                    {
                        for (int i = 0; i <= _size; i++)
                        {
                            xNew = xNew + 1;

                            _callsPoints.Add(new Point(xNew, yNew));
                        }
                    }
                    else if (unit.Angel == EAngel.Top)
                    {
                        for (int i = 0; i <= _size; i++)
                        {
                            yNew = yNew - 1;

                            _callsPoints.Add(new Point(xNew, yNew));
                        }
                    }
                    else if (unit.Angel == EAngel.Bottom)
                    {
                        for (int i = 0; i <= _size; i++)
                        {
                            yNew = yNew + 1;

                            _callsPoints.Add(new Point(xNew, yNew));
                        }
                    }

                    _activeCall = null;
                    _callsPoints.Reverse();
                    ///Выбираем ячейку куда прыгать
                    foreach (var item in _callsPoints)
                    {
                        Map_Cell activeCall = map.Calls.FirstOrDefault(p => p.IndexLeft == item.X && p.IndexTop == item.Y);
                        if (activeCall != null &&
                            !activeCall.Block &&
                            activeCall.IUnits.Any(p => p.UnitType == EUnitType.Grass))
                        {
                            _activeCall = activeCall;
                            ///Прыгаем, в первую дальнюю ячейку
                            _activeCall.Using = true;
                            break;
                        }
                    }

                    if (_activeCall != null)
                    {
                        _unit.UnitFrozen = true;
                    }

                    ///Таймер время кастования телепорта
                    _firstTimer = new Storyboard()
                    {
                        Duration = TimeSpan.FromSeconds(Duration)
                    };
                    _firstTimer.Completed += _firstTimer_Completed;
                    _firstTimer.Begin();

                    ///Таймер кулдауна заклинания
                    _secondTimer = new Storyboard()
                    {
                        Duration = TimeSpan.FromSeconds(Culdaun)
                    };
                    _secondTimer.Completed += _secondTimer_Completed;
                    _secondTimer.Begin();

                    if (Paused)
                    {
                        Pause();
                    }

                    if (StartUseSpell != null)
                    {
                        StartUseSpell(this, null);
                    }

                    UnitGenerator.UpdatePlayerView(unit);
                }
                else
                ///Маны нету
                {
                }
            }
        }
Пример #22
0
        /// <summary>
        /// Запуск пули
        /// </summary>
        /// <param name="property">Уровень прокача способности, умножется на 5 и получается магический урон стрелы</param>
        public void UseSpall(Map map, Game_Object_In_Call obj, IUnit unit, object property)
        {
            _unit = unit;
            bool upSpell = UnitGenerator.UpPlayerSpell(unit, this);


            /// Если есть аганим
            if (UnitGenerator.HasAghanim(unit))
            {
                /// То ульт у снайпера быстрее востанавливается
                _culdaun = _culdaun / 2;
            }


            if (unit.UnitFrozen == false &&
                !_culdaunBool && LevelCast != 0 &&
                !upSpell && !unit.Silenced &&
                !unit.Hexed &&
                !Paused)
            {
                if (unit.Mana >= ManaCost)
                ///Проверка есть ли мана на каст
                {
                    Speed = unit.AttackSpeed;

                    ///Флаг кулдауна
                    _culdaunBool = true;

                    ///Отнимаем нужное количество
                    unit.Mana -= ManaCost;

                    ///Создаем визуальный объект стрела
                    UC_Sniper_Headshot arrow = new UC_Sniper_Headshot();
                    arrow.ChengAngel(unit.Angel);
                    Bullet bullArrow = new Bullet();
                    bullArrow.GameObject = new Game_Object_In_Call()
                    {
                        EnumCallType = EnumCallType.Bullet,
                        View         = arrow
                    };
                    bullArrow.UnitUsed   = unit;
                    bullArrow.PositionX  = unit.PositionX;
                    bullArrow.PositionY  = unit.PositionY;
                    bullArrow.Speed      = 0.3;
                    bullArrow.DemagePhys = unit.Demage;

                    if (LevelCast == 1)
                    {
                        bullArrow.DemageMagic = 30;
                    }


                    bullArrow.CurrentMap = map;
                    bullArrow.Angel      = unit.Angel;
                    bullArrow.Range      = 30;

                    ///Теперь выбераем цель пули
                    ///Это первый юнит на которого была наведена пуля

                    Map_Cell callsPoint = null;
                    ///Получаем ячейки которые находятся перед героем
                    #region Select first unit
                    int xNew = unit.PositionX;
                    int yNew = unit.PositionY;
                    if (unit.Angel == EAngel.Left)
                    {
                        for (int i = 0; i <= map.Width / 50; i++)
                        {
                            xNew = xNew - 1;
                            Map_Cell call = map.Calls.FirstOrDefault(p => p.IndexLeft == xNew && p.IndexTop == yNew);
                            if (call != null && !call.Block)
                            {
                                if (call.IUnits.Any(p => p.GameObject.EnumCallType == EnumCallType.Unit ||
                                                    p.GameObject.EnumCallType == EnumCallType.Player))
                                {
                                    callsPoint = call;
                                    break;
                                }
                            }
                        }
                    }
                    else if (unit.Angel == EAngel.Right)
                    {
                        for (int i = 0; i <= map.Width / 50; i++)
                        {
                            xNew = xNew + 1;
                            Map_Cell call = map.Calls.FirstOrDefault(p => p.IndexLeft == xNew && p.IndexTop == yNew);
                            if (call != null && !call.Block)
                            {
                                if (call.IUnits.Any(p => p.GameObject.EnumCallType == EnumCallType.Unit ||
                                                    p.GameObject.EnumCallType == EnumCallType.Player))
                                {
                                    callsPoint = call;
                                    break;
                                }
                            }
                        }
                    }
                    else if (unit.Angel == EAngel.Top)
                    {
                        for (int i = 0; i <= map.Height / 50; i++)
                        {
                            yNew = yNew - 1;
                            Map_Cell call = map.Calls.FirstOrDefault(p => p.IndexLeft == xNew && p.IndexTop == yNew);
                            if (call != null && !call.Block)
                            {
                                if (call.IUnits.Any(p => p.GameObject.EnumCallType == EnumCallType.Unit ||
                                                    p.GameObject.EnumCallType == EnumCallType.Player))
                                {
                                    callsPoint = call;
                                    break;
                                }
                            }
                        }
                    }
                    else if (unit.Angel == EAngel.Bottom)
                    {
                        for (int i = 0; i <= map.Height / 50; i++)
                        {
                            yNew = yNew + 1;
                            Map_Cell call = map.Calls.FirstOrDefault(p => p.IndexLeft == xNew && p.IndexTop == yNew);
                            if (call != null && !call.Block)
                            {
                                if (call.IUnits.Any(p => p.GameObject.EnumCallType == EnumCallType.Unit ||
                                                    p.GameObject.EnumCallType == EnumCallType.Player))
                                {
                                    callsPoint = call;
                                    break;
                                }
                            }
                        }
                    }

                    if (callsPoint != null)
                    {
                        bullArrow.Aim = callsPoint.IUnits.FirstOrDefault(p => p.GameObject.EnumCallType == EnumCallType.Player);
                        if (bullArrow.Aim == null)
                        {
                            bullArrow.Aim = callsPoint.IUnits.FirstOrDefault(p => p.GameObject.EnumCallType == EnumCallType.Unit);
                        }
                    }
                    #endregion

                    bullArrow.Spells.Add(new SPB_Sniper_Assassinate()
                    {
                        Name = "Fly"
                    });

                    ///И его же добавим в масив всех объектов
                    map.GameObjectInCall.Add(bullArrow.GameObject);

                    Canvas.SetLeft(bullArrow.GameObject.View, bullArrow.PositionX * 50);
                    Canvas.SetTop(bullArrow.GameObject.View, bullArrow.PositionY * 50);
                    ///Отображение
                    map.MapCanvas.Children.Add(bullArrow.GameObject.View);

                    bullArrow.UseSpall("Fly");

                    ///Таймер кулдауна заклинания
                    _secondTimer = new Storyboard()
                    {
                        Duration = TimeSpan.FromSeconds(Culdaun)
                    };
                    _secondTimer.Completed += _secondTimer_Completed;
                    _secondTimer.Begin();

                    if (Paused)
                    {
                        Pause();
                    }

                    if (StartUseSpell != null)
                    {
                        StartUseSpell(this, null);
                    }

                    UnitGenerator.UpdatePlayerView(unit);
                }
                else
                ///Маны нету
                {
                }
            }
        }
Пример #23
0
        /// <summary>
        /// Этот метод наносит урон
        /// </summary>
        private void BoomMethod(int x, int y)
        {
            _isBoom = true;
            ///Если ракета попала или должна исчезнуть
            ///Берем все ячейки вокруг колбы
            List <Point> roundPoint = UnitGenerator.BigRoundNumber(x, y);

            roundPoint.Add(new Point(x, y));
            ///Теперь рисуем взрыв
            for (int i = 0; i < roundPoint.Count; i++)
            {
                Map_Cell callBoom = _map.Calls.FirstOrDefault(p => p.IndexLeft == roundPoint[i].X && p.IndexTop == roundPoint[i].Y);
                if (callBoom != null && !callBoom.Block)
                {
                    UC_Super_Mega_Death_Rocket arrow = new UC_Super_Mega_Death_Rocket();
                    if (i == 0 || i == 1)
                    {
                        arrow.ChengAngel(EAngel.Left);
                    }
                    else if (i == 2 || i == 3)
                    {
                        arrow.ChengAngel(EAngel.Right);
                    }
                    else if (i == 4 || i == 5)
                    {
                        arrow.ChengAngel(EAngel.Top);
                    }
                    else if (i == 6 || i == 7)
                    {
                        arrow.ChengAngel(EAngel.Bottom);
                    }
                    else if (i == 8)
                    {
                        ///Центральная ячейка
                        arrow.ChengAngelCenter();
                    }

                    Bullet bullArrow = new Bullet();
                    bullArrow.GameObject = new Game_Object_In_Call()
                    {
                        EnumCallType = EnumCallType.Bullet,
                        View         = arrow
                    };
                    bullArrow.UnitUsed  = _bullet.UnitUsed;
                    bullArrow.PositionX = (int)roundPoint[i].X;
                    bullArrow.PositionY = (int)roundPoint[i].Y;
                    bullArrow.Speed     = 0;

                    if (i != 8)
                    {
                        bullArrow.DemageMagic = _bullet.DemageMagic;
                    }
                    else
                    {
                        bullArrow.DemageMagic = (int)(_bullet.DemageMagic * 0.8);
                    }

                    bullArrow.CurrentMap = _map;
                    bullArrow.Angel      = _bullet.UnitUsed.Angel;
                    bullArrow.Range      = 0;

                    ///И его же добавим в масив всех объектов
                    _map.GameObjectInCall.Add(bullArrow.GameObject);
                    Canvas.SetLeft(bullArrow.GameObject.View, bullArrow.PositionX * 50);
                    Canvas.SetTop(bullArrow.GameObject.View, bullArrow.PositionY * 50);
                    ///Отображение
                    _map.MapCanvas.Children.Add(bullArrow.GameObject.View);

                    UnitGenerator.AddDamage(callBoom, bullArrow);
                    UnitGenerator.AddStune(callBoom, bullArrow, _bullet.StunDuration);

                    _boom.Add(bullArrow);
                }
            }

            _secondTimer = new Storyboard()
            {
                Duration = TimeSpan.FromSeconds(0.5)
            };
            _secondTimer.Completed += _secondTimer_Completed;
            _secondTimer.Begin();
        }
Пример #24
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();
                    }
                }
            }
        }
Пример #25
0
        public void UseSpall(Map map, Game_Object_In_Call obj, IUnit unit, object property)
        {
            if (unit.UnitFrozen == false &&
                !_culdaunBool && LevelCast != 0 &&
                !unit.Hexed)
            {
                if (unit.Mana >= ManaCost)
                ///Проверка есть ли мана на каст
                {
                    ///Проверка диагонали по которой будет запущено сало
                    ///метод проверки вернет ячейку в которой произошло столкновение
                    Map_Cell call = UnitGenerator.FiratCollision(unit.PositionX, unit.PositionY, map, unit.Angel);

                    _culdaunBool = true;
                    _unit        = unit;
                    ///Отнимаем нужное количество
                    unit.Mana -= ManaCost;

                    if (call != null)
                    ///Произошло попадение
                    {
                        _silencedUnits = new List <IUnit>();
                        _saveDemage    = new List <int>();

                        foreach (var item in call.IUnits)
                        {
                            if (!item.Silenced)
                            {   ///Если на целе не наложен эфект сайленса
                                item.Silenced        = true;
                                item.GetDemageEvent += item_GetDemageEvent;
                                _silencedUnits.Add(item);
                                _saveDemage.Add(0);
                            }
                        }

                        ///Время действия
                        _firstTimer = new Storyboard()
                        {
                            Duration = TimeSpan.FromSeconds(Duration)
                        };
                        _firstTimer.Completed += _firstTimer_Completed;
                        _firstTimer.Begin();
                    }
                    else
                    {
                        (unit.GameObject.View as IGameControl).GetDemage("Miss");
                    }

                    ///Кулдаун
                    _secondTimer = new Storyboard()
                    {
                        Duration = TimeSpan.FromSeconds(Culdaun)
                    };
                    _secondTimer.Completed += _secondTimer_Completed;
                    _secondTimer.Begin();

                    if (Paused)
                    {
                        Pause();
                    }

                    if (StartUseSpell != null)
                    {
                        StartUseSpell(this, null);
                    }
                    UnitGenerator.UpdatePlayerView(unit);
                }
            }
        }
Пример #26
0
    void Update()
    {
        /*  Debug Code  */
        if (Input.GetKeyDown("l"))
        {
            toggle = !toggle;
        }
        if (toggle)
        {
            speed     = 1;
            mineSpeed = 1;
        }
        else
        {
            speed     = 100;
            mineSpeed = 100;
        }
        /*  End Of Debug Code  */

        if (State.Equals("Mine"))
        {
            //UnityEngine.Debug.Log (destinationPath);
            if (jobTarget.Selected == false)
            {
                State            = "Idle";
                jobTarget        = null;
                astardestination = transform.position;
            }
            else
            {
                if (destinationPath == null && transform.position != new Vector3(astardestination.x, transform.position.y, astardestination.z))
                {
                    HiveMind.RequestPath(new PathRequest(this.gameObject, getClosetPoint(transform.position), getClosetPoint(astardestination)));
                }
                //destinationPath = PathFind (getClosetPoint (transform.position), getClosetPoint (astardestination));

                //astardestination = jobTarget.GetComponent<Map_CellControl>().assignPosition(gameObject);
                if (Vector3.Distance(transform.position, new Vector3(destinationPoint.Location.x, transform.position.y, destinationPoint.Location.z)) <= 8)
                {
                    MineCell(jobTarget);
                }
            }
            if (transform.position != astardestination)
            {
                if (destinationPath != null)
                {
                    try{
                        if (transform.position.Equals(new Vector3(destinationPath [pathPosition].x, transform.position.y, destinationPath [pathPosition].z)))
                        {
                            if (pathPosition < destinationPath.Count - 1)
                            {
                                pathPosition++;
                            }
                        }
                    }
                    catch (System.ArgumentOutOfRangeException ex) {
                        Debug.Log(ex);
                    }
                    if (pathPosition >= destinationPath.Count)
                    {
                        pathPosition = destinationPath.Count - 1;
                    }
                    //Debug.Log (pathPosition + " : " + (destinationPath.Count-1));
                    transform.position = Vector3.MoveTowards(transform.position, new Vector3(destinationPath [pathPosition].x, transform.position.y, destinationPath [pathPosition].z), speed);
                }
                //	transform.position = Vector3.MoveTowards (transform.position, new Vector3 (astardestination.x, transform.position.y, astardestination.z), 1f);
            }
            else
            {
                destinationPath = null;
                pathPosition    = 0;
            }
        }
        else if (State.Equals("ClaimGround"))
        {
            if (jobTarget.Cell == 2)
            {
                State            = "Idle";
                jobTarget        = null;
                astardestination = transform.position;
            }
            else
            {
                astardestination = new Vector3(jobTarget.position.x, transform.position.y, jobTarget.position.z);

                if (destinationPath == null && transform.position != new Vector3(astardestination.x, transform.position.y, astardestination.z))
                {
                    HiveMind.RequestPath(new PathRequest(this.gameObject, getClosetPoint(transform.position), getClosetPoint(astardestination)));
                }

                if (Vector3.Distance(transform.position, new Vector3(destinationPoint.Location.x, transform.position.y, destinationPoint.Location.z)) <= 8)
                {
                    ClaimCell(jobTarget);
                }
            }
            if (transform.position != astardestination)
            {
                if (destinationPath != null)
                {
                    if (transform.position.Equals(new Vector3(destinationPath [pathPosition].x, transform.position.y, destinationPath [pathPosition].z)))
                    {
                        if (pathPosition < destinationPath.Count - 1)
                        {
                            pathPosition++;
                        }
                    }

                    if (pathPosition >= destinationPath.Count)
                    {
                        pathPosition = destinationPath.Count - 1;
                    }
                    transform.position = Vector3.MoveTowards(transform.position, new Vector3(destinationPath [pathPosition].x, transform.position.y, destinationPath [pathPosition].z), speed);
                }
                //	transform.position = Vector3.MoveTowards (transform.position, new Vector3 (astardestination.x, transform.position.y, astardestination.z), 1f);
            }
            else
            {
                destinationPath = null;
                pathPosition    = 0;
            }
        }
        else if (State.Equals("Idle"))
        {
            destinationPath  = null;
            destinationPoint = null;
            astardestination = Vector3.zero;
        }
    }
Пример #27
0
        private void BulletMuve(Bullet bullArrow)
        {
            _moveCount++;

            if (IsSfUlt)
            {
                SfUlt(bullArrow.Angel);
            }

            int xNew = 0;
            int yNew = 0;

            if (bullArrow.Angel == EAngel.Left)
            {
                xNew = bullArrow.PositionX - 1;
                yNew = bullArrow.PositionY;
            }
            else if (bullArrow.Angel == EAngel.Right)
            {
                xNew = bullArrow.PositionX + 1;
                yNew = bullArrow.PositionY;
            }
            else if (bullArrow.Angel == EAngel.Top)
            {
                xNew = bullArrow.PositionX;
                yNew = bullArrow.PositionY - 1;
            }
            else if (bullArrow.Angel == EAngel.Bottom)
            {
                xNew = bullArrow.PositionX;
                yNew = bullArrow.PositionY + 1;
            }

            _xNew = xNew;
            _yNew = yNew;

            ///Проверяем не край экрана ли блок
            Map_Cell newCall = _map.Calls.FirstOrDefault(p => p.IndexLeft == xNew &&
                                                         p.IndexTop == yNew);

            if (_hitCountOrij != _hitCount && _exeptHit)
            {///Если было попадение в цель
                if (newCall != null && !newCall.Block && _stopAngels != _bullet.Angel)
                {
                    _exeptHit = false;
                    ///Запуск анимации перемещения
                    StartStoryboard(bullArrow, xNew, yNew);
                }
                else
                {
                    if (bullArrow.Angel == (EAngel)0)
                    {
                        bullArrow.Angel = (EAngel)3;
                    }
                    else
                    {
                        bullArrow.Angel = _bullet.Angel - 1;
                    }

                    bullArrow.DemageMagic += Multiply;


                    BulletMuve(bullArrow);
                }
            }
            else
            {
                StartStoryboard(bullArrow, xNew, yNew);
            }
        }
Пример #28
0
        public void UseSpall(Map map, Game_Object_In_Call obj, IUnit unit, object property)
        {
            _unit = unit;
            _map  = map;

            if (!_culdaunBool && !Paused)
            {
                ///Флаг кулдауна
                _culdaunBool = true;

                ///Тут кординаты ячеек в которых действует тучка
                List <Point> callsPoint = new List <Point>();
                ///Получаем ячейки которые находятся перед героем
                ///использывавшим тучку
                ///Сначала добавляем ячеку с героем
                callsPoint.Add(new Point(unit.PositionX, unit.PositionY));
                int xNew = unit.PositionX;
                int yNew = unit.PositionY;

                for (int i = 0; i <= _size; i++)
                {
                    xNew = xNew - 1;
                    callsPoint.Add(new Point(xNew, yNew));
                    callsPoint.Add(new Point(xNew, yNew + 1));
                    callsPoint.Add(new Point(xNew, yNew - 1));
                }
                xNew = unit.PositionX;
                yNew = unit.PositionY;
                for (int i = 0; i <= _size; i++)
                {
                    xNew = xNew + 1;
                    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));
                }
                xNew = unit.PositionX;
                yNew = unit.PositionY;
                for (int i = 0; i <= _size; i++)
                {
                    yNew = yNew - 1;
                    callsPoint.Add(new Point(xNew, yNew));
                    if (i != 0)
                    {
                        callsPoint.Add(new Point(xNew + 1, yNew));
                        callsPoint.Add(new Point(xNew - 1, yNew));
                    }
                }
                xNew = unit.PositionX;
                yNew = unit.PositionY;
                for (int i = 0; i <= _size; i++)
                {
                    yNew = yNew + 1;
                    callsPoint.Add(new Point(xNew, yNew));
                    if (i != 0)
                    {
                        callsPoint.Add(new Point(xNew + 1, yNew));
                        callsPoint.Add(new Point(xNew - 1, 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_Alchemist_AcidSpray acidSpray = new UC_Alchemist_AcidSpray();
                        //  acidSpray.ChengAngel(unit.Angel);
                        for (int i = 0; i < call.IUnits.Count; i++)
                        {
                            var itemUnit = call.IUnits[i];
                            if (itemUnit != null && itemUnit.GroupType != _unit.GroupType)
                            {
                                //item.GatDamage(_bullet.DemagePhys, _bullet.DemageMagic, _bullet.DemagePure, _unit);

                                Buff buff = itemUnit.Buffs.FirstOrDefault(p => p.Name == "AssaultCuirass");
                                if (buff != null)
                                {
                                    buff.Duration = 2;
                                }
                                else
                                {
                                    Buff alchBuff = new Buff()
                                    {
                                        MinusArmor = _minusArmor,
                                        Duration   = 2,
                                        Name       = "AssaultCuirass"
                                    };
                                    itemUnit.UseBuff(alchBuff);
                                }
                            }
                            else if (itemUnit != null && itemUnit.GroupType == _unit.GroupType)
                            {
                                Buff buff = itemUnit.Buffs.FirstOrDefault(p => p.Name == "AssaultCuirassPositive");
                                if (buff != null)
                                {
                                    buff.Duration = 2;
                                }
                                else
                                {
                                    Buff alchBuff = new Buff()
                                    {
                                        Armor       = _armor,
                                        AttackSpeed = _attackSpeed,
                                        Duration    = 2,
                                        Name        = "AssaultCuirassPositive"
                                    };
                                    itemUnit.UseBuff(alchBuff);
                                }
                            }
                        }
                    }
                }

                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);
            }
        }
Пример #29
0
    // Use this for initialization
    void Start()
    {
        mapCells      = new Map_Cell[map_HEIGHT, map_WIDTH];
        mapCellNumber = new int[map_HEIGHT, map_WIDTH];
        mapStarMap    = new aStarPoint[map_HEIGHT * 3, map_WIDTH *3];



        int count = 0;

        for (int y = 0; y < map_HEIGHT; y++)
        {
            for (int x = 0; x < map_WIDTH; x++)
            {
                mapCells [y, x] = new Map_Cell(new Vector3(x * 12, 6, y * 12));
                mapCells [y, x].setPosition(x, y);
                mapCells [y, x].name = "Map_Cell " + count.ToString();
                if (x == 0 || y == 0 || x == map_WIDTH - 1 || y == map_HEIGHT - 1)
                {
                    mapCells [y, x].ChangeCell(-1);
                }
                else
                {
                    mapCells [y, x].ChangeCell(0);
                }
                count++;
            }
        }
        Vector2 center = new Vector2(map_HEIGHT / 2, map_WIDTH / 2);

        for (int x = -3; x < 4; x++)
        {
            for (int y = -3; y < 4; y++)
            {
                if (x >= -2 && x <= 2 && y >= -2 && y <= 2)
                {
                    mapCells [(int)(center.y) + y, (int)(center.x) + x].ChangeCell(2);
                }
                else
                {
                    mapCells [(int)(center.y) + y, (int)(center.x) + x].ChangeCell(1);
                }
            }
        }
        for (int y = 0; y < map_HEIGHT * 3; y++)
        {
            for (int x = 0; x < map_WIDTH * 3; x++)
            {
                mapStarMap [y, x].Location = new Vector3((x - 1) * 4f, 20, (y - 1) * 4f);
            }
        }
        fullyGenerated = true;
        //StaticOcclusionCulling.Compute ();

        GameObject w1 = Instantiate(Worker, mapCells[(int)center.y - 1, (int)center.x - 1].position + new Vector3(0, 7, 0), Quaternion.identity) as GameObject;

        w1.name = "Worker1";
        //*
        GameObject w2 = Instantiate(Worker, mapCells[(int)center.y - 1, (int)center.x].position + new Vector3(0, 7, 0), Quaternion.identity) as GameObject;

        w2.name = "Worker2";

        GameObject w3 = Instantiate(Worker, mapCells[(int)center.y - 1, (int)center.x + 1].position + new Vector3(0, 7, 0), Quaternion.identity) as GameObject;

        w3.name = "Worker3";

        GameObject w4 = Instantiate(Worker, mapCells[(int)center.y, (int)center.x - 1].position + new Vector3(0, 7, 0), Quaternion.identity) as GameObject;

        w4.name = "Worker4";
        GameObject w5 = Instantiate(Worker, mapCells[(int)center.y, (int)center.x].position + new Vector3(0, 7, 0), Quaternion.identity) as GameObject;

        w5.name = "Worker5";
        GameObject w6 = Instantiate(Worker, mapCells[(int)center.y, (int)center.x + 1].position + new Vector3(0, 7, 0), Quaternion.identity) as GameObject;

        w6.name = "Worker6";
        GameObject w7 = Instantiate(Worker, mapCells[(int)center.y + 1, (int)center.x - 1].position + new Vector3(0, 7, 0), Quaternion.identity) as GameObject;

        w7.name = "Worker7";
        GameObject w8 = Instantiate(Worker, mapCells[(int)center.y + 1, (int)center.x].position + new Vector3(0, 7, 0), Quaternion.identity) as GameObject;

        w8.name = "Worker8";
        GameObject w9 = Instantiate(Worker, mapCells[(int)center.y + 1, (int)center.x + 1].position + new Vector3(0, 7, 0), Quaternion.identity) as GameObject;

        w9.name = "Worker9";
        //*/
        GameObject hm = Instantiate(Hive, new Vector3(), Quaternion.identity) as GameObject;

        hm.name = "HiveMind";
        foreach (Map_Cell cell in mapCells)
        {
            cell.Hive = hm.GetComponent <HiveMindAI>();
        }
        /* Mesh Test */
        generateVerticies();
        generateMesh();
        generateTextures();
    }
Пример #30
0
        /// <summary>
        /// Анимация перемещения закончена
        /// </summary>
        void storyboard_Completed(object sender, object e)
        {
            _storyboard.Completed -= storyboard_Completed;
            _storyboard            = null;

            if (_hitCount == 0 ||
                _bullet.Range == 0 ||
                _exept)
            {
                #region Эти 2 метода находятся в пуле
                ///Было попадение, анимация исчезновения стрелы
                //_bullet.GameObject.View.Visibility = Visibility.Collapsed;
                //_map.MapCanvas.Children.Remove(_bullet.GameObject.View);

                (_bullet.GameObject.View as IGameControl).Remove(_map.MapCanvas);
                #endregion
                ///Было попадение стрела исчезает
                ///Удаляем из масива всех объектов
                _map.GameObjectInCall.Remove(_bullet.GameObject);


                if (_map.Calls.Any(p => p.IndexLeft == _bullet.PositionX &&
                                   p.IndexTop == _bullet.PositionY))
                {
                    Map_Cell newCall = _map.Calls.Single(p => p.IndexLeft == _bullet.PositionX &&
                                                         p.IndexTop == _bullet.PositionY);
                    newCall.Bullet.Remove(_bullet);
                }
            }
            else
            {
                _bullet.Range--;
                if (_bullet.Exept)
                {
                    _exeptHit = true;

                    if (_bullet.Angel == EAngel.Left)
                    {
                        _stopAngels = EAngel.Right;
                    }
                    else if (_bullet.Angel == EAngel.Right)
                    {
                        _stopAngels = EAngel.Left;
                    }
                    else if (_bullet.Angel == EAngel.Top)
                    {
                        _stopAngels = EAngel.Bottom;
                    }
                    else if (_bullet.Angel == EAngel.Bottom)
                    {
                        _stopAngels = EAngel.Top;
                    }

                    ///Выбераем рандомную сторону куда отобется молния
                    Random rand = new Random((int)DateTime.Now.Ticks);
                    _bullet.Angel = (EAngel)rand.Next(0, 3);
                    _bullet.Exept = false;
                }
                ///Молния летит дальше, у нее не кончелся ренж
                ///или небыло максимального количества попадений
                BulletMuve(_bullet);
            }

            if (E_TestEvent != null)
            {
                E_TestEvent("Storyboard_Completed", null);
            }
        }