private IEnumerator SpawnPoints()
{
while(true)
{
float randomX = Random.Range(leftDown.position.x, rightDown.position.x);
float randomY = Random.Range(leftDown.position.y, leftUP.position.y);
Instantiate(prefab, new Vector3(randomX, randomY, 0), Quaternion.identity);
yield return new WaitForSeconds(1f);
}
}
private void Update()
{
rigidbody2D.velocity = new Vector2(speed, rigidbody2D.velocity.y);
if (leftPos != leftBttn.transform.position.y)
{
//rigidbody2D.velocity = new Vector2(speed, rigidbody2D.velocity.y);
speed = -5f;
}
else if (rightPos != rightBttn.transform.position.y)
{
speed = 5f;
}
else
{
speed = 0f;
}
rigidbody2D.velocity = new Vector2(speed, rigidbody2D.velocity.y);
}
private void OnCollisionEnter2D(Collision2D coll)
{
if (coll.gameObject.CompareTag("Shop") && gameObject.name == works.ci.ToString())
{
allVariables.money += 5;
works.howMuchEarn += 5;
works.textMoneyCourierEarn.text = "Заработано - " + works.howMuchEarn;
Destroy(gameObject);
}
}
[SerializeField]
private GameObject card; // твоя карта
public void BuyACard()
{
card.SetActive(true);
}
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.EventSystems;
public class DND : MonoBehaviour, IBeginDragHandler, IDragHandler
{
public Transform transform;
public Vector2 vector2;
private void Awake()
{
transform = GetComponent<Transform>();
}
public void OnBeginDrag(PointerEventData eventData)
{
Debug.Log("OnBeginDrag");
}
public void OnDrag(PointerEventData eventData)
{
Debug.Log("OnDrag");
vector2 = Camera.main.ScreenToWorldPoint(eventData.position);
transform.position = new Vector3(vector2.x, vector2.y, 0);
//transform.position = eventData.pointerCurrentRaycast.screenPosition;
}
}