Esempio n. 1
0
    public void CreatePlayer()
    {
        player      = Instantiate(playerPrefab);
        player.name = "Player";
        player.transform.SetParent(mapContainer.transform);

        var controller = player.GetComponent <MapMovementController> ();

        controller.map                 = map;
        controller.tileSize            = tileSize;
        controller.tileActionCallback += TileActionCallback;

        var moveScript = Camera.main.GetComponent <MoveCamera> ();

        moveScript.target = player;

        controller.MoveTo(map.castleTile.id);

        playerActor = playerTemplate.Clone <Actor>();
        playerActor.ResetHealth();

        statsWindow        = windowManager.Open((int)Windows.StatsWindow - 1, false) as StatsWindow;
        statsWindow.target = playerActor;
        statsWindow.UpdateStats();
    }
Esempio n. 2
0
 private StatsWindow OpenStatsWindow()
 {
     statsWindow        = windowManager.Open((int)Windows.StatsWindow - 1, false) as StatsWindow;
     statsWindow.player = gameObject.GetComponent <Actor>();
     statsWindow.UpdateStats();
     return(statsWindow);
 }
Esempio n. 3
0
        /// <summary>
        /// Shows Stats Window (Total tiles used in a world.)
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void Stats_Click(object sender, RoutedEventArgs e)
        {
            SortedList <string, int> placed = new SortedList <string, int>();

            for (int i = 0; i < DB.TileMap.GetLength(0); i++)
            {
                for (int j = 0; j < DB.TileMap.GetLength(1); j++)
                {
                    if (AnyTileAt(DB, i, j))
                    {
                        foreach (var tile in DB.TileMap[i, j].Tiles)
                        {
                            if (Array.IndexOf(blacklist, tile.TileName) > -1)
                            {
                                continue;
                            }
                            else if (placed.ContainsKey(tile.TileName))
                            {
                                placed[tile.TileName]++;
                            }
                            else
                            {
                                placed.Add(tile.TileName, 1);
                            }
                        }
                    }
                }
            }
            StatsWindow statsWindow = new StatsWindow(placed);

            statsWindow.ShowDialog();
        }
Esempio n. 4
0
    private void OnDisable()
    {
        StatsWindow s = this.GetComponent <StatsWindow>();

        s.OnWindowDestroy -= CreateWindow;
        s.OnWindowDestroy -= InitializeSlots;
        s.OnWindowDestroy -= EnableControls;
    }
Esempio n. 5
0
        private void StatsButton_Click(object sender, RoutedEventArgs e)
        {
            SoundManager.PlayClickSound();

            var statsWindow = new StatsWindow();

            statsWindow.Show();
        }
Esempio n. 6
0
    static void Init()
    {
        StatsWindow window = (StatsWindow)EditorWindow.GetWindow(typeof(StatsWindow));

        Refresh();

        window.Show();
        //
    }
Esempio n. 7
0
        //====== private methods

        private void PaintStatsWindow(TextCanvas canvas)
        {
            var statsView = canvas.Slice(canvas.Size.AsRectangle.ChangeWidth(30));

            statsView.ClearColor(Color16.DarkBlue);

            var app         = new WindowAppearance(Color16.Black, Color16.Teal, Color16.Lime, true);
            var statsWindow = new StatsWindow(playerName, gameLogic.GetStatus(), statsView.Size, app);

            statsWindow.Paint(statsView, Point.Zero);
        }
Esempio n. 8
0
 public void Show()
 {
     if (StatsWindow.IsDisposed)
     {
         StatsWindow = new StatsWindow();
     }
     if (StatsWindow.chromiumWebBrowser == null)
     {
         StatsWindow.SetupBrowser();
     }
     StatsWindow.Show();
 }
Esempio n. 9
0
    private void Awake()
    {
        if (Instance == null)
        {
            Instance = this;
        }
        else
        {
            Destroy(this);
        }

        this.m_ReturnButton.onClick.AddListener(UIMenuNavigator.SwitchToMainMenuUI);
    }
Esempio n. 10
0
        private void ShowStats()
        {
            using (var scope = App.DiContainer.BeginLifetimeScope())
            {
                var statsViewModel = scope.Resolve <StatsViewModel>();
                statsViewModel.LoadStatsAsync();

                var statsWindow = new StatsWindow {
                    DataContext = statsViewModel
                };

                statsWindow.Show();
            }
        }
    public void StartBattle()
    {
        var monsterActor = monsterTemplate.Clone <Actor>();

        monsterActor.ResetHealth();

        statsWindow        = windowManager.Open((int)Windows.StatsWindow - 1, false) as StatsWindow;
        statsWindow.target = playerActor;
        statsWindow.UpdateStats();

        battleWindow = windowManager.Open((int)Windows.BattleWindow - 1, false) as BattleWindow;
        battleWindow.battleOverCallback += BattleOver;
        battleWindow.StartBattle(playerActor, monsterActor);
        togglePlayerMovement = false;
    }
