Ejemplo n.º 1
0
    //Called when health drops down to 0
    IEnumerator OnDeath()
    {
        if (isDead)
        {
            yield break;
        }
        isDead = true;
        StartCoroutine(TiltColor());
        GameObject sfxInstance = FindObjectsOfType <EffectPooler>()
                                 .First(pooler => pooler.effectType == deathSFX)
                                 .GetPooledObject();

        sfxInstance.transform.position = transform.position;
        sfxInstance.SetActive(true);

        yield return(new WaitForSeconds(1f));

        sfxInstance.SetActive(false);

        GameManager.Instance.OnMobKilled.Invoke(EnemyType.Tower);
        //Drop Timer Powerup
        ItemPooler itemPooler = FindObjectsOfType <ItemPooler>().ToList().First(pooler => pooler.itemType == ItemType.TimerAddOn);

        if (itemPooler != null)
        {
            var item = itemPooler.GetPooledObject();
            item.transform.position = transform.position;
            item.SetActive(true);
        }
        gameObject.SetActive(false);
    }
Ejemplo n.º 2
0
 private static void DropEvenly(ItemType t, Vector2 baseLoc, int count, bool autocollect, float r, float a0)
 {
     for (int ii = 0; ii < count; ++ii)
     {
         ItemPooler.RequestItem(new ItemRequestContext(baseLoc, r * M.CosSinDeg(a0 + ii * 360f / count)), t)
         ?.Autocollect(autocollect || t.Autocollect());
     }
 }
Ejemplo n.º 3
0
    //Apply explosion effect and cast ripple that deal damage to players inside the radisu
    IEnumerator CastExplosion()
    {
        //This time corresponds to the duration of the explosion animation
        yield return(new WaitForSeconds(.9f));

        GameObject rippleEffect = FindObjectsOfType <EffectPooler>()
                                  .First(pooler => pooler.effectType == EffectType.Shockwave)
                                  .GetPooledObject();

        rippleEffect.transform.position = transform.position;
        rippleEffect.SetActive(true);
        rippleEffect.GetComponent <DesactivateObject>().Desactivate(.45f);
        CinemachineShake.Instance.ShakeCamera(10, 0.25f);

        RaycastHit2D[] explosionHits = Physics2D.CircleCastAll(transform.position, enemySettings.explosionRadius, Vector2.up, enemySettings.explosionRadius, targetsMask);
        foreach (RaycastHit2D hit in explosionHits)
        {
            Health health = hit.transform.GetComponent <Health>();
            if (health && health.IsAlive())
            {
                MaterialModifier modifier = hit.transform.root.GetComponentInChildren <MaterialModifier>();
                if (modifier)
                {
                    modifier.SetTintColor(new Color(1, 0, 0, 1f));
                }
                health.ChangeHealth(-enemySettings.explosionDamage);
            }
        }

        yield return(new WaitForSeconds(0.5f));

        GameManager.Instance.OnMobKilled.Invoke(EnemyType.Slime);


        //Drop Health Potion
        ItemPooler itemPooler = FindObjectsOfType <ItemPooler>().ToList().First(pooler => pooler.itemType == ItemType.Health);

        if (Random.Range(0f, 1f) > 0.5f)
        {
            if (itemPooler != null)
            {
                var healthPotion = itemPooler.GetPooledObject();
                healthPotion.transform.position = transform.position;
                healthPotion.SetActive(true);
            }
        }


        gameObject.SetActive(false);
    }
Ejemplo n.º 4
0
        private static void DropEvenly(ItemType t, ItemType small, decimal smallRatio, Vector2 baseLoc,
                                       decimal count, bool autocollect, float r, float a0)
        {
            int fullCt  = (int)Math.Floor(count);
            int smallCt = (int)Math.Floor((count - fullCt) / smallRatio);
            var step    = 360f / (smallCt + fullCt);

            if (fullCt > 0)
            {
                a0 -= (fullCt - 1f) / 2f * step;
            }
            for (int ii = 0; ii < smallCt + fullCt; ++ii)
            {
                ItemPooler.RequestItem(new ItemRequestContext(baseLoc, r * M.CosSinDeg(a0 + ii * step)), ii < fullCt ? t : small)
                ?.Autocollect(autocollect || t.Autocollect());
            }
        }
Ejemplo n.º 5
0
        private void Awake()
        {
            if (gm != null)
            {
                DestroyImmediate(gameObject);
                return;
            }
            Initialized = true;
            gm          = this;
            DontDestroyOnLoad(this);

            //This looks silly, but the static initializer needs to be actively run to ensure that the locale is set correctly.
            _ = SaveData.s;

            Log.Unity($"Danmokou {EngineVersion}, {References.gameIdentifier} {References.gameVersion}");
            SceneIntermediary.Setup(References.defaultTransition);
            ParticlePooler.Prepare();
            GhostPooler.Prepare(Prefabs.cutinGhost);
            BEHPooler.Prepare(Prefabs.inode);
            ItemPooler.Prepare(References.items);
            ETime.RegisterPersistentSOFInvoke(Replayer.BeginFrame);
            ETime.RegisterPersistentSOFInvoke(Enemy.FreezeEnemies);
            ETime.RegisterPersistentEOFInvoke(BehaviorEntity.PrunePoolControls);
            ETime.RegisterPersistentEOFInvoke(CurvedTileRenderLaser.PrunePoolControls);
            SceneIntermediary.RegisterSceneUnload(ClearForScene);
            SceneIntermediary.RegisterSceneLoad(OnSceneLoad);

            //The reason we do this instead of Awake is that we want all resources to be
            //loaded before any State Machines are constructed, which may occur in other entities' Awake calls.
            GetComponent <ResourceManager>().Setup();
            GetComponent <BulletManager>().Setup();
            GetComponentInChildren <SFXService>().Setup();
            GetComponentInChildren <AudioTrackService>().Setup();

            if (References.achievements != null)
            {
                Achievements = References.achievements.MakeRepo().Construct();
            }

            RunDroppableRIEnumerator(DelayedInitialAchievementsCheck());
        }
Ejemplo n.º 6
0
 public void DropOne(ItemType type) =>
 ItemPooler.RequestItem(new ItemRequestContext(rBPI.loc, Vector2.zero), type);
Ejemplo n.º 7
0
        public void DropDropLabel(IGradient color, string text, float speed = 0.4f, float ttl = 0.7f)
        {
            var req = new LabelRequestContext(Loc, LABEL_RAD, speed, RNG.GetFloatOffFrame(40, 140), ttl, color, text);

            ItemPooler.RequestLabel(req);
        }