Пример #1
0
        public static void SpawnThing(Thing a_thing, Player a_player)
        {
            switch (a_thing.m_type)
            {
            case ThingType.C_Cube:
                //Sets ze attackbehavior!!
                a_thing.m_attackBehavior = new StandardAttack(a_player.m_thingsAssets.m_cube.m_attackBehavior.GetAttackRate()
                                                              , a_player.m_thingsAssets.m_cube.m_attackBehavior.GetDamage()
                                                              , a_player.m_thingsAssets.m_cube.m_attackBehavior.GetAttackRange());
                //Sets the cubes moveBehavior!!
                a_thing.m_moveBehavior = a_player.m_thingsAssets.m_cube.m_moveBehavior;

                //a_thing.m_buildBehavior = BuildFactory.CreateNewStandardBuild(a_player,a_thing);
                a_thing.m_buildBehavior = BuildFactory.CreateNewVisibleBuild(a_player, a_thing, a_player.m_thingsAssets.m_cube.m_buildBehavior.GetBuildRange(), m_map, m_worldObjects);

                break;

            case ThingType.C_Extractor:
                Units.Cubes.Extractor f_extractor = (Units.Cubes.Extractor)a_thing;

                a_thing.m_buildBehavior = BuildFactory.CreateNewCSBuilder(a_player, a_thing, f_extractor.m_SoL);
                if (a_player.m_race == Races.Cubes)
                {
                    a_thing.m_buildBehavior.AddToBuildQueue(ThingType.C_Cube);
                }

                break;
            }
        }
Пример #2
0
        protected override async System.Threading.Tasks.Task InitializeAsync(CancellationToken cancellationToken, IProgress <ServiceProgressData> progress)
        {
            // Switches to the UI thread, which most of this package requires. Even joining the main thread here improves
            // the load time of the package, and it stops a warning popping up when you load vs2019 with the package installed.
            await JoinableTaskFactory.SwitchToMainThreadAsync(cancellationToken);

            await base.InitializeAsync(cancellationToken, progress);

            output = new OutputWindowWrapper(this);

            SettingsManager       settingsManager = new ShellSettingsManager(ServiceProvider.GlobalProvider);
            WritableSettingsStore settingsStore   = settingsManager.GetWritableSettingsStore(SettingsScope.UserSettings);

            Settings.Instance = new Settings(settingsStore);

            var factory    = new BuildFactory();
            var repository = new BuildRepository(Settings.Instance.RepositoryPath);

            monitor      = new BuildMonitor.Domain.Monitor(factory, repository);
            dataAdjuster = new DataAdjusterWithLogging(repository, output.WriteLine);

            //if invalid data, adjust it
            dataAdjuster.Adjust();


            // Get solution build manager
            sbm = ServiceProvider.GlobalProvider.GetService(typeof(SVsSolutionBuildManager)) as IVsSolutionBuildManager2;
            if (sbm != null)
            {
                sbm.AdviseUpdateSolutionEvents(this, out updateSolutionEventsCookie);
            }

            // Must hold a reference to the solution events object or the events wont fire, garbage collection related
            events         = GetDTE().Events.SolutionEvents;
            events.Opened += Solution_Opened;
            GetDTE().Events.BuildEvents.OnBuildBegin += Build_Begin;

            output.WriteLine("Build monitor initialized");
            output.WriteLine("Path to persist data: {0}", Settings.Instance.RepositoryPath);

            monitor.SolutionBuildFinished = b =>
            {
                output.Write("[{0}] Time Elapsed: {1} \t\t", b.SessionBuildCount, b.SolutionBuildTime.ToTime());
                output.WriteLine("Session build time: {0}\n", b.SessionMillisecondsElapsed.ToTime());
                output.WriteLine("Rebuild All: {0}\n", b.SolutionBuild.IsRebuildAll);
                //System.Threading.Tasks.Task.Factory.StartNew(() => SaveToDatabase(b));
            };

            monitor.ProjectBuildFinished = b => output.WriteLine(" - {0}\t-- {1} --", b.MillisecondsElapsed.ToTime(), b.ProjectName);

            // In vs 2017 and earlier, this event was always called, but in 2019 it isn't called if you open a solution on startup.
            // I imagine this is because the solution has already loaded before we connect to the events. To get over it we just
            // manually call the event here.
            Solution_Opened();

            AnalyseBuildTimesCommand.Initialize(this);
        }
