V3.3.1 添加一些summary
添加一些summary
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
using UnityEngine;
|
||||
using UnityEngine;
|
||||
|
||||
public class SceneBlockContainer : MonoBehaviour
|
||||
{
|
||||
@@ -22,7 +22,16 @@ public class SceneBlockContainer : MonoBehaviour
|
||||
scenePrefabSet.InitializeSceneBlocksSet(hudObj);
|
||||
}
|
||||
|
||||
// create appointed block at appointed position
|
||||
/// <summary>
|
||||
/// Creates a specified block at a specified position.
|
||||
/// 在指定位置创建指定类型的场景块。
|
||||
/// </summary>
|
||||
/// <param name="targetType">The target type.</param>
|
||||
/// <param name="level">The level.</param>
|
||||
/// <param name="blockType">The block type.</param>
|
||||
/// <param name="blockPosition">The block position.</param>
|
||||
/// <param name="tag1">Tag 1 (optional, default is "Player").</param>
|
||||
/// <param name="tag2">Tag 2 (optional, default is "Enemy").</param>
|
||||
public void CreateNewBlock(Targets targetType, int level, int blockType, Vector3 blockPosition, string tag1 = "Player", string tag2 = "Enemy")
|
||||
{
|
||||
// check if nowBlock is deleted
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
using System;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using Random = UnityEngine.Random;
|
||||
@@ -140,8 +140,15 @@ public class TargetController : MonoBehaviour
|
||||
}
|
||||
}
|
||||
|
||||
#region Train Mode Initialization Functions
|
||||
|
||||
/// <summary>
|
||||
/// Generates a new scene configuration by selecting a random target type and spawning related scene blocks.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// This method is responsible for creating a new scene configuration, which involves selecting a target type
|
||||
/// (Go, Attack, Defence, or Free) based on predefined probabilities. Depending on the chosen target type,
|
||||
/// the method spawns the associated scene blocks, updates various flags, and informs the user interface about
|
||||
/// the selected target type.
|
||||
/// </remarks>
|
||||
public void RollNewScene()
|
||||
{
|
||||
startTime = Time.time;// Reset StartTime as now time
|
||||
@@ -188,11 +195,12 @@ public class TargetController : MonoBehaviour
|
||||
envUICon.UpdateTargetType(targetTypeInt);
|
||||
}
|
||||
|
||||
#endregion Train Mode Initialization Functions
|
||||
|
||||
#region Agent Move Method
|
||||
|
||||
// move Agent into Agent Spawn Area
|
||||
/// <summary>
|
||||
/// Move the agent to the spawn area.
|
||||
/// 将Agent移动到生成区域。
|
||||
/// </summary>
|
||||
private void MoveAgentToSpwanArea()
|
||||
{
|
||||
float randX = UnityEngine.Random.Range(minAgentAreaX, maxAgentAreaX); ;
|
||||
@@ -213,7 +221,17 @@ public class TargetController : MonoBehaviour
|
||||
MoveAgentTo(initAgentLoc);
|
||||
}
|
||||
|
||||
// move Agent to this position
|
||||
/// <summary>
|
||||
/// Move the agent to the specified position.
|
||||
/// 将代理移动到指定位置。
|
||||
/// </summary>
|
||||
/// <param name="position">要移动到的位置。</param>
|
||||
/// <remarks>
|
||||
/// When moving the character using transform.localPosition,
|
||||
/// must disable the character controller, or it won't work properly.
|
||||
/// 使用 transform.localPosition 移动角色时,
|
||||
/// 必须禁用角色控制器,否则它将无法正常工作。
|
||||
/// </remarks>
|
||||
public void MoveAgentTo(Vector3 position)
|
||||
{
|
||||
// while using transform.localPosition to move character
|
||||
@@ -227,7 +245,15 @@ public class TargetController : MonoBehaviour
|
||||
|
||||
#region Random SceneBlock Spawn Method
|
||||
|
||||
// initialize scene block by target type
|
||||
/// <summary>
|
||||
/// Randomly spawns a scene block based on the target type.
|
||||
/// 根据目标类型随机生成场景块。
|
||||
/// </summary>
|
||||
/// <param name="targetType">要生成的场景块的目标类型。The target type of the scene block to be generated.</param>
|
||||
/// <remarks>
|
||||
/// This method generates a random scene block based on the target type and spawns enemies at the specified location.
|
||||
/// 此方法根据目标类型生成一个随机场景块,并在指定位置生成敌人。
|
||||
/// </remarks>
|
||||
private void RandomSpawnSceneBlock(SceneBlockContainer.Targets targetType)
|
||||
{
|
||||
randLevel = GetRandomLevelIndex(targetType);
|
||||
@@ -250,8 +276,11 @@ public class TargetController : MonoBehaviour
|
||||
|
||||
#region Reward function
|
||||
|
||||
// check over and get rewards
|
||||
// 1 = success,2 = overtime,0 = notover
|
||||
/// <summary>
|
||||
/// Checks the game's end state and retrieves rewards.
|
||||
/// </summary>
|
||||
/// <returns>A tuple containing the game's end type, current reward, and final reward.
|
||||
/// 1 = success,2 = overtime,0 = notover</returns>
|
||||
public (int, float, float) CheckOverAndRewards()
|
||||
{
|
||||
int endTypeInt = 0;
|
||||
@@ -393,7 +422,13 @@ public class TargetController : MonoBehaviour
|
||||
return (endTypeInt, nowReward, endReward);
|
||||
}
|
||||
|
||||
// caulculate sceneReward if close to target then get great reward
|
||||
/// <summary>
|
||||
/// Calculates scene reward based on distance, granting higher rewards for being closer to the target.
|
||||
/// 根据距离计算场景奖励,靠近目标则获得更高奖励。
|
||||
/// </summary>
|
||||
/// <param name="nowDistance">The current distance.</param>
|
||||
/// <param name="inarea">Whether inside an area.</param>
|
||||
/// <returns>The reward value calculated based on distance.</returns>
|
||||
private float GetDistanceReward(float nowDistance, int inarea)
|
||||
{
|
||||
if (firstRewardFlag)
|
||||
@@ -418,7 +453,12 @@ public class TargetController : MonoBehaviour
|
||||
return nowSeneReward;
|
||||
}
|
||||
|
||||
// calculate kill reward base on killed enemy's position
|
||||
/// <summary>
|
||||
/// Calculates kill reward based on the position of the killed enemy.
|
||||
/// 根据击杀的敌人位置计算击杀奖励。
|
||||
/// </summary>
|
||||
/// <param name="enemyPosition">The position of the killed enemy.</param>
|
||||
/// <returns>The reward value calculated based on the kill position.</returns>
|
||||
public float KillReward(Vector3 enemyPosition)
|
||||
{
|
||||
float nowKillReward = 0f;
|
||||
@@ -449,7 +489,12 @@ public class TargetController : MonoBehaviour
|
||||
return nowKillReward;
|
||||
}
|
||||
|
||||
// calculate hit reward base on killed enemy's position and now mode
|
||||
/// <summary>
|
||||
/// Calculates hit reward based on the position of the hit enemy and the current mode.
|
||||
/// 根据击中的敌人位置和当前模式计算击中Reward。
|
||||
/// </summary>
|
||||
/// <param name="enemyPosition">The position of the hit enemy.</param>
|
||||
/// <returns>The reward value calculated based on the hit position and mode.</returns>
|
||||
public float HitEnemyReward(Vector3 enemyPosition)
|
||||
{
|
||||
float nowHitReward = 0f;
|
||||
@@ -485,7 +530,18 @@ public class TargetController : MonoBehaviour
|
||||
|
||||
#region Play Mode Method
|
||||
|
||||
// Initialize Play mode
|
||||
/// <summary>
|
||||
/// Initializes the game in play mode.
|
||||
/// 初始化游戏playMode。
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// This method is used to initialize the game in play mode,
|
||||
/// including setting the target type, updating target states,
|
||||
/// updating UI display, moving the agent to the spawn area,
|
||||
/// destroying all enemies, and scene blocks.
|
||||
/// 该方法用于初始化游戏播放模式,包括设置目标类型、更新目标状态、更新UI显示、
|
||||
/// 将代理移动到生成区域、销毁所有敌人和场景块。
|
||||
/// </remarks>
|
||||
public void PlayInitialize()
|
||||
{
|
||||
targetTypeInt = (int)SceneBlockContainer.Targets.Stay;
|
||||
@@ -530,7 +586,11 @@ public class TargetController : MonoBehaviour
|
||||
|
||||
#endregion Play Mode Method
|
||||
|
||||
// get target observation states
|
||||
/// <summary>
|
||||
/// Gets the target observation states.
|
||||
/// 获取目标观测状态。
|
||||
/// </summary>
|
||||
/// <param name="targetPosition">The target position (optional).</param>
|
||||
private void UpdateTargetStates(Vector3? targetPosition = null)
|
||||
{
|
||||
// targettype, x,y,z, firebasesAreaDiameter
|
||||
@@ -555,7 +615,11 @@ public class TargetController : MonoBehaviour
|
||||
}
|
||||
}
|
||||
|
||||
// get in area state
|
||||
/// <summary>
|
||||
/// Gets the in-area state.
|
||||
/// 获取是否在区域内的State
|
||||
/// </summary>
|
||||
/// <returns>The in-area state.</returns>
|
||||
public int GetInAreaState()
|
||||
{
|
||||
if (targetTypeInt == (int)SceneBlockContainer.Targets.Go)
|
||||
@@ -568,7 +632,12 @@ public class TargetController : MonoBehaviour
|
||||
}
|
||||
}
|
||||
|
||||
// get random Level by target type
|
||||
/// <summary>
|
||||
/// Gets a random level index based on the target type.
|
||||
/// 根据目标类型获取随机关卡索引。
|
||||
/// </summary>
|
||||
/// <param name="target">The target type.</param>
|
||||
/// <returns>A random level index.</returns>
|
||||
public int GetRandomLevelIndex(SceneBlockContainer.Targets target)
|
||||
{
|
||||
List<float> targetProbs;
|
||||
|
||||
Reference in New Issue
Block a user