Delete near Enemy Detect future. Use different density sensor.
Unity: No more detect Closest enemy info. Add different density sensor let agent get more state information on the center of view. Adjust Start Scene UI manager. Add in game visible rayCast & information that rayCast detect. Python: Start use mypy black and flake8 to format Python.
This commit is contained in:
@@ -65,7 +65,6 @@ public class AgentWithGun : Agent
|
||||
public float mouseYSensitivity = 200;
|
||||
public float yRotation = 0.1f;//定义一个浮点类型的量,记录‘围绕’X轴旋转的角度
|
||||
|
||||
|
||||
private float startTime = 0;
|
||||
private int shoot = 0;
|
||||
private float lastShootTime = 0.0f;
|
||||
@@ -95,47 +94,80 @@ public class AgentWithGun : Agent
|
||||
|
||||
void Start()
|
||||
{
|
||||
DataTransfer = GameObject.Find("StartSeneDataTransfer").GetComponent<StartSeneData>();
|
||||
UICon = transform.GetComponent<UIController>();
|
||||
HistoryRec = transform.GetComponent<HistoryRecorder>();
|
||||
rayScript = GetComponent<RaySensors>();
|
||||
try
|
||||
{
|
||||
// get DataTranfer
|
||||
DataTransfer = GameObject.Find("StartSeneDataTransfer").GetComponent<StartSeneData>();
|
||||
// Enemy Num
|
||||
enemyNum = DataTransfer.EnemyNum;
|
||||
|
||||
// Enemy Num
|
||||
enemyNum = DataTransfer.EnemyNum;
|
||||
// Time Limit
|
||||
timeLimit = DataTransfer.Timelim;
|
||||
|
||||
// Time Limit
|
||||
timeLimit = DataTransfer.Timelim;
|
||||
// get load directory.
|
||||
LoadDirDate = DataTransfer.LoadDirDate;
|
||||
LoadDirTime = DataTransfer.LoadDirTime;
|
||||
LoadDirDateF = float.Parse(LoadDirDate);
|
||||
loadDirTimeF = float.Parse(LoadDirTime);
|
||||
|
||||
// get load directory.
|
||||
LoadDirDate = DataTransfer.LoadDirDate;
|
||||
LoadDirTime = DataTransfer.LoadDirTime;
|
||||
LoadDirDateF = float.Parse(LoadDirDate);
|
||||
loadDirTimeF = float.Parse(LoadDirTime);
|
||||
// get Default reward.
|
||||
nonRewardDefault = DataTransfer.nonReward;
|
||||
shootRewardDefault = DataTransfer.shootReward;
|
||||
shootWithoutReadyRewardDefault = DataTransfer.shootWithoutReadyReward;
|
||||
hitRewardDefault = DataTransfer.hitReward;
|
||||
killRewardDefault = DataTransfer.killReward;
|
||||
winRewardDefault = DataTransfer.winReward;
|
||||
loseRewardDefault = DataTransfer.loseReward;
|
||||
|
||||
// get Default reward.
|
||||
nonRewardDefault = DataTransfer.nonReward;
|
||||
shootRewardDefault = DataTransfer.shootReward;
|
||||
shootWithoutReadyRewardDefault = DataTransfer.shootWithoutReadyReward;
|
||||
hitRewardDefault = DataTransfer.hitReward;
|
||||
killRewardDefault = DataTransfer.killReward;
|
||||
winRewardDefault = DataTransfer.winReward;
|
||||
loseRewardDefault = DataTransfer.loseReward;
|
||||
|
||||
// give default Reward to Reward value will be used.
|
||||
nonReward = nonRewardDefault;
|
||||
shootReward = shootRewardDefault;
|
||||
shootWithoutReadyReward = shootWithoutReadyRewardDefault;
|
||||
hitReward = hitRewardDefault;
|
||||
winReward = winRewardDefault;
|
||||
loseReward = loseRewardDefault;
|
||||
killReward = killRewardDefault;
|
||||
// change Decision Period & Take Actions Between Decisions
|
||||
transform.GetComponent<DecisionRequester>().DecisionPeriod = DataTransfer.DecisionPeriod;
|
||||
transform.GetComponent<DecisionRequester>().TakeActionsBetweenDecisions = DataTransfer.ActionsBetweenDecisions;
|
||||
|
||||
// change Decision Period & Take Actions Between Decisions
|
||||
transform.GetComponent<DecisionRequester>().DecisionPeriod = DataTransfer.DecisionPeriod;
|
||||
transform.GetComponent<DecisionRequester>().TakeActionsBetweenDecisions = DataTransfer.ActionsBetweenDecisions;
|
||||
}
|
||||
catch (NullReferenceException)
|
||||
{
|
||||
// Enemy Num
|
||||
enemyNum = 3;
|
||||
|
||||
//initialize remainTime
|
||||
remainTime = (int)(timeLimit - Time.time + startTime);
|
||||
// Time Limit
|
||||
timeLimit = 30;
|
||||
|
||||
// get load directory.
|
||||
LoadDirDate = "0";
|
||||
LoadDirTime = "0";
|
||||
LoadDirDateF = float.Parse(LoadDirDate);
|
||||
loadDirTimeF = float.Parse(LoadDirTime);
|
||||
|
||||
// get Default reward.
|
||||
nonRewardDefault = -0.05f;
|
||||
shootRewardDefault = -0.06f;
|
||||
shootWithoutReadyRewardDefault = -0.06f;
|
||||
hitRewardDefault = 5.0f;
|
||||
killRewardDefault = 10.0f;
|
||||
winRewardDefault = 20.0f;
|
||||
loseRewardDefault = -10.0f;
|
||||
|
||||
// change Decision Period & Take Actions Between Decisions
|
||||
transform.GetComponent<DecisionRequester>().DecisionPeriod = 1;
|
||||
transform.GetComponent<DecisionRequester>().TakeActionsBetweenDecisions = true;
|
||||
}
|
||||
finally
|
||||
{
|
||||
UICon = transform.GetComponent<UIController>();
|
||||
HistoryRec = transform.GetComponent<HistoryRecorder>();
|
||||
rayScript = GetComponent<RaySensors>();
|
||||
|
||||
// give default Reward to Reward value will be used.
|
||||
nonReward = nonRewardDefault;
|
||||
shootReward = shootRewardDefault;
|
||||
shootWithoutReadyReward = shootWithoutReadyRewardDefault;
|
||||
hitReward = hitRewardDefault;
|
||||
winReward = winRewardDefault;
|
||||
loseReward = loseRewardDefault;
|
||||
killReward = killRewardDefault;
|
||||
//initialize remainTime
|
||||
remainTime = (int)(timeLimit - Time.time + startTime);
|
||||
}
|
||||
}
|
||||
|
||||
/* ----------此Update用于debug,Build前删除或注释掉!----------*/
|
||||
@@ -300,7 +332,7 @@ public class AgentWithGun : Agent
|
||||
//且绕轴旋转的坐标轴是父节点本地坐标系的坐标轴
|
||||
}
|
||||
|
||||
// GotKill 获得击杀时用于呼出
|
||||
// GotKill 获得击杀时用于被呼出
|
||||
public void GotKill()
|
||||
{
|
||||
enemyKillCount += 1;
|
||||
@@ -493,19 +525,17 @@ public class AgentWithGun : Agent
|
||||
//List<float> enemyLDisList = RaySensors.enemyLDisList;// All Enemy Lside Distances
|
||||
//List<float> enemyRDisList = RaySensors.enemyRDisList;// All Enemy Rside Distances
|
||||
|
||||
|
||||
int allEnemyNum = RaySensors.allEnemyNum;
|
||||
rayScript.updateRayInfo();
|
||||
float[] myObserve = { thisAgent.position.x, thisAgent.position.y, thisAgent.position.z, thisAgent.rotation.w };
|
||||
float[] rayTagResult = RaySensors.rayTagResult;// 探测用RayTag结果 float[](raySensorNum,1)
|
||||
float[] rayDisResult = RaySensors.rayDisResult; // 探测用RayDis结果 float[](raySensorNum,1)
|
||||
float[] focusEnemyObserve = RaySensors.focusEnemyInfo;// 最近的Enemy情报 float[](3,1) MinEnemyIndex,x,z
|
||||
int raySensorNum = rayScript.rayNum;// raySensor数量 int
|
||||
float[] rayTagResult = rayScript.rayTagResult;// 探测用RayTag结果 float[](raySensorNum,1)
|
||||
float[] rayDisResult = rayScript.rayDisResult; // 探测用RayDis结果 float[](raySensorNum,1)
|
||||
//float[] focusEnemyObserve = RaySensors.focusEnemyInfo;// 最近的Enemy情报 float[](3,1) MinEnemyIndex,x,z
|
||||
|
||||
//sensor.AddObservation(allEnemyNum); // 敌人数量 int
|
||||
sensor.AddObservation(myObserve); // 自机位置xyz+朝向 float[](4,1)
|
||||
sensor.AddObservation(rayTagResult); // 探测用RayTag结果 float[](raySensorNum,1)
|
||||
sensor.AddObservation(rayDisResult); // 探测用RayDis结果 float[](raySensorNum,1)
|
||||
sensor.AddObservation(focusEnemyObserve); // 最近的Enemy情报 float[](3,1) MinEnemyIndex,x,z
|
||||
//sensor.AddObservation(focusEnemyObserve); // 最近的Enemy情报 float[](3,1) MinEnemyIndex,x,z
|
||||
//sensor.AddObservation(raySensorNum); // raySensor数量 int
|
||||
sensor.AddObservation(LoadDirDateF); // 用于loadModel的第一级dir
|
||||
sensor.AddObservation(loadDirTimeF); // 用于loadModel的第二级dir
|
||||
|
||||
@@ -6,6 +6,7 @@ public class CameraChange : MonoBehaviour
|
||||
{
|
||||
public Camera FPSCamera;
|
||||
public Camera TPSCamera;
|
||||
public GameObject AgentOBJ;
|
||||
|
||||
public void switchCamera()
|
||||
{
|
||||
@@ -26,10 +27,12 @@ public class CameraChange : MonoBehaviour
|
||||
{
|
||||
TPSCamera.enabled = true;
|
||||
FPSCamera.enabled = false;
|
||||
AgentOBJ.GetComponent<RaySensors>().showInGameRay = true;
|
||||
}
|
||||
public void ShowFPSView()
|
||||
{
|
||||
FPSCamera.enabled = true;
|
||||
TPSCamera.enabled = false;
|
||||
AgentOBJ.GetComponent<RaySensors>().showInGameRay = false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,52 +0,0 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class Camera_Control : MonoBehaviour
|
||||
{
|
||||
public Transform Agent;
|
||||
public Camera Cam;
|
||||
public float MouseSensitivity = 100;
|
||||
public float yRotation = 0.1f;//定义一个浮点类型的量,记录‘围绕’X轴旋转的角度
|
||||
public float viewDistance = 100;
|
||||
|
||||
private float Mouse_X;
|
||||
private float Mouse_Y;
|
||||
|
||||
void Start()
|
||||
{
|
||||
Cursor.lockState = CursorLockMode.Locked;// 隐藏并且锁定鼠标
|
||||
}
|
||||
|
||||
void Update()
|
||||
{
|
||||
//Mouse_X = Input.GetAxis("Mouse X") * MouseSensitivity * Time.deltaTime;
|
||||
//Debug.Log(Input.GetAxis("Mouse X"));
|
||||
//Mouse_Y = Input.GetAxis("Mouse Y") * MouseSensitivity * Time.deltaTime;
|
||||
|
||||
//yRotation = yRotation - Mouse_Y;
|
||||
//xRotation值为正时,屏幕下移,当xRotation值为负时,屏幕上移
|
||||
//当鼠标向上滑动,Mouse_Y值为正,xRotation-Mouse_Y的值为负,xRotation总的值为负,屏幕视角向上滑动
|
||||
//当鼠标向下滑动,Mouse_Y值为负,xRotation-Mouse_Y的值为正,xRotation总的值为正,屏幕视角向下滑动
|
||||
//简单来说就是要控制鼠标滑动的方向与屏幕移动的方向要相同
|
||||
|
||||
//limit UP DOWN between -90 -> 90
|
||||
//yRotation = Mathf.Clamp(yRotation, -90f, 90f);
|
||||
|
||||
|
||||
//相机左右旋转时,是以Y轴为中心旋转的,上下旋转时,是以X轴为中心旋转的
|
||||
//Agent.Rotate(Vector3.up * Mouse_X);
|
||||
//Vector3.up相当于Vector3(0,1,0),CameraRotation.Rotate(Vector3.up * Mouse_X)相当于使CameraRotation对象绕y轴旋转Mouse_X个单位
|
||||
//即相机左右旋转时,是以Y轴为中心旋转的,此时Mouse_X控制着值的大小
|
||||
|
||||
//相机在上下旋转移动时,相机方向不会随着移动,类似于低头和抬头,左右移动时,相机方向会随着向左向右移动,类似于向左向右看
|
||||
//所以在控制相机向左向右旋转时,要保证和父物体一起转动
|
||||
//this.transform.localRotation = Quaternion.Euler(yRotation, 0, 0);
|
||||
//this.transform指这个CameraRotation的位置,localRotation指的是旋转轴
|
||||
//transform.localRotation = Quaternion.Eular(x,y,z)控制旋转的时候,按照X-Y-Z轴的旋转顺规
|
||||
//即以围绕X轴旋转x度,围绕Y轴旋转y度,围绕Z轴旋转z度
|
||||
//且绕轴旋转的坐标轴是父节点本地坐标系的坐标轴
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -15,6 +15,10 @@ public class EnemyHPBar : MonoBehaviour
|
||||
EnemyOBJ = transform.parent.gameObject;
|
||||
BGOBJ = transform.GetChild(0).gameObject;
|
||||
gaugeImgOBJ = BGOBJ.transform.GetChild(0).gameObject;
|
||||
Vector3 v = Camera.main.transform.position - transform.position;
|
||||
v.x = v.z = 0.0f;
|
||||
transform.LookAt(Camera.main.transform.position - v);
|
||||
transform.Rotate(0,180,0);
|
||||
}
|
||||
|
||||
void Update()
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using System.Collections;
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
@@ -7,30 +8,59 @@ using UnityEngine;
|
||||
|
||||
public class RaySensors : MonoBehaviour
|
||||
{
|
||||
|
||||
public Camera agentCam;
|
||||
public GameObject myself;
|
||||
public int rayNum = 6;
|
||||
public string EnemyTagName;
|
||||
public string WallTagName;
|
||||
public float viewDistance = 100; // how long the ray can detect
|
||||
public float Damage = 50; // damage to enemy
|
||||
public float attentionRange = 1f; //注意力范围,1为最大
|
||||
public float MaxDistance = 9999999999f;
|
||||
public float EnemyWidthRedundancy = 0.01f; //为了确保Ray可以击中Enemy,用于缩小EnemyWidth的长度
|
||||
//public List<string> tagNames = new List<string>();
|
||||
public static int allEnemyNum = 0;//All Enemy Num
|
||||
public static float[] focusEnemyInfo = new float[3];
|
||||
public static float[] rayTagResult; // Array to save Tag Result
|
||||
public static float[] rayDisResult; // Array to save Distance Result
|
||||
public static List<float> enemyLDisList = new List<float>();// All Enemy Lside Distances
|
||||
public static List<float> enemyRDisList = new List<float>();// All Enemy Rside Distances
|
||||
public Material lineMeterial;
|
||||
public GameObject rayInfoPrefab;
|
||||
public GameObject agentCanvas;
|
||||
|
||||
[SerializeField, Range(0, 500)] public float viewDistance = 100; // how long the ray can detect
|
||||
//[SerializeField, Range(0, 1)] public float totalRange = 1f; // Total view range Max = 1
|
||||
[SerializeField, Range(0, 1)] public float focusRange = 0.15f; // center focus range
|
||||
public int halfOuterRayNum = 3; // >=2
|
||||
public int focusRayNum = 5; // >= 1 and must be odd num!
|
||||
|
||||
[Header("InGameLineSetting")]
|
||||
public bool showInGameRay = true;
|
||||
public bool showDebugRay = true;
|
||||
public bool showInGameRayInfo = true;
|
||||
public float lineWidth = 0.05f;
|
||||
|
||||
public bool showEnemySensor = true;
|
||||
public bool showEyeSensor = true;
|
||||
[Header("RayCastResult")]
|
||||
public float[] rayTagResult;
|
||||
public float[] rayDisResult;
|
||||
|
||||
[System.NonSerialized] public int totalRayNum;
|
||||
GameObject[] linesOBJ;
|
||||
GameObject[] rayInfoOBJ;
|
||||
LineRenderer[] lineRenderers;
|
||||
rayInfoUI[] rayInfoUIs;
|
||||
|
||||
|
||||
private void Start()
|
||||
{
|
||||
|
||||
totalRayNum = halfOuterRayNum * 2 + focusRayNum;
|
||||
rayTagResult = new float[totalRayNum];
|
||||
rayDisResult = new float[totalRayNum];
|
||||
linesOBJ = new GameObject[totalRayNum];
|
||||
lineRenderers = new LineRenderer[totalRayNum];
|
||||
rayInfoOBJ = new GameObject[totalRayNum];
|
||||
rayInfoUIs = new rayInfoUI[totalRayNum];
|
||||
for(int i = 0; i < totalRayNum; i++)
|
||||
{
|
||||
linesOBJ[i] = new GameObject();
|
||||
linesOBJ[i].name = "rayCastLine-" + Convert.ToString(i);
|
||||
linesOBJ[i].transform.parent = agentCam.transform;
|
||||
linesOBJ[i].AddComponent<LineRenderer>();
|
||||
lineRenderers[i] = linesOBJ[i].GetComponent<LineRenderer>();
|
||||
lineRenderers[i].material = lineMeterial;
|
||||
|
||||
rayInfoOBJ[i] = (GameObject)Instantiate(rayInfoPrefab);
|
||||
rayInfoOBJ[i].transform.SetParent(agentCanvas.transform,false);
|
||||
rayInfoOBJ[i].name = "rayInfo-" + Convert.ToString(i);
|
||||
rayInfoUIs[i] = rayInfoOBJ[i].GetComponent<rayInfoUI>();
|
||||
}
|
||||
}
|
||||
|
||||
static int tagToInt(string tag)
|
||||
{
|
||||
@@ -45,277 +75,107 @@ public class RaySensors : MonoBehaviour
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
// 敌人Ray探测处理
|
||||
// 返回
|
||||
(int, List<float>, List<float>, float[]) enemySensorRay(GameObject myself, Camera agentCam, float attentionRange)
|
||||
private void singleRaycastUpdate(Ray ray,LineRenderer thisLineRenderer,rayInfoUI thisRayInfoUI, out float rayTagResult, out float rayDisResult)
|
||||
{
|
||||
List<float> thisLDistanceList = new List<float>();
|
||||
List<float> thisRDistanceList = new List<float>();
|
||||
|
||||
GameObject[] EnemyGameObjs;
|
||||
EnemyGameObjs = GameObject.FindGameObjectsWithTag("Enemy");
|
||||
int EnemyIndex = 0;
|
||||
float MinEnemyDis = MaxDistance+1.0f;
|
||||
int MinEnemyIndex = 0;
|
||||
float[] MinEnemyInfo = new float[3];
|
||||
|
||||
//遍历所有Enemy
|
||||
foreach (GameObject EnemyObj in EnemyGameObjs)
|
||||
// get Raycast hit infomation and return Tag and distance
|
||||
RaycastHit thisHit;
|
||||
Color rayColor = Color.cyan;
|
||||
float lineLength = viewDistance;
|
||||
string rayInfoText = "";
|
||||
Vector3 rayInfoPosition;
|
||||
if (Physics.Raycast(ray, out thisHit, viewDistance)) // 若在viewDistance范围内有碰撞
|
||||
{
|
||||
Vector3 thisEnemyPosition = EnemyObj.transform.position;
|
||||
Vector3 thisEnemyScale = EnemyObj.transform.localScale;
|
||||
Vector3 MyselfPosition = myself.transform.position;
|
||||
float thisEnemyWidth = (float)(thisEnemyScale.x / 2) - EnemyWidthRedundancy;
|
||||
float thisEnemyDistance = Vector3.Distance(MyselfPosition, thisEnemyPosition);
|
||||
|
||||
//探测到Agent为自己时的处理
|
||||
if (thisEnemyPosition == MyselfPosition)
|
||||
rayInfoText = thisHit.collider.tag;
|
||||
rayTagResult = tagToInt(thisHit.collider.tag);
|
||||
rayDisResult = thisHit.distance;
|
||||
lineLength = rayDisResult;
|
||||
rayInfoText += "\n" + Convert.ToString(rayDisResult);
|
||||
//输出log
|
||||
switch (rayTagResult)
|
||||
{
|
||||
//Debug.Log("OH It's me");
|
||||
thisLDistanceList.Add(MaxDistance);
|
||||
thisRDistanceList.Add(MaxDistance);
|
||||
}
|
||||
//非己Agent处理
|
||||
else
|
||||
{
|
||||
EnemyIndex += 1;
|
||||
Vector3 Vertical = new Vector3(0, 100, 0);//垂直向上的向量
|
||||
Vector3 EnemytoMe = MyselfPosition - thisEnemyPosition;//Enemy和自机连线,指向自机的向量
|
||||
Vector3 LHorizontal = Vector3.Cross(Vertical, EnemytoMe);// 垂直于EnemytoMe与Vertical向量所组成的面的,且指向<-左侧的小向量<- Enemy
|
||||
Vector3 RHorizontal = Vector3.Cross(EnemytoMe, Vertical);// 垂直于EnemytoMe与Vertical向量所组成的面的,且指向->右侧的小向量Enemy ->
|
||||
//此时RHorizontal,LHorizontal的长度巨几把长,需要下面操作标准化为1/2Enemy宽度
|
||||
float standaedization = (float)thisEnemyWidth / Vector3.Distance(thisEnemyPosition, RHorizontal);//计算需要缩小的比例
|
||||
RHorizontal *= standaedization;//应用缩小比例,标准化完成
|
||||
LHorizontal *= standaedization;//应用缩小比例,标准化完成
|
||||
Vector3 LMetoEnemy = LHorizontal - EnemytoMe;//自机与左侧边界连线Me<- Enemy
|
||||
Vector3 RMetoEnemy = RHorizontal - EnemytoMe;//自机与右侧边界连线Enemy ->Me
|
||||
Vector3 L0toEnemy = LHorizontal + thisEnemyPosition;// Enemy左侧绝对坐标
|
||||
Vector3 R0toEnemy = RHorizontal + thisEnemyPosition;// Enemy右侧绝对坐标
|
||||
float LMetoEnemyDist = Vector3.Distance(MyselfPosition, L0toEnemy);
|
||||
float RMetoEnemyDist = Vector3.Distance(MyselfPosition, R0toEnemy);
|
||||
Vector3 LEnemyInView = agentCam.WorldToViewportPoint(L0toEnemy);//Enemy左侧于视角中位置
|
||||
Vector3 REnemyInView = agentCam.WorldToViewportPoint(R0toEnemy);//Enemy右侧于视角中位置
|
||||
//Debug连线,颜色遵循飞机航行灯基本使用规则,左红右绿尾翼白。
|
||||
//Debug.DrawRay(thisEnemyPosition, EnemytoMe, Color.white);//Enemy和自机连线,指向自机的向量
|
||||
//Debug.DrawRay(thisEnemyPosition, Vertical, Color.white);//垂直向上的向量
|
||||
//Debug.DrawRay(thisEnemyPosition, LHorizontal, Color.red);// 垂直于Vc与Vertical向量所组成的面的,且指向<-左侧的小向量<- Enemy
|
||||
//Debug.DrawRay(thisEnemyPosition, RHorizontal, Color.green);// 垂直于Vc与Vertical向量所组成的面的,且指向->右侧的小向量Enemy ->
|
||||
//Debug.DrawRay(MyselfPosition, LMetoEnemy, Color.red);//自机与左侧边界连线<- Enemy
|
||||
//Debug.DrawRay(MyselfPosition, RMetoEnemy, Color.green);//自机与右侧边界连线Enemy ->
|
||||
//Debug.Log("EnemyObj" + EnemyIndex + "Position:" + thisEnemyPosition);
|
||||
|
||||
|
||||
//左侧于可见范围内--<--<--<--<--<--<--<--<--<--<--<--<--<--<
|
||||
if (LEnemyInView.x >= (thisEnemyWidth - attentionRange / 2) && LEnemyInView.x <= (thisEnemyWidth + attentionRange / 2) && LEnemyInView.z > 0)
|
||||
{
|
||||
//射出Raycast
|
||||
Ray LRay = new Ray(MyselfPosition, LMetoEnemy);
|
||||
RaycastHit LHit;
|
||||
if (showEnemySensor)
|
||||
{
|
||||
Debug.DrawRay(LRay.origin, LRay.direction * LMetoEnemyDist, Color.white);//自机与左侧边界连线<- Enemy
|
||||
}
|
||||
//Ray Hit Something
|
||||
if (Physics.Raycast(MyselfPosition, LMetoEnemy, out LHit, LMetoEnemyDist))
|
||||
{
|
||||
//Ray Hit Enemy
|
||||
//并且当射线射到的Enemy的距离与当前判断Enemy的距离差小于该Enemy半径时
|
||||
//既该射线所射到的Enemy为当前Enemy而不是别的时
|
||||
if (LHit.collider.tag == EnemyTagName && System.Math.Abs(LHit.distance - thisEnemyDistance) <= thisEnemyWidth)
|
||||
{
|
||||
if (showEnemySensor)
|
||||
{
|
||||
Debug.DrawRay(LRay.origin, LRay.direction * LHit.distance, Color.red);//自机与所击中物体的连线
|
||||
}
|
||||
thisLDistanceList.Add(LHit.distance);
|
||||
//Debug.Log("Hit Tag = " + LHit.collider.tag);
|
||||
//Debug.Log(LDistance[EnemyIndex-1]);
|
||||
//Debug.Log("ADD_LIST_ENEMYL");
|
||||
}
|
||||
//当射线所hit的不是enemy或hit的enemy不是当前所判断的enemy
|
||||
else
|
||||
{
|
||||
if (showEnemySensor)
|
||||
{
|
||||
Debug.DrawRay(LRay.origin, LRay.direction * LHit.distance, Color.cyan);//自机与所击中物体的连线
|
||||
}
|
||||
thisLDistanceList.Add(MaxDistance);
|
||||
//Debug.LogWarning("Hit Tag = " + LHit.collider.tag);
|
||||
//Debug.LogWarning(LDistance[EnemyIndex-1]);
|
||||
//Debug.Log("ADD_LIST_ENEMYL");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
thisLDistanceList.Add(MaxDistance);
|
||||
Debug.LogError("LRAY HIT NOTHING, Check Code!");
|
||||
}
|
||||
}
|
||||
//左侧不在可见范围内时--<--<--<--<--<--<--<--<--<--<--<--<--<--<
|
||||
else
|
||||
{
|
||||
thisLDistanceList.Add(MaxDistance);
|
||||
//Debug.LogError("NoVisual");
|
||||
//Debug.LogError(LDistance[EnemyIndex-1]);
|
||||
//Debug.Log("ADD_LIST_ENEMYL_ELSE");
|
||||
}
|
||||
|
||||
//右侧于可见范围内-->-->-->-->-->-->-->-->-->-->-->-->-->-->
|
||||
if (REnemyInView.x >= (thisEnemyWidth - attentionRange / 2) && REnemyInView.x <= (thisEnemyWidth + attentionRange / 2) && REnemyInView.z > 0)
|
||||
{
|
||||
//射出Raycast
|
||||
Ray RRay = new Ray(MyselfPosition, RMetoEnemy);
|
||||
RaycastHit RHit;
|
||||
if (showEnemySensor)
|
||||
{
|
||||
Debug.DrawRay(RRay.origin, RRay.direction * RMetoEnemyDist, Color.white);//自机与左侧边界连线<- Enemy
|
||||
}
|
||||
//Ray Hit Something
|
||||
if (Physics.Raycast(MyselfPosition, RMetoEnemy, out RHit, RMetoEnemyDist))
|
||||
{
|
||||
//Ray Hit Enemy
|
||||
//并且当射线射到的Enemy的距离与当前判断Enemy的距离差小于该Enemy半径时
|
||||
//既该射线所射到的Enemy为当前Enemy而不是别的时
|
||||
if (RHit.collider.tag == EnemyTagName && System.Math.Abs(RHit.distance - thisEnemyDistance) <= thisEnemyWidth)
|
||||
{
|
||||
if (showEnemySensor)
|
||||
{
|
||||
Debug.DrawRay(RRay.origin, RRay.direction * RHit.distance, Color.red);//自机与所击中物体的连线
|
||||
}
|
||||
thisRDistanceList.Add(RHit.distance);
|
||||
//Debug.Log("Hit Tag = " + LHit.collider.tag);
|
||||
//Debug.Log(LDistance[EnemyIndex-1]);
|
||||
//Debug.Log("ADD_LIST_ENEMYR");
|
||||
}
|
||||
//当射线所hit的不是enemy或hit的enemy不是当前所判断的enemy
|
||||
else
|
||||
{
|
||||
if (showEnemySensor)
|
||||
{
|
||||
Debug.DrawRay(RRay.origin, RRay.direction * RHit.distance, Color.cyan);//自机与所击中物体的连线
|
||||
}
|
||||
thisRDistanceList.Add(MaxDistance);
|
||||
//Debug.LogWarning("Hit Tag = " + LHit.collider.tag);
|
||||
//Debug.LogWarning(LDistance[EnemyIndex-1]);
|
||||
//Debug.Log("ADD_LIST_ENEMYR");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
thisLDistanceList.Add(MaxDistance);
|
||||
Debug.LogError("RRAY HIT NOTHING, Check Code!");
|
||||
}
|
||||
}
|
||||
//右侧不在可见范围内时-->-->-->-->-->-->-->-->-->-->-->-->-->-->
|
||||
else
|
||||
{
|
||||
thisRDistanceList.Add(MaxDistance);
|
||||
//Debug.LogError("NoVisual");
|
||||
//Debug.LogError(LDistance[EnemyIndex-1]);
|
||||
//Debug.Log("ADD_LIST_ENEMYR_ELSE");
|
||||
}
|
||||
}
|
||||
//Debug.LogWarning("EnemyIndex" + EnemyIndex);
|
||||
//Debug.LogWarning(thisLDistanceList.Count);
|
||||
//Debug.LogWarning(MinEnemyIndex);
|
||||
//Debug.Log("thisLDistanceList" + thisLDistanceList.Count);
|
||||
//Debug.Log("thisRDistanceList" + thisRDistanceList.Count);
|
||||
|
||||
//检查最近Enemy
|
||||
if (System.Math.Min(thisLDistanceList[EnemyIndex], thisRDistanceList[EnemyIndex]) < MinEnemyDis)
|
||||
{
|
||||
//Debug.Log("EnemyIndex" + EnemyIndex);
|
||||
MinEnemyDis = System.Math.Min(thisLDistanceList[EnemyIndex], thisRDistanceList[EnemyIndex]);
|
||||
MinEnemyIndex = EnemyIndex;
|
||||
case 1:// Wall
|
||||
rayColor = Color.white;
|
||||
break;
|
||||
case 2: // Enemy
|
||||
rayColor = Color.red;
|
||||
break;
|
||||
case -1: // Hit Nothing
|
||||
rayColor = Color.gray;
|
||||
break;
|
||||
default: // default,got wrong
|
||||
rayColor = Color.cyan;
|
||||
break;
|
||||
}
|
||||
}
|
||||
// 获取最近敌人的准确位置信息
|
||||
MinEnemyInfo[0] = (float)MinEnemyIndex;
|
||||
if(MinEnemyInfo[0] <= 0)
|
||||
else // 若在viewDistance范围无碰撞
|
||||
{
|
||||
MinEnemyInfo[1] = MaxDistance;
|
||||
MinEnemyInfo[2] = MaxDistance;
|
||||
rayTagResult = -1f;
|
||||
rayDisResult = -1f;
|
||||
//输出log
|
||||
//Debug.Log(0);
|
||||
//Debug.Log(0);
|
||||
}
|
||||
rayInfoPosition = ray.origin + (ray.direction * lineLength);
|
||||
if (showInGameRay)
|
||||
{
|
||||
drawLine(ray, lineLength, thisLineRenderer, rayColor);
|
||||
}
|
||||
else
|
||||
{
|
||||
MinEnemyInfo[1] = EnemyGameObjs[MinEnemyIndex].transform.position.x;
|
||||
MinEnemyInfo[2] = EnemyGameObjs[MinEnemyIndex].transform.position.z;
|
||||
turnOffLine(thisLineRenderer, rayColor);
|
||||
}
|
||||
return (EnemyIndex, thisLDistanceList, thisRDistanceList,MinEnemyInfo);
|
||||
// drawRay in game
|
||||
if (showInGameRayInfo) thisRayInfoUI.updateInfo(rayInfoText, rayInfoPosition, rayColor);
|
||||
// Show log
|
||||
if (showDebugRay) Debug.DrawRay(ray.origin, ray.direction * viewDistance, rayColor); // drawRay in debug
|
||||
// Debug.Log(ray.origin + ray.direction);
|
||||
// Debug.Log(rayTagResult);
|
||||
// Debug.Log(tagToInt(thisHit.collider.tag));
|
||||
}
|
||||
|
||||
|
||||
// 全局Ray探测处理
|
||||
(float[], float[]) eyeSensorRay(int rayNum, Camera agentCam, float viewDistance)
|
||||
private void drawLine(Ray ray,float lineLength, LineRenderer thisLineRenderer, Color lineColor)
|
||||
{
|
||||
//初始化result Array
|
||||
float[] thisRayTagResult = new float[rayNum];
|
||||
float[] thisRayDisResult = new float[rayNum];
|
||||
|
||||
//于视角范围内一帧射出rayNum条射线
|
||||
for (int a = 0; a <= rayNum - 1; a = a + 1)
|
||||
{
|
||||
//射线射出
|
||||
Vector3 point = new Vector3(a * agentCam.pixelWidth / (rayNum - 1), agentCam.pixelHeight / 2, 0);//发射位置
|
||||
Ray ray = agentCam.ScreenPointToRay(point);
|
||||
RaycastHit hit;
|
||||
if (showEyeSensor)
|
||||
{
|
||||
Debug.DrawRay(ray.origin, ray.direction * viewDistance, Color.black);
|
||||
}
|
||||
//若在viewDistance范围内有碰撞
|
||||
if (Physics.Raycast(ray, out hit, viewDistance))
|
||||
{
|
||||
thisRayTagResult[a] = tagToInt(hit.collider.tag);
|
||||
thisRayDisResult[a] = hit.distance;
|
||||
if (showEyeSensor)
|
||||
{
|
||||
Debug.DrawRay(ray.origin, ray.direction * hit.distance, Color.yellow);
|
||||
}
|
||||
//输出log
|
||||
//Debug.Log(rayTagResult[a]);
|
||||
//Debug.Log(tagToInt(hit.collider.tag));
|
||||
|
||||
}
|
||||
//若在viewDistance范围无碰撞
|
||||
else
|
||||
{
|
||||
thisRayTagResult[a] = -1f;
|
||||
thisRayDisResult[a] = -1f;
|
||||
//输出log
|
||||
//Debug.Log(0);
|
||||
//Debug.Log(0);
|
||||
}
|
||||
}
|
||||
return (thisRayTagResult, thisRayDisResult);
|
||||
thisLineRenderer.startColor = lineColor;
|
||||
thisLineRenderer.endColor = lineColor;
|
||||
thisLineRenderer.startWidth = lineWidth;
|
||||
thisLineRenderer.endWidth = lineWidth;
|
||||
thisLineRenderer.SetPosition(0, ray.origin);
|
||||
thisLineRenderer.SetPosition(1, ray.origin + (ray.direction * lineLength));
|
||||
}
|
||||
|
||||
void Start()
|
||||
private void turnOffLine(LineRenderer thisLineRenderer, Color lineColor)
|
||||
{
|
||||
rayTagResult = new float[rayNum];
|
||||
rayDisResult = new float[rayNum];
|
||||
thisLineRenderer.startColor = lineColor;
|
||||
thisLineRenderer.endColor = lineColor;
|
||||
thisLineRenderer.startWidth = 0f;
|
||||
thisLineRenderer.endWidth = 0f;
|
||||
thisLineRenderer.SetPosition(0, new Vector3(0, 0, 0));
|
||||
thisLineRenderer.SetPosition(1, new Vector3(0, 0, 0));
|
||||
}
|
||||
|
||||
|
||||
|
||||
void Update()
|
||||
public void updateRayInfo()
|
||||
{
|
||||
(rayTagResult, rayDisResult) = eyeSensorRay(rayNum, agentCam, viewDistance);
|
||||
(allEnemyNum, enemyLDisList, enemyRDisList, focusEnemyInfo) = enemySensorRay(myself, agentCam, attentionRange);
|
||||
transform.gameObject.GetComponent<UIController>().updateRemainEnemy(allEnemyNum);
|
||||
/*
|
||||
Debug.LogWarning("rayNum :" + rayNum);
|
||||
for (int i =0;i < rayNum; i++)
|
||||
float focusLEdge = agentCam.pixelWidth * (1 - focusRange) / 2;
|
||||
float focusREdge = agentCam.pixelWidth * (1 + focusRange) / 2;
|
||||
float thisCamPixelHeight = agentCam.pixelHeight;
|
||||
|
||||
for (int i = 0; i < halfOuterRayNum; i++) // create left outside rays; 0 ~ focusLeftEdge
|
||||
{
|
||||
Debug.Log("rayTagResult" + rayTagResult[i] + "rayDisResult"+ rayDisResult[i]);
|
||||
Vector3 point = new Vector3(i * focusLEdge / (halfOuterRayNum - 1), thisCamPixelHeight / 2, 0);
|
||||
Ray thisRay = agentCam.ScreenPointToRay(point);
|
||||
singleRaycastUpdate(thisRay,lineRenderers[i], rayInfoUIs[i] , out rayTagResult[i], out rayDisResult[i]);
|
||||
}
|
||||
Debug.LogWarning("EnemyNum Include Me:" + allEnemyNum);
|
||||
for(int i = 0; i < allEnemyNum; i++)
|
||||
for (int i = 0; i < halfOuterRayNum; i++) // create right outside rays; focusRightEdge ~ MaxPixelHeight
|
||||
{
|
||||
Debug.Log("enemyLDisList" + enemyLDisList[i] + "enemyRDisList" + enemyRDisList[i]);
|
||||
Vector3 point = new Vector3(focusREdge + (i * focusLEdge / (halfOuterRayNum - 1)), thisCamPixelHeight / 2, 0);
|
||||
Ray thisRay = agentCam.ScreenPointToRay(point);
|
||||
singleRaycastUpdate(thisRay, lineRenderers[halfOuterRayNum + i], rayInfoUIs[halfOuterRayNum + i], out rayTagResult[halfOuterRayNum + i], out rayDisResult[halfOuterRayNum + i]);
|
||||
}
|
||||
for (int i = 0; i < focusRayNum; i++) // create center focus rays; focusLeftEdge ~ focusLeftEdge
|
||||
{
|
||||
Vector3 point = new Vector3(focusLEdge + ((i + 1) * (focusREdge - focusLEdge) / (focusRayNum + 1)), thisCamPixelHeight / 2, 0);
|
||||
Ray thisRay = agentCam.ScreenPointToRay(point);
|
||||
singleRaycastUpdate(thisRay, lineRenderers[halfOuterRayNum * 2 + i], rayInfoUIs[halfOuterRayNum * 2 + i], out rayTagResult[halfOuterRayNum*2 + i], out rayDisResult[halfOuterRayNum*2 + i]);
|
||||
}
|
||||
*/
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,25 @@
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
using TMPro;
|
||||
|
||||
public class rayInfoUI : MonoBehaviour
|
||||
{
|
||||
TextMeshProUGUI infoText;
|
||||
|
||||
// Start is called before the first frame update
|
||||
void Start()
|
||||
{
|
||||
infoText = transform.GetChild(0).gameObject.GetComponent<TextMeshProUGUI>();
|
||||
}
|
||||
|
||||
public void updateInfo(string info,Vector3 infoPosition, Color infoColor)
|
||||
{
|
||||
infoText.text = info;
|
||||
infoText.color = infoColor;
|
||||
transform.position = infoPosition;
|
||||
Vector3 v = Camera.main.transform.position - infoPosition;
|
||||
v.x = v.z = 0.0f;
|
||||
transform.LookAt(Camera.main.transform.position - v);
|
||||
transform.Rotate(0, 180, 0);
|
||||
}
|
||||
}
|
||||
+1
-1
@@ -1,5 +1,5 @@
|
||||
fileFormatVersion: 2
|
||||
guid: cce4f6a22ca8eba4b94c1bfc6ac08072
|
||||
guid: 812dfed7ee1d09c4fa7c3ed8372f54ae
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
@@ -1,22 +0,0 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
public class DecisionPeriodChanger : MonoBehaviour
|
||||
{
|
||||
public GameObject DataTransfer;
|
||||
public Slider DecisionPeriodSlide;
|
||||
public Text DecisionPeriodDataText;
|
||||
public Toggle TakeActionsBetweenDecisionsToggle;
|
||||
|
||||
public void onSlideValueChanged()
|
||||
{
|
||||
DataTransfer.GetComponent<StartSeneData>().DecisionPeriod = (int)(DecisionPeriodSlide.GetComponent<Slider>().value);
|
||||
DecisionPeriodDataText.text = DataTransfer.GetComponent<StartSeneData>().DecisionPeriod.ToString();
|
||||
}
|
||||
public void onToggleChanged()
|
||||
{
|
||||
DataTransfer.GetComponent<StartSeneData>().ActionsBetweenDecisions = TakeActionsBetweenDecisionsToggle.isOn;
|
||||
}
|
||||
}
|
||||
@@ -1,11 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 0d097ecbef2d7b843b772144dd301b2b
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,62 @@
|
||||
using System;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
public class EnvArgsChanger : MonoBehaviour
|
||||
{
|
||||
public GameObject DataTransfer;
|
||||
|
||||
[Header("EnemyNum")]
|
||||
public Text EnemyNumText;
|
||||
public InputField EnemyNumInput;
|
||||
|
||||
[Header("TimeLimit")]
|
||||
public Text TimeLimText;
|
||||
public InputField TimelimInput;
|
||||
|
||||
[Header("Decision Period")]
|
||||
public Slider DecisionPeriodSlide;
|
||||
public Text DecisionPeriodDataText;
|
||||
public Toggle TakeActionsBetweenDecisionsToggle;
|
||||
|
||||
|
||||
public void onEnemynumValueChanged()
|
||||
{
|
||||
// enemy total num value control
|
||||
if (EnemyNumInput.GetComponent<InputField>().text == "" || EnemyNumInput.GetComponent<InputField>().text.Contains("-"))
|
||||
{
|
||||
EnemyNumText.color = Color.gray;
|
||||
}
|
||||
else
|
||||
{
|
||||
EnemyNumText.color = Color.yellow;
|
||||
DataTransfer.GetComponent<StartSeneData>().EnemyNum = Math.Abs(int.Parse(EnemyNumInput.GetComponent<InputField>().text));
|
||||
}
|
||||
}
|
||||
|
||||
public void onTimeValueChanged()
|
||||
{
|
||||
// time limit value control
|
||||
if (TimelimInput.GetComponent<InputField>().text == "" || TimelimInput.GetComponent<InputField>().text.Contains("-"))
|
||||
{
|
||||
TimeLimText.color = Color.gray;
|
||||
}
|
||||
else
|
||||
{
|
||||
TimeLimText.color = Color.yellow;
|
||||
DataTransfer.GetComponent<StartSeneData>().Timelim = Math.Abs(int.Parse(TimelimInput.GetComponent<InputField>().text));
|
||||
}
|
||||
}
|
||||
|
||||
public void onDPSlideValueChanged()
|
||||
{
|
||||
// DecisionPeriod(DP) value Control
|
||||
DataTransfer.GetComponent<StartSeneData>().DecisionPeriod = (int)(DecisionPeriodSlide.GetComponent<Slider>().value);
|
||||
DecisionPeriodDataText.text = DataTransfer.GetComponent<StartSeneData>().DecisionPeriod.ToString();
|
||||
}
|
||||
public void onABDToggleChanged()
|
||||
{
|
||||
// Actions Between Decisions(ABD) Toggle Control
|
||||
DataTransfer.GetComponent<StartSeneData>().ActionsBetweenDecisions = TakeActionsBetweenDecisionsToggle.isOn;
|
||||
}
|
||||
}
|
||||
+1
-1
@@ -1,5 +1,5 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 7ab8f48d4eac07f44b093f714ede051c
|
||||
guid: ccfe892ab0f980343b6df0fafaec38e2
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
+14
-7
@@ -3,19 +3,15 @@ using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
public class LoadDirToggle : MonoBehaviour
|
||||
public class LoadDirChanger : MonoBehaviour
|
||||
{
|
||||
public InputField LoadDirDateTextBox;
|
||||
public InputField LoadDirTimeTextBox;
|
||||
public Toggle Toggle;
|
||||
public GameObject DataTransfer;
|
||||
// Start is called before the first frame update
|
||||
void Start()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public void OnToggleChanged()
|
||||
|
||||
public void OnDirToggleChanged()
|
||||
{
|
||||
// if loadDirToggle is on then turn off the input text boxs.
|
||||
LoadDirDateTextBox.interactable = Toggle.isOn;
|
||||
@@ -27,4 +23,15 @@ public class LoadDirToggle : MonoBehaviour
|
||||
DataTransfer.GetComponent<StartSeneData>().LoadDirTime = "0";
|
||||
}
|
||||
}
|
||||
|
||||
public void OnDateValueChanged()
|
||||
{
|
||||
string input = LoadDirDateTextBox.GetComponent<InputField>().text;
|
||||
DataTransfer.GetComponent<StartSeneData>().LoadDirDate = input;
|
||||
}
|
||||
public void OnTimeValueChanged()
|
||||
{
|
||||
string input = LoadDirTimeTextBox.GetComponent<InputField>().text;
|
||||
DataTransfer.GetComponent<StartSeneData>().LoadDirTime = input;
|
||||
}
|
||||
}
|
||||
+1
-1
@@ -1,5 +1,5 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 8396a1a162e012447a0e4f7626e70dc7
|
||||
guid: 664e98da80fb4d842b0c3aff09fd4dc9
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
@@ -1,14 +0,0 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
public class LoadDirDateTextChange : MonoBehaviour
|
||||
{
|
||||
public GameObject DataTransfer;
|
||||
public void OnValueChanged()
|
||||
{
|
||||
string input = this.GetComponent<InputField>().text;
|
||||
DataTransfer.GetComponent<StartSeneData>().LoadDirDate = input;
|
||||
}
|
||||
}
|
||||
@@ -1,14 +0,0 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
public class LoadDirTimeTextChange : MonoBehaviour
|
||||
{
|
||||
public GameObject DataTransfer;
|
||||
public void OnValueChanged()
|
||||
{
|
||||
string input = this.GetComponent<InputField>().text;
|
||||
DataTransfer.GetComponent<StartSeneData>().LoadDirTime = input;
|
||||
}
|
||||
}
|
||||
@@ -1,11 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: e18f417f93a39c74481660da3236c133
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,5 +1,3 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
using UnityEngine.SceneManagement;
|
||||
|
||||
@@ -1,25 +0,0 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
public class StartSceneEnemyNumChanger : MonoBehaviour
|
||||
{
|
||||
public GameObject DataTransfer;
|
||||
public InputField EnemyNumInput;
|
||||
public Text EnemyNumText;
|
||||
|
||||
public void onValueChanged()
|
||||
{
|
||||
if (EnemyNumInput.GetComponent<InputField>().text == "" || EnemyNumInput.GetComponent<InputField>().text.Contains("-"))
|
||||
{
|
||||
EnemyNumText.color = Color.gray;
|
||||
}
|
||||
else
|
||||
{
|
||||
EnemyNumText.color = Color.yellow;
|
||||
DataTransfer.GetComponent<StartSeneData>().EnemyNum = Math.Abs(int.Parse(EnemyNumInput.GetComponent<InputField>().text));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,11 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 64d0bcf55e4db0c488996ba1051c279f
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,25 +0,0 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
public class StartSceneTimeLimChanger : MonoBehaviour
|
||||
{
|
||||
public GameObject DataTransfer;
|
||||
public Text TimeLimText;
|
||||
public InputField TimelimInput;
|
||||
|
||||
public void onValueTimeChanged()
|
||||
{
|
||||
if (TimelimInput.GetComponent<InputField>().text == "" || TimelimInput.GetComponent<InputField>().text.Contains("-"))
|
||||
{
|
||||
TimeLimText.color = Color.gray;
|
||||
}
|
||||
else
|
||||
{
|
||||
TimeLimText.color = Color.yellow;
|
||||
DataTransfer.GetComponent<StartSeneData>().Timelim = Math.Abs(int.Parse(TimelimInput.GetComponent<InputField>().text));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,11 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 7857e2b2e5caf6b4686c4a7d87fa998e
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Reference in New Issue
Block a user