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


C# GameEntity.ForceDestroy方法代码示例

本文整理汇总了C#中GameEntity.ForceDestroy方法的典型用法代码示例。如果您正苦于以下问题:C# GameEntity.ForceDestroy方法的具体用法?C# GameEntity.ForceDestroy怎么用?C# GameEntity.ForceDestroy使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在GameEntity的用法示例。


在下文中一共展示了GameEntity.ForceDestroy方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Control

        public override bool Control( GameEntity control, TimeSpan gameTime, Microsoft.Xna.Framework.Input.KeyboardState keyState )
        {
            if ( !control.Variables.ContainsKey( "VacuumSpeed" ) )
            {
                control.Variables[ "VacuumSpeed" ] = baseSpeed;
            }

            float vacSpeed = ( float )control.Variables[ "VacuumSpeed" ];
            float d = Vector2.Distance( Owner.Position, control.Position );
            if ( d * 2 <= Owner.GameWidth + Owner.GameHeight )
            {
                control.Variables.Remove( "VacuumSpeed" );
                control.ForceDestroy();
            }
            else
            {
                control.Move( vacSpeed, Tools.Angle( control, Owner ) );
                if ( spiral )
                {
                    control.Move( vacSpeed + 10, Tools.Angle( control, Owner ) + 90 );
                }
            }
            if ( vacSpeed < maxSpeed )
            {
                vacSpeed += acceleration;
            }
            else
            {
                vacSpeed = maxSpeed;
            }
            control.Variables[ "VacuumSpeed" ] = vacSpeed;

            if ( t != null )
            {
                Tank ta = ( Tank )Owner;
                if ( !Game.HasController( this ) )
                {
                    destroyTime += 1;
                    if ( destroyTime > 1000 )
                    {
                        ta.RemoveTankController();
                    }
                }
            }

            return true;
        }
开发者ID:nitzanbueno,项目名称:TanksDropTwo,代码行数:47,代码来源:VacuumController.cs

示例2: Control

        public override bool Control( GameEntity control, TimeSpan gameTime, KeyboardState keyState )
        {
            if ( !control.Variables.ContainsKey( "VacuumSpeed" ) )
            {
                control.Variables[ "VacuumSpeed" ] = baseSpeed;
            }

            float vacSpeed = ( float )control.Variables[ "VacuumSpeed" ]; // The current pull speed
            float d = Vector2.Distance( Position, control.Position ); // The current distance
            if ( d <= 16 * Scale ) // if the distance is smaller than that value, the entity is inside the black hole and therefore should be destroyed.
            {
                // Destroy
                control.Variables.Remove( "VacuumSpeed" );
                control.ForceDestroy();
            }
            else // Else the control is outside so do the orbit
            {
                control.Move( vacSpeed, Tools.Angle( control.Position, Position ) ); // The pull
                control.Move( vacSpeed + spiralFactor, Tools.Angle( control.Position, Position ) + 90 ); // The turn
            }
            // Accelerate the pull speed
            vacSpeed += acceleration;
            if ( vacSpeed > maxSpeed && maxSpeed >= 0 )
            {
                // Limit the pull speed from the top
                vacSpeed = maxSpeed;
            }
            if ( vacSpeed < minSpeed && minSpeed >= 0 )
            {
                // Limit the pull speed from the bottom
                vacSpeed = minSpeed;
            }
            control.Variables[ "VacuumSpeed" ] = vacSpeed;
            return true;
        }
开发者ID:nitzanbueno,项目名称:TanksDropTwo,代码行数:35,代码来源:Orbit.cs


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