-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathLamba2.cs
55 lines (40 loc) · 1.14 KB
/
Lamba2.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Lamba2 : MonoBehaviour
{
public LambaTipi lambaTipi;
public int xIndex;
public int yIndex;
public bool isMatched;
private Vector2 currentPos;
private Vector2 targetPos;
public bool isMoving;
public void SetIndicies(int _x, int _y)
{
xIndex = _x;
yIndex = _y;
}
//hedefe hareket
public void MoveToTarget(Vector2 _targetPos)
{
StartCoroutine(MoveCoroutine(_targetPos));
}
//rutine hareket ettir
private IEnumerator MoveCoroutine(Vector2 _targetPos)
{
isMoving = true;
float duration = 0.2f;
Vector2 startPosition = transform.position;
float elaspedTime = 0f;
while (elaspedTime < duration)
{
float t = elaspedTime / duration;
transform.position = Vector2.Lerp(startPosition, _targetPos, t);
elaspedTime += Time.deltaTime;
yield return null;
}
transform.position = _targetPos;
isMoving = false;
}
}