Esempio n. 12
0
    public static void EndGame()
    {
        Destroy(Instance._mapInstance.gameObject);

        for (int i = Instance._playerList.Count - 1; i >= 0; i--)
        {
            Destroy(Instance._playerList[i]);
        }

        Instance._playerList.Clear();
        Instance._enemyList.Clear();

        UIMenuNavigator.SwitchToPostGameUI();
        StatsWindow.UpdateStats();
    }
Esempio n. 13
0
        /// <summary>
        /// Shows Stats Window (Total tiles used in a world.)
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void Stats_Click(object sender, RoutedEventArgs e)
        {
            SortedList<string, int> placed = new SortedList<string, int>();

            for (int i = 0; i < TileDB.Tiles.GetLength(0); i++)
            {
                for (int j = 0; j < TileDB.Tiles.GetLength(1); j++)
                {
                    if (TileDB.Tiles[i, j] != null)
                    {
                        if (TileDB.Tiles[i, j].bgName != null)
                        {
                            string itemName = TileDB.Tiles[i, j].bgName;
                            if (placed.ContainsKey(TileDB.Tiles[i, j].bgName))
                            {
                                placed[itemName]++;
                            }
                            else
                            {
                                placed.Add(itemName, 1);
                            }
                        }

                        if (TileDB.Tiles[i, j].blName != null)
                        {
                            string itemName = TileDB.Tiles[i, j].blName;

                            //Blacklist bedrock
                            if (Array.IndexOf(blacklist, TileDB.Tiles[i, j].blName) > -1)
                            {
                                continue;
                            }
                            else if (placed.ContainsKey(TileDB.Tiles[i, j].blName))
                            {
                                placed[itemName]++;
                            }
                            else
                            {
                                placed.Add(itemName, 1);
                            }
                        }
                    }
                }
            }
            StatsWindow statsWindow = new StatsWindow(placed);
            statsWindow.ShowDialog();

        }
    public void CreatePlayer()
    {
        playerActor = playerTemplate.Clone <Actor> ();

        playerActor.ResetHealth();

        statsWindow        = windowManager.Open((int)Windows.StatsWindow - 1, false) as StatsWindow;
        statsWindow.target = playerActor;

        statsWindow.UpdateStats();

        if (Application.isPlaying)
        {
            StartBattle();
            print("call StartBattle");
        }
    }
Esempio n. 15
0
        public void Init()
        {
            GameSession  = new GameSession();
            InputManager = new InputManager();
            Parameters   = new Parameters();

            Parameters.WidthOrHeightChanged += UpdateSize;

            MessageWindow = new MessageWindow(Parameters.MessageX, Parameters.MessageY, Parameters.MessageWidth, Parameters.MessageHeight, ConWindow.BorderType.Double);

            BindingsWindow  = new BindingsWindow(Parameters.BindingsX, Parameters.BindingsY, Parameters.BindingsWidth, Parameters.BindingsHeight, ConWindow.BorderType.Double);
            StatsWindow     = new StatsWindow(Parameters.StatsX, Parameters.StatsY, Parameters.StatsWidth, Parameters.StatsHeight, ConWindow.BorderType.Double);
            LocationWindow  = new LocationWindow(Parameters.LocationX, Parameters.LocationY, Parameters.LocationWidth, Parameters.LocationHeight, ConWindow.BorderType.Single);
            TravelWindow    = new TravelWindow(Parameters.TravelX, Parameters.TravelY, Parameters.TravelWidth, Parameters.TravelHeight, ConWindow.BorderType.Double);
            InventoryWindow = new InventoryWindow(Parameters.InventoryX, Parameters.InventoryY, Parameters.InventoryWidth, Parameters.InventoryHeight, ConWindow.BorderType.Double);

            // dev
            DeveloperWindow = new DeveloperWindow(Parameters.DeveloperX, Parameters.DeveloperY, Parameters.DeveloperWidth, Parameters.DeveloperHeight, ConWindow.BorderType.Double, Parameters.DeveloperHeight - 2, "DEV CONSOLE", true, false);
            DeveloperWindow.Add("Developer window successfuly initialized.");

            CurrentlyFocused = FocusableWindows.MainWindow;
        }
