当前位置: 首页>>代码示例>>C#>>正文


C# LevelManager.RegisterSolider方法代码示例

本文整理汇总了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();
    }
开发者ID:JamesZinger,项目名称:NeuralNetworkAssignment,代码行数:85,代码来源:Solider.cs


注:本文中的LevelManager.RegisterSolider方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。