public static Entity CreateCollision(this Pool pool, Collision2D collision)
    {
        return pool.CreateEntity()
            .AddCollision(collision)
            .IsDestroying(true);

    }
 public static Entity CreateDiscEntity(this Pool pool, int x, int y, bool isBlack = false)
 {
     return pool.CreateEntity()
       .AddPosition(x, y)
       .AddDisc(isBlack)
       .AddPrefab((GameObject)Resources.Load("Disc"));
 }
 public static Entity CreateRandomUnit(this Pool pool)
 {
     return pool.CreateEntity()
         .AddUnit(_unitsNames[Random.Range(0, _unitsNames.Length)])
         .AddTurnOrder(Random.Range(0, 100))
         .AddResource(_units[Random.Range(0, _units.Length)]);
 }
Example #4
0
	public static Entity StartGameOver(this Pool pool)
	{
		var e = pool.CreateEntity()
			.IsGameOver(true);
		
		return e.AddCoroutine(LeaderboardHelper.GetCoroutine(pool, e));
	}
Example #5
0
 public static Entity CreateBlocker(this Pool pool, int x, int y)
 {
     return pool.CreateEntity()
         .IsGameBoardElement(true)
         .AddPosition(x, y)
         .AddResource(Res.Blocker);
 }
 public static Entity CreateCamera(this EntityWorld world, string tag, GraphicsDevice device)
 {
     var entity = world.CreateEntity();
     var camera = new Camera(device);
     entity.AddComponent(camera);
     entity.Tag = tag;
     return entity;
 }
 public static Entity CreateGun(this Pool pool, GameObject view)
 {
     return pool.CreateEntity()
         .AddGun(0.3f, 0)
         .IsControllable(true)
         .IsFireable(true)
         .AddView(view);
 }
 public static Entity CreateRedGem(this Pool pool, int x, int y) {
     return pool.CreateEntity()
                .IsGameBoardElement(true)
                .IsMovable(true)
                .AddPosition(x, y)
                .AddResource(Res.redGem)
                .IsInteractive(true);
 }
 public static Entity CreateRandomPiece(this Pool pool, int x, int y) {
     return pool.CreateEntity()
         .IsGameBoardElement(true)
         .AddPosition(x, y)
         .IsMovable(true)
         .IsInteractive(true)
         .AddResource(_pieces[Random.Range(0, _pieces.Length)]);
 }
Example #10
0
 public static Entity CreateStoryOverlay(this EntityWorld world, string text, string className = "storyoverlay")
 {
     var entity = world.CreateEntity();
     var element = new LibRocketNet.Element("div");
     element.SetClass(className);
     element.InnerRml = text;
     entity.AddComponent(new GuiComponent(element));
     return entity;
 }
 /// Creates a new entity and adds copies of all
 /// specified components to it.
 /// If replaceExisting is true it will replace exisintg components.
 public static Entity CloneEntity(this Context context,
                                  Entity entity,
                                  bool replaceExisting = false,
                                  params int[] indices)
 {
     var target = context.CreateEntity();
     entity.CopyTo(target, replaceExisting, indices);
     return target;
 }
 public static Entity CreateAsteroid(this Pool pool, float x, float y, AsteroidSize size)
 {
     return pool.CreateEntity()
         .AddAsteroid(size)
         .AddPosition(x, y)
         .AddHitpoints(1)
         .AddCollisionRadius(AsteroidData.Radii[size])
         .IsWrappedAroundGameBounds(true)
         .AddResource("Prefabs/" + AsteroidData.Resources[size]);
 }
 public static Entity CreateGame(this Pool pool, bool playing, int level, Bounds bounds)
 {
     return pool.CreateEntity()
         .IsGame(true)
         .AddBounds(bounds)
         .AddLevel(level)
         .AddLives(3)
         .AddScore(0)
         .IsPlaying(playing);
 }
 public static Entity CreatePlayer(this Pool pool, bool controllable)
 {
     return pool.CreateEntity()
         .IsPlayer(true)
         .AddPosition(0, 0)
         .AddSpaceship(0.5f, 0.02f)
         .AddCollisionRadius(1)
         .IsControllable(controllable)
         .IsWrappedAroundGameBounds(true)
         .AddForce(new List<Vector2>(), 0)
         .AddResource("Prefabs/Spaceship");
 }
