Ejemplo n.º 1
0
Archivo: Map.cs Proyecto: rio900/voins
        public void CreateRandomMap(bool noBlock)
        {
            Calls = new List <Map_Cell>();
            MapCanvas.Children.Clear();
            _players          = new List <Player>();
            _deadPlayers      = new List <Player>();
            _killsDeath       = new List <Point>();
            _gameObjectInCall = new List <Game_Object_In_Call>();

            for (int i = 0; i < Width / 50; i++)
            {
                for (int j = 0; j < Height / 50; j++)
                {
                    Map_Cell map_Call = new Map_Cell()
                    {
                        IndexLeft = i,
                        IndexTop  = j
                    };

                    ///Это для размещения блока стены(не пробиваймые блоки)
                    if (i % 2 != 0 && j % 2 != 0)
                    {
                        if (!noBlock)
                        {
                            Unit unit = new Unit()
                            {
                                PositionX = i,
                                PositionY = j
                            };

                            UC_Block uc_Block = new UC_Block()
                            {
                                Width  = 50,
                                Height = 50
                            };
                            Canvas.SetLeft(uc_Block, i * 50);
                            Canvas.SetTop(uc_Block, j * 50);

                            ///Непроходимый блок
                            Game_Object_In_Call block = new Game_Object_In_Call()
                            {
                                EnumCallType = EnumCallType.Block,
                                View         = uc_Block
                            };
                            unit.GameObject = block;

                            map_Call.Block = true;
                            ///В этой ячейке находится непроходимый блок
                            map_Call.IUnits.Add(unit);
                            ///И его же добавим в масив всех объектов
                            GameObjectInCall.Add(block);
                            ///Отображение
                            MapCanvas.Children.Add(block.View);
                        }
                    }
                    Calls.Add(map_Call);
                }
            }
        }
Ejemplo n.º 2
0
Archivo: Map.cs Proyecto: rio900/voins
 public void CreateObjectUnitInCall(Map_Cell item, Unit unit)
 {
     unit.CurrentMap = this;
     ///И его же добавим в масив всех объектов
     GameObjectInCall.Add(unit.GameObject);
     ///Добавляем в список всех юнитов
     item.IUnits.Add(unit);
     item.Used = true;
     ///Отображение
     MapCanvas.Children.Add(unit.GameObject.View);
 }
Ejemplo n.º 3
0
Archivo: Map.cs Proyecto: rio900/voins
        public void DeleteCurrentMap()
        {
            foreach (var item in Players)
            {
                item.DeadEvent -= item_DeadEvent;
            }
            if (Calls != null)
            {
                if (_farmGameDispatcherTimer != null)
                {
                    _farmGameDispatcherTimer.Stop();
                }
                Pause();

                foreach (var call in Calls)
                {
                    for (int i = 0; i < call.IUnits.Count; i++)
                    {
                        if (call.IUnits[i].AI != null)
                        {
                            call.IUnits[i].AI.StopAI();
                        }
                        Player palyer = call.IUnits[i] as Player;
                        if (palyer != null)
                        {
                            palyer.AllowRespaum = false;
                            palyer.DeleteUnit();
                        }
                        if (call.IUnits[i].GameObject.EnumCallType != EnumCallType.Block)
                        {
                            call.IUnits[i].GatDamage(int.MaxValue, int.MaxValue, int.MaxValue, null);
                        }
                    }

                    foreach (var item in call.Bullet)
                    {
                        MapCanvas.Children.Remove(item.GameObject.View);
                    }
                    call.Bullet.Clear();

                    foreach (var item in call.Item)
                    {
                        MapCanvas.Children.Remove(item.View);
                    }
                    call.Item.Clear();
                }

                DroppedItemsList.Clear();
                GameObjectInCall.Clear();
                Players.Clear();
                StopPause();
            }
        }
Ejemplo n.º 4
0
Archivo: Map.cs Proyecto: rio900/voins
        public void CreatePlayer(Player player)
        {
            Players.Add(player);
            Canvas.SetZIndex(player.GameObject.View, 1000);
            ///Если один игрок
            ///Левый верхний угол спаума
            if (Players.Count == 1)
            {
                CreateObject(player, 0, 0);
            }
            else if (Players.Count == 2)
            {
                player.PositionX = Calls.Last().IndexLeft;
                player.PositionY = Calls.Last().IndexTop;
                CreateObject(player, Calls.Last().IndexLeft, Calls.Last().IndexTop);
                //player.PositionX = Calls[2].IndexLeft;
                //player.PositionY = Calls[2].IndexTop;
                //CreateObject(player, Calls[2].IndexLeft, Calls[2].IndexTop);
            }
            else if (Players.Count == 3)
            {
                Map_Cell call = Calls[208];
                player.PositionX = call.IndexLeft;
                player.PositionY = call.IndexTop;
                CreateObject(player, call.IndexLeft, call.IndexTop);
            }
            else if (Players.Count == 4)
            {
                Map_Cell call = Calls[12];
                player.PositionX = call.IndexLeft;
                player.PositionY = call.IndexTop;
                CreateObject(player, call.IndexLeft, call.IndexTop);
            }

            #region Добавление игрока
            ///И его же добавим в масив всех объектов
            GameObjectInCall.Add(player.GameObject);
            ///Отображение
            MapCanvas.Children.Add(player.GameObject.View);
            #endregion
        }
