void OnGUI()
 {
     if (beginning)
     {
         if (Screen.width <= 640 && Screen.height <= 960)
         {
             if (GUI.Button(new Rect(Screen.width / 2 - Screen.width / 4, Screen.height / 2, Screen.width / 2, Screen.width / 5), buttonTexture))
             {
                 beginning                 = false;
                 BirdBehavior.life         = 1;
                 BirdBehavior.instructions = true;
                 BirdBehavior.inGame       = true;
                 ScoreBehavior.Setup();
             }
         }
         else
         {
             if (GUI.Button(new Rect(Screen.width / 2 - buttonTexture.width / 2, Screen.height / 2 + buttonTexture.height / 4, buttonTexture.width, buttonTexture.height), buttonTexture))
             {
                 beginning                 = false;
                 BirdBehavior.life         = 1;
                 BirdBehavior.instructions = true;
                 BirdBehavior.inGame       = true;
                 ScoreBehavior.Setup();
             }
         }
     }
 }
 // Start is called before the first frame update
 void Awake()
 {
     if (instance)
     {
         Destroy(gameObject);
     }
     else
     {
         instance = this;
     }
 }
Exemple #3
0
 // Start is called before the first frame update
 void Start()
 {
     Cursor.visible = false;                                                               //Hide the mouse cursor
     Instantiate(crosshairo);                                                              //Instance a crosshair at origin
     image     = GetComponent <SpriteRenderer>();                                          //image is set equal to the attached SpriteRenderer component
     rb        = GetComponent <Rigidbody2D>();                                             //rb is set equal to the attached RigidBody2D component
     crosshair = GameObject.FindGameObjectWithTag("Crosshair");                            //crosshair is set equal to the GameObject with the tag "Crosshair"
     col       = GetComponent <Collider2D>();                                              //col is set equal to the attached Collider2D component
     score     = GameObject.FindGameObjectWithTag("Score").GetComponent <ScoreBehavior>(); //score is set equal to the ScoreBehavior component attached to the score UI element
     ramsound  = GetComponents <AudioSource>()[0];                                         //ramsound is set equal to the attached Audiosource component of index 0
     explode   = GetComponents <AudioSource>()[1];                                         //explode is set equal to the attached Audiosource component of index 1
 }
Exemple #4
0
 // Use this for initialization
 void Start()
 {
     plane         = GameObject.Find("plane");
     livesHandler  = GameObject.Find("heartContainer").gameObject.GetComponent <HeartsBehavior>();
     scoreHandler  = GameObject.Find("scoreContainer").gameObject.GetComponent <ScoreBehavior>();
     buttonHandler = Resources.FindObjectsOfTypeAll <ButtonBehavior>().First();
     buttonHandler.buttonClicked += () =>
     {
         SceneManager.LoadScene("Level1");
     };
     GenerateSpawnTime();
 }
    /**
     * Gets the position of the mouse and sets the transform forward of the bullet to face the mouse.**/
    public void SetForward()
    {
        Vector3 mousePosition = Input.mousePosition;
        Ray     mouseRay      = Camera.main.ScreenPointToRay(mousePosition);
        Plane   playerPlane   = new Plane(Vector3.up, transform.position);

        float rayDistance = 0;

        playerPlane.Raycast(mouseRay, out rayDistance);

        Vector3 target = mouseRay.GetPoint(rayDistance);

        Vector3 fireDirection = target - transform.position;

        transform.forward = fireDirection;

        score = GameObject.Find("Score").GetComponent <ScoreBehavior>();
    }
Exemple #6
0
    private void launchScore(int nb, int idFinished)
    {
        Debug.Log("AFFICHAGE");
        //create prefab Score
        ScoreBehavior pfScore = Instantiate(prefabScore);

        pfScore.transform.SetParent(ListeScore.transform);
        pfScore.GetComponent <TextMesh>().text  = "+" + nb;
        pfScore.GetComponent <TextMesh>().color = GetColorFromId(idFinished);

        //get call from idFinished
        Call c = getCallFromId(idFinished);

        //Vector2 sizeDelta = pfScore.GetComponent<RectTransform>().sizeDelta;
        //place score in the position of the reciever
        Debug.Log("POSITION SCORE");
        pfScore.transform.position = (c.reciever.transform.position) - new Vector3(0, 0, 1);// +new Vector3(sizeDelta.x, -sizeDelta.y,0)/2.0f;
    }
 private void OnCollisionEnter(Collision collision)
 {
     if (collision.gameObject.name.Contains("SquareTarget"))
     {
         ScoreBehavior.UpdateScore(1);
     }
     else if (collision.gameObject.name == "right")
     {
         UISelection.OnRightSelected();
     }
     else if (collision.gameObject.name == "left")
     {
         UISelection.OnLeftSelected();
     }
     else
     {
         HealthBehavior.UpdateHealth();
     }
 }