Esempio n. 16
0
    public void CreatePlayer()
    {
        // Instantiate player
        player = Instantiate(playerPrefab);
        // Name player
        player.name = "Player";
        // Set player parent
        player.transform.SetParent(mapContainer.transform);

        var controller = player.GetComponent <MapMovementController>();

        controller.map                 = map;
        controller.tileSize            = tileSize;
        controller.tileActionCallback += TileActionCallback;

        var moveScript = Camera.main.GetComponent <MoveCamera>();

        moveScript.target = player;

        controller.MoveTo(map.castleTile.id);

        playerActor = playerTemplate.Clone <Actor>();
        playerActor.ResetHealth();

        statsWindow        = windowManager.Open((int)Windows.StatsWindow - 1, false) as StatsWindow;
        statsWindow.target = playerActor;
        statsWindow.UpdateStats();

        //// get position of the castle tile
        //PosUtil.CalculatePos(map.castleTile.id, map.columns, out tmpX, out tmpY);

        //tmpX *= (int)tileSize.x;
        //tmpY *= -(int)tileSize.y;

        //// set player position on the map on top of the castle tile
        //player.transform.position = new Vector3(tmpX,tmpY, 0);
    }
 private void CreateStatsWindow()
 {
     if (statsWindow == null)
     {
         statsWindow = new StatsWindow();
         statsWindow.Show();
     }
 }
        /// <summary>
        /// Instantiate windows upon launch.
        /// </summary>
        public static void Initialize()
        {
            var gameWindow = new GameWindow(Constants.GameWidth, Constants.GameHeight)
            {
                IsFocused = true,
                IsVisible = true
            };

            Add(gameWindow);

            var characterWindow = new CharacterWindow(Constants.Windows.CharacterWidth, Constants.Windows.CharacterHeight)
            {
                IsVisible = false,
                IsFocused = false
            };

            Add(characterWindow);

            var statsWindow = new StatsWindow(Constants.Windows.StatsWidth, Constants.Windows.StatsHeight);

            Add(statsWindow);

            var inventoryWindow = new InventoryWindow(Constants.Windows.InventoryWidth, Constants.Windows.InventoryHeight)
            {
                IsVisible = false,
                IsFocused = false
            };

            Add(inventoryWindow);

            var previewWindow = new ItemPreviewWindow(Constants.Windows.ItemPreviewWidth, Constants.Windows.ItemPreviewHeight)
            {
                IsVisible = false,
                IsFocused = false
            };

            Add(previewWindow);

            var travelWindow = new TravelWindow(Constants.Windows.TravelWidth, Constants.Windows.TravelHeight)
            {
                IsVisible = false,
                IsFocused = false
            };

            Add(travelWindow);

            var messageWindow = new MessageWindow(Constants.Windows.MessageWidth, Constants.Windows.MessageHeight);

            Add(messageWindow);

            // Initialize last so all consoles are instantiated prior to creating keybinding bools for visibility
            var keybindingsWindow = new KeybindingsWindow(Constants.Windows.KeybindingsWidth, Constants.Windows.KeybindingsHeight);

            Add(keybindingsWindow);

            var generalKeybindingsWindow = new GeneralKeybindingsWindow(Constants.Windows.GeneralKeybindingsWidth, Constants.Windows.GeneralKeybindingsHeight);

            Add(generalKeybindingsWindow);

            var locationKeybindingsWindow = new LocationKeybindingsWindow(Constants.Windows.LocationKeybindingsWidth, Constants.Windows.LocationKeybindingsHeight);

            Add(locationKeybindingsWindow);

            var actionKeybindingsWindow = new ActionKeybindingsWindow(Constants.Windows.ActionKeybindingsWidth, Constants.Windows.ActionKeybindingsHeight);

            Add(actionKeybindingsWindow);


            // Action windows
            var choppingWindow = new ChoppingWindow(Constants.Windows.Actions.ChoppingWidth, Constants.Windows.Actions.ChoppingHeight)
            {
                IsVisible = false,
                IsFocused = false
            };

            Add(choppingWindow);

            var characterKeybindingsWindow = new CharacterKeybindingsWindow(Constants.Windows.CharacterKeybindingsWidth, Constants.Windows.CharacterKeybindingsHeight)
            {
                IsVisible = false
            };

            Add(characterKeybindingsWindow);

            IsInitialized = true;
        }
Esempio n. 19
0
 private StatsController()
 {
     StatsWindow = new StatsWindow();
 }
