public void HaltAgent(DCAgent doomCube) { Rigidbody rigidbody = doomCube.GetComponent <Rigidbody>(); rigidbody.velocity = Vector3.zero; rigidbody.angularVelocity = Vector3.zero; }
void ShootWeapon() { // VFX if (m_MuzzleFlash) { m_MuzzleFlash.Play(); } // SFX if (m_ShootSFX) { m_AudioSource.Play(); } // Hit detection RaycastHit hit; if (Physics.Raycast(m_AgentCamera.transform.position, m_AgentCamera.transform.forward, out hit, 150f)) { DCAgent hitAgent = hit.transform.GetComponent <DCAgent>(); if (hitAgent != null) { m_AgentArea.ResolveHit(this, hitAgent, stepsTaken / MaxStep); } } }
bool HasTargetsInSight() { bool someTargetInSight = false; foreach (DCAgent doomCubeAgent in m_AgentTargets) { if (doomCubeAgent != this) { Vector3 tPos = m_AgentCamera.WorldToViewportPoint(doomCubeAgent.transform.position); if (tPos.x > 0f && tPos.x < 1f && tPos.y > 0f && tPos.y < 1f && tPos.z > 0f) { RaycastHit hit; Vector3 tDir = doomCubeAgent.transform.position - m_AgentCamera.transform.position; if (Physics.Raycast(m_AgentCamera.transform.position, tDir, out hit, 150f)) { DCAgent hitAgent = hit.transform.GetComponent <DCAgent>(); if (hitAgent != null && hitAgent == doomCubeAgent) { someTargetInSight = true; break; } } } } } return(someTargetInSight); }
public void ResolveHit(DCAgent winnerAgent, DCAgent loserAgent, float stepRatio) { // winnerAgent.AddReward(2f - stepRatio); // loserAgent.AddReward(-2f + stepRatio); winnerAgent.SetReward(1f); loserAgent.SetReward(-1f); winnerAgent.EndEpisode(); loserAgent.EndEpisode(); }
public static DCAgent getInstance() { if(!instance) { GameObject go = new GameObject("DCAgent"); DontDestroyOnLoad(go); instance = go.AddComponent<DCAgent>(); } return instance; }
public static DCAgent getInstance() { if (!instance) { GameObject go = new GameObject("DCAgent"); DontDestroyOnLoad(go); instance = go.AddComponent <DCAgent>(); } return(instance); }
//------------------------------------------------------------------------- /// <summary> /// DataEye统计初始化 /// </summary> /// <param name="app_id"></param> /// <param name="channel_id"></param> /// <param name="report_mode"></param> public static void initWithAppIdAndChannelId(string app_id, string channel_id, bool open_adtracking = true, DCReportMode report_mode = DCReportMode.DC_AFTER_LOGIN) { //if (open_adtracking) //{ // DCAgent.openAdTracking(); //} DCAgent.setReportMode(report_mode); DCAgent.getInstance().initWithAppIdAndChannelId(app_id, channel_id); }
// Update is called once per frame void Update() { // Hit detection RaycastHit hit; if (Physics.Raycast(m_Camera.transform.position, m_Camera.transform.forward, out hit, 150f)) { DCAgent hitAgent = hit.transform.GetComponent <DCAgent>(); if (hitAgent != null) { m_Crosshair.color = Color.red; } else { m_Crosshair.color = Color.white; } } }
public void PlaceAgent(DCAgent doomCube) { // Physics HaltAgent(doomCube); // Spawn zone int zone = Random.Range(0, 9); // Spawn position var newPosition = Vector3.zero; Collider[] hitColliders; bool overlaps = false; float colliderRadius = doomCube.GetComponent <SphereCollider>().radius; do { newPosition = ChooseRandomPosition(zone); hitColliders = Physics.OverlapSphere(newPosition, colliderRadius); overlaps = false; foreach (Collider hitCollider in hitColliders) { DCAgent otherAgent = hitCollider.transform.GetComponent <DCAgent>(); if (otherAgent != null) { overlaps = true; } } } while (overlaps); doomCube.transform.position = newPosition; // Spawn direction doomCube.transform.rotation = ChooseRandomRotation(); }
public override void Init() { DCAgent.getInstance().initWithAppIdAndChannelId(appId, channelId); //DCAgent.setDebugMode(true); }
//------------------------------------------------------------------------- /// <summary> /// DataEye统计初始化 /// </summary> /// <param name="app_id"></param> /// <param name="channel_id"></param> /// <param name="report_mode"></param> public static void initWithAppIdAndChannelId(string app_id, string channel_id, DCReportMode report_mode = DCReportMode.DC_AFTER_LOGIN) { DCAgent.getInstance().initWithAppIdAndChannelId(app_id, channel_id); }