Пример #1
0
    private void OnTriggerEnter2D(Collider2D other)
    {
        Debug.Log("hit " + other.name);

        if (other.gameObject.tag == "shield" && !hasReflected)
        {
            ShieldScript shield = other.GetComponent <ShieldScript>();
            if (shield.reflecting)
            {
                transform.Rotate(0, 0, (other.transform.eulerAngles.z - transform.eulerAngles.z));
                Instantiate(parryParticle, transform.position, transform.rotation);
                hasReflected        = true;
                shield.hasReflected = hasReflected;
                shield.isRecharging = false;
                shield.reflecting   = false;
                if (shield.shieldHealth < shield.maxShieldHealth)
                {
                    shield.shieldHealth++;
                }
                shield.rechargeTime       = shield.maxRechargeTimer;
                shield.activeReflectTimer = shield.maxTimeReflecting;
                shield.aSource.PlayOneShot(shield.aClipReflect);
            }
            else if (!shield.isRecharging)
            {
                shield.aSource.PlayOneShot(shield.aClipBlock);
                shield.shieldHealth--;
                Destroy(gameObject);
            }
        }

        if (other.gameObject.tag == "Player")
        {
            ShipControler ship = other.GetComponent <ShipControler>();
            if (ship.invFrames >= ship.maxInvFrames)
            {
                ship.TakeDamage();

                Destroy(gameObject);
            }
        }
        if (lifeSpawn > 0.1f && other.gameObject.tag == "enemy")
        {
            EnemyScript enemy = other.GetComponent <EnemyScript>();
            if (!hasReflected)
            {
                enemy.TakeDamage();
                gManager.score += 50;
            }
            else
            {
                enemy.health   -= 3;
                gManager.score += 200;
            }
            Destroy(gameObject);
        }
    }
Пример #2
0
 private void OnTriggerStay2D(Collider2D other)
 {
     if (other.tag == "Player")
     {
         ShipControler ship = other.GetComponent <ShipControler>();
         if (ship.invFrames >= ship.maxInvFrames)
         {
             ship.TakeDamage();
             ship.health = 0;
         }
     }
 }
Пример #3
0
 void Start()
 {
     anim      = GetComponent <Animator>();
     sprite    = GetComponent <SpriteRenderer>();
     aSource   = GetComponent <AudioSource>();
     gManager  = FindObjectOfType <GManager>();
     gmASource = gManager.GetComponent <AudioSource>();
     firingCd  = fireRate + 2;
     target    = FindObjectOfType <ShipControler>();
     Debug.Log("Spawned ship: " + shipID);
     anim.SetInteger("ID", shipID);
 }