-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathStealLegScript
113 lines (96 loc) · 2.97 KB
/
StealLegScript
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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class transitionScript : MonoBehaviour
{
Transform player;
Animator animator;
Animator bossAnim;
itemHandler iH;
LightScript lS;
PlayerMovement pM;
public speechScript sS;
public Transform legPos;
public GameObject stealText;
public GameObject afterStealText;
public GameObject SatchelBag;
Vector3 satchelStartPos;
public bool stealing;
bool legOn = true;
bool playerInRange;
bool countDown;
float time;
// Start is called before the first frame update
void Start()
{
bossAnim = GetComponent<Animator>();
animator = GameObject.Find("Player").GetComponent<Animator>();
player = GameObject.Find("Player").GetComponent<Transform>();
iH = GameObject.Find("Player").GetComponent<itemHandler>();
lS = GameObject.Find("Player").GetComponent<LightScript>();
pM = GameObject.Find("Player").GetComponent<PlayerMovement>();
}
// Update is called once per frame
void FixedUpdate()
{
checkIfPlayerInRange();
if (playerInRange)
{
if (Input.GetKeyDown(KeyCode.E) && !stealing)
{
animator.SetTrigger("stealLeg");
stealing = true;
time = 0;
countDown = true;
pM.enabled = false;
satchelStartPos = SatchelBag.transform.position;
satchelStartPos.y -= 2.1f;
SatchelBag.transform.position = satchelStartPos;
}
if (!stealing)
{
stealText.SetActive(true);
}
else
{
stealText.SetActive(false);
}
}
else
{
stealText.SetActive(false);
}
if (countDown)
{
//Countdownen tillader at animationen har nok tid til at blive færdig, før man spiller videre.
time += Time.deltaTime;
player.position = new Vector3(legPos.position.x, player.position.y, player.position.z);
if(time > 0.6f && legOn)
{
legOn = false;
bossAnim.SetBool("legOff", true);
}
if (time > 6.4)
{
countDown = false;
iH.swordObtained = true;
lS.changeState = 1;
sS.showText = true;
afterStealText.SetActive(true);
pM.enabled = true;
stealing = false;
satchelStartPos = SatchelBag.transform.position;
satchelStartPos.y += 2.1f;
SatchelBag.transform.position = satchelStartPos;
}
}
}
void checkIfPlayerInRange()
{
if (Vector2.Distance(player.position, legPos.position) < 0.5f)
{
playerInRange = true;
}
else { playerInRange = false; }
}
}