示例#1
0
        public void Send(CommandType commandType, Vector3 targetPos, Unit targetUnit, bool queue)
        {
            _units.Clear();
            _units.AddRange(_selectionManager.SelectedUnits);

            var formation = FormationFactory.GetOrCreate(
                FormationSelector.GetFormationType(_units, targetPos, commandType));

            formation.Init(_units.Select(x => x.Navigation.Position), targetPos);

            int index = 0;

            foreach (var unit in _units)
            {
                if (!queue)
                {
                    unit.CommandProcessor.Clear();
                }

                var command = CommandFactory.GetOrCreate(commandType);
                command.Init(unit, formation.GetTargePos(index++), targetUnit);

                unit.CommandProcessor.Add(command);
            }

            //_lastFormation = formation;
            FormationFactory.Release(formation);
        }
示例#2
0
 public void Init()
 {
     _selectionManager = ManagerProvider.Instance.SelectionManager;
     CommandFactory    = new CommandFactory(ManagerProvider.Instance.TimeManager);
     FormationFactory  = new FormationFactory();
 }
示例#3
0
        public Game1()
        {
            graphics = new GraphicsDeviceManager(this);


            graphics.PreferredBackBufferWidth  = 800;
            graphics.PreferredBackBufferHeight = 600;
            Content.RootDirectory = "Content";

            MapHandler.GetInstance().SetDebug(false);

            m_TreeList = new List <TreeEntity>();
            //m_TreeList.Add(new TreeEntity(new Vector2(2 * 64, 4 * 64/4 )));
            //m_TreeList.Add(new TreeEntity(new Vector2(9 * 64 + 32, 7 * 64 / 4)));
            //m_TreeList.Add(new TreeEntity(new Vector2(0 * 64, 0 * 64 / 4)));
            //m_TreeList.Add(new TreeEntity(new Vector2(1 * 64, 10 * 64 / 4)));

            m_LumberMills = new List <LumberMill>();
            //m_LumberMills.Add(new LumberMill(new Vector2(8 * 64, 8 * 64/4)));

            m_mouseSource = new Rectangle(0, 0, 19, 19);

            m_TestLayer  = new MapLayer(new Vector2(m_LayerWidth, m_LayerHeight), new Vector2(64, 64));
            m_WaterLayer = new MapLayer(new Vector2(m_LayerWidth, m_LayerHeight), new Vector2(64, 64));

            GenerateRandomMap();

            //for (int i = 4; i < 6; i++)
            //{
            //    for (int j = 0; j < 22; j++)
            //        m_TestLayer.SetTileToSolid(i, j, m_bSetTilesToSolid);
            //}
            //m_TestLayer.SetTileToSolid(5, 21, false);
            //m_TestLayer.SetTileToSolid(4, 0, false);

            MapHandler.GetInstance().SetActiveLayer(m_TestLayer);
            SetTilesToSolid();

            m_TestTile = new MapTile(new Vector2(0, 0), 0, new Vector2(64, 64));


            m_GoblinList = new List <GoblinLumberjack>();
            m_Goblin     = new GoblinLumberjack(ENTITY_COLOR.RED, new Vector2(5 * 64, 12 * 64 / 4), DIRECTION.DOWN);

            m_GoblinList.Add((GoblinLumberjack)m_Goblin);

            m_GoblinList.Add(new GoblinLumberjack(ENTITY_COLOR.ORANGE,
                                                  MapHandler.GetInstance().GetTilePosition(new Vector2(0, 0)), DIRECTION.DOWN));

            m_GoblinList.Add(new GoblinLumberjack(ENTITY_COLOR.ORANGE,
                                                  MapHandler.GetInstance().GetTilePosition(new Vector2(0, 0)), DIRECTION.DOWN));

            m_GoblinList.Add(new GoblinLumberjack(ENTITY_COLOR.ORANGE,
                                                  MapHandler.GetInstance().GetTilePosition(new Vector2(0, 0)), DIRECTION.DOWN));

            m_GoblinList.Add(new GoblinLumberjack(ENTITY_COLOR.ORANGE,
                                                  MapHandler.GetInstance().GetTilePosition(new Vector2(0, 0)), DIRECTION.DOWN));

            GameEntity tempGobling;

            m_goblinSquad = new CompositeSquad(m_Goblin);
            tempGobling   = m_GoblinList[1];
            m_goblinSquad.AddSquad(new AtomicSquad(ref tempGobling));
            tempGobling = m_GoblinList[2];
            m_goblinSquad.AddSquad(new AtomicSquad(ref tempGobling));
            tempGobling = m_GoblinList[3];
            m_goblinSquad.AddSquad(new AtomicSquad(ref tempGobling));
            tempGobling = m_GoblinList[4];
            m_goblinSquad.AddSquad(new AtomicSquad(ref tempGobling));


            m_FormationList = new List <Formation>();
            m_FormationList.Add(FormationFactory.GetInstance().GetBoxFormation());
            m_FormationList.Add(FormationFactory.GetInstance().GetDiamondFormation());
            m_FormationList.Add(FormationFactory.GetInstance().GetFightingVFormation());
            m_FormationList.Add(FormationFactory.GetInstance().GetLineFormation());
            m_FormationList.Add(FormationFactory.GetInstance().GetShieldFormation());
            //((GoblinLumberjack)m_Goblin).SetTargetLumberMill(m_LumberMills[0]);
            m_goblinSquad.SetFormation(m_FormationList[m_currFormationIndex]);

            m_Goblin.SetEntitySpeed(new Vector2(1, 1));
            m_mapList = new List <List <int> >();
            m_mapList.Add(new List <int>()
            {
            });

            //List<Vector2> adjacents = MapHandler.GetInstance().GetAdjacentsToTile(new Vector2(5, 5));

            //for (int i = 0; i < adjacents.Count; i++)
            //{
            //    Console.WriteLine(adjacents[i]);
            //}

            //AStarPathFinder finder = new AStarPathFinder();
            //PathNode m_path = finder.FindPath(new Vector2(0, 0), new Vector2(3, 2));
            //AStarNode node = null;
            //if(m_path != null)
            //node = (AStarNode) m_path;

            //int counter = 0;
            //while (node != null)
            //{
            //    Console.WriteLine("" + counter + ": " + node.GetNodePosition());
            //    counter++;
            //    node = (AStarNode)node.GetNextNode();
            //}
        }