예제 #1
0
        protected override void Execute(World world, UpdateMessage message)
        {
            for (var i = 0; i < data.Length; i++)
            {
                data.Weapons[i].Timeout -= message.DeltaTime;
            }

            for (var i = 0; i < data.Length; i++)
            {
                if ((data.Inputs[i].Commands & InputCommands.Fire) > 0 && data.Weapons[i].Timeout <= 0)
                {
                    bulletSpawner.Spawn(
                        new BulletSpawner.PlayerBullet(
                            data.Positions[i],
                            new Heading(new Vector2(0, 1)),
                            new ParentEntity(data.entities[i]),
                            data.Weapons[i].Power));
                    bulletSpawner.Spawn(
                        new BulletSpawner.PlayerBullet(
                            data.Positions[i],
                            new Heading(Vector2.Normalize(new Vector2(.2f, 1))),
                            new ParentEntity(data.entities[i]),
                            data.Weapons[i].Power));
                    bulletSpawner.Spawn(
                        new BulletSpawner.PlayerBullet(
                            data.Positions[i],
                            new Heading(Vector2.Normalize(new Vector2(-.2f, 1))),
                            new ParentEntity(data.entities[i]),
                            data.Weapons[i].Power));
                    data.Weapons[i].Timeout = data.Weapons[i].Frequency;
                }
            }
        }
예제 #2
0
        protected override void Execute(World world, UpdateMessage message)
        {
            for (var i = 0; i < data.Length; i++)
            {
                data.Weapons[i].Timeout1 -= message.DeltaTime;
                if (data.Weapons[i].Timeout1 > 0)
                {
                    continue;
                }
                data.Weapons[i].Timeout1 = .8f;

                var nearestPosition = players.Positions[0];
                var closestDistance = Vector2.DistanceSquared(data.Positions[i].Vector, players.Positions[0].Vector);

                for (var j = 1; j < players.Length; i++)
                {
                    var distance = Vector2.DistanceSquared(data.Positions[i].Vector, players.Positions[j].Vector);
                    if (closestDistance > distance)
                    {
                        closestDistance = distance;
                        nearestPosition = players.Positions[j];
                    }
                }

                var heading = new Heading(Vector2.Normalize(nearestPosition.Vector - data.Positions[i].Vector) * .8f);
                bulletSpawner.Spawn(new BulletSpawner.EnemyBullet(data.Positions[i], heading));
            }
        }
예제 #3
0
    private void OnTriggerEnter2D(Collider2D collision)
    {
        if (!(isP1Platform && isP2Platform && isP3Platform))
        {
            if (isP1Platform && collision.name != "P1")
            {
                return;
            }
            else if (isP2Platform && collision.name != "P2")
            {
                return;
            }
            else if (isP3Platform && collision.name != "P3")
            {
                return;
            }
        }

        /* if (collision.name == "P1")
         * {
         *  if (collision.GetComponent<Player1Controls>().GotKey)
         *  {
         *      bulletSpawner.Spawn();
         *  }
         * } */

        if (firesBullet)
        {
            // if bullet is loaded

            bulletSpawner.Spawn();
        }

        if (openGate)
        {
            gate.SetActive(false);
        }

        if (isTrap)
        {
            tilemap.SetTile(new Vector3Int(-1, -13, 0), tileActive);
            tilemap.SetTile(new Vector3Int(-2, -13, 0), tileActive);
            tilemap.SetTile(new Vector3Int(-1, -14, 0), tileActive);
            tilemap.SetTile(new Vector3Int(-2, -14, 0), tileActive);

            deathPlane.enabled = true;
            deathPlaneObject.SetActive(true);
        }
    }
 private void Start()
 {
     _bulletSpawner.Spawn();
 }
        private void SpawnBullet()
        {
            Vector3 shotDirection = GetDirectionWithinAngle();

            _bulletSpawner.Spawn(_tip.position, shotDirection);
        }
 public void Fire(GunnerControlScript freddy)
 {
     Spawner.Spawn(Projectile, MuzzleFlash, freddy);
 }
예제 #7
0
 protected override void OnShoot()
 {
     bulletSpawner.Spawn();
 }