public void SetupPlayer(HealthStats stats) { currentControl = input.currentControlScheme; stats.SetupBehaviour(); anim.SetupBehaviour(); health = stats; }
public void SpawnPlayer() { Vector3 spawnPoint = Camera.main.transform.position + Camera.main.transform.forward * 10; Network.Instantiate(selectedPlayer, spawnPoint, Quaternion.identity, 0); TutorialManager tutorialManager = gameObject.GetComponent <TutorialManager> (); tutorialManager.StartTutorial(selectedPlayer.name); int playerID; if (selectedPlayer.name.Contains("Syphen")) { playerID = 0; } else { playerID = 1; } HealthBar hb = GameObject.Find("HealthBar").GetComponent <HealthBar> (); hb.StartHealthBar(playerID); HealthStats hs = GameObject.Find("HealthStats").GetComponent <HealthStats> (); hs.StartStats(playerID); this.enabled = false; }
public void Init() { stats = Utilities.CheckScriptableObject <HealthStats>(stats); Amount = stats.startingHealth; Shield = stats.startingShield; Armor = stats.startingArmor; }
private void Awake() { enemySpawnRate = 1 / enemySpawnRate; isRunning = true; gameOverCanvas.enabled = false; MoneyStats = new MoneyStats(1000, moneyText); HealthStats = new HealthStats(5, healthText); }
public void Init() { // foreach (var obj in healthObjects) // { // obj.Init(); // } stats = Utilities.CheckScriptableObject <HealthStats>(stats); health = stats.startingHealth; shield = stats.startingShield; armor = stats.startingArmor; }
// Use this for initialization void Start() { if (FloatStats == null) { InitFloatStats(); } StatMutators = new Dictionary <ActorStatsDeclaration, StatMutatorBus>(); FloatStatsForThisUpdate = new ActorStatsToFloatDictionary(); //new Dictionary<ActorStatsDeclaration, float>(); Movement = new MovementStats(StatMutators, FloatStatsForThisUpdate); Health = new HealthStats(StatMutators, FloatStatsForThisUpdate); Combat = new CombatStats(FloatStats, StatMutators, FloatStatsForThisUpdate); Experience = new ExperienceStats(StatMutators, FloatStatsForThisUpdate); }
// Use this for initialization void Start() { _healthStats = GetComponentInParent <HealthStats>(); if (_healthStats == null) { Debug.LogError("Could not find health stats"); } var childLineRenderers = GetComponentsInChildren <LineRenderer>(true); if (childLineRenderers.Count() != 2) { throw new Exception("There should be exactly 2 LineRenderes in Children. Found " + childLineRenderers.Count()); } _greenBar = childLineRenderers[0]; _redGround = childLineRenderers[1]; }
void Start() { stats = GetComponent <HealthStats>(); shields = stats.gameObject.GetComponent <HealthStats>().shieldObject.GetComponent <Shields>(); }
private void ResetStats() { healthStats = new HealthStats(); }
public async Task <CommandProcessorClusterUpgradeDescription> GetClusterUpgradeDescriptionAsync(PaasClusterUpgradePolicy paasUpgradePolicy, ClusterHealth currentClusterHealth, CancellationToken token) { if (paasUpgradePolicy == null) { return(null); } CommandProcessorClusterUpgradeDescription upgradeDescription = new CommandProcessorClusterUpgradeDescription() { ForceRestart = paasUpgradePolicy.ForceRestart, HealthCheckRetryTimeout = paasUpgradePolicy.HealthCheckRetryTimeout, HealthCheckStableDuration = paasUpgradePolicy.HealthCheckStableDuration, HealthCheckWaitDuration = paasUpgradePolicy.HealthCheckWaitDuration, UpgradeDomainTimeout = paasUpgradePolicy.UpgradeDomainTimeout, UpgradeReplicaSetCheckTimeout = paasUpgradePolicy.UpgradeReplicaSetCheckTimeout, UpgradeTimeout = paasUpgradePolicy.UpgradeTimeout, }; if (paasUpgradePolicy.HealthPolicy == null && paasUpgradePolicy.DeltaHealthPolicy == null) { return(upgradeDescription); } upgradeDescription.HealthPolicy = new CommandProcessorClusterUpgradeHealthPolicy(); var paasHealthPolicy = paasUpgradePolicy.HealthPolicy; if (paasHealthPolicy != null) { upgradeDescription.HealthPolicy.MaxPercentUnhealthyApplications = paasHealthPolicy.MaxPercentUnhealthyApplications; upgradeDescription.HealthPolicy.MaxPercentUnhealthyNodes = paasHealthPolicy.MaxPercentUnhealthyNodes; if (paasHealthPolicy.ApplicationHealthPolicies != null) { upgradeDescription.HealthPolicy.ApplicationHealthPolicies = paasHealthPolicy.ApplicationHealthPolicies.ToDictionary( keyValuePair => keyValuePair.Key, KeyValuePair => KeyValuePair.Value.ToCommondProcessorServiceTypeHealthPolicy()); } } var paasDeltaHealthPolicy = paasUpgradePolicy.DeltaHealthPolicy; if (paasDeltaHealthPolicy != null) { upgradeDescription.DeltaHealthPolicy = new CommandProcessorClusterUpgradeDeltaHealthPolicy() { MaxPercentDeltaUnhealthyNodes = paasDeltaHealthPolicy.MaxPercentDeltaUnhealthyNodes, MaxPercentUpgradeDomainDeltaUnhealthyNodes = paasDeltaHealthPolicy.MaxPercentUpgradeDomainDeltaUnhealthyNodes }; if (paasDeltaHealthPolicy.MaxPercentDeltaUnhealthyApplications == 100) { upgradeDescription.HealthPolicy.MaxPercentUnhealthyApplications = paasDeltaHealthPolicy.MaxPercentDeltaUnhealthyApplications; } else { int totalAppCount = 0, unhealthyAppCount = 0; if (currentClusterHealth == null) { upgradeDescription.HealthPolicy.MaxPercentUnhealthyApplications = 0; Trace.WriteWarning( TraceType, "currentClusterHealth is null. Setting MaxPercentUnhealthyApplications conservatively to 0"); } else if (currentClusterHealth.ApplicationHealthStates != null) { var filteredAppHealthStates = currentClusterHealth.ApplicationHealthStates.Where( appHealthState => { if (appHealthState.ApplicationName.OriginalString.Equals("fabric:/System", StringComparison.OrdinalIgnoreCase)) { return(false); } if (paasHealthPolicy != null && paasHealthPolicy.ApplicationHealthPolicies != null && paasHealthPolicy.ApplicationHealthPolicies.ContainsKey(appHealthState.ApplicationName.OriginalString)) { return(false); } if (paasDeltaHealthPolicy.ApplicationDeltaHealthPolicies != null && paasDeltaHealthPolicy.ApplicationDeltaHealthPolicies.ContainsKey(appHealthState.ApplicationName.OriginalString)) { return(false); } return(true); }); unhealthyAppCount = filteredAppHealthStates.Count(health => health.AggregatedHealthState == HealthState.Error); totalAppCount = filteredAppHealthStates.Count(); upgradeDescription.HealthPolicy.MaxPercentUnhealthyApplications = CommandParameterGenerator.GetMaxUnhealthyPercentage( unhealthyAppCount, totalAppCount, paasDeltaHealthPolicy.MaxPercentDeltaUnhealthyApplications); } Trace.WriteInfo( TraceType, "Delta health policy is specified. MaxPercentUnhealthyApplications is overwritten to {0}. TotalApps={1}, UnhealthyApps={2}, MaxPercentDeltaUnhealthyApplications={3}.", upgradeDescription.HealthPolicy.MaxPercentUnhealthyApplications, totalAppCount, unhealthyAppCount, paasDeltaHealthPolicy.MaxPercentDeltaUnhealthyApplications); } if (paasDeltaHealthPolicy.ApplicationDeltaHealthPolicies != null) { foreach (var applicationDeltaHealthPolicy in paasDeltaHealthPolicy.ApplicationDeltaHealthPolicies) { var applicationName = applicationDeltaHealthPolicy.Key; var paasApplicationDeltaHealthPolicy = applicationDeltaHealthPolicy.Value; if (paasApplicationDeltaHealthPolicy.DefaultServiceTypeDeltaHealthPolicy == null && paasApplicationDeltaHealthPolicy.SerivceTypeDeltaHealthPolicies == null) { // no policy provided continue; } ApplicationHealthState matchingHealthState = null; if (currentClusterHealth != null) { matchingHealthState = currentClusterHealth.ApplicationHealthStates.FirstOrDefault( appHealthState => appHealthState.ApplicationName.OriginalString.Equals(applicationName, StringComparison.OrdinalIgnoreCase)); } if (matchingHealthState == null) { Trace.WriteWarning( TraceType, "Application {0} is not found in the current cluster health. Ignoring the application since delta policy cannot be computed.", applicationName); // the application is not found in the cluster continue; } Dictionary <string, CommandProcessorServiceTypeHealthPolicy> commandProcessorServiceTypeHealthPolicies = new Dictionary <string, CommandProcessorServiceTypeHealthPolicy>(); var serviceList = await this.fabricClientWrapper.GetServicesAsync(matchingHealthState.ApplicationName, Constants.MaxOperationTimeout, token); // Compute the total and unhealthy services by ServiceType for this application Dictionary <string, HealthStats> serviceTypeHealthStatsDictionary = new Dictionary <string, HealthStats>(); foreach (var service in serviceList) { HealthStats serviceTypeHealthstats; if (!serviceTypeHealthStatsDictionary.TryGetValue(service.ServiceTypeName, out serviceTypeHealthstats)) { serviceTypeHealthstats = new HealthStats(); serviceTypeHealthStatsDictionary.Add(service.ServiceTypeName, serviceTypeHealthstats); } if (service.HealthState == HealthState.Error) { serviceTypeHealthstats.UnhealthyCount++; } serviceTypeHealthstats.TotalCount++; } // For each service type specific healthy policy provided, compute the delta health policy if (paasApplicationDeltaHealthPolicy.SerivceTypeDeltaHealthPolicies != null) { foreach (var serviceTypeHealthPolicyKeyValue in paasApplicationDeltaHealthPolicy.SerivceTypeDeltaHealthPolicies) { var serviceTypeName = serviceTypeHealthPolicyKeyValue.Key; var serviceTypeDeltaPolicy = serviceTypeHealthPolicyKeyValue.Value; HealthStats stats; if (serviceTypeHealthStatsDictionary.TryGetValue(serviceTypeName, out stats)) { byte maxUnhealthyPercentage = CommandParameterGenerator.GetMaxUnhealthyPercentage(stats.UnhealthyCount, stats.TotalCount, serviceTypeDeltaPolicy.MaxPercentDeltaUnhealthyServices); commandProcessorServiceTypeHealthPolicies.Add( serviceTypeName, new CommandProcessorServiceTypeHealthPolicy() { MaxPercentUnhealthyServices = maxUnhealthyPercentage }); Trace.WriteInfo( TraceType, "Delta health policy is specified for ServiceType {0} in Application {1}. MaxPercentUnhealthyServices is overwritten to {2}. TotalCount={3}, UnhealthyCount={4}, MaxPercentDeltaUnhealthyServices={5}.", serviceTypeName, applicationName, maxUnhealthyPercentage, stats.TotalCount, stats.UnhealthyCount, serviceTypeDeltaPolicy.MaxPercentDeltaUnhealthyServices); } else { Trace.WriteWarning( TraceType, "ServiceType {0} in Application {1} is not found in the current application. Ignoring the ServiceType since delta policy cannot be computed.", serviceTypeName, applicationName); continue; } } } // If default service type delta policy is specified, compute the delta health policy for ServiceType // which does not have an explicit policy if (paasApplicationDeltaHealthPolicy.DefaultServiceTypeDeltaHealthPolicy != null) { foreach (var serviceTypeHealthStatsKeyValue in serviceTypeHealthStatsDictionary) { var serviceTypeName = serviceTypeHealthStatsKeyValue.Key; var serviceTypeHealthStats = serviceTypeHealthStatsKeyValue.Value; if (commandProcessorServiceTypeHealthPolicies.ContainsKey(serviceTypeName)) { // Explicit policy has been specified continue; } byte maxUnhealthyPercentage = CommandParameterGenerator.GetMaxUnhealthyPercentage( serviceTypeHealthStats.UnhealthyCount, serviceTypeHealthStats.TotalCount, paasApplicationDeltaHealthPolicy.DefaultServiceTypeDeltaHealthPolicy.MaxPercentDeltaUnhealthyServices); commandProcessorServiceTypeHealthPolicies.Add( serviceTypeName, new CommandProcessorServiceTypeHealthPolicy() { MaxPercentUnhealthyServices = maxUnhealthyPercentage }); Trace.WriteInfo( TraceType, "Using default delta health policy for ServiceType {0} in Application {1}. MaxPercentUnhealthyServices is overwritten to {2}. TotalCount={3}, UnhealthyCount={4}, MaxPercentDeltaUnhealthyServices={5}.", serviceTypeName, applicationName, maxUnhealthyPercentage, serviceTypeHealthStats.UnhealthyCount, serviceTypeHealthStats.UnhealthyCount, paasApplicationDeltaHealthPolicy.DefaultServiceTypeDeltaHealthPolicy.MaxPercentDeltaUnhealthyServices); } } if (commandProcessorServiceTypeHealthPolicies.Any()) { if (upgradeDescription.HealthPolicy.ApplicationHealthPolicies == null) { upgradeDescription.HealthPolicy.ApplicationHealthPolicies = new Dictionary <string, CommandProcessorApplicationHealthPolicy>(); } CommandProcessorApplicationHealthPolicy applicationHealthPolicy; if (!upgradeDescription.HealthPolicy.ApplicationHealthPolicies.TryGetValue(applicationName, out applicationHealthPolicy)) { applicationHealthPolicy = new CommandProcessorApplicationHealthPolicy() { SerivceTypeHealthPolicies = new Dictionary <string, CommandProcessorServiceTypeHealthPolicy>() }; upgradeDescription.HealthPolicy.ApplicationHealthPolicies.Add( applicationName, applicationHealthPolicy); } foreach (var commandProcessorServiceTypeHealthPolicy in commandProcessorServiceTypeHealthPolicies) { if (applicationHealthPolicy.SerivceTypeHealthPolicies == null) { applicationHealthPolicy.SerivceTypeHealthPolicies = new Dictionary <string, CommandProcessorServiceTypeHealthPolicy>(); } applicationHealthPolicy.SerivceTypeHealthPolicies[commandProcessorServiceTypeHealthPolicy.Key] = commandProcessorServiceTypeHealthPolicy.Value; } } } } } return(upgradeDescription); }
private async void CreateAreaChart() { try { List <OxyColor> objlstOxycolor = new List <OxyColor>() { OxyColor.FromRgb(156, 29, 2) }; HealthStats objHealthStats = await App.TodoManager.GetHealthStats(); //objHealthStats.data.cholesterol.data dcCholestrol = objHealthStats.data.cholesterol.data; int MaxValueCholestrol = objHealthStats.data.cholesterol.data.Count - 1; var plotModel = new PlotModel { LegendPosition = LegendPosition.TopCenter }; plotModel.AxisTierDistance = 0; plotModel.PlotAreaBorderColor = OxyColors.Transparent; plotModel.DefaultColors = objlstOxycolor; #region CholestrolChart plotModel.Axes.Add(new LinearAxis() { Position = AxisPosition.Bottom, Title = "Month", MinorTickSize = 0, MajorStep = 1, AbsoluteMinimum = 0, AbsoluteMaximum = MaxValueCholestrol, LabelFormatter = ValueAxisLabelFormatter, AxislineStyle = LineStyle.Solid, }); plotModel.Axes.Add(new LinearAxis { Position = AxisPosition.Left, AbsoluteMaximum = 300, AbsoluteMinimum = 0, Title = "Value", MinorTickSize = 0, MajorStep = 50, IsZoomEnabled = false, IsPanEnabled = false, MinimumMajorStep = 3, AxislineStyle = LineStyle.Solid, }); plotModel.Axes.Add(new LinearAxis() { Position = AxisPosition.Right, IsAxisVisible = false, AxislineColor = OxyColors.Transparent }); plotModel.Axes.Add(new LinearAxis() { Position = AxisPosition.Top, IsAxisVisible = false, AxislineColor = OxyColors.Transparent }); var series1 = new LineSeries { MarkerType = MarkerType.Circle, MarkerSize = 5, MarkerStroke = OxyColors.White, Title = "Total Cholestrol" }; var series2 = new LineSeries { MarkerType = MarkerType.None, MarkerSize = 0, MarkerStroke = OxyColors.Transparent }; series2.Points.Add(new DataPoint(2, 300)); int KeyCount = 0; foreach (var a in dcCholestrol) { series1.Points.Add(new DataPoint(KeyCount, a.Value)); KeyCount++; } plotModel.Series.Add(series2); plotModel.Series.Add(series1); series1.MouseDown += Series1_MouseDown; ChartCholesterol.Model = plotModel; #endregion #region SugarChart dcSugar = objHealthStats.data.sugar.data; MaxValueCholestrol = objHealthStats.data.sugar.data.Count - 1; plotModel = new PlotModel { LegendPosition = LegendPosition.TopCenter, DefaultColors = objlstOxycolor }; plotModel.AxisTierDistance = 0; plotModel.PlotAreaBorderColor = OxyColors.Transparent; plotModel.Axes.Add(new LinearAxis { Position = AxisPosition.Bottom, Title = "Month", MinorTickSize = 0, MajorStep = 1, AbsoluteMinimum = 0, AbsoluteMaximum = MaxValueCholestrol, LabelFormatter = ValueAxisLabelFormatterSugar, AxislineStyle = LineStyle.Solid }); plotModel.Axes.Add(new LinearAxis { Position = AxisPosition.Left, AbsoluteMaximum = 450, AbsoluteMinimum = 0, Title = "Value", MinorTickSize = 0, MajorStep = 50, IsZoomEnabled = false, IsPanEnabled = false, MinimumMajorStep = 3, AxislineStyle = LineStyle.Solid, }); plotModel.Axes.Add(new LinearAxis() { Position = AxisPosition.Right, IsAxisVisible = false, AxislineColor = OxyColors.Transparent }); plotModel.Axes.Add(new LinearAxis() { Position = AxisPosition.Top, IsAxisVisible = false, AxislineColor = OxyColors.Transparent }); series1 = new LineSeries { MarkerType = MarkerType.Circle, MarkerSize = 5, MarkerStroke = OxyColors.White, Title = "Blood Sugar" }; series2 = new LineSeries { MarkerType = MarkerType.None, MarkerSize = 0, MarkerStroke = OxyColors.Transparent }; series2.Points.Add(new DataPoint(2, 450)); KeyCount = 0; foreach (var a in dcSugar) { series1.Points.Add(new DataPoint(KeyCount, a.Value)); KeyCount++; } plotModel.Series.Add(series2); plotModel.Series.Add(series1); ChartSugar.Model = plotModel; #endregion #region BMI dcBMI = objHealthStats.data.bmi.data; MaxValueCholestrol = objHealthStats.data.bmi.data.Count - 1; plotModel = new PlotModel { LegendPosition = LegendPosition.TopCenter, DefaultColors = objlstOxycolor }; plotModel.AxisTierDistance = 0; plotModel.PlotAreaBorderColor = OxyColors.Transparent; // plotModel.DefaultXAxis = OxyColor.FromRgb(156, 29, 2); plotModel.Axes.Add(new LinearAxis { Position = AxisPosition.Bottom, Title = "Month", MinorTickSize = 0, MajorStep = 1, AbsoluteMinimum = 0, AbsoluteMaximum = MaxValueCholestrol, LabelFormatter = ValueAxisLabelFormatterBMI, AxislineStyle = LineStyle.Solid }); plotModel.Axes.Add(new LinearAxis { Position = AxisPosition.Left, AbsoluteMaximum = 50, AbsoluteMinimum = 0, Title = "Value", MinorTickSize = 0, MajorStep = 10, IsZoomEnabled = false, IsPanEnabled = false, MinimumMajorStep = 3, AxislineStyle = LineStyle.Solid }); plotModel.Axes.Add(new LinearAxis() { Position = AxisPosition.Right, IsAxisVisible = false, AxislineColor = OxyColors.Transparent }); plotModel.Axes.Add(new LinearAxis() { Position = AxisPosition.Top, IsAxisVisible = false, AxislineColor = OxyColors.Transparent }); series1 = new LineSeries { MarkerType = MarkerType.Circle, MarkerSize = 5, MarkerStroke = OxyColors.White, Title = "BMI" }; series2 = new LineSeries { MarkerType = MarkerType.None, MarkerSize = 0, MarkerStroke = OxyColors.Transparent }; series2.Points.Add(new DataPoint(2, 50)); KeyCount = 0; foreach (var a in dcBMI) { series1.Points.Add(new DataPoint(KeyCount, Convert.ToInt32(a.Value))); KeyCount++; } plotModel.Series.Add(series2); plotModel.Series.Add(series1); chartBMI.Model = plotModel; #endregion #region Blood Pressure dcBPsys = objHealthStats.data.blood_pressure_systolic.data; dcBPdys = objHealthStats.data.blood_pressure_diastolic.data; MaxValueCholestrol = objHealthStats.data.blood_pressure_systolic.data.Count - 1; #region systolic plotModel = new PlotModel { LegendPosition = LegendPosition.TopCenter, DefaultColors = objlstOxycolor }; plotModel.AxisTierDistance = 0; plotModel.PlotAreaBorderColor = OxyColors.Transparent; plotModel.Axes.Add(new LinearAxis { Position = AxisPosition.Bottom, Title = "Month", MinorTickSize = 0, MajorStep = 1, AbsoluteMinimum = 0, AbsoluteMaximum = MaxValueCholestrol, LabelFormatter = ValueAxisLabelFormatterBMI, AxislineStyle = LineStyle.Solid }); plotModel.Axes.Add(new LinearAxis { Position = AxisPosition.Left, AbsoluteMaximum = 300, AbsoluteMinimum = 0, Title = "Value", MinorTickSize = 0, MajorStep = 50, IsZoomEnabled = false, IsPanEnabled = false, MinimumMajorStep = 3, AxislineStyle = LineStyle.Solid, }); plotModel.Axes.Add(new LinearAxis() { Position = AxisPosition.Right, IsAxisVisible = false, AxislineColor = OxyColors.Transparent }); plotModel.Axes.Add(new LinearAxis() { Position = AxisPosition.Top, IsAxisVisible = false, AxislineColor = OxyColors.Transparent }); series1 = new LineSeries() { MarkerType = MarkerType.Circle, MarkerSize = 5, MarkerStroke = OxyColors.White, Title = "Systolic" }; series2 = new LineSeries() { MarkerType = MarkerType.Diamond, MarkerSize = 5, MarkerStroke = OxyColors.White, Title = "Diastolic" }; var series3 = new LineSeries { MarkerType = MarkerType.None, MarkerSize = 0, MarkerStroke = OxyColors.Transparent }; series3.Points.Add(new DataPoint(2, 300)); KeyCount = 0; foreach (var a in dcBPsys) { series1.Points.Add(new DataPoint(KeyCount, a.Value)); KeyCount++; } KeyCount = 0; foreach (var a in dcBPdys) { series2.Points.Add(new DataPoint(KeyCount, a.Value)); KeyCount++; } plotModel.Series.Add(series1); plotModel.Series.Add(series2); plotModel.Series.Add(series3); chartBloodPressure.Model = plotModel; #endregion // ObservableCollection<FileImageSource> objimage = new ObservableCollection<FileImageSource>() { new FileImageSource() { File = (FileImageSource)ImageSource.FromFile("book.png") }, // new FileImageSource() { File = (FileImageSource)ImageSource.FromFile("claim.png") }, // new FileImageSource() { File = (FileImageSource)ImageSource.FromFile("cross.png") }, // new FileImageSource() { File = (FileImageSource)ImageSource.FromFile("cloud.png") } //}; // cvimage.Images = objimage; #endregion } catch (Exception ex) { DependencyService.Get <IMessage>().LongAlert(); } }
void GameLost(HealthStats hm) { print("You have lost the Game"); isRunning = false; gameOverCanvas.enabled = true; //Canvas im Vordergrund blockiert User Input (Workaround) }