Example #15
0
        public static Entity CreateGrid(this EntityWorld world, Vector2 gridSize, Color color)
        {
            var entity = world.CreateEntity();
            var grid = new GridComponent
            {
                GridSize = gridSize,
                GridColor = color
            };

            entity.AddComponent(grid);
            return entity;
        }
Example #16
0
	public static Entity CreatePlayer(this Pool pool)
	{
		return pool.CreateEntity()
			.AddPlayer(0.2f)
			.IsFriendly(true)
			.AddHealth(1) // One hit one kill
			.AddPosition(0f, -2.8f)
			.AddSpeed(Vector2.zero)
			.AddSpeedMovement(new Vector2(0.1f, 0.08f))
			.AddScreenLimitedPosition(new Vector4(0.55f, -0.5f, -0.55f, 1.0f))
			.AddResource("Ships/playerShip");
	}
 public static Entity CreateBullet(this Pool pool, float x, float y, float rotation)
 {
     return pool.CreateEntity()
         .IsBullet(true)
         .AddPosition(x, y)
         .AddRotation(rotation)
         .AddAge(0)
         .AddMaxAge(1f)
         .IsWrappedAroundGameBounds(true)
         .AddForce(new List<Vector2> { new Vector2(0, 10) }, 0)
         .AddResource("Prefabs/Bullet");
 }
        public static Entity CreateEntity(this Pool pool, Blueprints.IBlueprint blueprint)
        {
            var entity = pool.CreateEntity();

            foreach (var componentTypeName in blueprint.ComponentTypes)
            {
                var componentId = ComponentNameToId[componentTypeName];

                switch (componentId)
                {
                   case ComponentIds.Movable:
                        entity.IsMovable(true);
                        break;
                   case ComponentIds.Position:
                        entity.AddPosition(blueprint.PropertyValues);
                        break;
                   case ComponentIds.Destroy:
                        entity.IsDestroy(true);
                        break;
                   case ComponentIds.GameBoardCache:
                        entity.AddGameBoardCache(blueprint.PropertyValues);
                        break;
                   case ComponentIds.GameBoard:
                        entity.AddGameBoard(blueprint.PropertyValues);
                        break;
                   case ComponentIds.GameBoardElement:
                        entity.IsGameBoardElement(true);
                        break;
                   case ComponentIds.Input:
                        entity.AddInput(blueprint.PropertyValues);
                        break;
                   case ComponentIds.Interactive:
                        entity.IsInteractive(true);
                        break;
                   case ComponentIds.Resource:
                        entity.AddResource(blueprint.PropertyValues);
                        break;
                   case ComponentIds.View:
                        entity.AddView(blueprint.PropertyValues);
                        break;
                   case ComponentIds.Score:
                        entity.AddScore(blueprint.PropertyValues);
                        break;
                   case ComponentIds.ScoreValue:
                        entity.AddScoreValue(blueprint.PropertyValues);
                        break;

                }
            }

            return entity;
        }
        // ------------------ Constants and statics
        // ------------------ Events
        // ------------------ Serialized fields and properties
        // ------------------ Non-serialized fields
        // ------------------ Methods
        public static Entity CreateEffect(this Pool pool, Vector3 position, string resourcePath )
        {
            Entity entity           = pool.CreateEntity();
            entity.AddPosition      (position, false);
            entity.AddResource      (resourcePath);

            //keep short until I can figure out how to shorten the particle lifetime
            //(looks like looping now, but looping bool is not true)
            entity.AddDestroyMe     (1);

            //Most effects won't rotate by rotating the game object. Must manually edit prefab
            entity.AddRotation      (RMC.Common.UnityEngineReplacement.Vector3.zero, false);
            return entity;
        }
Example #20
0
	public static Entity CreateEnemySuicide(this Pool pool, float x, float y, int health, int points, string coroutineType)
	{
		var e = pool.CreateEntity()
			.IsEnemy(true)
			.IsNotFriendly(true)
			.AddPoints(points)
			.AddHealth(health)
			.AddScreenLimitedDestroy(new Vector4(-1.0f, 2.0f, 1.0f, -1.0f))
			.AddCollisionDamage(100)
			.AddPosition(x, y)
			.IsRotateView(true)
			.AddResource("Ships/enemySuicide");
		
		return e.AddCoroutine(EnemyCoroutines.GetCoroutine(coroutineType, pool, e));
	}
        private static Entity CreateBullet(this Pool pool, string resourcePath, Vector3 fromPosition, Vector3 toPosition, float speed)
        {
            Entity entity = pool.CreateEntity ();
            entity.AddPosition (fromPosition, false);

            //
            Vector3 newVelocity         =   (toPosition - fromPosition).Normalize() * speed;
            entity.AddFriction        (RMC.Common.UnityEngineReplacement.Vector3.zero);
            entity.AddResource        (resourcePath);
            entity.AddVelocity        (newVelocity);
            entity.AddTick            (0);
            entity.AddDestroyMe       (4);
            entity.AddRotation        (RMC.Common.UnityEngineReplacement.Vector3.zero, false);

            return entity;
        }