Ejemplo n.º 5
0
Archivo: Map.cs Proyecto: rio900/voins
        /// <summary>
        /// Заполнение карту блоками
        /// </summary>
        public void CreateMobs()
        {
            #region CreateMobs
            int randInt = 0;

            foreach (var item in Calls)
            {
                ///Проверка ячеек которые не могут быть заполнены
                if (!item.Used &&
                    !item.Block)
                {
                    Random random = new Random((int)DateTime.Now.Ticks + randInt++);
                    int    rand   = random.Next(0, 100);

                    if (rand < StepMobs)
                    {
                        Unit unit = UnitGenerator.M1_Ball(item.IndexLeft, item.IndexTop, this);

                        ///И его же добавим в масив всех объектов
                        GameObjectInCall.Add(unit.GameObject);
                        ///Добавляем в список всех юнитов
                        item.IUnits.Add(unit);
                        item.Used = true;

                        ///Отображение
                        MapCanvas.Children.Add(unit.GameObject.View);

                        if (unit.AI != null)
                        {
                            unit.AI.StartAI();
                        }
                    }
                }
            }
            #endregion
        }
Ejemplo n.º 6
0
Archivo: Map.cs Proyecto: rio900/voins
        void farmGameDispatcherTimer_Tick(object sender, object e)
        {
            if (GameType == EGameType.FurmGame)
            {
                if (GameObjectInCall.Count(p => p.EnumCallType == EnumCallType.UnitBlock) == 0 &&
                    GameObjectInCall.Count(p => p.EnumCallType == EnumCallType.Unit) == 0)
                {
                    StepMobs = 8;
                    if (_mapNumberFarmGame == 0)
                    {
                        CreateBlock();
                        CreateMobs();
                    }
                    else if (_mapNumberFarmGame > 0)
                    {
                        MapGenerator.FarmGameMap(this, _mapNumberFarmGame, _modFarmGame);
                    }
                    else
                    {
                        MapGenerator.SpecialGameMap(this, Math.Abs(_mapNumberFarmGame), _modFarmGame);
                    }

                    CreateDroppedItems();
                }
            }
            else if (GameType == EGameType.Coop)
            {
                if (GameObjectInCall.Count(p => p.EnumCallType == EnumCallType.UnitBlock) == 0 &&
                    GameObjectInCall.Count(p => p.EnumCallType == EnumCallType.Unit) == 0)
                {
                    CreateBlock();

                    CoopTimer += 1;

                    if (CoopTimer == 2)
                    {
                        MapGenerator.CreateMobsCoopEasyMob(this, 5, EMobType.RangeBall);
                        MapGenerator.CreateMobsCoopEasyMob(this, 1, EMobType.BlueBall);
                        MapGenerator.CreateMobsCoopEasyMob(this, 5, EMobType.Ball);
                    }
                    else if (CoopTimer == 3)
                    {
                        MapGenerator.CreateMobsCoopEasyMob(this, 3, EMobType.RangeBall);
                        MapGenerator.CreateMobsCoopEasyMob(this, 3, EMobType.Ball);
                        MapGenerator.CreateMobsCoopEasyMob(this, 2, EMobType.BlueBall);
                        MapGenerator.CreateMobsCoopEasyMob(this, 1, EMobType.RedBall);
                    }
                    else if (CoopTimer == 4)
                    {
                        MapGenerator.CreateMobsCoopEasyMob(this, 1, EMobType.RangeBall);
                        MapGenerator.CreateMobsCoopEasyMob(this, 3, EMobType.BlackHunter);
                        MapGenerator.CreateMobsCoopEasyMob(this, 3, EMobType.BlueBall);
                        MapGenerator.CreateMobsCoopEasyMob(this, 1, EMobType.RedBall);
                    }
                    else if (CoopTimer == 5)
                    {
                        MapGenerator.CreateMobsCoopEasyMob(this, 3, EMobType.BlackHunter);
                        MapGenerator.CreateMobsCoopEasyMob(this, 3, EMobType.BlueBall);
                        MapGenerator.CreateMobsCoopEasyMob(this, 1, EMobType.RedBall);
                    }
                    else if (CoopTimer == 6)
                    {
                        MapGenerator.CreateMobsCoopEasyMob(this, 5, EMobType.BlackHunter);
                        MapGenerator.CreateMobsCoopEasyMob(this, 2, EMobType.BlueBall);
                        MapGenerator.CreateMobsCoopEasyMob(this, 2, EMobType.RedBall);
                    }
                    else if (CoopTimer == 7)
                    {
                        MapGenerator.CreateMobsCoopEasyMob(this, 2, EMobType.BlueBall);
                        MapGenerator.CreateMobsCoopEasyMob(this, 5, EMobType.BlackHunter);
                        MapGenerator.CreateMobsCoopEasyMob(this, 1, EMobType.BlackHunterBoss);
                    }
                    else
                    {
                        MapGenerator.CreateMobsCoopEasyMob(this, 3, EMobType.RangeBall);
                        MapGenerator.CreateMobsCoopEasyMob(this, 3, EMobType.BlackHunter);
                        MapGenerator.CreateMobsCoopEasyMob(this, 3, EMobType.BlueBall);
                        MapGenerator.CreateMobsCoopEasyMob(this, 1, EMobType.RedBall);
                    }

                    CreateCoopDroppedItems();
                }
            }
        }