Пример #1
0
    void OnTriggerEnter(Collider theCollider)
    {
        if (!theCollider.CompareTag("Bullet"))
        {
            return;
        }

        if (--enemyHealth <= 0)
        {
            Destroy(gameObject);
            BulletImpactPool.PlayBulletImpact(transform.position);
        }
    }
Пример #2
0
    protected override void OnUpdate()
    {
        Entities.ForEach((Entity entity, ref Health health, ref Translation pos) =>
        {
            if (health.Value <= 0)
            {
                if (EntityManager.HasComponent(entity, typeof(PlayerTag)))
                {
                    Settings.PlayerDied();
                }

                else if (EntityManager.HasComponent(entity, typeof(EnemyTag)))
                {
                    PostUpdateCommands.DestroyEntity(entity);
                    BulletImpactPool.PlayBulletImpact(pos.Value);
                }
            }
        });
    }
Пример #3
0
    void Awake()
    {
        if (instance != null && instance != this)
        {
            Destroy(gameObject);
            return;
        }
        else
        {
            instance = this;
        }

        impactPool = new GameObject[impactPoolSize];
        for (int i = 0; i < impactPoolSize; i++)
        {
            impactPool[i] = Instantiate(bulletHitPrefab, instance.transform) as GameObject;
            impactPool[i].SetActive(false);
        }
    }
        protected override void OnUpdate()
        {
            Entities.ForEach((Entity entity, ref Health health, ref Translation translation) =>
            {
                if (health.Value > 0f)
                {
                    return;
                }

                if (EntityManager.HasComponent(entity, typeof(PlayerTag)))
                {
                    PlayerSettings.PlayerDied();
                }
                else if (EntityManager.HasComponent(entity, typeof(EnemyTag)))
                {
                    PostUpdateCommands.DestroyEntity(entity);
                    BulletImpactPool.PlayBulletImpact(translation.Value);

                    var instantiated = PostUpdateCommands.Instantiate(PlayerSettings.Coin);
                    PostUpdateCommands.SetComponent(instantiated, new Translation {
                        Value = translation.Value
                    });
                }
                else if (EntityManager.HasComponent <BulletTag>(entity))
                {
                    PostUpdateCommands.DestroyEntity(entity);
                }
            });

            var count = _enemies.CalculateEntityCount();

            if (count == 0 && GameManager.Instance.GameStatus == GameManager.Status.Play)
            {
                GameManager.Instance.Success();
            }
        }