Exemple #8
0
 void OnTriggerEnter2D(Collider2D collision)
 {
     if (collision.gameObject.name == "Ground")
     {
         GetComponent <SpriteRenderer>().sprite = spriteDead;
         if (audioMusic.isPlaying)
         {
             audioMusic.Stop();
         }
         if (AudioButtonBehavior.audioSetting == 0)
         {
             audioAmbience.Play();
             audioSound.Play();
         }
         ending = true;
         life   = 0;
     }
     else if (collision.gameObject.name == "YellowCar")
     {
         if (life == 0)
         {
             slideYellow = true;
         }
     }
     else if (collision.gameObject.name == "RedCar")
     {
         if (life == 1)
         {
             bouncing = true;
             GetComponent <SpriteRenderer>().sprite = spriteFloat;
             if (AudioButtonBehavior.audioSetting == 0)
             {
                 audioImpact.Play();
             }
             ScoreBehavior.addPoint();
         }
         else if (life == 0)
         {
             slideRed = true;
         }
     }
 }
        protected override void CreateScene()
        {
            this.VirtualScreenManager.Activate(App.PreferredWidth, App.PreferredHeight, StretchMode.Uniform);

            var camera = new FixedCamera2D("defaultCamera2D");

            this.EntityManager.Add(camera);

            this.AddBackground();

            var harry = new Harry();

            this.EntityManager.Add(harry);

            var scoreBehavior         = new ScoreBehavior();
            var mapGenerationBehavior = new MapGenerationBehavior(scoreBehavior);

            this.AddSceneBehavior(mapGenerationBehavior, SceneBehavior.Order.PreUpdate);
            this.AddSceneBehavior(new CollisionDetectionBehavior(harry, mapGenerationBehavior, scoreBehavior), SceneBehavior.Order.PostUpdate);
            this.AddSceneBehavior(scoreBehavior, SceneBehavior.Order.PostUpdate);
#if DEBUG
            this.AddSceneBehavior(new DebugSceneBehavior(), SceneBehavior.Order.PostUpdate);
#endif
        }
Exemple #10
0
 // Start is called before the first frame update
 void Start()
 {
     scoreBehavior = FindObjectOfType <ScoreBehavior>();
     isDead        = false;
 }
Exemple #11
0
    private ScoreBehavior score; //The score UI element's ScoreBehavior component

    // Start is called before the first frame update
    void Start()
    {
        rb    = GetComponent <Rigidbody2D>();                                             //set rb equal to the attached Rigidbody2D component
        score = GameObject.FindGameObjectWithTag("Score").GetComponent <ScoreBehavior>(); //score is set equal to the ScoreBehavior component attached to the score UI element
        rb.AddForce(transform.up * force);                                                //AddForce to rb in the updirection multiplied by force
    }
 void Start()
 {
     ScoreBehavior.SaveScore();
     end = false;
 }
 private void Awake()
 {
     _instance = this;
 }
    private ScoreBehavior score;    //The score UI element's ScoreBehavior component

    // Start is called before the first frame update
    private void Start()
    {
        score = GameObject.FindGameObjectWithTag("Score").GetComponent <ScoreBehavior>();    //score is set equal to the ScoreBehavior component attached to the score UI element
    }
Exemple #15
0
 // Do physics engine updates here
 void FixedUpdate()
 {
     if (instructions == false)
     {
         if (inGame == true)
         {
             if (audioAmbience.isPlaying == true && AudioButtonBehavior.audioSetting == 0)
             {
                 audioAmbience.Stop();
             }
             if (MusicButtonBehavior.musicSetting == 0)
             {
                 audioMusic.Play();
             }
             inGame = false;
         }
         if (life == 1)
         {
             slideRed    = false;
             slideYellow = false;
             if (bouncing == false)
             {
                 if (diving == false)
                 {
                     transform.position += down * gravitySpeed * Time.deltaTime;
                 }
                 else
                 {
                     transform.position += down * diveSpeed * Time.deltaTime;
                 }
             }
             else
             {
                 if (diving == true)
                 {
                     diving      = false;
                     bounceIndex = 20;
                 }
                 transform.position += up * bounceIndex * Time.deltaTime;
                 bounceIndex        -= 1;
                 if (bounceIndex == 0)
                 {
                     bouncing    = false;
                     bounceIndex = bounceSpeed;
                 }
             }
         }
         else if (life == 0)
         {
             if (audioMusic.isPlaying)
             {
                 audioMusic.Stop();
             }
             if (slideRed == true && transform.position.x > -4)
             {
                 slideYellow         = false;
                 transform.position += RedCarBehavior.speed * Time.deltaTime;
             }
             if (slideYellow == true && transform.position.x > -4)
             {
                 slideRed            = false;
                 transform.position += YellowCarBehavior.speed * Time.deltaTime;
             }
             if (transform.position.x < -3 && ending == true)
             {
                 RetryButtonBehavior.end = true;
                 ScoreBehavior.show      = 0;
                 ScoreBehavior.SaveScore();
                 ending = false;
             }
         }
         else if (life == 3 && instructions == false)
         {
             if (audioAmbience.isPlaying == true)
             {
                 audioAmbience.Stop();
             }
             ending             = true;
             inGame             = true;
             bouncing           = false;
             diving             = false;
             slideRed           = false;
             slideYellow        = false;
             bounceIndex        = bounceSpeed;
             transform.position = startingPosition;
             GetComponent <SpriteRenderer>().sprite = spriteFloat;
             life = 1;
         }
     }
 }