Exemplo n.º 1
0
 public void PlaySound(AudioClip ac)
 {
     foreach (AudioSource AS in MiscAudioSources)
     {
         if (!AS.isPlaying)
         {
             AS.clip = ac;
             AS.Play();
         }
     }
 }
Exemplo n.º 2
0
        public void Spawn(Sprite[] effect, Vector2 position, Vector2 velocity, int depthOffset = 0)
        {
            sprite.frames = effect;
            // sprite expects a valid frame number, length is the last frame + 1.
            sprite.returnTo = effect.Length - 1;
            sprite.Play();
            sprite.depthOffset = depthOffset;

            this.position             = position;
            sprite.transform.position = new Vector3(
                Mathf.Round(this.position.x * S.SIZE),
                Mathf.Round(this.position.y * S.SIZE)
                );
            this.velocity = velocity;

            timer = new FrameTimer(effect.Length * AS.FRAME_DURATION);
            timer.Start();

            active = true;
            sprite.Show();
        }
Exemplo n.º 3
0
    private void Update()
    {
        TutoTimeline += Time.unscaledDeltaTime;
        if (TutoTimeline >= TutoSpeed && TutoUp != null)
        {
            TutoTimeline = 0;
            TutoDown.SetActive(!TutoDown.activeSelf);
        }

        RStickStrength += Mathf.Abs(Input.GetAxis("Joy1 RightYAxis") + Input.GetAxis("Joy2 RightYAxis") + Input.GetAxis("Joy3 RightYAxis") + Input.GetAxis("Joy4 RightYAxis"));

        if (RStickStrength > 500 && !IsStarted)
        {
            IsStarted = true;

            playerSonorEffectsAS.clip  = startAC;
            playerSonorEffectsAS.pitch = 1f;
            playerSonorEffectsAS.Play();
        }

        if (IsStarted)
        {
            StartTimeline -= Time.unscaledDeltaTime;
        }

        if (StartTimeline <= TimeBeforeStart - TimeKillTuto && TutoUp != null)
        {
            Destroy(TutoUp);
            Destroy(TutoDown);
        }

        if (StartTimeline <= 1f && Foreground != null)
        {
            Color foregroundColor = Foreground.color;
            foregroundColor.a -= Time.unscaledDeltaTime;
            Foreground.color   = foregroundColor;

            if (Foreground.color.a <= .05f)
            {
                Destroy(Foreground.gameObject);
            }
        }

        if (StartTimeline <= 1)
        {
            foreach (PlayerAcceleration PA in Players)
            {
                PA.ForwardSpeed = Random.Range(150, 160);
            }
            Time.timeScale = 1;
            foreach (AudioSource AS in StartingAudioSources)
            {
                AS.Play();
            }
        }

        if (StartTimeline <= 0)
        {
            Destroy(this);
        }
    }
Exemplo n.º 4
0
    protected override void use( )
    {
        if (!delay.running)
        {
            if (ammo > 0)
            {
                for (int i = 0; i < pellets; i++)
                {
                    var dir = directionVector;
                    dir += U.RandomVec() * (spread + spreadInc);
                    var start = transform.position + getOffset(muzzleOffset / S.SIZE);
                    Fire(start, dir);
                }

                ammo--;
                delay.Start();

                if (ammo <= 0)
                {
                    sprite.returnTo = 3;
                }
                else
                {
                    sprite.returnTo = 1;
                }
                sprite.Play(2);

                if (this.eject)
                {
                    Vector3 eject;

                    switch (direction)
                    {
                    case 3:
                        eject = U.RandomVec(new Vector3(1, -1, -1), new Vector3(ejectForce, 1, ejectForce / 3));
                        break;

                    case 2:
                        eject = U.RandomVec(new Vector3(-1, -1, -1), new Vector3(ejectForce / 3, 1, -ejectForce));
                        break;

                    case 1:
                        eject = U.RandomVec(new Vector3(-1, -1, ejectForce / -3), new Vector3(-ejectForce, 1, 1));
                        break;

                    case 0:
                    default:
                        eject = U.RandomVec(new Vector3(ejectForce / -3, -1, 1), new Vector3(1, 1, ejectForce));
                        break;
                    }

                    G.I.casings.Add(
                        transform.position + new Vector3(0, -0.5f, 0.5f),
                        eject
                        );
                }

                G.I.PlaySound(Random.Range(soundId, soundId + 3));

                // Did the player suicide?
                if (attachedTo != null)
                {
                    attachedTo.GetComponent <Rigidbody2D>().AddForce(directionVector * -recoil, ForceMode2D.Impulse);
                }
                spreadInc += recoil * 0.5f;

                active = true;
            }
            else
            {
                sprite.returnTo = 3;
                sprite.Play(2, 3);
                G.I.PlaySound(2);
                delay.Start();
            }
        }
    }