Ejemplo n.º 1
0
    void Update()
    {
        if (target != null)
        {
            transform.position = Vector2.MoveTowards(transform.position, target.transform.position, Time.deltaTime * speed);

            if (gameObject.transform.position.Equals(target.transform.position))
            {
                Enemy enemy = target.GetComponent <Enemy>();
                enemy.CurrentHealth -= damage;
                enemy.ApplyPoison(damageOverTime);
                enemy.CurrentMoveSpeed = Mathf.Max(enemy.CurrentMoveSpeed - slowSpeed * enemy.CurrentMoveSpeed, 0.1f);
                // 4
                if (enemy.CurrentHealth <= 0)
                {
                    Destroy(target);
                    gameManager.Gold += goldOnKill;
                }
                GameObject     bulletParticle  = (GameObject)Instantiate(explosiveParticles, new Vector3(transform.position.x, transform.position.y, -1), transform.rotation);
                BulletParticle bulletParticle1 = bulletParticle.GetComponent <BulletParticle>();
                bulletParticle1.bulletColor = spriteRenderer.color;


                Destroy(gameObject);
            }
        }
        else
        {
            GameObject     bulletParticle  = (GameObject)Instantiate(explosiveParticles, new Vector3(transform.position.x, transform.position.y, -1), transform.rotation);
            BulletParticle bulletParticle1 = bulletParticle.GetComponent <BulletParticle>();
            bulletParticle1.bulletColor = spriteRenderer.color;
            Destroy(gameObject);
        }
    }
Ejemplo n.º 2
0
        void unit_OnAttackMade(ICombatEntity arg1, IEntity arg2)
        {
            Vector3 o = arg1.WorldPosition + Vector3.Up;
            Vector3 d = arg2.WorldPosition + Vector3.Up;

            d -= o;
            d.Normalize();
            BulletParticle bp = new BulletParticle(o, d, 0.05f, 1.4f, 0.1f);

            bp.Tint = Color.Red;
            AddParticle(bp);
        }
Ejemplo n.º 3
0
    private IEnumerator PopAnimation()
    {
        int nParticles = UnityEngine.Random.Range(2, 6);

        for (int i = 0; i < nParticles; i++)
        {
            BulletParticle particle = Instantiate(bulletParticle, transform.position, Quaternion.identity);
            particle.GetComponent <Rigidbody2D>().velocity = new Vector2(UnityEngine.Random.Range(-1, 1), UnityEngine.Random.Range(0, 2));
        }
        yield return(new WaitForSeconds(2));

        Destroy(gameObject);
        yield return(null);
    }
Ejemplo n.º 4
0
        void unit_OnAttackMade(ICombatEntity arg1, IEntity arg2)
        {
            Vector2 cpvd = new Vector2(arg1.ViewDirection.Y, -arg1.ViewDirection.X);

            Vector2 o2 = cpvd * initArgs.BulletOffset.X + arg1.ViewDirection * initArgs.BulletOffset.Z;
            Vector3 o  = new Vector3(o2.X, initArgs.BulletOffset.Y, o2.Y);

            o += arg1.WorldPosition;

            Vector2 d2 = cpvd * initArgs.BulletDirection.X + arg1.ViewDirection * initArgs.BulletDirection.Z;
            Vector3 d  = new Vector3(d2.X, initArgs.BulletDirection.Y, d2.Y);

            d.Normalize();

            BulletParticle bp = new BulletParticle(o, d, 0.05f, 1.4f, 0.1f);

            bp.Tint = initArgs.BulletTint;
            AddParticle(bp);
        }
Ejemplo n.º 5
0
 void unit_OnAttackMade(ICombatEntity arg1, IEntity arg2)
 {
     Vector3 o = arg1.WorldPosition + Vector3.Up;
     Vector3 d = arg2.WorldPosition + Vector3.Up;
     d -= o;
     d.Normalize();
     BulletParticle bp = new BulletParticle(o, d, 0.05f, 1.4f, 0.1f);
     bp.Tint = Color.Red;
     AddParticle(bp);
 }
Ejemplo n.º 6
0
        void unit_OnAttackMade(ICombatEntity arg1, IEntity arg2)
        {
            Vector2 cpvd = new Vector2(arg1.ViewDirection.Y, -arg1.ViewDirection.X);

            Vector2 o2 = cpvd * initArgs.BulletOffset.X + arg1.ViewDirection * initArgs.BulletOffset.Z;
            Vector3 o = new Vector3(o2.X, initArgs.BulletOffset.Y, o2.Y);
            o += arg1.WorldPosition;

            Vector2 d2 = cpvd * initArgs.BulletDirection.X + arg1.ViewDirection * initArgs.BulletDirection.Z;
            Vector3 d = new Vector3(d2.X, initArgs.BulletDirection.Y, d2.Y);
            d.Normalize();

            BulletParticle bp = new BulletParticle(o, d, 0.05f, 1.4f, 0.1f);
            bp.Tint = initArgs.BulletTint;
            AddParticle(bp);
        }