private void Start() { if (instance == null) { instance = this; } else if (instance != this) { Debug.LogError("Duplicate " + this.GetType().Name); Destroy(gameObject); } }
/// <summary> /// Update the appearance of a playershape by the data provided by a player /// </summary> /// <param name="p"></param> public void UpdatePlayerShape(Player p) { EntityShape ps = this; if (p.HP <= 0) { ps.Active = false; } if (p.HP > 0) { ps.Active = true; } if (!ps.Active) { ps.Fill = new SolidColorBrush(UIColoring.DEAD_PLAYER); ps.Stroke = new SolidColorBrush(UIColoring.DEAD_PLAYER); return; } else { Color color; //TODO: Choose Color by game and team. at the moment just csgo if (p.GetTeam() == Team.T) { color = UIColoring.TEAM_1; } else { color = UIColoring.TEAM_2; } ps.Fill = new SolidColorBrush(color); ps.Stroke = new SolidColorBrush(color); } if (p.IsSpotted) { var colorps = ((SolidColorBrush)ps.Fill); colorps.Color = UIColoring.ChangeColorBrightness(colorps.Color, 0.2f); ps.Fill = colorps; } else if (!p.IsSpotted) { var colorps = ((SolidColorBrush)ps.Fill); colorps.Color = UIColoring.ChangeColorBrightness(colorps.Color, -0.2f); ps.Fill = colorps; } ps.X = p.Position.X; ps.Y = p.Position.Y; ps.Yaw = Angle.FromDegrees(-p.Facing.Yaw).Radians; }