Esempio n. 20
0
        public void Start()
        {
            Register.Populate();
            //Run Menu/startup logic for starting a game/creating character

            Map = new ParseMapFromText().GetLevel;

            var gameplayWindow =
                new BorderedWindow("Gameplay", 5, 0, GameplayWindowWidth, GameplayWindowHeight, false, 1);

            var hpWindow          = new StatsWindow(0, 0, GameplayWindowWidth, 4, Player, 1);
            var atrWindow         = new AttrubitesWindow("Attributes", 0, GameplayWindowWidth, 24, 5, new Symbol(' '), true, Player);
            var combatStats       = new CombatStats("Combat Stats", 6, GameplayWindowWidth + 1, 23, 12, new Symbol(' '), true, Player);
            var borderUnderAtrWin = new TextLineWindow(5, GameplayWindowWidth, 24, Color4.White, Color4.Green, 5);

            borderUnderAtrWin.Update(new Symbol[] { });
            var turnCountWin = new TextLineWindow(ConsoleHeight - 1, 1, 15, Color4.White, Color4.Green, 2);

            turnCountWin.SetTextLine(Symbol.ParseString($"Turn: {TurnCounter}"), 0);

            var logWindow = new LogWindow("Log", 8, GameplayWindowWidth, 24, 20, 55);

            //LogWindow currently is not supported

            //Logger = logWindow;

            windowsManager.AddWindow(gameplayWindow);
            windowsManager.AddWindow(hpWindow);
            windowsManager.AddWindow(atrWindow);
            windowsManager.AddWindow(combatStats);
            windowsManager.AddWindow(borderUnderAtrWin);

            windowsManager.AddWindow(turnCountWin);
            windowsManager.AddWindow(inventoryWindow);
            windowsManager.AddWindow(EnemyInfoWindow);
            // WindowsManager.AddWindow(logWindow);
            visualization.UpdateGameplayWindow(gameplayWindow);
            hpWindow.Update();
            atrWindow.Update();

            visualization.PrintToConsole(windowsManager, console);
            var debugWindow1 = new Window("debug1", 0, 0, 70, 4, 10);
            var debugWindow2 = new Window("combatDebug", 5, GameplayWindowWidth, 23, 20, 10);

            if (Debug)
            {
                windowsManager.AddWindow(debugWindow1);
                windowsManager.AddWindow(debugWindow2);
            }


            // Finally, update the window until a key is pressed or the window is closed:
            while (console.WindowUpdate() && Run)
            {
                if (console.KeyPressed)
                {
                    //Handle player input

                    keyHandler.Handle(console.GetKey());

                    //Wake up enemies and setsup path
                    foreach (var enemy in Map.Enemies)
                    {
                        if (enemy.CanSee(Player.Location, math))
                        {
                            //Wake up enemies
                            if (!Map.AwakenedEnemies.Contains(enemy))
                            {
                                Map.AwakenedEnemies.Add(enemy);
                            }

                            enemy.UpdatePath(Player.Location, math);
                        }
                    }
                    //Enemy Activity
                    foreach (var enemy in Map.AwakenedEnemies)
                    {
                        //Checks if enemy can atack else it moves
                        if (enemy.Map.Neighbours(enemy.Location).Any(neighbour => neighbour.CordY == Player.Location.CordY && neighbour.CordX == Player.Location.CordX))
                        {
                            var successfulHit = combatManager.HandleAttack(enemy, Player);
                            if (successfulHit && !combatManager.OnePunchMode)
                            {
                                if (Player.Dead)
                                {
                                    Run = false;
                                }
                            }
                        }
                        else
                        {
                            //Simulates diffrent running speeds so the player can try and run from enemies
                            bool skipMovingTowardsPlayer = true;
                            int  movementScore           = enemy.Attributes.Agility + 1;

                            if (movementScore <= 0)
                            {
                                movementScore = 1;
                            }
                            else if (movementScore >= 10)
                            {
                                skipMovingTowardsPlayer = false;
                            }
                            else
                            {
                                skipMovingTowardsPlayer = movementScore < randomProvider.Next(10);
                            }

                            if (!skipMovingTowardsPlayer && enemy.MovementQueue.Count != 0 && movement.CanBeMovedTo(enemy.MovementQueue.Peek()))
                            {
                                movement.Move(enemy, enemy.MovementQueue.Dequeue());
                            }
                            else
                            {
                                movement.MoveRandom(enemy);
                            }
                            //else do nothing
                        }
                    }

                    TurnCounter++;
                    combatManager.MassRegenerate(Map.AwakenedEnemies, Engine.Player);

                    hpWindow.Update();
                    atrWindow.Update();

                    //logWindow.Update();
                    turnCountWin.SetTextLine(Symbol.ParseString($"Turn: {TurnCounter}"), 0);
                    visualization.UpdateGameplayWindow(gameplayWindow);

                    visualization.PrintToConsole(windowsManager, console);
                }
            }
        }
