Example #1
0
    // Use this for initialization
    public override void Start()
    {
        base.Start();

        // Randomize color
        mainRenderer.color = IPowerUp.FromHSV(Random.value, IEnemy.saturation, IEnemy.brightness);

        if ((ShipController.Instance != null) && (IGameManager.Instance != null))
        {
            // Randomize torque
            rigidbody2D.angularVelocity = Random.Range(spawnParams.torqueRange.x, spawnParams.torqueRange.y);

            if (IGameManager.Instance is ObjectSpawner)
            {
                // Calculate where to aim for
                mSpawnPosition    = ShipController.Instance.transform.position;
                mRandomOffset     = Random.insideUnitCircle.normalized * spawnParams.aimRange;
                mSpawnPosition.x += mRandomOffset.x;
                mSpawnPosition.y += mRandomOffset.y;
                mSpawnPosition   -= transform.position;
                mSpawnPosition.Normalize();

                // Randomize force
                mSpawnPosition      *= Random.Range(spawnParams.speedRange.x, spawnParams.speedRange.y);
                rigidbody2D.velocity = mSpawnPosition;
            }
        }
    }
Example #2
0
    // Use this for initialization
    public override void Start()
    {
        base.Start();

        // Randomize color
        mainRenderer.color = IPowerUp.FromHSV(Random.value, IEnemy.saturation, IEnemy.brightness);

        if ((ShipController.Instance != null) && (IGameManager.Instance != null))
        {
            // Check if we need to fling this enemy towards the player
            if (IGameManager.Instance is ObjectSpawner)
            {
                // Calculate where to aim for
                mSpawnPosition    = ShipController.Instance.transform.position;
                mRandomOffset     = Random.insideUnitCircle.normalized * spawnParams.aimRange;
                mSpawnPosition.x += mRandomOffset.x;
                mSpawnPosition.y += mRandomOffset.y;
                mSpawnPosition   -= transform.position;
                mSpawnPosition.Normalize();

                // Face the direction of velocity
                transform.rotation = ShipController.LookRotation2D(mSpawnPosition);

                // Randomize force
                mSpawnPosition      *= Random.Range(spawnParams.speedRange.x, spawnParams.speedRange.y);
                rigidbody2D.velocity = mSpawnPosition;
            }

            // Setup detection
            detection.detectRange *= detection.detectRange;
        }
    }
Example #3
0
    // Use this for initialization
    public override void Start()
    {
        base.Start();

        // Update sprite renderer color
        mainRenderer.color = IPowerUp.FromHSV(Random.value, IEnemy.saturation, IEnemy.brightness);

        if ((ShipController.Instance != null) && (IGameManager.Instance != null))
        {
            // Check if we need to fling this enemy to the player
            if (IGameManager.Instance is ObjectSpawner)
            {
                // Randomize torque
                rigidbody2D.angularVelocity = Random.Range(spawnParams.torqueRange.x, spawnParams.torqueRange.y);

                // Calculate where to aim for
                mSpawnPosition    = ShipController.Instance.transform.position;
                mRandomOffset     = Random.insideUnitCircle.normalized * spawnParams.aimRange;
                mSpawnPosition.x += mRandomOffset.x;
                mSpawnPosition.y += mRandomOffset.y;
                mSpawnPosition   -= transform.position;
                mSpawnPosition.Normalize();

                // Randomize force
                mSpawnPosition      *= Random.Range(spawnParams.speedRange.x, spawnParams.speedRange.y);
                rigidbody2D.velocity = mSpawnPosition;
            }

            // Update when we last fired
            detection.detectRange *= detection.detectRange;
            lastFired              = Time.time;
        }
    }
Example #4
0
    // Use this for initialization
    public override void Start()
    {
        // Play animation
        animation.Play();

        // Get a random hue
        hue = Random.value;
        IPowerUp.FromHSV(hue, saturation, brightness, ref spriteColor);
        label.color = spriteColor;
    }
Example #5
0
 void UpdateBackgroundColor()
 {
     hue += hueChangeSpeed * Time.deltaTime;
     if (hue > 1)
     {
         hue = 0;
     }
     IPowerUp.FromHSV(hue, saturation, brightness, ref backgroundColor);
     if (backgroundMesh != null)
     {
         backgroundMaterial.color = backgroundColor;
     }
 }
Example #6
0
    // Use this for initialization
    public override void Start()
    {
        base.Start();

        // Randomize color
        mainRenderer.color = IPowerUp.FromHSV(Random.value, IEnemy.saturation, IEnemy.brightness);

        if (IGameManager.Instance != null)
        {
            IGameManager.Instance.AddDestructable(this);

            // Randomize torque
            rigidbody2D.angularVelocity = Random.Range(torqueRange.x, torqueRange.y);
        }
    }
    private void ComboEffect(string text)
    {
        // Play the text animation
        comboTextAnimation.Stop();
        comboTextAnimation.Play();

        // Update the label
        comboTextLabel.text             = text;
        comboTextLabel.renderer.enabled = true;

        // Get a random hue
        comboHue = Random.value;
        IPowerUp.FromHSV(comboHue, ScoreLabel.saturation, ScoreLabel.brightness, ref comboSpriteColor);
        comboTextLabel.color = comboSpriteColor;
    }
