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


C# Entity.GetComponent方法代码示例

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


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

示例1: Awake

	protected void Awake()
	{
		animator = GetComponent<Animator>();
		entity = GetComponentInParent<Entity>();
		agent = entity.GetComponent<NavMeshAgent>();
		movement = entity.GetComponent<EntityMovement>();
	}
开发者ID:Snakybo-School,项目名称:OUTGEFOUND,代码行数:7,代码来源:EnemyAnimator.cs

示例2: UpdateThrusters

        private void UpdateThrusters(Entity ship)
        {
            var shipComponent = ship.GetComponent<ShipComponent>();
            var thrusters = shipComponent.Thrusters.Select(e => e.GetComponent<ThrusterComponent>());
            var xform = ship.GetComponent<Transform>();

            bool isShipTurning = Math.Abs(shipComponent.AngularTorque) > 0;
            var isShipThrusting = shipComponent.LinearThrustVector.LengthSquared() > 0;

            foreach (var thruster in thrusters)
            {
                if (thruster == null) continue;
                bool isThrusting = false;
                if (isShipThrusting)
                {
                    var offset = Math.Abs(GetLesserAngleDifference(shipComponent.LinearThrustVector.GetAngleRadians() - MathHelper.Pi / 2f, thruster.Part.Transform.Rotation));
                    isThrusting = offset < 1;
                }
                if (isShipTurning)
                {
                    var rotateDir = (AngularDirection)Math.Sign(shipComponent.AngularTorque);
                    //isThrusting = rotateDir == thruster.RotateDir;
                    isThrusting |= thruster.GetAngularThrustMult(rotateDir, Vector2.Zero) > 0;
                }

                thruster.IsThrusting = isThrusting;
                if (isThrusting)
                    thruster.ThrustPercentage = MathHelper.Clamp(thruster.ThrustPercentage + 0.05f, 0, 1);
                else
                    thruster.ThrustPercentage = MathHelper.Clamp(thruster.ThrustPercentage - 0.05f, 0, 1);
            }
        }
开发者ID:raycrasher,项目名称:Fell-Sky,代码行数:32,代码来源:ShipUpdateSystem.cs

示例3: ClosestTarget

 public Body ClosestTarget(Entity e)
 {
     AI a = e.GetComponent<AI>();
     PhysicsBody pb = world.GetClosestBody(e.GetComponent<ITransform>().Position, a.HostileGroup);
     Body b = new Body(world, pb.UserData as Entity);
     return b;
 }
开发者ID:LostCodeStudios,项目名称:SpaceHordes,代码行数:7,代码来源:AISystem.cs

示例4: Attach

 public void Attach(Entity newMaster)
 {
     master = newMaster;
     master.OnShutdown += master_OnShutdown;
     master.GetComponent<TransformComponent>(ComponentFamily.Transform).OnMove += HandleOnMasterMove;
     Translate(master.GetComponent<TransformComponent>(ComponentFamily.Transform).Position);
 }
开发者ID:millpond,项目名称:space-station-14,代码行数:7,代码来源:SlaveMoverComponent.cs

示例5: ProcessEntity

		protected override void ProcessEntity(Engine engine, Entity entity)
		{
			// 2 per 1000 milliseconds
			var amountPerSecond = 2;
			var people = entity.GetComponent<PeopleComponent>().Value;
			entity.GetComponent<GoldComponent>().Value += (engine.DeltaMs * amountPerSecond / 1000.0) * people;
		}
开发者ID:tolemac,项目名称:RosWorld,代码行数:7,代码来源:GameConfig.cs

示例6: Process

        public override void Process(Entity entity, float dt)
        {
            var physics = entity.GetComponent<PhysicsComponent>();
            var render = entity.GetComponent<RenderComponent>();

            render.RenderPosition = physics.Position;
        }
开发者ID:koniin,项目名称:Drakborgen,代码行数:7,代码来源:RenderSystem.cs

示例7: Process

 public override void Process(Entity e)
 {
     Moving moving = e.GetComponent<Moving>();
     Transform spatial = e.GetComponent<Transform>();
     spatial.Position += moving.Velocity * EntityWorld.Delta / 10000000;
     moving.Velocity += moving.Acceleration * EntityWorld.Delta / 10000000;
 }
开发者ID:nicojans,项目名称:FinalQuest,代码行数:7,代码来源:MovingSystem.cs

示例8: Process

 public override void Process(Entity e)
 {
     Acting acting = e.GetComponent<Acting>();
     if (acting.State != ActingState.SkillSelection)
         return;
     InputControlled inputControlled = e.GetComponent<InputControlled>();
     if (String.IsNullOrEmpty(acting.SkillSelected.Name))
     {
         inputControlled.SkillMenu.Draw();
     }
     else
     {
         int count = acting.PossibleTargets.Count;
         if (count > 0)
         {
             if (inputControlled.IsTargetingGroup)
             {
                 foreach (Entity entity in acting.PossibleTargets)
                 {
                     if (entity.GetComponent<Transform>() != null)
                     {
                         Vector2 position = new Vector2(entity.GetComponent<Transform>().Center.X, entity.GetComponent<Transform>().Y - 10);
                         _spriteBatch.Draw(arrowTargeted, position, Color.White);
                     }
                 }
             }
             else
             {
                 Entity TargetedEntity = acting.PossibleTargets[inputControlled.TargetIndex];
                 foreach (Entity entity in acting.PossibleTargets)
                 {
                     if (entity.GetComponent<Transform>() != null)
                     {
                         Vector2 position = new Vector2(entity.GetComponent<Transform>().Center.X, entity.GetComponent<Transform>().Y - 10);
                         if (entity == TargetedEntity)
                         {
                             _spriteBatch.Draw(arrowTargeted, position, Color.White);
                         }
                         else
                         {
                             _spriteBatch.Draw(arrowCanBeTargeted, position, Color.White);
                         }
                     }
                 }
             }
         }
         else
         {
             foreach (Entity entity in acting.Targets)
             {
                 if (entity.GetComponent<Transform>() != null)
                 {
                     Vector2 position = new Vector2(entity.GetComponent<Transform>().Center.X, entity.GetComponent<Transform>().Y - 10);
                     _spriteBatch.Draw(arrowTargeted, position, Color.White);
                 }
             }
         }
     }
 }
开发者ID:nicojans,项目名称:FinalQuest,代码行数:59,代码来源:InputSkillSelectionRenderingSystem.cs

示例9: Process

        public override void Process(Entity e)
        {
            if(e.GetComponent<Health>()!=null)
                e.GetComponent<Health>().AddDamage(10);

            if (e.GetComponent<Power2>() != null)
                e.GetComponent<Power2>().POWER -=10;
        }
开发者ID:dackjaniels2001,项目名称:artemis_CSharp,代码行数:8,代码来源:ThirdMostSimpleSystemEver.cs

示例10: PlaceItem

 private void PlaceItem(Entity actor, Entity item)
 {
     var rnd = new Random();
     actor.SendMessage(this, ComponentMessageType.DropItemInCurrentHand);
     item.GetComponent<SpriteComponent>(ComponentFamily.Renderable).drawDepth = DrawDepth.ItemsOnTables;
     //TODO Unsafe, fix.
     item.GetComponent<TransformComponent>(ComponentFamily.Transform).TranslateByOffset(
         new Vector2(rnd.Next(-28, 28), rnd.Next(-28, 15)));
 }
开发者ID:Gartley,项目名称:ss13remake,代码行数:9,代码来源:WorktopComponent.cs

示例11: DamageTarget

 public static void DamageTarget(Entity user, Entity target, int damage, double hitSuccess = 1)
 {
     EntityCreator.CreateDamageInfo(target, damage, hitSuccess);
     BattleStats stats = target.GetComponent<BattleStats>();
     stats.Health.Decrease(damage);
     if (stats.IsDead && !target.GetComponent<Group>().IsHero)
     {
         target.Delete();
     }
 }
开发者ID:nicojans,项目名称:FinalQuest,代码行数:10,代码来源:BattleEngine.cs

示例12: BuildEntity

 public Entity BuildEntity(Entity e, EntityWorld world, params object[] args)
 {
     e.Group = "EFFECTS";
     e.AddComponentFromPool<Transform>();
     e.AddComponent(new SpatialForm());
     e.AddComponent(new Expires());
     e.GetComponent<SpatialForm>().SpatialFormFile = "ShipExplosion";
     e.GetComponent<Expires>().LifeTime = 1000;
     return e;
 }
开发者ID:dackjaniels2001,项目名称:starwarrior_CSharp,代码行数:10,代码来源:ShipExplosionTemplate.cs

示例13: BuildEntity

 public Entity BuildEntity(Entity e)
 {
     e.Group = "EFFECTS";
     e.AddComponent(new Transform());
     e.AddComponent(new SpatialForm());
     e.AddComponent(new Expires());
     e.GetComponent<SpatialForm>().SpatialFormFile = "BulletExplosion";
     e.GetComponent<Expires>().LifeTime = 1000;
     return e;
 }
开发者ID:sigod,项目名称:starwarrior_CSharp,代码行数:10,代码来源:BulletExplosionTemplate.cs

示例14: Process

        public override void Process (Entity entity)
        {
            var transform = entity.GetComponent<Transform>();
            var renderer = entity.GetComponent<Texture2DRenderer>();
            var spriteBatch = BlackBoard.GetEntry<SpriteBatch>("SpriteBatch");
            var texture = BlackBoard.GetEntry<ContentManager>("ContentManager").Load<Texture2D>(renderer.TextureName);


            spriteBatch.Draw(texture, transform.renderPosition, null, null, transform.globalOrigin, transform.renderRotation, transform.renderScale);
        }
开发者ID:bfollington,项目名称:Chill,代码行数:10,代码来源:RenderSystem.cs

示例15: BuildEntity

        public Entity BuildEntity(Entity e)
        {
            e.Group = "BULLETS";

            e.AddComponent(new Transform());
            e.AddComponent(new SpatialForm());
            e.AddComponent(new Velocity());
            e.AddComponent(new Expires());
            e.GetComponent<SpatialForm>().SpatialFormFile = "Missile";
            e.GetComponent<Expires>().LifeTime = 2000;
            return e;
        }
开发者ID:sigod,项目名称:starwarrior_CSharp,代码行数:12,代码来源:MissileTemplate.cs


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