Esempio n. 21
0
 public StatsControler(Hero hero)
 {
     StatsWindow = new StatsWindow(hero);
     items       = new List <int>();
     this.hero   = hero;
 }
		public MainWindow(GameV2 game)
		{
		    _game = game;

			InitializeComponent();
			Trace.Listeners.Add(new TextBoxTraceListener(Options.OptionsTrackerLogging.TextBoxLog));


			Helper.MainWindow = this;
			//Config.Load();
			EnableMenuItems(false);


			try
			{
				if(File.Exists("HDTUpdate_new.exe"))
				{
					if(File.Exists("HDTUpdate.exe"))
						File.Delete("HDTUpdate.exe");
					File.Move("HDTUpdate_new.exe", "HDTUpdate.exe");
				}
			}
			catch(Exception e)
			{
				Logger.WriteLine("Error updating updater\n" + e);
			}
			try
			{
				//updater used pre v0.9.6
				if(File.Exists("Updater.exe"))
					File.Delete("Updater.exe");
			}
			catch(Exception e)
			{
				Logger.WriteLine("Error deleting Updater.exe\n" + e);
			}


			HsLogReaderV2.Create();

			var configVersion = string.IsNullOrEmpty(Config.Instance.CreatedByVersion) ? null : new Version(Config.Instance.CreatedByVersion);

			var currentVersion = Helper.GetCurrentVersion();
			var versionString = string.Empty;
			if(currentVersion != null)
			{
				versionString = string.Format("{0}.{1}.{2}", currentVersion.Major, currentVersion.Minor, currentVersion.Build);
				Help.TxtblockVersion.Text = "Version: " + versionString;

				// Assign current version to the config instance so that it will be saved when the config
				// is rewritten to disk, thereby telling us what version of the application created it
				Config.Instance.CreatedByVersion = currentVersion.ToString();
			}

			ConvertLegacyConfig(currentVersion, configVersion);

			if(Config.Instance.SelectedTags.Count == 0)
				Config.Instance.SelectedTags.Add("All");

			_foundHsDirectory = FindHearthstoneDir();

			if(_foundHsDirectory)
				_updatedLogConfig = UpdateLogConfigFile();

			//hearthstone, loads db etc - needs to be loaded before playerdecks, since cards are only saved as ids now
			_game.Reset();

			if(!Directory.Exists(Config.Instance.DataDir))
				Config.Instance.Reset("DataDirPath");

			SetupDeckListFile();
			DeckList.Load();

			// Don't load active deck if it's archived
			if(DeckList.Instance.ActiveDeck != null && DeckList.Instance.ActiveDeck.Archived)
				DeckList.Instance.ActiveDeck = null;

			UpdateDeckList(DeckList.Instance.ActiveDeck);

			SetupDefaultDeckStatsFile();
			DefaultDeckStats.Load();


			SetupDeckStatsFile();
			DeckStatsList.Load();

			_notifyIcon = new NotifyIcon
			{
				Icon = new Icon(@"Images/HearthstoneDeckTracker16.ico"),
				Visible = true,
				ContextMenu = new ContextMenu(),
				Text = "Hearthstone Deck Tracker v" + versionString
			};

			MenuItem startHearthstonMenuItem = new MenuItem("Start Launcher/Hearthstone", (sender, args) => StartHearthstoneAsync());
			startHearthstonMenuItem.Name = "startHearthstone";
			_notifyIcon.ContextMenu.MenuItems.Add(startHearthstonMenuItem);

			MenuItem useNoDeckMenuItem = new MenuItem("Use no deck", (sender, args) => UseNoDeckContextMenu());
			useNoDeckMenuItem.Name = "useNoDeck";
			_notifyIcon.ContextMenu.MenuItems.Add(useNoDeckMenuItem);

			MenuItem autoSelectDeckMenuItem = new MenuItem("Autoselect deck", (sender, args) => AutoDeckDetectionContextMenu());
			autoSelectDeckMenuItem.Name = "autoSelectDeck";
			_notifyIcon.ContextMenu.MenuItems.Add(autoSelectDeckMenuItem);

			MenuItem classCardsFirstMenuItem = new MenuItem("Class cards first", (sender, args) => SortClassCardsFirstContextMenu());
			classCardsFirstMenuItem.Name = "classCardsFirst";
			_notifyIcon.ContextMenu.MenuItems.Add(classCardsFirstMenuItem);

			_notifyIcon.ContextMenu.MenuItems.Add("Show", (sender, args) => ActivateWindow());
			_notifyIcon.ContextMenu.MenuItems.Add("Exit", (sender, args) => Close());
			_notifyIcon.MouseClick += (sender, args) =>
			{
				if(args.Button == MouseButtons.Left)
					ActivateWindow();
			};

			//create overlay
			Overlay = new OverlayWindow(_game) {Topmost = true};

			PlayerWindow = new PlayerWindow(_game,Config.Instance, _game.IsUsingPremade ? _game.PlayerDeck : _game.PlayerDrawn);
			OpponentWindow = new OpponentWindow(_game, Config.Instance, _game.OpponentCards);
			TimerWindow = new TimerWindow(Config.Instance);
			StatsWindow = new StatsWindow();

			if(Config.Instance.PlayerWindowOnStart)
				PlayerWindow.Show();
			if(Config.Instance.OpponentWindowOnStart)
				OpponentWindow.Show();
			if(Config.Instance.TimerWindowOnStartup)
				TimerWindow.Show();

			LoadConfig();
			if(!Config.Instance.NetDeckClipboardCheck.HasValue)
			{
				var path = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData),
				                        @"Google\Chrome\User Data\Default\Extensions\lpdbiakcpmcppnpchohihcbdnojlgeel");

				if(Directory.Exists(path))
				{
					Config.Instance.NetDeckClipboardCheck = true;
					Config.Save();
				}
			}

			if(!Config.Instance.RemovedNoteUrls)
				RemoveNoteUrls();
			if(!Config.Instance.ResolvedDeckStatsIssue)
				ResolveDeckStatsIssue();

			TurnTimer.Create(90);

			SortFilterDecksFlyout.HideStuffToCreateNewTag();
			TagControlEdit.OperationSwitch.Visibility = Visibility.Collapsed;
			TagControlEdit.GroupBoxSortingAllConstructed.Visibility = Visibility.Collapsed;
			TagControlEdit.GroupBoxSortingArena.Visibility = Visibility.Collapsed;

			FlyoutNotes.ClosingFinished += (sender, args) => DeckNotesEditor.SaveDeck();


			UpdateDbListView();

			_doUpdate = _foundHsDirectory;

			SelectDeck(DeckList.Instance.ActiveDeck, true);

			if(_foundHsDirectory)
				HsLogReaderV2.Instance.Start(_game);

			Helper.SortCardCollection(ListViewDeck.Items, Config.Instance.CardSortingClassFirst);
			DeckPickerList.PropertyChanged += DeckPickerList_PropertyChanged;
			DeckPickerList.UpdateDecks();
			DeckPickerList.UpdateArchivedClassVisibility();

			CopyReplayFiles();

			LoadHearthStats();

			UpdateOverlayAsync();
			UpdateAsync();

			BackupManager.Run();

			_initialized = true;

			PluginManager.Instance.LoadPlugins();
			Options.OptionsTrackerPlugins.Load();
			PluginManager.Instance.StartUpdateAsync();
		}
