Advertisement
La_zars

Untitled

Mar 6th, 2015
224
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.98 KB | None | 0 0
  1. using UnityEngine;
  2. using System.Collections;
  3.  
  4. public class GameScript : MonoBehaviour
  5. {
  6.     public GameObject cellBufer;
  7.     public GameObject cellBuferWoomen;
  8.     public GameObject buferEda;
  9.     GameObject cell;
  10.     GameObject cellWoomen;
  11.     GameObject eda;
  12.     float x, y;
  13.     float x2, y2;
  14.     float speed = 5;
  15.     float timer, timer2;
  16.     float timeBuffer = 30;
  17.     float timerBufWoomen = 40;
  18.    
  19.    
  20.    
  21.     void Start()
  22.     {
  23.         cell = (GameObject)GameObject.Instantiate(cellBufer);
  24.         cell.name = "cell";
  25.         cell.transform.position = new Vector3(0, 0);
  26.         timer = timeBuffer;
  27.  
  28.         cellWoomen = (GameObject)GameObject.Instantiate(cellBuferWoomen);
  29.         cellWoomen.name = "cellWoomen";
  30.         cellWoomen.transform.position = new Vector3(-20, 30);
  31.         timer2 = timerBufWoomen;
  32.  
  33.         eda = (GameObject)GameObject.Instantiate(buferEda);
  34.         eda.name = "eda";
  35.         eda.transform.position = new Vector2(Random.Range(-6, 6), Random.Range(-6, 6));
  36.     }
  37.  
  38.  
  39.     void Update()
  40.     {
  41.         timer--;
  42.         if (timer == 0)
  43.         {
  44.             CellRondomXy();
  45.         }
  46.         CellMoving();
  47.  
  48.         timer2--;
  49.         if (timer2 == 0)
  50.         {
  51.             CellRondomXyWoom();
  52.         }
  53.         CellMovingWoom();
  54.         CellSex();
  55.         Eda();
  56.        
  57.        
  58.     }
  59.     void CellRondomXy()
  60.     {
  61.         x = Random.Range(-2, 2);
  62.         y = Random.Range(-2, 2);
  63.         timer = timeBuffer;
  64.     }
  65.  
  66.     public void CellMoving()
  67.     {
  68.         cell.transform.position = Vector2.Lerp(cell.transform.position, new Vector2(x, y), speed * Time.deltaTime);
  69.     }
  70.  
  71.     void CellRondomXyWoom()
  72.     {      
  73.         x2 = Random.Range(-2, 2);
  74.         y2 = Random.Range(-2, 2);
  75.         timer2 = timerBufWoomen;
  76.     }
  77.  
  78.     public void CellMovingWoom()
  79.     {      
  80.         cellWoomen.transform.position = Vector2.Lerp(cellWoomen.transform.position, new Vector2(x2, y2 ), speed * Time.deltaTime);
  81.     }
  82.  
  83.     void CellSex()
  84.     {
  85.         if ((cell.transform.position.x < cellWoomen.transform.position.x + 0.2) && (cell.transform.position.y < cellWoomen.transform.position.y + 0.2))
  86.         {
  87.             if ((cell.transform.position.x > cellWoomen.transform.position.x - 0.2) && (cell.transform.position.y > cellWoomen.transform.position.y - 0.2))
  88.             {
  89.              
  90.                 cell = (GameObject)GameObject.Instantiate(cellBufer);
  91.                 cell.name = "cell";
  92.                 cell.transform.position = new Vector3(Random.Range(-40,40), Random.Range(-40,40));
  93.             }
  94.         }
  95.  
  96.     }
  97.  
  98.     void Eda()
  99.     {
  100.         if ((cell.transform.position.x < eda.transform.position.x + 0.2) && (cell.transform.position.y < eda.transform.position.y + 0.2))
  101.         {
  102.             if ((cell.transform.position.x > eda.transform.position.x - 0.2) && (cell.transform.position.y > eda.transform.position.y + 0.2))
  103.             {
  104.                 GameObject.Destroy(eda);
  105.             }
  106.         }
  107.  
  108.     }
  109. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement