-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathgetScore.cs
78 lines (61 loc) · 2.34 KB
/
getScore.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
74
75
76
77
78
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class getScore : MonoBehaviour
{
Player player;
public static int isAntUpSideDown = 0; //뒤집어질때 사용할 변수
public int finalBread = 0; //breadCount 에서 true 개수 count할 변수
public bool goalCollide; //땅바닥에 충돌했는지 확인하는 변수
void OnTriggerEnter(Collider other)
{
if (other.tag == "Goal")
{
Debug.Log("개미가 골대에 닿음");
goalCollide = true;
}
}
void OnTriggerExit(Collider other)
{
if (other.tag == "Goal")
{
Debug.Log("개미가 골대에서 떨어짐!");
goalCollide = false;
}
}
void Start()
{
player = GameObject.Find("ant").GetComponent<Player>();
}
// Update is called once per frame
void Update()
{
if (Input.GetKeyDown(KeyCode.Space) && goalCollide && isAntUpSideDown % 2 == 1) //누르는 동안 hold //바닥에 닿았을 때 //개미가 역방향일 때 -> 정방향
{
GameObject.Find("Canvas").GetComponent<PopupLoad>().chkSpace = false;
Player.isParent_A = false;
Player.isParent_S = false;
Player.isParent_K = false;
Player.isParent_L = false;
transform.eulerAngles = new Vector3(0.0f, 90.0f, 90.0f);
isAntUpSideDown++;
finalBread = 0;
for (int i = 0; i < 4; i++)
{
if (GameObject.Find("ant").GetComponent<Player>().breadCount[i] == true)
{
finalBread++;
GameObject.Find("ant").GetComponent<Player>().breadCount[i] = false;
}
}
score.scoreValue += finalBread;
SoundManager.PlaySound("pointsound");
}
else if (Input.GetKeyDown(KeyCode.Space) && player.isPlayerEnter && isAntUpSideDown % 2 == 0) //식빵 닿았을 때 //개미가 정방향일 때 -> 역방향
{
transform.eulerAngles = new Vector3(0.0f, 270.0f, 270.0f);
transform.position = new Vector3(transform.position.x, 37.99f, transform.position.z);
isAntUpSideDown++;
}
}
}