public void apply()
    {
        GameObject effectBomb = (GameObject)Instantiate(Resources.Load("PickupBomb"), transform.position, Quaternion.identity);
        ColorLerp  bombColor  = effectBomb.transform.GetChild(0).gameObject.GetComponent <ColorLerp>();

        bombColor.startColor = effectColor;
        bombColor.endColor   = new Color(effectColor.r, effectColor.g, effectColor.b, 0);

        if (ctrl.bombs < MAX_BOMBS)
        {
            ctrl.bombs += bombAdd;
        }
        else if (ctrl.bombs >= MAX_BOMBS && bombAdd > 0)
        {
            ctrl.changeMultiplier(3);   //increment multiplier by 1
        }
        if (ctrl.getHealth() < MAX_HEALTH)
        {
            ctrl.setHealth(ctrl.getHealth() + healthAdd);
        }
        else if (ctrl.getHealth() >= MAX_HEALTH && healthAdd > 0)
        {
            ctrl.changeMultiplier(3);   //increment mulitiplier by 1
        }
        HelperFunctions.playSound(ref _audioSource, pickUpSound);
        foreach (GameObject g in HelperFunctions.getChildren(gameObject.transform))
        {
            if (g.GetComponent <SpriteRenderer>() != null)
            {
                g.GetComponent <SpriteRenderer>().color = Color.clear;
            }
        }
        pickedUp = true;
        Destroy(gameObject, 0);
    }
Exemple #2
0
 void Start()
 {
     state     = GetComponent <State>();
     col       = GetComponent <BoxCollider2D>();
     colorLerp = GetComponent <ColorLerp>();
     anim      = GetComponent <Animator>();
     source    = GetComponent <AudioSource>();
 }
    public void Pulse()
    {
        GameObject pulse     = (GameObject)Instantiate(Resources.Load("PulseBomb"), transform.position, Quaternion.identity);
        ColorLerp  bombColor = pulse.transform.GetChild(0).gameObject.GetComponent <ColorLerp>();

        bombColor.startColor = effectColor;
        bombColor.endColor   = new Color(effectColor.r, effectColor.g, effectColor.b, 0);
    }
    private IEnumerator TransitionAndLoad(string sceneName)
    {
        ColorLerp c = GameObject.FindGameObjectWithTag("Transition").GetComponent <ColorLerp>();

        c.SetActivated(true);
        yield return(new WaitForSeconds(c.ChangeDuration));

        SceneManager.LoadScene(sceneName);
    }
    public static IEnumerator TransitionAndLoad(string sceneName)
    {
        ColorLerp c = GameObject.FindGameObjectWithTag("Transition").GetComponent <ColorLerp>();

        c.SetActivated(true);
        GameObject.Find("EventSystem").GetComponent <EventSystem>().enabled = false;
        yield return(new WaitForSeconds(c.ChangeDuration));

        SceneManager.LoadScene(sceneName);
    }
Exemple #6
0
 void Awake()
 {
     player         = GameObject.FindGameObjectWithTag("Player");
     col            = GetComponent <BoxCollider2D>();
     colorLerp      = GetComponent <ColorLerp>();
     oscillator     = GetComponent <SpriteColorOscillation>();
     spriteRenderer = GetComponent <SpriteRenderer>();
     colorA         = colorLerp.startColor;
     colorB         = colorLerp.endColor;
 }
Exemple #7
0
    public virtual void die(Color deathColor, bool byBomb)
    {
        if (!isDead)
        {
            if (!byBomb)                 // Die not by bomb
            {
                if (controller.survival) // Add points and drop item
                {
                    controller.addPoints((int)(points * ctrl.multiplier));
                    GameObject p = Instantiate(pointsText, canvas.transform);
                    p.GetComponent <RectTransform>().localPosition = HelperFunctions.objectCameraConvert(transform.position, canvas, cam);
                    p.GetComponent <Text>().text = ((int)(points * ctrl.multiplier)).ToString();

                    if (ctrl.willDrop())
                    {
                        dropItem();
                    }
                }

                _particleSystem.Play();
            }
            _audioSource.pitch = Random.Range(.5f, 1.5f);
            HelperFunctions.playSound(ref _audioSource, deathSound); //i think popping sound because the enemy dies before sound finishes

            isDead     = true;
            invincible = true;



            if (GetComponent <Simple_Movement>() != null)
            {
                GetComponent <Simple_Movement>().stopMovement();
            }
            foreach (GameObject spriteObject in spriteObjects)
            {
                if (spriteObject.GetComponent <ConstantRotation>() != null)
                {
                    spriteObject.GetComponent <ConstantRotation>().setSpeed(0);
                }
                if (spriteObject.GetComponent <ColorLerp>() != null)
                {
                    ColorLerp colorLerp = spriteObject.GetComponent <ColorLerp>(); // Fade to transparent
                    colorLerp.startColor = deathColor;
                    colorLerp.endColor   = new Color(deathColor.r, deathColor.g, deathColor.b, 0);
                    colorLerp.startColorChange();
                }
                if (spriteObject.GetComponent <ColorOscillationWithSprites>() != null)
                {
                    spriteObject.GetComponent <ColorOscillationWithSprites>().stopColorChange();
                }
            }
            Destroy(gameObject, 1);
        }
    }
    public static IEnumerator TransitionThenLoad(string nextScene)
    {
        AllowUIInput = false;
        ColorLerp transition = GameObject.FindGameObjectWithTag("Transition").GetComponentInChildren <ColorLerp>();

        transition.Activated = true;
        yield return(new WaitForSeconds(transition.ChangeDuration));

        AllowUIInput = true;
        SceneManager.LoadScene(nextScene);
    }
