void OnTriggerEnter2D(Collider2D col) { GameObject other = col.gameObject; Debug.Log("Collision with " + other.tag); if (other.tag == "Stuff") { StuffController temp = other.GetComponent <StuffController>(); points = points + temp.Points < 0 ? 0 : points + temp.Points; this.TakeDamage(temp.Damage); if (temp.Type == StuffController.StuffType.Bonus) { BonusStuff stuf = (BonusStuff)temp; Effect tempEff = new BonusEffect(stuf.bonusType, stuf.EffectTime); SetEffect(tempEff); effects.Add(tempEff); StartCoroutine(DeleteEffect(stuf.EffectTime, tempEff)); } Destroy(other); } else if (other.tag == "Fish") { Debug.Log("Fish collide"); FishController Fc = other.GetComponent <FishController>(); points = points + Fc.GetPoints() < 0 ? 0 : points + Fc.GetPoints(); Effect tempEff = new FishEffect(Fc.Type, Fc.GetSeconds(), Fc.GetValue()); SetEffect(tempEff); effects.Add(tempEff); StartCoroutine(DeleteEffect(Fc.GetSeconds(), tempEff)); Destroy(other); } }
void ParseBonus(string id) { bonusNameText.text = ""; bonusText.text = ""; BonusEffect be = DataStore.bonusEffects.Where(x => x.bonusID == id).FirstOr(null); if (be == null || be.effects.Count == 0) { return; } //first choose a random bonus int[] rnd = GlowEngine.GenerateRandomNumbers(be.effects.Count); string e = be.effects[rnd[0]]; //get the bonus name int idx = e.IndexOf(':'); bonusNameText.text = e.Substring(0, idx); bonusText.text = ReplaceGlyphs(e.Substring(idx + 1)).Trim(); //At each activation, there’s a 25% chance that no bonus effect will be applied if (DataStore.sessionData.difficulty == Difficulty.Easy) { if (GlowEngine.RandomBool(25)) { Debug.Log("EASY MODE: applied 25% chance bonus skipped"); bonusNameText.text = ""; bonusText.text = ""; } } }
// Use this for initialization void Awake() { _effect = GetComponent< BonusEffect > (); _effect.enabled = false; _follow = GetComponent< FollowTarget > (); _follow.enabled = false; }
public void BonusCollected(Bonus bonus) { BonusEffect type = bonus.type; if (effects.ContainsKey(type)) { bool startCoroutine = false; if (effects[type].Time == 0f) { startCoroutine = true; if (type == BonusEffect.Boost) { InvokeRepeating("BoostScore", 0f, .3f); } } effects[type].Time += bonus.effectTime; ParticleSystem ps = effects[type].System; ps.Stop(); var main = ps.main; main.duration = effects[type].Time; ps.Play(); if (startCoroutine) { StartCoroutine(StartEffect(type)); } } }
public void ReplaceItem(AGameObject replaced, BonusEffect bonus = BonusEffect.NONE) { AGameObject ni = null; switch (bonus) { case BonusEffect.LINE_V: ni = gFactory.GetGameObject(replaced, LineType.V); break; case BonusEffect.LINE_H: ni = gFactory.GetGameObject(replaced, LineType.H); break; default: ni = gFactory.GetGameObject(replaced, bonus); break; } if (replaced.Left == null && replaced.Top == null) { first = ni; } if (OnItemKilled != null) { OnItemKilled(); } }
public AGameObject GetGameObject(AGameObject gameObject, BonusEffect bonus = BonusEffect.NONE) { if (bonus == BonusEffect.BANG) { return(new BangGameObject(gameObject)); } return(new SimpleGameObject(gameObject, RandomSpriteName())); }
static public int BonusAccessibility(BonusEffect type) { int index = bonusOrder.IndexOf(type); if (index == -1) { return(0); } return(index * 75); }
private IEnumerator StartEffect(BonusEffect type) { while (effects[type].Time > 0f) { effects[type].Time -= Time.deltaTime; yield return(null); } effects[type].Time = 0f; effects[type].System.Stop(); Bonus.RemoveEffect(type); if (type == BonusEffect.Boost) { CancelInvoke("BoostScore"); } }
public bool SpawnActivatedBonus(BonusEffect type) { if (activated && bonuses == null) { return(false); } GameObject bonus = bonuses[Random.Range(0, bonuses.Length)]; BonusEffect bonusType = bonus.GetComponent <Bonus>().type; if (bonusType != type || bonusType == BonusEffect.Star) { return(false); } if (bonus && GameController.instance.Score >= Bonus.BonusAccessibility(bonusType)) { Instantiate(bonus, transform.position, transform.rotation, transform); activated = true; } return(true); }
static public bool HasEffect(BonusEffect effect) { return((Effects & effect) != BonusEffect.None); }
static public void RemoveEffect(BonusEffect effect) { Effects &= ~effect; }
static public void AddEffect(BonusEffect effect) { Effects |= effect; }