-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathLamba.cs
73 lines (57 loc) · 1.36 KB
/
Lamba.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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Lamba : MonoBehaviour
{
public LambaTipi lambaTipi;
public int xIndex;
public int yIndex;
public bool isMatched;
private Vector2 currentPos;
private Vector2 targetPos;
public bool isMoving;
public Lamba(int _x, int _y)
{
xIndex = _x;
yIndex = _y;
}
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;
}
}
public enum LambaTipi
{
Mavi,
Sari,
Yesil,
Gri,
Siyah,
Beyaz,
Mor,
Kahverengi,
Turuncu,
}