Exemple #9
0
    void Start()
    {
        if (target == null)
        {
            target = gameObject.GetComponent <ColorLerp>();
        }
        onEvent = gameObject.GetComponent <OnEvent>();

        onEvent.enter += setHoverColor;
        onEvent.exit  += stopHoverColor;
    }
Exemple #10
0
    // Use this for initialization
    void Start()
    {
        m_Laser = Instantiate(m_LaserPrefab, Vector3.zero, transform.rotation) as GameObject;
        m_Laser.transform.parent        = transform.GetChild(0);
        m_Laser.transform.localPosition = new Vector3(0, 0, -1.0f);
        m_Laser.name = "EyeLaser";

        eyeClosed = this.transform.Find("EyeClosed").gameObject;
        colorLerp = this.GetComponent <ColorLerp>();

        attackPattern         = this.GetComponent <EnragedAttackPattern> ();
        attackPattern.enabled = false;
    }
Exemple #11
0
 void Awake()
 {
     laserSprite = laser.GetComponent <SpriteRenderer>();
     laserColor  = laser.GetComponent <ColorLerp>();
     ctrl        = GameObject.Find("GameController").GetComponent <gameController>();
     try
     {
         _audioSource      = GetComponents <AudioSource>()[0];
         _multiplierSource = GetComponents <AudioSource>()[1];
     }
     catch
     {
     }
 }
    void ClickEnemy()
    {
        if (enemyCurrent != null)
        {
            // todo: have a subsystem drive the click damage variable
            float damageClick = 2.0f;

            // apply damage
            enemyCurrent.Damage(damageClick);

            // if the enemy is dead, destroy it and spawn a new enemy
            if (enemyCurrent.healthCurrent <= 0.0f)
            {
                DestroyEnemy();
                SpawnEnemy();
            }

            // play the sound fx
            if (enemyCurrent.onClickedAudioClip != null)
            {
                AudioSource audioSource = enemyCurrent.GetComponent <AudioSource>();
                UnityEngine.Assertions.Assert.IsNotNull(audioSource);
                audioSource.PlayOneShot(enemyCurrent.onClickedAudioClip);
            }

            // Add the color lerp.

            var renderer = enemyCurrent.GetComponent <Renderer>();
            UnityEngine.Assertions.Assert.IsNotNull(renderer);

            ColorLerp colorLerp = enemyCurrent.GetComponent <ColorLerp>();
            if (colorLerp != null)
            {
                Destroy(colorLerp);
            }
            enemyCurrent.gameObject.AddComponent <ColorLerp>();
        }
    }
    private IEnumerator EnableDelay()
    {
        yield return(new WaitForEndOfFrame());

        //_eventSystem.enabled = false;
        if (SceneManager.GetActiveScene().name == "openpacks")
        {
            _packReceiver       = GameObject.Find("PackReceiver").transform;
            _colorLerp          = _packReceiver.GetComponent <ColorLerp>();
            _dragParticles      = GameObject.Find("FlowContainer").GetComponentsInChildren <ParticleSystemRenderer>();
            _eventSystem        = GameObject.Find("EventSystem");
            _dragParticles      = GameObject.Find("FlowContainer").GetComponentsInChildren <ParticleSystemRenderer>();
            _eventSystem        = GameObject.Find("EventSystem");
            _backButton         = GameObject.FindWithTag(Tags.SINGLETONTAG).GetComponent <BackButton>();
            _backButton.enabled = false;
            _packTrail          = GameObject.Find("PackTrail").GetComponent <PackTrail>();
        }
        _packExpansion = _onDragBeginPack._packExpansion;
        ChangeFlowVisibility(1);
        _colorLerp.ControlLerp(true);
        _packTrail.packToFollow = transform;
        _packTrail.GetComponent <ParticleSystem>().Play();
    }
 void Start()
 {
     state     = GetComponent <State>();
     col       = GetComponent <BoxCollider2D>();
     colorLerp = GetComponent <ColorLerp>();
 }
Exemple #15
0
 void Start()
 {
     timer          = 0;
     spriteRenderer = GetComponent <SpriteRenderer>();
     colorLerp      = GetComponent <ColorLerp>();
 }
 private void Start()
 {
     _colorLerpPresets = _colorPresetsGameObject.GetComponents <ColorLerpPreset>();
     _colorLerp        = GetComponent <ColorLerp>();
 }
Exemple #17
0
    // Use this for initialization
    void Start()
    {
        m_Laser = Instantiate(m_LaserPrefab, Vector3.zero, transform.rotation) as GameObject;
        m_Laser.transform.parent = transform.GetChild(0);
        m_Laser.transform.localPosition = new Vector3(0, 0, -1.0f);
        m_Laser.name = "EyeLaser";

        eyeClosed = this.transform.Find("EyeClosed").gameObject;
        colorLerp = this.GetComponent<ColorLerp>();

        attackPattern = this.GetComponent<EnragedAttackPattern> ();
        attackPattern.enabled = false;
    }