private void LoadDependencies() { this.AC = Player.Character.GetComponent <AttributesComponent>(); this.EC = Player.Character.GetComponent <EquipmentComponent>(); this.PCC = Player.Character.GetComponent <PlayerControlComponent>(); this.SC = Player.Character.GetComponent <ScoreComponent>(); }
// Create all the components that should be used by this game private void CreateComponents() { _menuComponent = new MenuComponent(this); Components.Add(_menuComponent); _backgroundComponent = new BackgroundComponent(this); Components.Add(_backgroundComponent); _actorComponent = new ActorComponent(this); Components.Add(_actorComponent); _collisionComponent = new CollisionComponent(this); Components.Add(_collisionComponent); _scoreComponent = new ScoreComponent(this); Components.Add(_scoreComponent); _timeComponent = new TimeComponent(this); Components.Add(_timeComponent); _speedComponent = new SpeedComponent(this); Components.Add(_speedComponent); _statusComponent = new StatusComponent(this); Components.Add(_statusComponent); }
public void Test7() { var score = new ScoreComponent(new ChatScore("case", "ball", 100)) { Extra = new List <ChatComponent> { new StringComponent("text1"), new StringComponent("text2") } }; var chat = new Chat(score); var j = chat.ToJObject(); Assert.Equal("case", j.SelectToken("score.name")); Assert.Equal("ball", j.SelectToken("score.objective")); Assert.Equal(100, j.SelectToken("score.value").Value <int>()); Assert.Equal("text1", j.SelectToken("extra[0].text")); Assert.Equal("text2", j.SelectToken("extra[1].text")); const string json = @"{ ""score"":{ ""name"":""case"", ""objective"":""ball"", ""value"":100 }, ""extra"":[ { ""text"":""text1"" }, { ""text"":""text2"" } ] }"; var chat2 = Chat.Parse(json); Assert.True(JToken.DeepEquals(j, chat2.ToJObject())); }
public Entity AddScore(int newScore) { var component = new ScoreComponent(); component.score = newScore; return(AddScore(component)); }
public void TestCalculateScoreforCase2() { ScoreComponent obj = new ScoreComponent(); List <string> blocks = new List <string>(new string[] { "1", "2", "+", "Z" }); int result = obj.CalculateScore(blocks, blocks.Count); Assert.AreEqual(3, result); }
public void TestCalculateScoreCase1() { ScoreComponent obj = new ScoreComponent(); List <string> blocks = new List <string>(new string[] { "5", "-2", "4", "Z", "X", "9", "+", "+" }); int result = obj.CalculateScore(blocks, blocks.Count); Assert.AreEqual(27, result); }
void Awake() { xOffset = new List <float>(); foreach (GameObject obj in objects) { xOffset.Add(obj.GetComponent <Image>().rectTransform.rect.width / 2); } scoreKeeper = scoreManager.GetComponent <ScoreComponent>(); scoreKeeper.resetScore(); }
public Entity SetScore(ScoreComponent component) { if (hasScore) { throw new SingleEntityException(Matcher.Score); } var entity = CreateEntity(); entity.AddScore(component); return(entity); }
public void Animate(ScoreComponent score, BeatInfo beat) { if (beat.BeatNo % 2 != 0) { return; } var hue = Random.value; _currentAnimation = (_currentAnimation + 1) % _animationCount; _animations[_currentAnimation](hue); }
public void Animate(ScoreComponent score, BeatInfo beat) { if (beat.BeatNo % 2 != 0) { return; } var hue = Random.value; for (int i = 0; i < 7; i++) { for (int j = 0; j < 7; j++) { if (j % 2 == 0 && i % 2 == 0) { continue; } if (j % 2 == 1 && i % 2 == 1) { continue; } MessageBroker.Default.Publish(new ActLightUp { X = i, Y = j, FallOff = 1f, Delay = 0, BlinkColor = Color.HSVToRGB(hue, 1, 1), }); } } for (int i = 0; i < 7; i++) { for (int j = 0; j < 7; j++) { if (j % 2 == 0 && i % 2 == 1) { continue; } if (j % 2 == 1 && i % 2 == 0) { continue; } MessageBroker.Default.Publish(new ActLightUp { X = i, Y = j, FallOff = 1f, Delay = 0.5f, BlinkColor = Color.HSVToRGB(hue, 1, 1), }); } } }
public Entity ReplaceScore(int newScore) { ScoreComponent component; if (hasScore) { WillRemoveComponent(ComponentIds.Score); component = score; } else { component = new ScoreComponent(); } component.score = newScore; return ReplaceComponent(ComponentIds.Score, component); }
public void Execute() { var count = ClickedComponents.Length; for (var i = 0; i < count; ++i) { var destroyPos = ClickedComponents[i]; var clickedEntity = CachedEntities[Helper.GetI(destroyPos.x, destroyPos.y)]; if (clickedEntity == Entity.Null) { continue; } var groupId = InGroup[clickedEntity].GroupId; var groupSize = 0; for (var y = 0; y < CachedEntities.Length; ++y) { var entity = CachedEntities[y]; if (entity == Entity.Null) { continue; } if (InGroup[entity].GroupId == groupId) { ++groupSize; } } if (groupSize < MinGroupSize) { continue; } for (var y = 0; y < CachedEntities.Length; ++y) { var entity = CachedEntities[y]; if (entity == Entity.Null) { continue; } if (InGroup[entity].GroupId == groupId) { CommandBuffer.DestroyEntity(entity); } } var scores = Score[ScoreEntity]; Score[ScoreEntity] = new ScoreComponent { Scores = scores.Scores + groupSize }; } }
public void Animate(ScoreComponent score, BeatInfo beat) { var hue = Random.value; MessageBroker.Default.Publish(new ActLightUp { X = Random.Range(0, 7), Y = Random.Range(0, 7), FallOff = 1.5f, Delay = 0, BlinkColor = Color.HSVToRGB(hue, 1, 1), }); }
private ScoreboardDataPacket CreateScoreboardDataPacket(Entity e, bool respawned) { ScoreboardDataPacket p = new ScoreboardDataPacket(); ScoreComponent score = e.GetComponent <ScoreComponent>(); LifeComponent life = e.GetComponent <LifeComponent>(); p.EntityId = e.EntityId; p.Score = score.Value; p.Lives = life.Lives; p.EntityRespawned = respawned; return(p); }
void addScore(ScoreComponent scoreComponent, bool shouldMultiply, int enemyType, float gameTime) { if (shouldMultiply) { scoreComponent.score += getMultipliedScore(scoreComponent.multiplier, enemyType); scoreComponent.multiplierCount++; } else { scoreComponent.score += getScore(enemyType); scoreComponent.multiplierCount = 0; } scoreComponent.time = gameTime; }
public Entity ReplaceScore(int newScore) { ScoreComponent component; if (hasScore) { WillRemoveComponent(ComponentIds.Score); component = score; } else { component = new ScoreComponent(); } component.score = newScore; return(ReplaceComponent(ComponentIds.Score, component)); }
public PlayerEntity(Scene scene, Vector2 position, PlayerInfo player) : base(scene, EntityType.Game, position, bodyType: FarseerPhysics.Dynamics.BodyType.Dynamic) { var playerAnimationDefinition = Scene.Game.Content.LoadFromJson <AnimationDefintion>("Animations/player_anim"); var scareAnimDefinition = Scene.Game.Content.LoadFromJson <AnimationDefintion>("Animations/scare_anim"); var attractAnimationDefinition = Scene.Game.Content.LoadFromJson <AnimationDefintion>("Animations/attract_anim"); this.PlayerInfo = player; switch (player.Color) { case PlayerColors.Green: playerAnimationDefinition.AssetName = "player_green_anim"; break; case PlayerColors.Pink: playerAnimationDefinition.AssetName = "player_pink_anim"; break; case PlayerColors.Purple: playerAnimationDefinition.AssetName = "player_purple_anim"; break; case PlayerColors.Yellow: playerAnimationDefinition.AssetName = "player_yellow_anim"; break; default: playerAnimationDefinition.AssetName = "player_yellow_anim"; break; } AddComponent(playerAnim = new AnimatedSpriteComponent(playerAnimationDefinition, new Vector2(1.0f, 1.0f), new Vector2(0.5f, 0.5f), name: "playerAnim")); AddComponent(attractAnim = new AnimatedSpriteComponent(attractAnimationDefinition, new Vector2(3.0f, 3.0f), new Vector2(0.5f, 0.5f), name: "attractAnim")); AddComponent(scareAnim = new AnimatedSpriteComponent(scareAnimDefinition, new Vector2(5.0f, 5.0f), new Vector2(0.5f, 0.5f), name: "scareAnim")); AddComponent(scoreComponent = new ScoreComponent(player.Color.GetColor(), name: "score")); AddComponent(new PhysicsComponent(new CircleShape(0.25f, 1))); AddComponent(new PlayerControllerComponent(player)); AddComponent(new AudioSourceComponent(new [] { "Audio/Hit1", "Audio/Hit2", "Audio/Hit3" }, new string[] {})); }
public void Animate(ScoreComponent score, BeatInfo beat) { if (beat.BeatNo % 2 != 0) { return; } var hue = Random.value; MessageBroker.Default.Publish(new ActLightUp { X = 3, Y = 3, FallOff = 1f, Delay = 0, BlinkColor = Color.HSVToRGB(hue, 1, 1), }); var arr = new List <Vector2Int> { new Vector2Int(3, 3) }; for (int i = 2; i < 5; i++) { for (int j = 2; j < 5; j++) { if (arr.Contains(new Vector2Int(i, j))) { continue; } MessageBroker.Default.Publish(new ActLightUp { X = i, Y = j, FallOff = 1f, Delay = 0.2f, BlinkColor = Color.HSVToRGB(hue, 1, 1), }); arr.Add(new Vector2Int(i, j)); } } for (int i = 1; i < 6; i++) { for (int j = 1; j < 6; j++) { if (arr.Contains(new Vector2Int(i, j))) { continue; } MessageBroker.Default.Publish(new ActLightUp { X = i, Y = j, FallOff = 1f, Delay = 0.4f, BlinkColor = Color.HSVToRGB(hue, 1, 1), }); arr.Add(new Vector2Int(i, j)); } } for (int i = 0; i < 7; i++) { for (int j = 0; j < 7; j++) { if (arr.Contains(new Vector2Int(i, j))) { continue; } MessageBroker.Default.Publish(new ActLightUp { X = i, Y = j, FallOff = 1f, Delay = 0.6f, BlinkColor = Color.HSVToRGB(hue, 1, 1), }); arr.Add(new Vector2Int(i, j)); } } }
public Entity AddScore(ScoreComponent component) { return(AddComponent(ComponentIds.Score, component)); }
public Entity SetScore(ScoreComponent component) { if (hasScore) { throw new SingleEntityException(Matcher.Score); } var entity = CreateEntity(); entity.AddScore(component); return entity; }
void setScoreComponent(ScoreComponent scoreComponent, bool shouldMultiply) { scoreComponent.multiplier = shouldMultiply ? scoreComponent.multiplier + GameConfig.SCORE_MULTIPLIER_PROGRESS : GameConfig.SCORE_MULTIPLIER_BASE; }
// Use this for initialization void Start() { //WaitingForRestart = false; WaitingForLeaderboard = false; WaitingForRestart = false; ZombiePigCollected = false; DarkPigCollected = false; RainbowPigCollected = false; CurrentAmmo = MaxAmmo; NumPieplSaved = 0; audios = GetComponents <AudioSource> (); SFXPieplCollected = audios [5]; AmmoDisplay.text = "Water: " + CurrentAmmo.ToString(); //SavedPieplDisplay.text = NumPieplSaved.ToString (); //Bonus Texts // Bonus.enabled = false; FinalScoreDisplay.text = "The Demons destroyed the Village"; FinalScoreDisplay.enabled = false; FinalScoreDemons.enabled = false; FinalScoreWaves.enabled = false; FinalPieplSaved.enabled = false; FinalForestFire.enabled = false; FinalScoreTotal.enabled = false; FinalScoreRank.enabled = false; ScoreComp = GetComponent <ScoreComponent>(); rend = gameObject.GetComponent <SpriteRenderer>(); SpeedBonusText = GameObject.Find("MaxSpeedText").GetComponent <Text>(); MaxAmmoBonusText = GameObject.Find("MaxAmmoText").GetComponent <Text>(); MaxShootingRangeText = GameObject.Find("MaxShootingRange").GetComponent <Text>(); GameObject.Find("FinalScore").GetComponent <Image>().enabled = false; GameObject.Find("FS_Demons_IMG").GetComponent <Image>().enabled = false; GameObject.Find("FS_Piggies_IMG").GetComponent <Image>().enabled = false; GameObject.Find("BonusChance_text").GetComponent <Text>().enabled = false; BonusChanceText = GameObject.Find("BonusChance_text").GetComponent <Text> (); BonusChanceImage = GameObject.Find("BonusChancePig").GetComponent <Image> (); BonusChanceAnimation = GameObject.Find("BonusChancePig").GetComponent <Animator> (); BonusDetailText = GameObject.Find("RarePigText").GetComponent <Text> (); BonusDetailText.enabled = false; /* * BonusChanceHasty = GameObject.Find ("BonusChanceHasty").GetComponent<Image> (); * BonusChanceHasty * BonusChanceWhale * BonusChanceSniper */ BonusChanceText.enabled = false; BonusChanceImage.enabled = false; BonusChanceAnimation.enabled = false; NumSpeedBonus = 0; NumMaxAmmoBonus = 0; NumMaxShootingRange = 0; }
public Entity AddScore(ScoreComponent component) { return AddComponent(ComponentIds.Score, component); }
void updateScore(Entity e, ScoreComponent scoreComponent) { setInfoIfNotExist(scoreComponent.multiplierCount); e.gameObject.gameObject.GetComponent<Text>().text = scoreComponent.score.ToString(); }
public Entity AddScore(int newScore) { var component = new ScoreComponent(); component.score = newScore; return AddScore(component); }
bool isMultiplierActive(ScoreComponent scoreComponent, float gameTime) { return (scoreComponent.time + scoreComponent.multiplierDuration) > gameTime; }
/// <summary> /// Get the score of solutions. The score may be database or XML (additional questions). /// </summary> /// <param name="solutionId"></param> /// <param name="challengeReference"></param> /// <param name="sw"></param> /// <returns></returns> protected string GetScoreJudge(Guid solutionId, string challengeReference, bool sw) { SolutionComponent solution = new SolutionComponent(solutionId); var scoresSolution = solution.Solution.Scores.Where(a => a.ScoreType != "CUSTOM_XML" && a.Active == true).OrderBy(x => x.UserProperty.FirstName); if (challengeReferences.Contains(challengeReference)) { //XML score scoresSolution = solution.Solution.Scores.Where(a => a.ScoreType == "CUSTOM_XML" && a.Active == true && (challengeReferences.Contains(a.ChallengeReference))).OrderBy(x => x.UserProperty.FirstName); } UserPropertyComponent userPropertyComponent; string text = string.Empty; StringBuilder return_ = new StringBuilder(); ScoreComponent.ScoreJudge scoreJudge; List <Int32> listUserID = new List <Int32>(); foreach (var score in scoresSolution) { if (score.UserId == UserId || sw) { if (challengeReference == score.ChallengeReference || challengeReference == string.Empty) { ScoreComponent scoreComponent = new ScoreComponent(solutionId, score.UserId, "CUSTOM_XML", score.ChallengeReference); var user = UserController.GetUserById(PortalId, score.UserId); if (scoreComponent.Score.ScoreId != Guid.Empty) { if (challengeReference == string.Empty) { scoreJudge = new ScoreComponent.ScoreJudge(solutionId, score.UserId); } else { scoreJudge = new ScoreComponent.ScoreJudge(solutionId, score.UserId, challengeReference); } double value = Math.Round(((scoreJudge.AbsoluteScore * 0.6) + (Convert.ToDouble(scoreComponent.Score.ComputedValue) * 0.4)), 1); if (challengeReferences.Contains(solution.Solution.ChallengeReference)) { value = Math.Round((Convert.ToDouble(scoreComponent.Score.ComputedValue)), 1); } if (user != null) { text += user.DisplayName + " (" + value.ToString() + "), "; } else { text += "Anonymous" + " (" + value.ToString() + "), "; } } else { if (challengeReference == string.Empty) { scoreJudge = new ScoreComponent.ScoreJudge(solutionId, score.UserId); } else { scoreJudge = new ScoreComponent.ScoreJudge(solutionId, score.UserId, challengeReference); } if (user != null) { text += user.DisplayName + " (" + scoreJudge.AbsoluteScore + "), "; } else { text += "Anonymous" + " (" + scoreJudge.AbsoluteScore + "), "; } } if (user != null) { listUserID.Add(user.UserID); } } } } if (sw) { var listJudgesAssignation = JudgesAssignationComponent.GetJudgesPerSolution(solution.Solution.SolutionId, challengeReference).OrderBy(x => x.ChallengeJudge.UserProperty.FirstName).ToList(); if (listJudgesAssignation.Count() > 0) { foreach (var item in listJudgesAssignation) { var existUser = listUserID.Exists(x => x == item.ChallengeJudge.UserId); if (!existUser) { var user = UserController.GetUserById(PortalId, item.ChallengeJudge.UserId); if (user != null) { text += user.DisplayName + " ( - ), "; } } } } } if (string.IsNullOrEmpty(text)) { text = "Not Scored"; } return(text); }
private void Awake() { ScoreComponent.AddOnScoreIncreaseListener((int score) => { ScoreViewComponent.SetScoreText(score); }); ScoreComponent.AddOnScoreResetListener((int score) => { ScoreViewComponent.SetScoreText(score); }); }
// Use this for initialization void Start() { //WaitingForRestart = false; WaitingForLeaderboard = false; WaitingForRestart = false; ZombiePigCollected = false; DarkPigCollected = false; RainbowPigCollected = false; CurrentAmmo = MaxAmmo; NumPieplSaved = 0; audios = GetComponents<AudioSource> (); SFXPieplCollected = audios [5]; AmmoDisplay.text = "Water: " + CurrentAmmo.ToString(); //SavedPieplDisplay.text = NumPieplSaved.ToString (); //Bonus Texts // Bonus.enabled = false; FinalScoreDisplay.text="The Demons destroyed the Village"; FinalScoreDisplay.enabled = false; FinalScoreDemons.enabled = false; FinalScoreWaves.enabled = false; FinalPieplSaved.enabled =false; FinalForestFire.enabled = false; FinalScoreTotal.enabled = false; FinalScoreRank.enabled = false; ScoreComp = GetComponent<ScoreComponent>(); rend = gameObject.GetComponent<SpriteRenderer>(); SpeedBonusText=GameObject.Find("MaxSpeedText").GetComponent<Text>(); MaxAmmoBonusText=GameObject.Find("MaxAmmoText").GetComponent<Text>(); MaxShootingRangeText=GameObject.Find("MaxShootingRange").GetComponent<Text>(); GameObject.Find("FinalScore").GetComponent<Image>().enabled=false; GameObject.Find("FS_Demons_IMG").GetComponent<Image>().enabled=false; GameObject.Find("FS_Piggies_IMG").GetComponent<Image>().enabled=false; GameObject.Find("BonusChance_text").GetComponent<Text>().enabled=false; BonusChanceText = GameObject.Find ("BonusChance_text").GetComponent<Text> (); BonusChanceImage = GameObject.Find ("BonusChancePig").GetComponent<Image> (); BonusChanceAnimation = GameObject.Find ("BonusChancePig").GetComponent<Animator> (); BonusDetailText=GameObject.Find ("RarePigText").GetComponent<Text> (); BonusDetailText.enabled = false; /* BonusChanceHasty = GameObject.Find ("BonusChanceHasty").GetComponent<Image> (); BonusChanceHasty BonusChanceWhale BonusChanceSniper */ BonusChanceText.enabled = false; BonusChanceImage.enabled = false; BonusChanceAnimation.enabled = false; NumSpeedBonus=0; NumMaxAmmoBonus=0; NumMaxShootingRange=0; }