本文整理汇总了C#中LevelManager.RegisterSolider方法的典型用法代码示例。如果您正苦于以下问题:C# LevelManager.RegisterSolider方法的具体用法?C# LevelManager.RegisterSolider怎么用?C# LevelManager.RegisterSolider使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类LevelManager
的用法示例。
在下文中一共展示了LevelManager.RegisterSolider方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Start
void Start()
{
Manager = GameObject.FindGameObjectWithTag( "Level" ).GetComponent<LevelManager>();
if ( Health > SOLIDER_MAX_HEALTH )
{
Health = SOLIDER_MAX_HEALTH;
UnityEngine.Debug.LogWarning( "Solider health is greater than the levels max health" );
}
if ( Ammo > SOLIDER_MAX_AMMO )
{
Ammo = SOLIDER_MAX_AMMO;
UnityEngine.Debug.LogWarning( "Solider ammo is greater than the levels max ammo" );
}
switch ( AssignedTeam )
{
case ( Team.Blue ):
gameObject.layer = LayerMask.NameToLayer( "BlueTeam" );
break;
case ( Team.Red ):
gameObject.layer = LayerMask.NameToLayer( "RedTeam" );
break;
default:
UnityEngine.Debug.LogException( new ArgumentException( "Solider cannot have a null team" ) );
break;
}
GetComponent<SpriteRenderer>().sprite = AliveSprite;
EffectedDamage = 0;
EffectedMovementSpeed = 0;
Manager.RegisterSolider( this );
moveTarget = new Vector2( 0, 0 );
isMoving = false;
if ( AssignedTeam == Team.Red )
gameObject.renderer.material.color = Color.red;
else if ( AssignedTeam == Team.Blue )
gameObject.renderer.material.color = Color.blue;
nearbyEnemies = new Solider[ SOLIDER_TRACK_ENEMY_COUNT ];
nearbyFriendlies = new Solider[ SOLIDER_TRACK_FRIENDLY_COUNT ];
canShoot = true;
///// Start up and train the NN /////
// Set up the MLP and configure its inputs to receive inputs within the expected ranges
// Note: This is to allow the MLP to normalize inputs to the range [0, 1]
neuralNetwork = new MLP( 20, 20, 6, ActivationFunction.Threshold );
for ( int i = 0; i < 5; i++ )
{
neuralNetwork.Inputs[ i ].MinValue = 0f; // Current health, friendly health
neuralNetwork.Inputs[ i ].MaxValue = 100f;
}
for ( int i = 5; i < 10; i++ )
{
neuralNetwork.Inputs[ i ].MinValue = 0f; // Current ammo, friendly ammo
neuralNetwork.Inputs[ i ].MaxValue = 1000f;
}
for ( int i = 10; i < 15; i++ )
{
neuralNetwork.Inputs[ i ].MinValue = 1f; // Nearest powerup distance, friendly distances
neuralNetwork.Inputs[ i ].MaxValue = 5f;
}
for ( int i = 15; i < 20; i++ )
{
neuralNetwork.Inputs[ i ].MinValue = 1f; // Nearest powerup distance, friendly distances
neuralNetwork.Inputs[ i ].MaxValue = 5f;
}
// Train the system with hardcoded training data
TrainNN();
}