public override void Update(IList <Entity> entities, double elapsedTime) { //Entities var entitiesToProcess = entities.Where(x => !x.ToRemove && x.HasComponent(6) && ((TypeComponent)x.GetComponent(5)).Type == Enums.EnumTypeEntity.ENEMY) .Select(x => new { Entity = x, Transform = ((TransformComponent)x.GetComponent(0)) }) .OrderByDescending(x => x.Transform.Y) .GroupBy(x => x.Transform.X) .Select(x => x.FirstOrDefault()); foreach (var e in entitiesToProcess) { ShootComponent shootComponent = (ShootComponent)e.Entity.GetComponent(6); var transformComponent = (TransformComponent)e.Entity.GetComponent(0); var typeComponent = (TypeComponent)e.Entity.GetComponent(5); shootComponent.LastShootTime += elapsedTime; if (shootComponent.LastShootTime > shootComponent.IntervalBetweenShoot * 1000) { var shoot = MyGame.Instance.World.EntityManager.CreateEntity(); FactoryEntity.CreateShoot(shoot, transformComponent.X, transformComponent.Y, 0, 1, 33, Enums.EnumTypeEntity.SHOOT_ENEMY); shootComponent.LastShootTime = 0; } } }
public void SetupCannon() { cannon = GetComponentInChildren <ShootComponent>(); if (cannon != null) { cannon.player = player; } }
public Enemy(Image image) : base(image, CollisionTag.ENEMY) { PositionComponent startPos = GetComponent(typeof(PositionComponent)) as PositionComponent; VelocityComponent velocity = GetComponent(typeof(VelocityComponent)) as VelocityComponent; velocity.Velocity.x = 50; ShootComponent shootStat = new ShootComponent(this, 0.2, 1, 0.5); AddComponent(shootStat); }
public void ProduceInput() { var duration = _getDuration(); var comp = new ShootComponent(_range, duration); Game.I.UserInputController.ProduceInput(GetActionType(), comp); _prediction.DrawShootingRange(_range); _range = null; _hide(); }
//Inicializo algunas vars private void Awake() { _rb = GetComponent <Rigidbody>(); _idle = new IdleComponent(); _move = new MoveComponent(_rb, transform, _speed); _shoot = new ShootComponent(transform, _manager); _view = GetComponent <View>(); }
private void Shoot() { ShootComponent shootComponent = (ShootComponent)weaponInventory.weapons[index].components.Find(BaseComponent => BaseComponent.GetType() == typeof(ShootComponent)); if (shootComponent != null) { Vector3 barrelPosition = weaponInventory.weapons[index].barrelPosition; Vector3 projectilePosition = weaponHolder.TransformPoint(barrelPosition); shootComponent.Shoot(projectilePosition, weaponTransform.rotation); } }
public void Tick(ref ShootComponent shootComp) { if (shootComp.CurrentDelay > 0) { shootComp.CurrentDelay -= Time.deltaTime; } else { Shoot(); shootComp.CurrentDelay = 1 / shootComp.FireRate; } }
public Player() : base(Image.FromFile("../../Resources/ship1.png"), CollisionTag.PLAYER) { PositionComponent startPos = GetComponent(typeof(PositionComponent)) as PositionComponent; startPos.Position.y = RenderForm.instance.Size.Height * 5.2 / 6; startPos.Position.x = RenderForm.instance.Size.Width / 2; VelocityComponent velocity = GetComponent(typeof(VelocityComponent)) as VelocityComponent; velocity.Velocity.x = 200; ShootComponent shootStatus = new ShootComponent(this, 0.2, 0, 1);//Le dernier parametre n'est pas nécessaire pour le joueur AddComponent(shootStatus); Life = 3; }
public override void Update(IList <Entity> entities, double elapsedTime) { //Entities var player = entities.Where(x => !x.ToRemove && ((TypeComponent)x.GetComponent(5)).Type == Enums.EnumTypeEntity.PLAYER).First(); ShootComponent shootComponent = (ShootComponent)player.GetComponent(6); var transformComponent = (TransformComponent)player.GetComponent(0); shootComponent.LastShootTime += elapsedTime; if (shootComponent.ShootAsked && shootComponent.LastShootTime > shootComponent.IntervalBetweenShoot * 1000) { var shoot = MyGame.Instance.World.EntityManager.CreateEntity(); FactoryEntity.CreateShoot(shoot, transformComponent.X, transformComponent.Y, 0, -1, 32, Enums.EnumTypeEntity.SHOOT_PLAYER); shootComponent.LastShootTime = 0; } }
private void GetBehaviours() { _shootComp = GetComponent <ShootComponent>(); _moveComp = GetComponent <MoveComponent>(); _bodyComp = GetComponent <BodyComponent>(); _poolObjectComponent = GetComponent <PoolObjectComponent>(); if (_poolObjectComponent) { _poolObjectComponent.OnResetBeforeBackToPool += ResetAfterDisable; } if (_moveComp) { _moveComp.OnOutOfBounds += SelfDestroy; } if (_bodyComp) { _bodyComp.OnDeath += SelfDestroy; } }
public ShootEnemyNode(Entity e) { EnemyPosition = (PositionComponent)e.GetComponent(typeof(PositionComponent)); ShootComponent = (ShootComponent)e.GetComponent(typeof(ShootComponent)); }
private void Awake() { shootComponent = GetComponent <ShootComponent>(); }
public ShootPlayerNode(Entity e) { PlayerPosition = (PositionComponent)e.GetComponent(typeof(PositionComponent)); ShootComponent = (ShootComponent)e.GetComponent(typeof(ShootComponent)); }
/// <summary> /// Fields and references initialization /// </summary> private void OnEnable() { m_SqrPerceptionRadius = m_PerceptionRadius * m_PerceptionRadius; m_ShootComponent = gameObject.GetComponent<ShootComponent>(); m_CurrentTarget = null; }