Esempio n. 23
0
        private void BouttonStatistiques_Click(object sender, RoutedEventArgs e)
        {
            StatsWindow statsWindow = new StatsWindow(this);

            statsWindow.ShowDialog();
        }
Esempio n. 24
0
		public MainWindow()
		{
			// Set working directory to path of executable
			Directory.SetCurrentDirectory(AppDomain.CurrentDomain.BaseDirectory);

			InitializeComponent();

			EnableMenuItems(false);

			try
			{
				if(File.Exists("Updater_new.exe"))
				{
					if(File.Exists("Updater.exe"))
						File.Delete("Updater.exe");
					File.Move("Updater_new.exe", "Updater.exe");
				}
			}
			catch
			{
				Logger.WriteLine("Error updating updater");
			}

			Helper.MainWindow = this;
			_configPath = Config.Load();
			HsLogReader.Create();

			var configVersion = string.IsNullOrEmpty(Config.Instance.CreatedByVersion)
				                    ? null
				                    : new Version(Config.Instance.CreatedByVersion);

			Version currentVersion;
			if(Config.Instance.CheckForUpdates)
			{
				currentVersion = Helper.CheckForUpdates(out NewVersion);
				_lastUpdateCheck = DateTime.Now;
			}
			else
				currentVersion = Helper.GetCurrentVersion();

			var versionString = string.Empty;
			if(currentVersion != null)
			{
				versionString = string.Format("{0}.{1}.{2}", currentVersion.Major, currentVersion.Minor, currentVersion.Build);
				Help.TxtblockVersion.Text = "Version: " + versionString;

				// Assign current version to the config instance so that it will be saved when the config
				// is rewritten to disk, thereby telling us what version of the application created it
				Config.Instance.CreatedByVersion = currentVersion.ToString();
			}

			ConvertLegacyConfig(currentVersion, configVersion);

			if(Config.Instance.SelectedTags.Count == 0)
				Config.Instance.SelectedTags.Add("All");

			if(Config.Instance.GenerateLog)
			{
				Directory.CreateDirectory("Logs");
				var listener = new TextWriterTraceListener(Config.Instance.LogFilePath);
				Trace.Listeners.Add(listener);
				Trace.AutoFlush = true;
			}

			_foundHsDirectory = FindHearthstoneDir();

			if(_foundHsDirectory)
				_updatedLogConfig = UpdateLogConfigFile();

			//hearthstone, loads db etc - needs to be loaded before playerdecks, since cards are only saved as ids now
			Game.Reset();

			_decksPath = Config.Instance.HomeDir + "PlayerDecks.xml";
			SetupDeckListFile();
			try
			{
				DeckList = XmlManager<Decks>.Load(_decksPath);
			}
			catch(Exception e)
			{
				MessageBox.Show(
					e.Message + "\n\n" + e.InnerException +
					"\n\n If you don't know how to fix this, please delete " + _decksPath +
					" (this will cause you to lose your decks).",
					"Error loading PlayerDecks.xml");
				Application.Current.Shutdown();
			}

			foreach(var deck in DeckList.DecksList)
				DeckPickerList.AddDeck(deck);

			SetupDeckStatsFile();
			DeckStatsList.Load();

			_notifyIcon = new NotifyIcon {Icon = new Icon(@"Images/HearthstoneDeckTracker.ico"), Visible = true, ContextMenu = new ContextMenu(), Text = "Hearthstone Deck Tracker v" + versionString};
			_notifyIcon.ContextMenu.MenuItems.Add("Show", (sender, args) => ActivateWindow());
			_notifyIcon.ContextMenu.MenuItems.Add("Exit", (sender, args) => Close());
			_notifyIcon.MouseClick += (sender, args) => { if(args.Button == MouseButtons.Left) ActivateWindow(); };

			//create overlay
			Overlay = new OverlayWindow {Topmost = true};

			PlayerWindow = new PlayerWindow(Config.Instance, Game.IsUsingPremade ? Game.PlayerDeck : Game.PlayerDrawn);
			OpponentWindow = new OpponentWindow(Config.Instance, Game.OpponentCards);
			TimerWindow = new TimerWindow(Config.Instance);
			StatsWindow = new StatsWindow();

			if(Config.Instance.PlayerWindowOnStart)
				PlayerWindow.Show();
			if(Config.Instance.OpponentWindowOnStart)
				OpponentWindow.Show();
			if(Config.Instance.TimerWindowOnStartup)
				TimerWindow.Show();
			if(!DeckList.AllTags.Contains("All"))
			{
				DeckList.AllTags.Add("All");
				WriteDecks();
			}
			if(!DeckList.AllTags.Contains("Arena"))
			{
				DeckList.AllTags.Add("Arena");
				WriteDecks();
			}
			if(!DeckList.AllTags.Contains("Constructed"))
			{
				DeckList.AllTags.Add("Constructed");
				WriteDecks();
			}

			Options.ComboboxAccent.ItemsSource = ThemeManager.Accents;
			Options.ComboboxTheme.ItemsSource = ThemeManager.AppThemes;
			Options.ComboboxLanguages.ItemsSource = Helper.LanguageDict.Keys;

			Options.ComboboxKeyPressGameStart.ItemsSource = EventKeys;
			Options.ComboboxKeyPressGameEnd.ItemsSource = EventKeys;

			LoadConfig();

			FillElementSorters();

			//this has to happen before reader starts
			var lastDeck = DeckList.DecksList.FirstOrDefault(d => d.Name == Config.Instance.LastDeck);
			DeckPickerList.SelectDeck(lastDeck);

			TurnTimer.Create(90);

			SortFilterDecksFlyout.HideStuffToCreateNewTag();
			TagControlEdit.OperationSwitch.Visibility = Visibility.Collapsed;
			TagControlEdit.PnlSortDecks.Visibility = Visibility.Collapsed;


			UpdateDbListView();

			_doUpdate = _foundHsDirectory;
			UpdateOverlayAsync();

			_initialized = true;
			Options.MainWindowInitialized();

			DeckPickerList.UpdateList();
			if(lastDeck != null)
			{
				DeckPickerList.SelectDeck(lastDeck);
				UpdateDeckList(lastDeck);
				UseDeck(lastDeck);
			}

			if(_foundHsDirectory)
				HsLogReader.Instance.Start();

			Helper.SortCardCollection(ListViewDeck.Items, Config.Instance.CardSortingClassFirst);
			DeckPickerList.SortDecks();
		}
