public void playChargeAnim()
 {
     anim.SetTrigger("Charge");
     gameObject.AddComponent(typeof(Horizontal_Line_Speed));
     hls                    = GetComponent <Horizontal_Line_Speed>();
     hls.speed              = tremblePower;
     hls.distance           = trembleDistance;
     hls.turnSpriteOnComple = false;
     Invoke("shoot", 2f);
     bullet = Instantiate(attackPrefab);
     bullet.transform.position = new Vector3(transform.position.x, transform.position.y - 0.5f, transform.position.z);
     bullet.GetComponent <LinearInfinite>().speed = Vector2.zero;
     isShooting = true;
     SoundManager.instance.RandomizeSfx(chargingSound);
 }
Exemplo n.º 2
0
    public void throwSlimeghter()
    {
        for (int i = 0; i < amount; i++)
        {
            GameObject instance = Instantiate(prefab, spawns.transform);
            instance.transform.position = transform.position;
            float   xForce            = force.x * Mathf.Cos(((float)i) / (amount - 1) * Mathf.PI);
            Vector2 rotatedForce      = new Vector2(xForce, force.y);
            Horizontal_Line_Speed hls = instance.GetComponent <Horizontal_Line_Speed>();
            if (hls != null)
            {
                hls.disableAndResetWithDealy(2f);
            }

            instance.GetComponent <Rigidbody2D>().AddForce(rotatedForce, ForceMode2D.Impulse);
        }
        //Destroys component so it can be called again
        Destroy(this);
    }