Example #22
0
	public static void CreateExplosion(this Pool pool, float x, float y)
	{
		const float fraction = (2f * Mathf.PI) / 5f;
		
		for(int i = 0; i < 5; ++i)
		{
			pool.CreateEntity()
				.IsExplosion(true)
				.AddPosition(x + Mathf.Sin(i*fraction) * 0.5f, y + Mathf.Cos(i*fraction) * 0.5f)
				.IsRotateView(true)
				.AddSpeed(new Vector2(Random.Range(-0.001f, 0.001f), Random.Range(-0.001f, 0.001f)))
				.AddResource("Explosion");
		}
		
		pool.CreateEntity()
			.IsExplosion(true)
			.AddPosition(x, y)
			.IsRotateView(true)
			.AddSpeed(new Vector2(Random.Range(-0.001f, 0.001f), Random.Range(-0.001f, 0.001f)))
			.AddResource("Explosion");
	}
Example #23
0
	public static Entity CreateBullet(this Pool pool, float x, float y, Vector2 velocity, int damage, int size, bool isFriendly)
	{
		if(size >= 10)
		{
			AudioController.PlayBigShoot();
		}
		else
		{
			AudioController.PlaySmallShoot();
		}
		
		return pool.CreateEntity()
			.IsBullet(true)
			.IsFriendly(isFriendly)
			.IsNotFriendly(!isFriendly)
			.AddPosition(x, y)
			.AddSpeed(velocity)
			.AddScreenLimitedDestroy(new Vector4(-1.0f, 1.0f, 1.0f, -1.0f))
			.AddCollisionDamage(damage)
			.AddResource("Bullets/bullet" + size);
	}
 public static Entity PlayAudio(this Pool pool, AudioComponent source)
 {
     return pool.CreateEntity().AddAudio(source.clips, source.randomizePitch);
 }
Example #25
0
	public static Entity CreateEnemyWave(this Pool pool, string waveType)
	{
		var e = pool.CreateEntity();
		return e.AddCoroutine(EnemySpawnerCoroutines.GetCoroutine(waveType, pool, e));
	}
Example #26
0
	public static Entity CreateShield(this Pool pool, Entity owner)
	{
		var e = pool.CreateEntity()
			.AddShield(owner)
			.AddHealth(10000)
			.AddImmortal(Time.time + 9999f)
			.IsFriendly(owner.isFriendly)
			.IsNotFriendly(owner.isNotFriendly)
			.AddResource("Shield");
		
		return e.AddCoroutine(ShieldHelper.GetCoroutine(e));
	}
Example #27
0
	public static Entity CreateCameraShake(this Pool pool, float duration, float magnitude)
	{
		return pool.CreateEntity()
			.AddCoroutine(CameraShakeSystem.DoCameraShake(Time.time, duration, magnitude).GetEnumerator());
	}
Example #28
0
	public static Entity CreateLifeUiNumber(this Pool pool, float x, float y, char number)
	{
		return pool.CreateEntity()
			.IsLifeNumScreen(true)
			.AddPosition(x, y)
			.AddResource("Numbers/Number" + number);
	}
Example #29
0
	public static Entity CreateMapBackground(this Pool pool, float y, int mapId = -1)
	{
		return pool.CreateEntity()
			.IsMap(true)
			.AddPosition(-5.5f, y)
			.AddSpeed(pool.mapSpeed.value)
			.AddResource("Background0" + (mapId >= 0 ? mapId : (int)Random.Range(1,8)));
	}
Example #30
0
	public static Entity CreatePlayerEnergy(this Pool pool)
	{
		return pool.CreateEntity()
			.AddEnergy(100f, 0f)
			.AddPosition(-3.75f, -4.25f);
	}