Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // image script - start //
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- [System.Serializable]
- public class PhotoData
- {
- public Object[] photo_4 = new Object[4];
- }
- // image script - end //
- // Image holder script-start //
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- [System.Serializable]
- public class TitleData
- {
- public int pointsAddedForPuzzle;
- public string photoTitle;
- public PhotoData[] photos;
- }
- // Image holder script-end //
- // All data script - start //
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- using System.IO;
- public class PuzzleController : MonoBehaviour {
- public TitleData[] allTitles;
- void Start ()
- {
- DontDestroyOnLoad(gameObject);
- for (int i = 0; i < allTitles.Length; i++)
- {
- for (int t = 0; t < allTitles[i].photos.Length; t++)
- {
- int newIndex = Random.Range(0, allTitles[i].photos[t].photo_4.Length);
- int currentIndex = newIndex;
- for (int p = 0; p < allTitles[i].photos[t].photo_4.Length; p++)
- {
- //allTitles[i].photos[t].photo_4[p] = allTitles[i].photos[t].photo_4[currentIndex];
- }
- }
- }
- }
- public TitleData GetCurrentTitle ()
- {
- return allTitles[0];
- }
- }
- // All data script - end //
- // Insert - image - start // From data to UI Image
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- using UnityEngine.UI;
- public class InsertImage : MonoBehaviour {
- public PuzzleController puzzleController;
- public Image[] childSprites;
- int randomLevel;
- private void Awake()
- {
- // Find puzzles
- puzzleController = FindObjectOfType<PuzzleController>();
- }
- private void Start()
- {
- // Randomize puzzle
- randomLevel = Random.Range(0, 2);
- // if easy level
- for (int i = 0; i < childSprites.Length; i++)
- {
- for (int a = 0; a < puzzleController.allTitles.Length; a++)
- {
- for (int p = 0; p < puzzleController.allTitles[a].photos.Length; p++)
- {
- int newIndex = Random.Range(0, puzzleController.allTitles[a].photos[p].photo_4.Length);
- childSprites[i].sprite = (Sprite)puzzleController.allTitles[a].photos[randomLevel].photo_4[newIndex];
- }
- }
- }
- }
- public void DeleteLevel ()
- {
- // Delete already passed level
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement