void FetchPlayer() { GameObject[] players = GameObject.FindGameObjectsWithTag("Player"); foreach (GameObject player in players) { PlayerInputHandler playerInput = player.GetComponent <PlayerInputHandler>(); if (playerInput != null) //players should always have a player input components { if (playerInput.controllerNumber == playerNumber) { target = player.GetComponent <StatsHandler>(); if (target == null) { Debug.Log("ERROR - Player " + playerNumber + " does not have a StatsHandler!"); } } } else { Debug.Log("ERROR - Player does not have an input component!"); } } }
private static void SetCharcterStatsRandomMulipliers(Character character) { for (int j = 0; j < character.stats.Length; j++) { StatsHandler.SetCurrentMultiplier(character.stats[j], Random.Range(-.1f, .1f), Time.time); } }
private static void SetCharcterStatsTreshholds(Character character) { for (int j = 0; j < character.stats.Length; j++) { StatsHandler.SetTreshhold(character.stats[j], Random.Range(0, 1f)); } }
// Inizialization void Start() { if (statsHandler == null) { statsHandler = GameObject.FindGameObjectWithTag("GameController").GetComponent <StatsHandler>();; } }
private void CastWithCost(GameObject caster, GameObject spell, bool movesWithCaster) { StatsHandler casterStats = caster.GetComponent <StatsHandler>(); //check for cooldown if (Time.time >= nextCast) { nextCast = Time.time + cooldownTime;//set nup next time for next cast //check if caster has enough mana and cast if they do, cast the spell if (casterStats.GetMana() >= manaCost) { //remove mana then cast casterStats.ChangeMana(-manaCost); InstatiateSpell(caster, spell, movesWithCaster); } else if (isBoodmagic && casterStats.GetHealth() + casterStats.GetMana() >= manaCost) { //remove mana and health then cast casterStats.ChangeHealth(-(manaCost - casterStats.GetMana()));//minus the extra needed casterStats.ChangeMana(-casterStats.GetMana()); InstatiateSpell(caster, spell, movesWithCaster); } } }
// Use this for initialization protected virtual void Start() { setName(); startTime = Time.time; stacks = 1; setLifetime(); stats = GetComponent <StatsHandler>(); }
void OnTriggerEnter(Collider other) { StatsHandler otherStats = other.GetComponent <StatsHandler>(); if (otherStats != null) { otherStats.moveSpeed -= slowAmount; } }
void OnTriggerExit(Collider other) //increases everyone's speed with chain lightning { StatsHandler otherStats = other.gameObject.GetComponent <StatsHandler>(); if (otherStats != null) { otherStats.moveSpeed += slowAmount; } }
internal void TickStats(float currentTime) { for (int i = 0; i < stats.Length; i++) { if (stats[i].ValueChangePerSecond != 0) { StatsHandler.Tick(stats[i], currentTime); } } }
public PlayWindow(WindowHandler windowHandler) { this._windowHandler = windowHandler; GoodCellList = new List <GoodCell>(); VirusList = new List <Virus>(); _levelParser = new LevelParser(this); _statsHandler = Shared.StatsHandler; mouseWatch.Start(); }
public void OnTriggerEnter(Collider other) { StatsHandler otherStats = other.gameObject.GetComponent <StatsHandler>(); Debug.Log(otherStats); if (otherStats != null) //if other object has stats { otherStats.AddElementalEffect(other.gameObject.AddComponent <E>()); } }
// Update is called once per frame void Update() { foreach (GameObject target in myTargeter.GetTargets()) { StatsHandler targetStats = target.GetComponent <StatsHandler>(); if (targetStats != null) { targetStats.ChangeHealth(hps * Time.deltaTime); } } }
private void Awake() { GameData.Instance.Data.LoadDataObjects(); PlayerController = FindObjectOfType <PlayerController>(); ThePlayer = FindObjectOfType <Player>(); GameObject scriptsObj = GameObject.Find("Scripts"); GameMusic = scriptsObj.AddComponent <GameMusicControl>(); Stats = GameData.Instance.Data.Stats; EventListener.OnDeath += OnDeath; }
public void Init() { TargetClosestPlayer(); playerStats = targetPlayer.GetComponent <StatsHandler>(); nav = GetComponent <NavMeshAgent>(); myStats = GetComponent <StatsHandler>(); nextAttackAt = 0; nav.speed = myStats.moveSpeed; }
//Trigger is activated first // Adds up to three enemy gameobject that got hit by main lightning void OnTriggerEnter(Collider other) { //if the gameObject's tag is the enemy StatsHandler otherStats = other.GetComponent <StatsHandler>(); if (other.tag == "Enemy" && otherStats != null) { if (!targetsMarked.Contains(other.gameObject) && chainUsed < chainLength) // if there are not repeats of enemies and no more than 3 enemies { chainUsed++; targetsMarked.Add(other.gameObject); //adds enemy to the list } } }
private void Start() { _dataHandler = GameData.Instance.Data.Stats; switch (AudioType) { case AudioTypes.Music: _enabled = _dataHandler.Settings.Music; break; case AudioTypes.SoundFx: _enabled = _dataHandler.Settings.Sfx; break; } }
void OnDisable() { List <GameObject> targets = myTargeter.GetTargets(); foreach (GameObject target in targets) { StatsHandler targetStats = target.GetComponent <StatsHandler>(); if (targetStats != null) { targetStats.moveSpeed += slowAmount; } } }
void Start() { characterController = GetComponent <CharacterController>(); if (characterController == null) { Debug.Log("Character Controller not found!"); } myStats = GetComponent <StatsHandler>(); if (myStats == null) { Debug.Log("Stats Handler not found!"); } }
public Skill(string skillName, string description = null, Dictionary <string, float> effectors = null) { Name = skillName; if (description == null) { Description = "No Description"; } else { Description = description; } Training = StatsHandler.CreateSingleStat(skillName + "_training"); Effectors = effectors; }
void Update() //called when the component is disabled or set to be destroyed //Get all targets { List <GameObject> targets = targeter.GetTargets(); foreach (GameObject target in targets) { if (target != null) //if target exists //if target has stats, apply damage { StatsHandler targetStats = target.GetComponent <StatsHandler>(); if (targetStats != null) { targetStats.ChangeHealth(-damagePerSec * Time.deltaTime); } } } }
/// <summary> /// /// </summary> public StatsSyncer( IOptions <IndexerSettings> configuration, ISyncOperations syncOperations, IStorageOperations storageOperations, IStorage storage, SyncConnection syncConnection, StatsHandler statsHandler, ILogger <StatsSyncer> logger) : base(configuration, logger) { log = logger; data = (MongoData)storage; this.statsHandler = statsHandler; this.storageOperations = storageOperations; // Only run the StatsSyncer every 5 minute. Delay = TimeSpan.FromMinutes(5); watch = Stopwatch.Start(); }
public void HookUp(Stat statToDisplay) { if (DisplayedStat != null) { DisplayedStat.OnValueChanged -= SetFiller; } DisplayedStat = statToDisplay; SetFiller(StatsHandler.Tick(DisplayedStat, Time.deltaTime)); NameText.text = statToDisplay.Name; if (statToDisplay.ValueChangePerSecond != 0) { isChanging = true; } SetTreshholdPosition(DisplayedStat.Threshhold); statToDisplay.OnThreshholdSet += SetTreshholdPosition; statToDisplay.OnValueChanged += SetFiller; }
//write the time of the player private void writeTimes(float timer) { string timerText = FloatToStringTime(timer); yourTimeText.text = "YOUR TIME: " + timerText; RecordTimer.SetActive(timer <= LevelInfo.levelInfo.recordTime); StatsHandler.statsHandler.saveScoreOnLevel(StatsHandler.statsHandler.getPlayerName(), timer); timesText.text = StatsHandler.statsHandler.getScoreOnLevel(); string timeToBeatText = FloatToStringTime(LevelInfo.levelInfo.recordTime); beatTimeText.text = "TIME TO BEAT: " + timeToBeatText; if (timer <= LevelInfo.levelInfo.recordTime) { StatsHandler.setTimeAchievement(); } }
private void Awake() { // Lazy load if (_instance != null && _instance != this) { Destroy(this.gameObject); } else { _instance = this; } cycleCounter = GameObject.Find("Text_Cycles").GetComponent <Text>(); walkedCounter = GameObject.Find("Text_Walked").GetComponent <Text>(); logs = GameObject.Find("Text_Logs").GetComponent <TextMeshProUGUI>(); scrollRect = GameObject.Find("Scroll_Logs").GetComponent <ScrollRect>(); // Setup Logging logs.text = " > Logger Awake"; log("StatsHandler Awake"); }
/// <summary> /// Initializes this instance. /// </summary> internal static void Initialize() { while (true) { Console.Write("[*] > "); string Input = Console.ReadLine(); if (!string.IsNullOrEmpty(Input)) { string[] Args = Input.Trim().Split(' '); if (Args[0] == "clear") { Console.Clear(); } else if (Args[0] == "exit") { ExitHandler.Run(Args); } else if (Args[0] == "player") { PlayerHandler.Handle(Args); } else if (Args[0] == "clan") { ClanHandler.Handle(Args); } else if (Args[0] == "stats") { StatsHandler.Handle(Args); } else if (Args[0] == "sound") { SoundHandler.Handle(Args); } } } }
public void LoadDataObjects() { // Create and load non-persistent objects var dataObject = new GameObject("DataObjects"); LevelData = dataObject.AddComponent <LevelDataControl>(); AbilityData = dataObject.AddComponent <AbilityControl>(); StoryData = dataObject.AddComponent <StoryEventControl>(); LevelData.Load(); AbilityData.Load(); StoryData.Load(); // Load persistent data, if not already loaded if (_bDataLoaded) { return; } Stats = new StatsHandler(); Stats.LoadStats(); _bDataLoaded = true; }
public MainWindow() : base(WindowType.Toplevel) { //Initialize the config files and check values. Config.Initialize(); // The config must be initialized before the handlers can be instantiated Checks = new ChecksHandler(); Launcher = new LauncherHandler(); Game = new GameHandler(); //Initialize the GTK UI this.Build(); // Set the initial launcher mode SetLauncherMode(ELauncherMode.Inactive, false); //set the window title Title = "Launchpad - " + Config.GetGameName(); ScrolledBrowserWindow.Add(Browser); ScrolledBrowserWindow.ShowAll(); IndicatorLabel.Text = LocalizationCatalog.GetString("Idle"); //First of all, check if we can connect to the FTP server. if (!Checks.CanPatch()) { MessageDialog dialog = new MessageDialog( null, DialogFlags.Modal, MessageType.Warning, ButtonsType.Ok, LocalizationCatalog.GetString("Failed to connect to the patch server. Please check your settings.")); dialog.Run(); dialog.Destroy(); IndicatorLabel.Text = LocalizationCatalog.GetString("Could not connect to server."); refreshAction1.Sensitive = false; } else { //if we can connect, proceed with the rest of our checks. if (ChecksHandler.IsInitialStartup()) { MessageDialog shouldInstallHereDialog = new MessageDialog( null, DialogFlags.Modal, MessageType.Question, ButtonsType.OkCancel, String.Format(LocalizationCatalog.GetString( "This appears to be the first time you're starting the launcher.\n" + "Is this the location where you would like to install the game?" + "\n\n{0}"), ConfigHandler.GetLocalDir() )); if (shouldInstallHereDialog.Run() == (int)ResponseType.Ok) { shouldInstallHereDialog.Destroy(); //yes, install here Console.WriteLine("Installing in current directory."); ConfigHandler.CreateUpdateCookie(); } else { shouldInstallHereDialog.Destroy(); //no, don't install here Console.WriteLine("Exiting..."); Environment.Exit(0); } } if (Config.ShouldAllowAnonymousStats()) { StatsHandler.SendUsageStats(); } // Load the changelog. Try a direct URL first, and a protocol-specific // implementation after. if (Launcher.CanAccessStandardChangelog()) { Browser.Open(Config.GetChangelogURL()); } else { Launcher.ChangelogDownloadFinished += OnChangelogDownloadFinished; Launcher.LoadFallbackChangelog(); } // If the launcher does not need an update at this point, we can continue checks for the game if (!Checks.IsLauncherOutdated()) { if (!Checks.IsGameInstalled()) { //if the game is not installed, offer to install it Console.WriteLine("Not installed."); SetLauncherMode(ELauncherMode.Install, false); } else { //if the game is installed (which it should be at this point), check if it needs to be updated if (Checks.IsGameOutdated()) { //if it does, offer to update it Console.WriteLine("Game is outdated or not installed"); SetLauncherMode(ELauncherMode.Update, false); } else { //if not, enable launching the game SetLauncherMode(ELauncherMode.Launch, false); } } } else { //the launcher was outdated. SetLauncherMode(ELauncherMode.Update, false); } } }
private void Start() { _stats = GameData.Instance.Data.Stats; GetMenuObjects(); InitialiseOptionsView(); }
void Start() { casterStats = gameObject.transform.parent.gameObject.GetComponent <StatsHandler>(); }
/// <summary> /// Creates a new instance of the <see cref="MainWindow"/> class. /// </summary> public MainWindow() : base(Gtk.WindowType.Toplevel) { // Initialize the GTK UI this.Build(); // Bind the handler events Game.ProgressChanged += OnModuleInstallationProgressChanged; Game.DownloadFinished += OnGameDownloadFinished; Game.DownloadFailed += OnGameDownloadFailed; Game.LaunchFailed += OnGameLaunchFailed; Game.GameExited += OnGameExited; Launcher.LauncherDownloadProgressChanged += OnModuleInstallationProgressChanged; Launcher.LauncherDownloadFinished += OnLauncherDownloadFinished; Launcher.ChangelogDownloadFinished += OnChangelogDownloadFinished; // Set the initial launcher mode SetLauncherMode(ELauncherMode.Inactive, false); // Set the window title Title = LocalizationCatalog.GetString("Launchpad - {0}", Config.GetGameName()); // Create a new changelog widget, and add it to the scrolled window this.Browser = new Changelog(this.browserWindow); browserWindow.ShowAll(); indicatorLabel.Text = LocalizationCatalog.GetString("Idle"); // First of all, check if we can connect to the patching service. if (!Checks.CanPatch()) { MessageDialog dialog = new MessageDialog( null, DialogFlags.Modal, MessageType.Warning, ButtonsType.Ok, LocalizationCatalog.GetString("Failed to connect to the patch server. Please check your settings.")); dialog.Run(); dialog.Destroy(); indicatorLabel.Text = LocalizationCatalog.GetString("Could not connect to server."); repairGameAction.Sensitive = false; } else { // TODO: Load this asynchronously // Load the game banner (if there is one) if (Config.GetPatchProtocol().CanProvideBanner()) { using (MemoryStream bannerStream = new MemoryStream()) { // Fetch the banner from the server Config.GetPatchProtocol().GetBanner().Save(bannerStream, ImageFormat.Png); // Load the image into a pixel buffer bannerStream.Position = 0; this.gameBanner.Pixbuf = new Pixbuf(bannerStream); } } // If we can connect, proceed with the rest of our checks. if (ChecksHandler.IsInitialStartup()) { Log.Info("This instance is the first start of the application in this folder."); MessageDialog shouldInstallHereDialog = new MessageDialog( null, DialogFlags.Modal, MessageType.Question, ButtonsType.OkCancel, LocalizationCatalog.GetString( "This appears to be the first time you're starting the launcher.\n" + "Is this the location where you would like to install the game?") + $"\n\n{ConfigHandler.GetLocalDir()}" ); if (shouldInstallHereDialog.Run() == (int)ResponseType.Ok) { shouldInstallHereDialog.Destroy(); // Yes, install here Log.Info("User accepted installation in this directory. Installing in current directory."); ConfigHandler.CreateLauncherCookie(); } else { shouldInstallHereDialog.Destroy(); // No, don't install here Log.Info("User declined installation in this directory. Exiting..."); Environment.Exit(2); } } if (Config.ShouldAllowAnonymousStats()) { StatsHandler.SendUsageStats(); } // Load the changelog. Try a direct URL first, and a protocol-specific // implementation after. if (LauncherHandler.CanAccessStandardChangelog()) { Browser.Navigate(Config.GetChangelogURL()); } else { Launcher.LoadFallbackChangelog(); } // If the launcher does not need an update at this point, we can continue checks for the game if (!Checks.IsLauncherOutdated()) { if (!Checks.IsPlatformAvailable(Config.GetSystemTarget())) { Log.Info($"The server does not provide files for platform \"{ConfigHandler.GetCurrentPlatform()}\". " + "A .provides file must be present in the platforms' root directory."); SetLauncherMode(ELauncherMode.Inactive, false); } else { if (!Checks.IsGameInstalled()) { // If the game is not installed, offer to install it Log.Info("The game has not yet been installed."); SetLauncherMode(ELauncherMode.Install, false); // Since the game has not yet been installed, disallow manual repairs this.repairGameAction.Sensitive = false; // and reinstalls this.reinstallGameAction.Sensitive = false; } else { // If the game is installed (which it should be at this point), check if it needs to be updated if (Checks.IsGameOutdated()) { // If it does, offer to update it Log.Info($"The game is outdated. \n\tLocal version: {Config.GetLocalGameVersion()}"); SetLauncherMode(ELauncherMode.Update, false); } else { // All checks passed, so we can offer to launch the game. Log.Info("All checks passed. Game can be launched."); SetLauncherMode(ELauncherMode.Launch, false); } } } } else { // The launcher was outdated. Log.Info($"The launcher is outdated. \n\tLocal version: {Config.GetLocalLauncherVersion()}"); SetLauncherMode(ELauncherMode.Update, false); } } }