Example #8
0
 // Update is called once per frame
 void Update()
 {
     if (animation.isPlaying == true)
     {
         hue += IPowerUp.hueChangeSpeed * Time.deltaTime;
         if (hue > 1)
         {
             hue = 0;
         }
         IPowerUp.FromHSV(hue, saturation, brightness, ref spriteColor);
         label.color = spriteColor;
     }
     else
     {
         gameObject.SetActive(false);
     }
 }
    // Use this for initialization
    public override void Start()
    {
        // Add this sprite into the collection
        allBackgroundSprites.Add(this);
        deactivateNextLoop = false;

        // Update start time
        startTime = Time.time;

        // Position the star
        position           = ShipController.Instance.transform.position;
        offset             = Random.insideUnitCircle * maximumDistanceFromShip;
        position.x        += offset.x;
        position.y        += offset.y;
        position.z         = transform.position.z;
        transform.position = position;

        // Cancel physics
        rigidbody2D.velocity        = Vector2.zero;
        rigidbody2D.angularVelocity = 0;

        // Rotate star
        transform.rotation = Quaternion.Euler(0, 0, Random.Range(0f, 360f));

        // Update color
        IPowerUp.FromHSV(Random.value, saturation, brightness, ref spriteColor);
        if (spriteRenderer != null)
        {
            spriteRenderer.color = spriteColor;
        }
        else if (textRenderer != null)
        {
            textRenderer.color = spriteColor;
        }

        // Update rotate speed
        rotateSpeed = Random.Range(-maxSpinSpeed, maxSpinSpeed);

        // Animate the star
        animation.Play();
    }
Example #10
0
    // Use this for initialization
    void Awake()
    {
        msInstance = this;

        // Update hue
        hue = Random.value;
        IPowerUp.FromHSV(hue, saturation, brightness, ref backgroundColor);
        mainCamera.backgroundColor = backgroundColor;

        // Fill the dictionary
        currentBackgroundSet = allSets[0];
        backgroundDictionary.Clear();
        for (int index = 0; index < allSets.Length; ++index)
        {
            backgroundDictionary.Add(allSets[index].type, allSets[index]);
        }

        if (backgroundMesh != null)
        {
            // Retrieving the background material
            backgroundMaterial      = backgroundMesh.material;
            backgroundMeshTransform = backgroundMesh.transform;
            meshPosition            = backgroundMeshTransform.position;

            // Grab texture transition
            textureTransition = backgroundMaterial.GetFloat(blendFloat);
            backgroundMaterial.SetTexture(mainTexture, currentBackgroundSet.background);
        }

        // Grab volume transition
        maxVolume        = mainBackgroundSoundSource.volume;
        volumeTransition = maxVolume;
        soundSource1     = mainBackgroundSoundSource;
        soundSource2     = fadeInSoundSource;
        playingSource1   = true;

        // Startup current settings
        currentBackgroundSet.generator.Active = true;
        mainBackgroundSoundSource.clip        = currentBackgroundSet.music;
    }
    public void TextEffect(string text, string animationName)
    {
        // Play the text animation
        textAnimation.Stop();
        if (string.IsNullOrEmpty(animationName) == true)
        {
            textAnimation.Play();
        }
        else
        {
            textAnimation.Play(animationName);
        }

        // Update the label
        textLabel.text             = text;
        textLabel.renderer.enabled = true;

        // Get a random hue
        hue = Random.value;
        IPowerUp.FromHSV(hue, ScoreLabel.saturation, ScoreLabel.brightness, ref spriteColor);
        textLabel.color = spriteColor;
    }
    void Update()
    {
        // FIXME: use InControl this time, since the control stuff I have is too buggy.
        if ((ShipState == State.Playing) || (ShipState == State.Tutorial))
        {
            if (Mathf.Approximately(Input.GetAxis("Pause"), 0) == false)
            {
                if (dontPauseOnPrompt == false)
                {
                    if (ShipState == State.Tutorial)
                    {
                        EndTutorial();
                    }
                    else
                    {
                        dontPauseOnPrompt = true;
                        Time.timeScale    = 0;
                        shipState         = State.Paused;
                        if (pauseEvent != null)
                        {
                            pauseEvent(this);
                        }
                    }
                }
                else
                {
                    UpdateControlScheme();
                    ControlShip();
                    ControlGun();
                }
            }
            else
            {
                UpdateControlScheme();
                ControlShip();
                ControlGun();
                dontPauseOnPrompt = false;
            }

            // Check if the text is visible
            if (textLabel.renderer.enabled == true)
            {
                // Check if it's still animating
                if (textAnimation.isPlaying == true)
                {
                    // Animate its color
                    hue += IPowerUp.hueChangeSpeed * Time.deltaTime;
                    if (hue > 1)
                    {
                        hue = 0;
                    }
                    IPowerUp.FromHSV(hue, ScoreLabel.saturation, ScoreLabel.brightness, ref spriteColor);
                    textLabel.color = spriteColor;
                }
                else
                {
                    // Hide the text label when it's done animating
                    textLabel.renderer.enabled = false;
                }
            }
            if (comboTextLabel.renderer.enabled == true)
            {
                // Check if it's still animating
                if (comboTextAnimation.isPlaying == true)
                {
                    // Animate its color
                    comboHue += IPowerUp.hueChangeSpeed * Time.deltaTime;
                    if (comboHue > 1)
                    {
                        comboHue = 0;
                    }
                    IPowerUp.FromHSV(comboHue, ScoreLabel.saturation, ScoreLabel.brightness, ref comboSpriteColor);
                    comboTextLabel.color = comboSpriteColor;
                }
                else
                {
                    // Hide the text label when it's done animating
                    comboTextLabel.renderer.enabled = false;
                }
            }
        }
    }