Ejemplo n.º 1
0
    private void ChangeColorState()
    {
        //Animator animator = GetComponent<Animator>();

        if (!firstColorChange && LevelManager.GetLevel() == LevelManager.LEVELS.TUTORIAL0)
        {
            GameObject tutorial = GameObject.Find("TutorialCollider");
            if (tutorial)
            {
                GameObject tutorialText = GameObject.Find("Tutorial Text");
                tutorialText.GetComponent <TutorialText>().NextText();
            }
            firstColorChange = true;
        }

        ParticleSystem.MainModule main = hitParticles.GetComponent <ParticleSystem>().main;

        if (hitParticles.GetComponent <ParticleSystem>())
        {
            switch (my_comp_color)
            {
            case COMP_COLOR.Purple:
                main.startColor = Color.yellow;      // yellow
                break;

            case COMP_COLOR.Red:
                main.startColor = Color.green;
                break;

            case COMP_COLOR.Orange:
                main.startColor = Color.blue;
                break;

            default:
                Debug.LogWarning("missing shark code");
                break;
            }

            Instantiate(hitParticles, transform.position, Quaternion.identity);

            AudioSource.PlayClipAtPoint(friendSound, transform.position, PPrefsMgr.GetSfxVolume());
            gameObject.layer = FRIENDLY_LAYER;
            if (score) // because no score on Start level
            {
                score.AddToScore(scoreValue);
            }

            Invoke("ChangeToFriendly", changetime); // will change shark color after particles
        }
    }
Ejemplo n.º 2
0
 public void OnCollisionEnter2D(Collision2D col)
 {
     if (col.gameObject.tag == "areas")  // all sea blocks, play collision sound
     {
         // sometimes when you hit blocks (especially from below) the sound is louder because two play at a time
         // (2 collisions happen), currently do not consider this a bug. Also this sound isn't as loud as colorray
         // which I could fix here if we want
         AudioSource.PlayClipAtPoint(bumpSound, transform.position, PPrefsMgr.GetSfxVolume());
     }
     else if (col.gameObject.tag == "enemy")
     {
         TriggerHurt();
     }
 }
Ejemplo n.º 3
0
    private void FireColorRay()
    {
        // for tutorial state
        if (!firstFireColorRay)
        {
            GameObject tutorial = GameObject.Find("TutorialCollider");
            if (tutorial)
            {
                GameObject tutorialText = GameObject.Find("Tutorial Text");
                if (tutorialText.GetComponent <TutorialText>().GetTutorialState() == TUTORIAL_STATE.SPACEBAR)
                {
                    firstFireColorRay = true;
                }
                else
                {
                    return; // you can't fire yet
                }
            }
            else
            {
                firstFireColorRay = true;
            }
        }
        // on my computer if i'm holding UP and LEFT at the same time then SPACEBAR doesn't work
        // but I'm fine using WA or the numberkey pad with numlock off

        //Debug.Log("FireColorRay " + my_facing);
        GameObject beam;

        beam = Instantiate(colorRayPrefabs[(int)my_Color], transform.position, Quaternion.identity) as GameObject;

        float speed = beam.gameObject.GetComponent <ColorRay>().GetSpeed();

        //Debug.Log("myspeed = " + my_speed + " coloray " + speed);
        // ensure colorRay faster than player
        if (speed < my_speed + 5f)
        {
            speed = my_speed + 5f;
        }

        beam.gameObject.GetComponent <ColorRay>().SetColor(my_Color);
        //beam.gameObject.GetComponent<ColorRay>().SetFacing(my_facing);

        //enum Facing { NORTH, NORTHEAST, EAST, SOUTHEAST, SOUTH, SOUTHWEST, WEST, NORTHWEST };
        Vector3 facingVector = FacingVector(my_facing);

        beam.GetComponent <Rigidbody2D>().velocity = new Vector2(speed * facingVector.x, speed * facingVector.y);

        AudioSource.PlayClipAtPoint(fireSound, transform.position, PPrefsMgr.GetSfxVolume()); // andrea
    }
Ejemplo n.º 4
0
/*    private void EndHurt()
 *  {
 *      //isHurt = false;
 *      Animator animator = GetComponent<Animator>();
 *      animator.speed = 1f;
 *  }
 */

    public void TriggerGoal()
    {
        AudioSource.PlayClipAtPoint(successSound, transform.position, PPrefsMgr.GetSfxVolume());
        Invoke("LoadNextScene", .5f); // will load next scene in two seconds
    }