Exemplo n.º 1
0
Arquivo: Map.cs Projeto: 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);
                }
            }
        }
Exemplo n.º 2
0
Arquivo: Map.cs Projeto: 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);
 }
Exemplo n.º 3
0
Arquivo: Map.cs Projeto: 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
        }
Exemplo n.º 4
0
Arquivo: Map.cs Projeto: 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
        }