-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathField.cs
71 lines (65 loc) · 1.9 KB
/
Field.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
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Field : MonoBehaviour
{
// Start is called before the first frame update
public float enemySpawn, enemyChoose;
public int enemyCount;
public GameObject Enemy1, Enemy2, EnemyBig;
public GameObject enemyClone;
public GameObject EnemySpawn;
public Vector3 EnPos;
public Transform Batya;
internal static bool StartFight;
public GameObject Dver;
internal static int DoorOpen;
public GameObject thisF;
void Start()
{
EnPos = new Vector3(transform.position.x,transform.position.y,5);
StartFight = false;
enemyCount = Random.Range(3, 6);
DoorOpen = enemyCount;
}
private void SpawnEnemies()
{
if (enemyCount > 0)
{
EnPos = new Vector3(transform.position.x + Random.Range(-7, 7), transform.position.y + Random.Range(-7, 7), 5);
enemyChoose = Random.Range(1, 101);
if (enemyChoose < 10) enemyClone = EnemyBig;
if (enemyChoose >= 10 && enemyChoose <= 55) { enemyClone = Enemy1; }
if (enemyChoose > 55) { enemyClone = Enemy2; }
Debug.Log(enemyChoose);
EnemySpawn = Instantiate(enemyClone, EnPos, Quaternion.identity,transform);
enemyCount -= 1;
Debug.Log(enemyCount);
}
if (enemyCount == 0)
{
StartFight = false;
}
}
public void OpenDoor()
{
Dver.SetActive(false);
}
// Update is called once per frame
void Update()
{
}
public void FixedUpdate()
{
if (StartFight == true)
{
SpawnEnemies();
}
if (DoorOpen == 0)
{
Dver.SetActive(false);
enemyCount = Random.Range(3, 6);
thisF.SetActive(false);
}
}
}