using System; using System.Linq; using UnityEngine; using System.Collections; using System.Collections.Generic; public class ruutudeloomine : MonoBehaviour { // Use this for initialization List ruudud=new List(); void Start () { //Lugege uute ruutude koordinaadid sisse failist GameObject ruut=(GameObject)GameObject.Find ("Ruut"); for (int x=-5; x<5; x=x+2) { GameObject uusRuut=(GameObject)Instantiate (ruut); uusRuut.transform.position=new Vector3(x, 0, 0); uusRuut.renderer.material.color=Color.black; ruudud.Add(uusRuut); } } void OnGUI(){ if (GUI.Button (new Rect (310, 10, 80, 20), "Vajuta")) { foreach(GameObject ruut in ruudud.Where( r => r.transform.position.x>0)){ ruut.transform.position+=Vector3.right; } } //Salvestage ruutude uued koordinaadid faili } public RaycastHit tabamus = new RaycastHit(); void Update () { if(Input.GetKey(KeyCode.Mouse0)){ Ray kiir=Camera.main.ScreenPointToRay(Input.mousePosition); if(Physics.Raycast(kiir, out tabamus, 100)){ if(tabamus.collider.renderer.material.color==Color.black){ tabamus.collider.renderer.material.color=Color.red; GameObject kera=(GameObject)GameObject.Find ("Kera"); GameObject uusKera=(GameObject)Instantiate(kera); uusKera.transform.position=new Vector3(tabamus.collider.transform.position.x, 1, 0); //Pange vastavalt mängule kerad ja kuubikud tekkima kordamööda } } } } }