Пример #3
0
        public BuildMonitorPackage()
        {
            Settings.CreateApplicationFolderIfNotExist();

            var factory    = new BuildFactory();
            var repository = new BuildRepository(Settings.RepositoryPath);

            monitor      = new Monitor(factory, repository);
            dataAdjuster = new DataAdjusterWithLogging(repository, PrintLine);
        }
        public BuildFacade(IBuildRepository buildBuildRepository = null)
        {
            buildBuildRepository ??= new InMemoryBuildRepository();

            buildFactory = new BuildFactory(buildBuildRepository);

            buildFactory.BuildCreatedEvent += OnBuildCreated;
            buildMonitor.StageUpdateEvent  += OnStageComplete;
            buildMonitor.BuildUpdateEvent  += OnBuildComplete;
        }
Пример #5
0
        protected override void Initialize()
        {
            base.Initialize();

            output = new OutputWindowWrapper(this);

            SettingsManager       settingsManager = new ShellSettingsManager(ServiceProvider.GlobalProvider);
            WritableSettingsStore settingsStore   = settingsManager.GetWritableSettingsStore(SettingsScope.UserSettings);

            Settings.Instance = new Settings(settingsStore);

            var factory    = new BuildFactory();
            var repository = new BuildRepository(Settings.Instance.RepositoryPath);

            monitor      = new Monitor(factory, repository);
            dataAdjuster = new DataAdjusterWithLogging(repository, output.WriteLine);

            //if invalid data, adjust it
            dataAdjuster.Adjust();


            // Get solution build manager
            sbm = ServiceProvider.GlobalProvider.GetService(typeof(SVsSolutionBuildManager)) as IVsSolutionBuildManager2;
            if (sbm != null)
            {
                sbm.AdviseUpdateSolutionEvents(this, out updateSolutionEventsCookie);
            }

            // Must hold a reference to the solution events object or the events wont fire, garbage collection related
            events         = GetDTE().Events.SolutionEvents;
            events.Opened += Solution_Opened;
            GetDTE().Events.BuildEvents.OnBuildBegin += Build_Begin;

            output.WriteLine("Build monitor initialized");
            output.WriteLine("Path to persist data: {0}", Settings.Instance.RepositoryPath);

            monitor.SolutionBuildFinished = b =>
            {
                output.Write("[{0}] Time Elapsed: {1} \t\t", b.SessionBuildCount, b.SolutionBuildTime.ToTime());
                output.WriteLine("Session build time: {0}\n", b.SessionMillisecondsElapsed.ToTime());
                output.WriteLine("Rebuild All: {0}\n", b.SolutionBuild.IsRebuildAll);
                //System.Threading.Tasks.Task.Factory.StartNew(() => SaveToDatabase(b));
            };

            monitor.ProjectBuildFinished = b => output.WriteLine(" - {0}\t-- {1} --", b.MillisecondsElapsed.ToTime(), b.ProjectName);
            AnalyseBuildTimesCommand.Initialize(this);
        }
Пример #6
0
    public BuildObj Build(Buildings buildingType)
    {
        string e  = buildingType.ToString();
        string ix = e + "_" + bIndex;

        if (!bDic.ContainsKey(e))
        {
            bDic.Add(e, new List <string>());
        }
        bDic[e].Add(ix);
        BuildObj obj = BuildFactory.BuildObj(ix);

        buildObjs.Add(ix, obj);
        bIndex++;

        return(obj);
    }
