Advertisement
Guest User

Untitled

a guest
Jun 26th, 2017
61
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.80 KB | None | 0 0
  1. public class WallGenerator : MonoBehaviour {
  2.  
  3.     public GameObject Canvas;
  4.     public GameObject WallTop;
  5.     public GameObject WallBot;
  6.     public float position;
  7.     public float between_wall;
  8.     public float StartPostion;
  9.     float Number_of_walls;
  10.  
  11.     // Мяу
  12.     void Start () {
  13.         Create (8);
  14.     }
  15.  
  16.     public void Create (float Number_of_walls)
  17.     {
  18.         for (float i = 0; i < Number_of_walls; i++) {
  19.             position = Random.Range (0, 5);
  20.             GameObject Wall1;
  21.             GameObject Wall2;
  22.             Wall1 = Instantiate (WallTop, new Vector3 ((StartPostion - i * between_wall),WallTop.transform.position.y,0), Quaternion.identity);
  23.             Wall1.GetComponent<RectTransform> ().sizeDelta = new Vector2 (100,100 + position * 32);
  24.             Wall1.transform.SetParent(Canvas.transform);
  25.             Wall1.SetActive (true);
  26.             Debug.Log ("Wall 1 Создано: " + position );
  27.             Wall2 = Instantiate (WallBot, new Vector3 ((StartPostion - i * between_wall),WallBot.transform.position.y,0), Quaternion.identity);
  28.             Wall2.GetComponent<RectTransform> ().sizeDelta = new Vector2 (100,100 + ((4 - position)* 32));
  29.             Wall2.transform.SetParent(Canvas.transform);
  30.             Wall2.SetActive (true);
  31.             Debug.Log ("Wall 2 Создано: " + position );
  32.         }
  33.     }
  34. }
  35.  
  36. using System.Collections;
  37. using System.Collections.Generic;
  38. using UnityEngine;
  39.  
  40. public class Move : MonoBehaviour {
  41.  
  42.     public float MS;
  43.     public int Side;
  44.     //Для указания стороны
  45.     //1 = право
  46.     //-1 = лево
  47.     void Start () {
  48.        
  49.     }
  50.  
  51.     // Update is called once per frame
  52.     void Update () {
  53.         transform.Translate (new Vector2 (Side, 0) * MS * Time.deltaTime);
  54.     }
  55. }
  56.  
  57. using System.Collections;
  58. using System.Collections.Generic;
  59. using UnityEngine;
  60.  
  61. public class RIP : MonoBehaviour {
  62.  
  63.     public float time;
  64.     //Убиваем :с
  65.     void Start () {
  66.         Destroy (this.gameObject, time);
  67.     }
  68. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement