本文整理汇总了C#中IEntity.GetComponent方法的典型用法代码示例。如果您正苦于以下问题:C# IEntity.GetComponent方法的具体用法?C# IEntity.GetComponent怎么用?C# IEntity.GetComponent使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IEntity
的用法示例。
在下文中一共展示了IEntity.GetComponent方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Update
void Update(IEntity entity)
{
var focus = entity.GetComponent<FocusingThingComponent>();
var breathing = entity.GetComponent<BreathingNode>();
var time = entity.GetComponent<TimeComponent>();
var player = EntityManager.Entities.Filter(typeof(PlayerConsentrationComponent))[0].GetComponent<PlayerConsentrationComponent>();
var focusCircle = focus.zone.WorldCircle;
if (focusCircle.Contains(Camera.main.GetMouseWorldPosition()) && breathing.actif)
{
focus.Sprite.color = focus.FocusedColor;
handleFocus(focus, breathing, time);
}
else
{
focus.Sprite.color = focus.UnfocusedColor;
focus.Sprite.transform.SetScale(new Vector3(1, 1, 1));
}
if (breathing.actif && breathing.counter > breathing.Activatingtime)
{
var scaleFocus = focus.Sprite.transform.localScale.x;
var scaleBreathing = breathing.IndicatorTransform.localScale.x;
if (Mathf.Abs(scaleFocus - scaleBreathing) >= focus.precisionNeeded)
player.Consentration -= focus.damage * time.DeltaTime;
else
player.Consentration += focus.regen * time.DeltaTime;
}
}
示例2: Init
public override void Init(IEntity entity)
{
base.Init(entity);
_transform = entity.GetComponent<ITranslateComponent>();
_uiEvents = entity.GetComponent<IUIEvents>();
_uiEvents.MouseDown.Subscribe(onMouseDown);
}
示例3: Update
void Update(IEntity entity)
{
var oscillator = entity.GetComponent<SpeedOscillator>();
var mouvementSpeed = entity.GetComponent<MouvementSpeedComponent>();
var time = entity.GetComponent<TimeComponent>();
mouvementSpeed.Speed = oscillator.Center + oscillator.Amplitude * Mathf.Sin(oscillator.Frequency * time.Time);
}
示例4: Update
void Update(IEntity entity)
{
var consentrationComponent = entity.GetComponent<PlayerConsentrationComponent>();
var consentrationZone = consentrationComponent.zone.WorldCircle;
var loseLife = entity.GetComponent<LoseLifeWhenOutOfConsentrationComponent>();
var time = entity.GetComponent<TimeComponent>();
if (time.DeltaTime <= 0) return;
var zones = EntityManager.Entities.Filter(typeof(ConsentrationKeeperZone));
bool colideWithSomething = false;
foreach (var zone in zones.ToArray())
{
if (zone.GetComponent<ConsentrationKeeperZone>().zone.WorldCircle.Intersects(consentrationZone))
{
colideWithSomething = true;
continue;
}
}
if (colideWithSomething)
consentrationComponent.Consentration += Time.deltaTime * loseLife.gainPerSecond;
else
consentrationComponent.Consentration -= Time.deltaTime * loseLife.amountPerSecond;
}
示例5: Init
public override void Init(IEntity entity)
{
base.Init(entity);
_characterName = entity.ID;
_emitter.Translate = entity.GetComponent<ITranslateComponent>();
_emitter.HasRoom = entity.GetComponent<IHasRoom>();
}
示例6: Update
void Update(IEntity entity)
{
var pathFollower = entity.GetComponent<PathFollower>();
var path = pathFollower.Path.GetComponent<SimpleWaypointsPath>();
var movementSpeed = entity.GetComponent<MouvementSpeedComponent>();
var time = entity.GetComponent<TimeComponent>();
if (time.DeltaTime <= 0) return;
Transform wp = path.Waypoints[pathFollower.CurrentPathIndexTarget];
TendTo(pathFollower, wp, movementSpeed.Speed);
if ((pathFollower.transform.position - wp.position).magnitude <= 0.1f)
{
if (pathFollower.random)
{
pathFollower.CurrentPathIndexTarget = PRandom.Range(0, path.Waypoints.Length - 1);
}
else
{
pathFollower.CurrentPathIndexTarget++;
if (pathFollower.CurrentPathIndexTarget >= path.Waypoints.Length)
pathFollower.CurrentPathIndexTarget = 0;
}
}
}
示例7: Init
public override void Init(IEntity entity)
{
base.Init(entity);
_entity = entity;
_enabled = entity.GetComponent<IEnabledComponent>();
_visible = entity.GetComponent<IVisibleComponent>();
_gameEvents.OnRepeatedlyExecute.SubscribeToAsync(onRepeatedlyExecute);
}
示例8: Init
public override void Init(IEntity entity)
{
base.Init(entity);
_drawableInfo = entity.GetComponent<IDrawableInfo>();
_obj = entity.GetComponent<IAnimationContainer>();
_scale = entity.GetComponent<IScaleComponent>();
_pixelPerfect = entity.GetComponent<IPixelPerfectComponent>();
}
示例9: Init
public override void Init (IEntity entity)
{
base.Init (entity);
_follower = entity;
_walk = entity.GetComponent<IWalkBehavior>();
_hasRoom = entity.GetComponent<IHasRoom> ();
_obj = entity.GetComponent<ITranslateComponent> ();
}
示例10: Update
void Update(IEntity entity)
{
var time = entity.GetComponent<TimeComponent>();
var colorizer = entity.GetComponent<ConcentrationColorizerComponent>();
var value = Mathf.Clamp01(level.Concentration * (colorizer.Concentration.Max - colorizer.Concentration.Min) + colorizer.Concentration.Min);
var color = colorizer.Color.Evaluate(value);
colorizer.Renderer.color = Color.Lerp(colorizer.Renderer.color, color, time.DeltaTime * colorizer.FadeSpeed);
}
示例11: Init
public override void Init(IEntity entity)
{
base.Init(entity);
_events = entity.GetComponent<IUIEvents>();
_animation = entity.GetComponent<IAnimationContainer>();
_events.MouseEnter.Subscribe(onMouseEnter);
_events.MouseLeave.Subscribe(onMouseLeave);
_events.MouseUp.Subscribe(onMouseUp);
}
示例12: Init
public override void Init(IEntity entity)
{
base.Init(entity);
_collider = entity.GetComponent<ICollider>();
_drawableInfo = entity.GetComponent<IDrawableInfo>();
_tree = entity.GetComponent<IInObjectTree>();
_visible = entity.GetComponent<IVisibleComponent>();
_enabled = entity.GetComponent<IEnabledComponent>();
_gameEvents.OnRepeatedlyExecute.Subscribe(onRepeatedlyExecute);
}
示例13: Update
void Update(IEntity entity)
{
var colorOverTime = entity.GetComponent<TextMeshColorOverLifeTime>();
var lifeTime = entity.GetComponent<LifeTimeComponent>();
var player = EntityManager.Entities.Filter(typeof(PlayerConsentrationComponent))[0].GetComponent<PlayerConsentrationComponent>();
var levelData = EntityManager.Entities.Filter(typeof(LevelDataComponent))[0].GetComponent<LevelDataComponent>();
Color newColor = colorOverTime.ColorGradient.Evaluate(lifeTime.TimeRatio);
Color color2 = levelData.TextColorOverConcentration.Evaluate(player.T);
colorOverTime.TargetTextMesh.color = Color.Lerp(newColor, color2, player.T);
}
示例14: OnEntityAdded
public override void OnEntityAdded(IEntity entity)
{
base.OnEntityAdded(entity);
var colorizer = entity.GetComponent<TileColorizerComponent>();
colorizer.CurrentColor = colorizer.Normal;
}
示例15: Update
void Update(IEntity entity)
{
var concentrate = entity.GetComponent<ConcentrateOnHoldComponent>();
if (concentrate.Hovering && concentrate.Clicking)
level.Concentration += concentrate.ConcentrationGain * TimeManager.World.DeltaTime * 0.1f;
}