Пример #7
0
        public override void SpawnMe(Player a_player, Map a_map, PathFinder a_pathfinder)
        {
            //abilities

            //build extractor
            m_actionbox[0, 2] = new ObjectAction("Extractor",
                                                 "Cost: 15\nRequires a Spark of Life.\nExtractor will produce new Cubes until it out of resources",
                                                 Microsoft.Xna.Framework.Input.Keys.E,
                                                 ObjectAction.Type.Target,
                                                 BuildExtractorFunction);

            m_actionbox[0, 2].SetBuildingTag(a_player.m_thingsAssets.m_extractor.m_size, true, a_player.m_thingsAssets.m_extractor.m_price);

            //Build igloo
            m_actionbox[1, 2] = new ObjectAction("Igloo",
                                                 "Cost: 2\nBuilds an Igloo to increase your supply by 8",
                                                 Microsoft.Xna.Framework.Input.Keys.G,
                                                 ObjectAction.Type.Target,
                                                 BuildIglooFunction);

            m_actionbox[1, 2].SetBuildingTag(a_player.m_thingsAssets.m_igloo.m_size, false, a_player.m_thingsAssets.m_igloo.m_price);

            //Build barracks
            m_actionbox[2, 2] = new ObjectAction("Barrack",
                                                 "Costs: 5\nBuilds a barrack to produce more potent units",
                                                 Microsoft.Xna.Framework.Input.Keys.B,
                                                 ObjectAction.Type.Target,
                                                 BuildBarrackFunction);

            m_actionbox[2, 2].SetBuildingTag(a_player.m_thingsAssets.m_barrack.m_size, false, a_player.m_thingsAssets.m_barrack.m_price);

            m_attackBehavior = new StandardAttack(this, a_player.m_thingsAssets.m_cube.m_attackBehavior.GetAttackRate()
                                                  , a_player.m_thingsAssets.m_cube.m_attackBehavior.GetDamage()
                                                  , a_player.m_thingsAssets.m_cube.m_attackBehavior.GetAttackRange());
            //Sets the cubes moveBehavior!!
            m_moveBehavior = a_player.m_thingsAssets.m_cube.m_moveBehavior;

            //a_thing.m_buildBehavior = BuildFactory.CreateNewStandardBuild(a_player, a_thing);
            m_buildBehavior = BuildFactory.CreateNewVisibleBuild(a_player, this, a_player.m_thingsAssets.m_cube.m_buildBehavior.GetBuildRangeSquared(), a_map, a_pathfinder);
        }
Пример #8
0
        public CubesAssets(Player a_player, ViewClasses.GameAssets a_assets, Map a_map, PathFinder a_pathfinder)
        {
            m_ownerID = a_player.m_playerID;
            m_race    = a_player.m_race;

            m_cube = new Cube(m_ownerID, a_assets.c_cube, 10, 10, Vector3.Zero, 10, a_player.AddUnderAttackPosition);

            m_cube.m_moveBehavior   = MovementFactory.m_standardMovement;
            m_cube.m_attackBehavior = new StandardAttack(m_cube, 1, 1, 3);

            m_cube.m_buildBehavior = BuildFactory.CreateNewVisibleBuild(a_player, m_cube, 1, a_map, a_pathfinder);

            m_barbarian = new Barbarian(m_ownerID, a_assets.c_barbarian, 30, 30, Vector3.Zero, 10, a_player.AddUnderAttackPosition);

            m_barbarian.m_moveBehavior   = MovementFactory.m_standardMovement;
            m_barbarian.m_attackBehavior = AttackFactory.CreateNewStandardAttack(m_barbarian, 1, 5, 3);

            m_extractor = new Extractor(m_ownerID, a_assets.c_extractor, 500, 500, Vector3.Zero, a_player.AddUnderAttackPosition);

            m_igloo = new CubeIgloo(m_ownerID, a_assets.c_igloo, 100, 100, Vector3.Zero, a_player.AddUnderAttackPosition);

            m_barrack = new Barrack(m_ownerID, a_assets.c_barrack, 200, 200, Vector3.Zero, a_player.AddUnderAttackPosition);
        }