public void changeLevelNames(int index)
	{
		int number = (index*10)+1;
		LevelDetailHandler levelDetailHandler = new LevelDetailHandler();
		foreach (GameObject child in children)
		{
			child.SendMessage(SET_NAME_METHOD,number+"");
			child.SendMessage(SET_STAR_METHOD,levelDetailHandler.getStarIndex(number));
			number++;
		}
	}
    public void changeLevelNames(int index)
    {
        int number = (index * 10) + 1;
        LevelDetailHandler levelDetailHandler = new LevelDetailHandler();

        foreach (GameObject child in children)
        {
            child.SendMessage(SET_NAME_METHOD, number + "");
            child.SendMessage(SET_STAR_METHOD, levelDetailHandler.getStarIndex(number));
            number++;
        }
    }
Пример #3
0
    void displayScoreDetails()
    {
        //Get and display score
        ScoreTracker scoreTracker = GetComponent <ScoreTracker>();
        string       scoreMessage = "";

        scoreMessage += "-Score-\n";
        scoreMessage += "Destruction Score: " + scoreTracker.getObjectDamageScore() + ".\n";
        scoreMessage += "Enemy Score: " + scoreTracker.getEnemyDamageScore() + ".\n";
        scoreMessage += "Ammo Score: " + scoreTracker.getAmmoScore() + ".\n";
        scoreMessage += "Total Score: " + scoreTracker.getTotalScore() + ".";

        mainCamera.SendMessage(DISPLAY_SCORE_DETAILS_METHOD, scoreMessage);
        LevelDetailHandler levelDetailHandler = new LevelDetailHandler();
        LevelDetail        detail             = new LevelDetail(Application.loadedLevel, scoreTracker.getTotalScore());

        mainCamera.SendMessage(DISPLAY_STAR_METHOD, levelDetailHandler.getStarIndex(detail));
    }
	// Use this for initialization
	void Start () 
	{
		if(display == true)
		{
			LevelDetailHandler levelDetailHander = new LevelDetailHandler();
			if(levelDetailHander.getStarIndex(Application.loadedLevel) == 0)
			{
				GetComponent<SpriteRenderer>().enabled = true;
				startColor = renderer.material.color;
				endColor = renderer.material.color;
				endColor.a = 0f;
			}
			else
			{
				display = false;
				Destroy(gameObject);
			}
		}
		else
		{
			Destroy(gameObject);
		}
	}
 // Use this for initialization
 void Start()
 {
     if (display == true)
     {
         LevelDetailHandler levelDetailHander = new LevelDetailHandler();
         if (levelDetailHander.getStarIndex(Application.loadedLevel) == 0)
         {
             GetComponent <SpriteRenderer>().enabled = true;
             startColor = renderer.material.color;
             endColor   = renderer.material.color;
             endColor.a = 0f;
         }
         else
         {
             display = false;
             Destroy(gameObject);
         }
     }
     else
     {
         Destroy(gameObject);
     }
 }
    void Update()
    {
        if (Input.GetKeyDown(KeyCode.Escape))
        {
            Application.Quit();
        }

        if (cameraLoaded == true)
        {
            Vector3 touchPosition = mainCamera.ScreenToWorldPoint(Input.mousePosition);

            if (Input.GetMouseButtonUp(0))
            {
                RaycastHit2D hit = Physics2D.Raycast(touchPosition, Vector2.zero);

                if (hit.transform != null)
                {
                    string hitName = hit.collider.name;

                    if (confirmState == false)
                    {
                        if (hitName.Equals(PLAY_BUTTON))
                        {
                            index = 0;

                            Invoke(LOAD_LEVEL_METHOD, 0.25f);
                            //Application.LoadLevel(LEVEL_1);
                        }
                        else if (hitName.Equals(NEXT_BUTTON))
                        {
                            index++;
                            if (index >= 2)
                            {
                                index--;
                            }
                            else
                            {
                                Invoke(LOAD_LEVEL_METHOD, 0.25f);
                            }
                        }
                        else if (hitName.Equals(PREVIOUS_BUTTON))
                        {
                            index--;
                            if (index < 0)
                            {
                                index = 0;
                                Destroy(tempObject);
                                tempObject = Instantiate(mainMenu_Prefab) as GameObject;
                            }
                            else
                            {
                                Invoke(LOAD_LEVEL_METHOD, 0.25f);
                            }
                        }
                        else if (hitName.Equals(RESET_BUTTON))
                        {
                            tempConfirm  = Instantiate(confirmPrefab) as GameObject;
                            confirmState = true;
                        }
                        else
                        {
                            Application.LoadLevel(int.Parse(hitName));
                            //Debug.Log(hitName);
                        }
                    }
                    else
                    {
                        if (hitName.Equals(YES_BUTTON))
                        {
                            LevelDetailHandler levelDetailHandler = new LevelDetailHandler();
                            levelDetailHandler.delete();
                            Destroy(tempConfirm);
                            confirmState = false;
                        }
                        else if (hitName.Equals(NO_BUTTON))
                        {
                            Destroy(tempConfirm);
                            confirmState = false;
                        }
                    }
                }
            }
        }
        else
        {
            if (Camera.main != null)
            {
                this.mainCamera = Camera.main;
                cameraLoaded    = true;
            }
        }
    }
	void Update () 
	{
		if (Input.GetKeyDown(KeyCode.Escape)) 
		{ 
			Application.Quit(); 
		}

		if(cameraLoaded == true)
		{
			Vector3 touchPosition = mainCamera.ScreenToWorldPoint(Input.mousePosition);
			
			if(Input.GetMouseButtonUp(0))
			{
				RaycastHit2D hit = Physics2D.Raycast(touchPosition, Vector2.zero);

				if(hit.transform!=null)
				{
					string hitName = hit.collider.name;

					if(confirmState == false)
					{
						if(hitName.Equals(PLAY_BUTTON))
						{
							index = 0;

							Invoke(LOAD_LEVEL_METHOD,0.25f);
							//Application.LoadLevel(LEVEL_1);
						}
						else if(hitName.Equals(NEXT_BUTTON))
						{
							index ++;
							if(index>=2)
							{
								index --;
							}
							else
							{
								Invoke(LOAD_LEVEL_METHOD,0.25f);
							}
						}
						else if(hitName.Equals(PREVIOUS_BUTTON))
						{
							index --;
							if(index<0)
							{
								index = 0;
								Destroy(tempObject);
								tempObject = Instantiate(mainMenu_Prefab) as GameObject;
							}
							else
							{
								Invoke(LOAD_LEVEL_METHOD,0.25f);
							}						
						}
						else if (hitName.Equals(RESET_BUTTON))
						{
							tempConfirm = Instantiate(confirmPrefab) as GameObject;
							confirmState = true;
						}
						else
						{
							Application.LoadLevel(int.Parse(hitName));
							//Debug.Log(hitName);
						}
					}
					else
					{
						if(hitName.Equals(YES_BUTTON))
						{
							LevelDetailHandler levelDetailHandler = new LevelDetailHandler();
							levelDetailHandler.delete();
							Destroy(tempConfirm);
							confirmState = false;
						}
						else if(hitName.Equals(NO_BUTTON))
						{
							Destroy(tempConfirm);
							confirmState = false;
						}
					}
				}
			}
		}
		else
		{
			if(Camera.main!=null)
			{
				this.mainCamera = Camera.main;
				cameraLoaded = true;
			}
		}
	}
	void displayScoreDetails()
	{
		//Get and display score
		ScoreTracker scoreTracker = GetComponent<ScoreTracker>();
		string scoreMessage = "";
		scoreMessage += "-Score-\n";
		scoreMessage += "Destruction Score: "+scoreTracker.getObjectDamageScore()+".\n";
		scoreMessage += "Enemy Score: "+scoreTracker.getEnemyDamageScore()+".\n";
		scoreMessage += "Ammo Score: "+scoreTracker.getAmmoScore()+".\n";
		scoreMessage += "Total Score: "+scoreTracker.getTotalScore()+".";

		mainCamera.SendMessage(DISPLAY_SCORE_DETAILS_METHOD,scoreMessage);
		LevelDetailHandler levelDetailHandler = new LevelDetailHandler();
		LevelDetail detail = new LevelDetail(Application.loadedLevel,scoreTracker.getTotalScore());

		mainCamera.SendMessage(DISPLAY_STAR_METHOD,levelDetailHandler.getStarIndex(detail));

	}