Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using UnityEngine;
- using System.Collections;
- public class GameScript : MonoBehaviour
- {
- public GameObject cellBufer;
- public GameObject cellBuferWoomen;
- public GameObject buferEda;
- GameObject cell;
- GameObject cellWoomen;
- GameObject eda;
- float x, y;
- float x2, y2;
- float speed = 5;
- float timer, timer2;
- float timeBuffer = 30;
- float timerBufWoomen = 40;
- void Start()
- {
- cell = (GameObject)GameObject.Instantiate(cellBufer);
- cell.name = "cell";
- cell.transform.position = new Vector3(0, 0);
- timer = timeBuffer;
- cellWoomen = (GameObject)GameObject.Instantiate(cellBuferWoomen);
- cellWoomen.name = "cellWoomen";
- cellWoomen.transform.position = new Vector3(-20, 30);
- timer2 = timerBufWoomen;
- eda = (GameObject)GameObject.Instantiate(buferEda);
- eda.name = "eda";
- eda.transform.position = new Vector2(Random.Range(-6, 6), Random.Range(-6, 6));
- }
- void Update()
- {
- timer--;
- if (timer == 0)
- {
- CellRondomXy();
- }
- CellMoving();
- timer2--;
- if (timer2 == 0)
- {
- CellRondomXyWoom();
- }
- CellMovingWoom();
- CellSex();
- Eda();
- }
- void CellRondomXy()
- {
- x = Random.Range(-2, 2);
- y = Random.Range(-2, 2);
- timer = timeBuffer;
- }
- public void CellMoving()
- {
- cell.transform.position = Vector2.Lerp(cell.transform.position, new Vector2(x, y), speed * Time.deltaTime);
- }
- void CellRondomXyWoom()
- {
- x2 = Random.Range(-2, 2);
- y2 = Random.Range(-2, 2);
- timer2 = timerBufWoomen;
- }
- public void CellMovingWoom()
- {
- cellWoomen.transform.position = Vector2.Lerp(cellWoomen.transform.position, new Vector2(x2, y2 ), speed * Time.deltaTime);
- }
- void CellSex()
- {
- if ((cell.transform.position.x < cellWoomen.transform.position.x + 0.2) && (cell.transform.position.y < cellWoomen.transform.position.y + 0.2))
- {
- if ((cell.transform.position.x > cellWoomen.transform.position.x - 0.2) && (cell.transform.position.y > cellWoomen.transform.position.y - 0.2))
- {
- cell = (GameObject)GameObject.Instantiate(cellBufer);
- cell.name = "cell";
- cell.transform.position = new Vector3(Random.Range(-40,40), Random.Range(-40,40));
- }
- }
- }
- void Eda()
- {
- if ((cell.transform.position.x < eda.transform.position.x + 0.2) && (cell.transform.position.y < eda.transform.position.y + 0.2))
- {
- if ((cell.transform.position.x > eda.transform.position.x - 0.2) && (cell.transform.position.y > eda.transform.position.y + 0.2))
- {
- GameObject.Destroy(eda);
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement