public void AssignUI() { unitGO.transform.SetParent(transform); //healthImage = unitGO.transform.Find("Health/Current Health Image").GetComponent<Image>(); //nameText = unitGO.transform.Find("Name/Name Text").GetComponent<Text>(); //energyImage = unitGO.transform.Find("Energy/Current Energy Image").GetComponent<Image>(); //manaImage = unitGO.transform.Find("Mana/Current Mana Image").GetComponent<Image>(); //selectImage = unitGO.transform.Find("Select/Select Image").GetComponent<Image>(); effectParent = unitGO.transform.Find("Effects").transform; // Assign effects parent // If unit type is an enemy, Assign effect UI if (unitType == UnitType.ENEMY) { effectParent.gameObject.SetActive(true); for (int i = 0; i < _combatManager.maxEffectsActive; i++) { effectImages.Add(effectParent.GetChild(i).GetComponent <Image>()); EffectImage effectImage = effectImages[i].GetComponent <EffectImage>(); effectImage.unit = this; effectImage.ToggleEffectImage(false); effectImage.ToggleEffectPowerText(false); } } else { effectParent.gameObject.SetActive(false); } }
public void UpdateEffectVisual(Effect effect, int effectPower, int effectDuration, SkillData skillData) { // If unit is currently already inflicted with an effect, increase the power of the same effect instead of adding a new effect for (int i = 0; i < effects.Count; i++) { if (effect.name == effects[i].name) { EffectImage effectImage = effectImages[i].GetComponent <EffectImage>(); effectImage.UpdateEffectPower(effectPower); effectImage.Functionality(skillData); return; } } // If this effect is unique to the current effects on the unit, spawn another one. for (int i = 0; i < effectImages.Count; i++) { if (!effectImages[i].enabled) { EffectImage effectImage = effectImages[i].GetComponent <EffectImage>(); effects.Add(effect); effectPowers.Add(effectPower); effectImage.UpdateEffectPower(effectPower); effectImage.UpdateEffectDuration(effectDuration); effectImage.ToggleEffectImage(true); effectImage.ToggleEffectPowerText(true); effectImage.SetEffectImage(effect.effectImage); effectImage.Functionality(skillData); return; } } }
/** * callback acionada quando a entidade colide com outra */ override public void collide(LinkedList <DefaultEntity> inCollideList) { if (!airDying) { foreach (DefaultEntity entity in inCollideList) { if (!entity.dead) { if (entity.deadly && GameModel.deltaTime == 1f) { Game1.playSound("pshh"); if (!isInvencible) { airDying = true; spriteSheet.play(AnimationStruct.AIRDYING); this.velocity.X = -this.velocity.X * 1.2f; this.velocity.Y = -this.velocity.Y * 1.2f; if (combo > maxCombo) { maxCombo = combo; } if (fallings > maxJumps) { maxJumps = fallings; } if (fallings > 0) { levelPoints += fallings * 2; DefaultFX comboFX = new FXLabel(40, 40, "+" + (string)(fallings * 2).ToString(), Color.White, new Color(63, 53, 127)); GameScreen.getFXLayer().add(comboFX); comboFX.init(content); collideCallback(); } fallings = -1; } entity.kill(); DefaultFX tempFX = new FXImpact(entity.position.X, entity.position.Y); GameScreen.getFXLayer().add(tempFX); tempFX.init(content); } else { if (entity.getDieEffect() != null) { Game1.playSound("bup"); DefaultFX tempFX = entity.getDieEffect(); GameScreen.getFXLayer().add(tempFX); tempFX.init(content); // if (mushComboCounter >= maxMushComboCounter) // mushComboCounter = 0; // else mushComboCounter++; combo++; if (entity.behaviour.type == AbstractBehaviour.MUSHROOM) { mushrooms++; Statistics.maxMushrooms++; } else if (entity.behaviour.type == AbstractBehaviour.BOLINHA) { bloobs++; Statistics.maxBloobs++; } else if (entity.behaviour.type == AbstractBehaviour.STAR) { specials++; Statistics.maxSpecials++; } if (entity.effect == RufusEffects.MAGNETIC) { screenFX.redraw(3); if (imgEff != null) { imgEff.kill(); } imgEff = new EffectImage(2); imgEff.init(content); GameScreen.getFXLayer().add(imgEff); GameModel.deltaTime = 1f; pointAcress = 1; isMagnetic = true; special = maxSpecial; Game1.playSound("uhul"); } else if (entity.effect == RufusEffects.INVENCIBLE) { screenFX.redraw(1); if (imgEff != null) { imgEff.kill(); } imgEff = new EffectImage(1); imgEff.init(content); GameScreen.getFXLayer().add(imgEff); GameModel.deltaTime = 1f; pointAcress = 1; isInvencible = true; special = maxSpecial; Game1.playSound("uhul"); } else if (entity.effect == RufusEffects.PLUS) { screenFX.redraw(2); if (imgEff != null) { imgEff.kill(); } imgEff = new EffectImage(4); imgEff.init(content); GameScreen.getFXLayer().add(imgEff); //GameModel.deltaTime = 0f; pointAcress = 2; special = maxSpecial; Game1.playSound("uhul"); } if (combo > 1) { //DefaultFX comboFX = new FXLabel(entity.position.X, entity.position.Y, "X" + combo.ToString(), new Color(162, 142, 250)); DefaultFX comboFX = new FXLabel(entity.position.X, entity.position.Y, "X" + combo.ToString(), Color.White, new Color(63, 53, 127)); GameScreen.getFXLayer().add(comboFX); comboFX.init(content); if (combo == 5) { GameLoop.mushRain(1); GameLoop.mushRain(2); // EffectImage imgEff = new EffectImage(3); // imgEff.init(content); //GameScreen.getFXLayer().add(imgEff); } } int pointss = ((int)(entity.behaviour.points * combo) + (int)levelBehaviour.points) * pointAcress; DefaultFX comboFXP = new FXLabel(240, 420, "+" + (string)(pointss).ToString(), new Color(63, 53, 127), Color.White); GameScreen.getFXLayer().add(comboFXP); comboFXP.init(content); levelPoints += pointss; } entity.dead = true; collideCallback(); } } } } }