12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394 |
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- public class MakeEnemyManager : MonoBehaviour
- {
- // Start is called before the first frame update
- public bool isMakeEnemy = true;
- public int myRandomEnemy;//随机生成敌人
- public static int myRandomEnemyAllNum;//随机生成多少个敌人
- private float myEnemeyPosX;
- private float myEnemeyPosZ;
- private GameObject enemyPrefab;
- public List<GameObject> enemyList = new List<GameObject>();
- public bool IsInstantiateEnemy=false;//是否产生敌人
- void Start()
- {
-
- myRandomEnemyAllNum = 3;
- enemyPrefab = Resources.Load("PlayerTypeOfWork") as GameObject;
- if (isMakeEnemy)
- {
- MakeEnemyPrefab(myRandomEnemyAllNum);
- }
- }
- // Update is called once per frame
- bool isAddMaxX ;
- bool isAddMaxZ ;
- int random;
- private void LateUpdate()
- {
-
- // RoBotEnemyRandomPos();
-
- }
- private void MakeEnemyPrefab(int num)
- {
-
- {
- }
- for (int i = 0; i < num; i++)
- {
- myRandomEnemy = UnityEngine.Random.Range(1, 4);
- myEnemeyPosX = UnityEngine.Random.Range(-1000, 1000);
- myEnemeyPosZ = UnityEngine.Random.Range(-1000, 1000);
- GameObject enemy = Instantiate(enemyPrefab, new Vector3(myEnemeyPosX, 0, myEnemeyPosZ), Quaternion.identity);
- enemy.GetComponent<MiniMapFit>().action = "";
- enemy.GetComponent<MiniMapFit>().id = i.ToString();
- enemy.GetComponent<MiniMapFit>().des = "Enemy" + i.ToString();
- enemy.GetComponent<MiniMapFit>().pos = myEnemeyPosX + "_" + "0" + "_" + myEnemeyPosZ;
- enemy.GetComponent<MiniMapFit>().eul = "";
- if (myRandomEnemy == 1)
- {
- enemy.GetComponent<MiniMapFit>().typeOfWork = "EnemyTypeOfWork1";
- }
- else if (myRandomEnemy == 2)
- {
- enemy.GetComponent<MiniMapFit>().typeOfWork = "EnemyTypeOfWork2";
- }
- else if (myRandomEnemy == 3)
- {
- enemy.GetComponent<MiniMapFit>().typeOfWork = "EnemyTanke";
- }
- enemy.GetComponent<MiniMapFit>().isRobotEnemy = true;
- enemyList.Add(enemy);
- }
- if (IsInstantiateEnemy==false)
- {
- IsInstantiateEnemy = true;
- }
- }
- public static Vector3 StrSubstringToV3(string str)
- {
- if (str == null)
- {
- return new Vector3();
- }
- string[] s = str.Split('_');
- return new Vector3(float.Parse(s[0]), float.Parse(s[1]), float.Parse(s[2]));
- }
-
- }
|