Esempio n. 25
0
    // Update is called once per frame
    void Update()
    {
        this.pv = GetComponent <PhotonView>();
        if (this.pv.isMine && !this.isNexus)
        {
            // Regeneracio manà
            this.time += Time.deltaTime;
            if (this.time >= 1)
            {
                // Si és un campió recuperarà manà, vida i sumarà or
                if (isChampion && unidad != null)
                {
                    this.time = 0;
                    this.ModifyMana(this.unidad.GetManaRegen());
                    this.ModifyHealth(this.unidad.GetHealthRegen(), false, 0, this.gameObject.name);
                    this.unidad.SetGold(this.unidad.GetGold() + 10);
                    goldText.text = this.unidad.GetGold().ToString();
                }
            }
            // Skills Input
            if (Input.GetButtonDown("Fire2"))
            {
                if (this.mr_skill != null)
                {
                    if (this.mr_skill.GetManaCost() <= this.mana)
                    {
                        if (this.mr_skill.Execute(DamageAbility(this.mr_skill)))
                        {
                            this.ModifyMana(-this.mr_skill.GetManaCost());
                        }
                    }
                }
            }
            else if (Input.GetKeyDown(KeyCode.Q))
            {
                if (this.q_skill != null)
                {
                    if (this.q_skill.GetManaCost() <= this.mana)
                    {
                        if (this.q_skill.Execute(DamageAbility(this.q_skill)))
                        {
                            this.ModifyMana(-this.q_skill.GetManaCost());
                        }
                    }
                }
            }
            else if (Input.GetKeyDown(KeyCode.E))
            {
                if (this.e_skill != null)
                {
                    if (this.e_skill.GetManaCost() <= this.mana)
                    {
                        if (this.e_skill.Execute(DamageAbility(this.e_skill)))
                        {
                            this.ModifyMana(-this.e_skill.GetManaCost());
                            if (this.animations != null)
                            {
                                //this.animations.Play("attack");
                            }
                        }
                    }
                }
            }
            else if (Input.GetKeyDown(KeyCode.B))
            {
                if (this.b_skill != null)
                {
                    if (this.b_skill.GetManaCost() <= this.mana)
                    {
                        if (this.b_skill.Execute(DamageAbility(this.b_skill)))
                        {
                            this.tornadaBase = true;
                            this.pv.RPC("ModifyHealth", PhotonTargets.All, unidad.GetMaxHealth(), false, 0, this.gameObject.name);
                            this.ModifyMana(unidad.GetMaxMana());
                        }
                    }
                }
            }
            else if (Input.GetKeyDown(KeyCode.P))
            {
                if (pv.isMine)
                {
                    ShopManager shopGO = netManager.shopManager;
                    if (!this.shopOpened)
                    {
                        shopOpened = true;
                        shopGO.gameObject.SetActive(true);
                    }
                    else
                    {
                        shopOpened = false;
                        shopGO.gameObject.SetActive(false);
                    }
                }
            }
            else if (Input.GetKeyDown(KeyCode.Tab))
            {
                if (pv.isMine)
                {
                    StatsWindow statsWindow = netManager.statsWindow;
                    if (!this.StatsOpened)
                    {
                        StatsOpened         = true;
                        statsWindow.AD.text = this.unidad.GetAtackDamage().ToString();
                        statsWindow.AP.text = this.unidad.GetAbilityPower().ToString();
                        statsWindow.AV.text = this.unidad.GetAtackSpeed().ToString();
                        statsWindow.RV.text = this.unidad.GetHealthRegen().ToString();
                        statsWindow.RM.text = this.unidad.GetManaRegen().ToString();
                        statsWindow.A.text  = this.unidad.GetArmour().ToString();
                        statsWindow.MR.text = this.unidad.GetMagicArmour().ToString();
                        statsWindow.gameObject.SetActive(true);
                    }
                    else
                    {
                        StatsOpened = false;
                        statsWindow.gameObject.SetActive(false);
                    }
                }
            }
        }

        if (this.mr_skill != null)
        {
            this.mr_skill.SetPhotonView(this.pv);
            this.mr_skill.SetCombatSystem(this);
        }
        if (this.q_skill != null)
        {
            this.q_skill.SetPhotonView(this.pv);
            this.q_skill.SetCombatSystem(this);
        }
        if (this.e_skill != null)
        {
            this.e_skill.SetPhotonView(this.pv);
            this.e_skill.SetCombatSystem(this);
        }
        if (this.b_skill != null)
        {
            this.b_skill.SetPhotonView(this.pv);
            this.b_skill.SetCombatSystem(this);
        }

        // IA dels monstres
        if (this.isMonster)
        {
            if (jugadorEnemic != null && this.unidad != null)
            {
                if (this.unidad.GetHealth() != this.unidad.GetMaxHealth() && !this.mort)
                {
                    PhotonView targetPV = jugadorEnemic.GetComponent <PhotonView>();
                    //rotate to look at player
                    if (!playerInTerritory)
                    {
                        transform.LookAt(jugadorEnemic.gameObject.transform.position);
                        transform.Rotate(new Vector3(0, -90, 0), Space.Self);

                        //move towards player
                        if (Vector3.Distance(transform.position, jugadorEnemic.gameObject.transform.position) < 10)
                        {
                            transform.Translate(new Vector3(4 * Time.deltaTime, 0, 0));

                            if (Time.time > elapsedTime)
                            {
                                targetPV.RPC("ModifyHealth", PhotonTargets.All, -1 * unidad.GetAtackDamage(), true, 1, this.gameObject.name);
                                animations.Stop();
                                animations.Play("Attack");
                                elapsedTime = Time.time + AttackInterval;
                            }
                        }
                        else
                        {
                            playerInTerritory  = false;
                            transform.rotation = initialRotation;
                            transform.position = initialPos;
                            this.pv.RPC("ModifyHealth", PhotonTargets.All, this.unidad.GetMaxHealth(), false, 0, this.gameObject.name);
                            animations.Stop();
                            animations.Play("Idle");
                        }
                    }
                    else
                    {
                        transform.Translate(new Vector3(4 * Time.deltaTime, 0, 0));
                    }
                    targetPV.RPC("MoureMonstre", PhotonTargets.All, gameObject.tag, transform.position.x, transform.position.y, transform.position.z);
                }
            }
        }
        if (this.isTorre)
        {
            if (this.unidad != null)
            {
                if (playerInTower)
                {
                    if (jugadorEnemic != null)
                    {
                        PhotonView targetPV = jugadorEnemic.GetComponent <PhotonView>();
                        if (targetActual == null)
                        {
                            atacTorre.GetComponent <MeshRenderer>().enabled = false;
                            targetActual = targetPV;
                            targetActual.RPC("CanviarVariable", PhotonTargets.All, targetPV.gameObject.name);
                        }
                        else
                        {
                            if (Time.time > elapsedTimeTower)
                            {
                                atacTorre.GetComponent <MeshRenderer>().enabled = true;
                                targetActual.RPC("ModifyHealth", PhotonTargets.All, -1 * unidad.GetAtackDamage(), true, 1, this.gameObject.name);
                                elapsedTimeTower = Time.time + AttackInterval;
                            }
                        }
                    }

                    if (unidad.GetHealth() <= 0)
                    {
                        atacTorre.GetComponent <MeshRenderer>().enabled = false;
                        playerInTower = false;
                        targetActual  = null;
                    }
                }
                else
                {
                    atacTorre.GetComponent <MeshRenderer>().enabled = false;
                    targetActual = null;
                    Debug.Log("Jugador fora torre");
                }
            }
        }
    }