Example #1
0
 public MapSystem(Contexts contexts) : base(contexts.game)
 {
     rnd                     = new System.Random();
     _gameContext            = contexts.game;
     _removableEntitiesGroup = _gameContext.GetGroup(GameMatcher.AllOf(GameMatcher.Position).NoneOf(GameMatcher.Player));
     _playerGroup            = _gameContext.GetGroup(GameMatcher.Player);
     _groundTiles            = _gameContext.GetGroup(GameMatcher.AllOf(GameMatcher.Position, GameMatcher.Tile).NoneOf(GameMatcher.Blocking));
     _blockingEntities       = _gameContext.GetGroup(GameMatcher.AllOf(GameMatcher.Position, GameMatcher.Blocking).NoneOf(GameMatcher.Tile));
 }
Example #2
0
 protected override void DoInit()
 {
     _destroyedGroup = contexts.game.GetGroup(GameMatcher.AllOf(
                                                  GameMatcher.Destroyed,
                                                  GameMatcher.EntityId,
                                                  GameMatcher.ItemType));
     _allEnmey = contexts.game.GetGroup(GameMatcher.AllOf(
                                            GameMatcher.EntityId,
                                            GameMatcher.TagEnemy));
 }
Example #3
0
 public TraceSystem(Contexts contexts)
 {
     //移动
     __traceGroup = Contexts.sharedInstance.game.GetGroup(
         GameMatcher.AllOf(
             GameMatcher.Trace,
             GameMatcher.Movement,
             GameMatcher.Transform
             ));
 }
Example #4
0
 public ViewEditorTransformSystem(Contexts contexts)
 {
     //移动
     __editorTransformGroup = Contexts.sharedInstance.game.GetGroup(
         GameMatcher.AllOf(
             GameMatcher.View,
             GameMatcher.Transform,
             GameMatcher.EditorEntity
             ));
 }
        public static GameEntity[] GetInfluencialPeople(GameContext gameContext)
        {
            var investors = gameContext
                            .GetEntities(GameMatcher.AllOf(GameMatcher.Shareholder, GameMatcher.Human))
                            .Where(e => GetInvestorCapitalCost(gameContext, e) > 0)
                            .OrderByDescending(e => GetInvestorCapitalCost(gameContext, e))
                            .ToArray();

            return(investors);
        }
Example #6
0
 public RenderNonTilesGridPositionToPosition(GameContext game)
 {
     this.game = game;
     entities  = game.GetGroup(GameMatcher
                               .AllOf(
                                   GameMatcher.GridPosition,
                                   GameMatcher.Position)
                               .NoneOf(
                                   GameMatcher.Tile));
 }
Example #7
0
        public BuildCommands(Contexts contexts) : base(contexts.input)
        {
            _game    = contexts.game;
            _grid    = UnityEngine.GameObject.FindObjectOfType <HexGridBehaviour>();
            _presets = new Presets(_game, _grid);

            _UICommands = contexts.input.GetGroup(InputMatcher.AnyOf(InputMatcher.UIBuildBarracks, InputMatcher.UIBuildTower));
            _selectedBarracksBuilders = _game.GetGroup(GameMatcher.AllOf(GameMatcher.Selected, GameMatcher.CanBuildBarracks));
            _selectedTowerBuilders    = _game.GetGroup(GameMatcher.AllOf(GameMatcher.Selected, GameMatcher.CanBuildBarracks));
        }
Example #8
0
    public ItemCleanupSystem(Contexts contexts)
    {
        _contexts = contexts;

        // Every item that is neither in a storage on placed in the world
        _items = contexts.game.GetGroup(
            GameMatcher
            .AllOf(GameMatcher.Item)
            .NoneOf(GameMatcher.StorageSource, GameMatcher.Position));
    }
    public ShootWeaponOnPressFireSystem(Contexts contexts) : base(contexts)
    {
        game = contexts.game;

        weaponMatcher = GameMatcher.AllOf(
            GameMatcher.Transform,
            GameMatcher.ProjectileSpeed,
            GameMatcher.Damage
            );
    }
Example #10
0
 public FollowTargetSystem(Contexts contexts)
 {
     _contexts = contexts;
     _group    = contexts.game.GetGroup(GameMatcher.AllOf(
                                            GameMatcher.TargetComp,
                                            GameMatcher.VelComp,
                                            GameMatcher.RotComp,
                                            GameMatcher.StatsComp
                                            ));
 }
Example #11
0
 public FollowSystem(Contexts contexts)
 {
     //移动
     __followGroup = Contexts.sharedInstance.game.GetGroup(
         GameMatcher.AllOf(
             GameMatcher.Follow,
             GameMatcher.Movement,
             GameMatcher.Transform
             ));
 }
Example #12
0
 public override void DoStart()
 {
     base.DoStart();
     _config         = Resources.Load <GameConfig>(GameConfig.ConfigPath);
     _assetBindGroup = _gameContext.GetGroup(GameMatcher.AllOf(
                                                 GameMatcher.LocalId,
                                                 GameMatcher.Asset,
                                                 GameMatcher.Pos,
                                                 GameMatcher.Dir));
 }
Example #13
0
 public CreateMapTileFromPrefab(GameContext game, GameObject mapTilePrefab)
 {
     this.game          = game;
     this.mapTilePrefab = mapTilePrefab;
     tiles = game.GetGroup(GameMatcher
                           .AllOf(
                               GameMatcher.Tile)
                           .NoneOf(
                               GameMatcher.GameObject));
 }
 public FadeObstructingObjectsSystem(Contexts contexts)
 {
     _contexts   = contexts;
     _seethrough = contexts.game.GetGroup(GameMatcher.AllOf(
                                              GameMatcher.Seethrough,
                                              GameMatcher.View
                                              ));
     _faded       = contexts.game.GetGroup(GameMatcher.Fade);
     _obstructing = new HashSet <GameEntity>();
 }
 public StartNewGameSystem(Contexts contexts)
 {
     gameContext        = contexts.game;
     inputContext       = contexts.input;
     newGameButtonGroup = gameContext.GetGroup(GameMatcher.AllOf(GameMatcher.NewGameButton, GameMatcher.View));
     buttonGroup        = gameContext.GetGroup(GameMatcher.NewGameButton);
     scoreGroup         = gameContext.GetGroup(GameMatcher.AnyOf(GameMatcher.Player1Score, GameMatcher.Player2Score));
     uiGroup            = gameContext.GetGroup(GameMatcher.UiElement);
     disableInputGroup  = inputContext.GetGroup(InputMatcher.DisableInput);
 }
Example #16
0
 public SystemExecuteMovePlayer(Contexts contexts, IServiceContainer serviceContainer) : base(contexts,
                                                                                              serviceContainer)
 {
     _moveRequest = contexts.game.GetGroup(GameMatcher.AllOf(
                                               GameMatcher.LocalId,
                                               GameMatcher.MoveRequest,
                                               GameMatcher.Move,
                                               GameMatcher.ActorId
                                               ));
 }
 public void InitializePieceEntityIndices()
 {
     game.AddEntityIndex(new PrimaryEntityIndex <GameEntity, Vector2Int>(
                             Piece,
                             game.GetGroup(GameMatcher
                                           .AllOf(GameMatcher.Piece, GameMatcher.Position)
                                           .NoneOf(GameMatcher.Destroyed)
                                           ),
                             (e, c) => (c as PositionComponent)?.value ?? e.position.value));
 }
 private void ShutDown()
 {
     foreach (var item in _contexts.GetEntities(GameMatcher.AllOf(GameMatcher.BalloonPosition)))
     {
         if (!item.isBalloonPopped)
         {
             item.AddComponent(GameComponentsLookup.BalloonPopped, new BalloonPoppedComponent());
         }
     }
 }
    private int CalculateCellItemLeftToGenerate(CellItemTypeInBoard type)
    {
        var cellItemCountInBoard = _contexts.game.GetEntities(GameMatcher.AllOf(GameMatcher.CellItem))
                                   .Count(e => Equals(e.cellItemType.Value, type.CellItemType));
        var cellItemReservations = _contexts.game.GetEntities(GameMatcher.CellItemReservation)
                                   .Count(e => Equals(e.cellItemReservation.CellItemType, type));
        var cellItemCountLeftInGoal = CalculateItemCountLeftInGoal(type.GoalType);

        return(cellItemCountLeftInGoal - (cellItemCountInBoard + cellItemReservations));
    }
    public AuraDamageSystem(Contexts contexts)
    {
        gameContext = contexts.game;
        var matcher = GameMatcher.AllOf(GameMatcher.Aura, GameMatcher.Position, GameMatcher.CircleCollider);

        auraGroup = gameContext.GetGroup(matcher);
        var damagableMatcher = GameMatcher.AllOf(GameMatcher.Position, GameMatcher.Collidable, GameMatcher.HealthPoints);

        damagableGroup = gameContext.GetGroup(damagableMatcher);
    }
    public void Initialize()
    {
        _selectedNavAgentsGroup = _contexts.game.GetGroup(GameMatcher.AllOf(GameMatcher.Selected, GameMatcher.NavAgent));

        GameObject targetGo = new GameObject("RightClickNavigationTarget");

        GameEntity targetEntity = _contexts.game.CreateEntity();

        targetEntity.isRightClickNavigationTarget = true;
        targetEntity.AddView(targetGo);
    }
Example #22
0
    public CollisionDetectionSystem(Contexts contexts, PositionChunks positionChunks)
    {
        chunks      = positionChunks;
        gameContext = contexts.game;
        var matcher = GameMatcher.AllOf(GameMatcher.Collidable, GameMatcher.CircleCollider, GameMatcher.Position);

        collidableGroup = gameContext.GetGroup(matcher);
        buffer          = new List <GameEntity>(predictedCapacity);
        idsToIndexes    = new Dictionary <ushort, int>(predictedCapacity);
        collidables     = new CollisionInfo[predictedCapacity];
    }
Example #23
0
 public SetPathEndTiles(GameContext game)
 {
     agents = game.GetGroup(GameMatcher
                            .AllOf(GameMatcher.PathFinderAgent, GameMatcher.PathFinderPath));
     tiles = game.GetGroup(GameMatcher
                           .AllOf(
                               GameMatcher.Tile,
                               GameMatcher.GridPosition)
                           .NoneOf(
                               GameMatcher.PathEndTile));
 }
Example #24
0
 public AttackCurrentEnemySystem(Contexts contexts)
 {
     gameContext     = contexts.game;
     charactersGroup = gameContext.GetGroup(GameMatcher
                                            .AllOf(
                                                GameMatcher.CurrentEnemy,
                                                GameMatcher.Attack,
                                                GameMatcher.Position
                                                )
                                            );
 }
Example #25
0
        public CreatePlayerSystem(Contexts contexts)
        {
            this.contexts = contexts;

            var player = contexts.game.GetGroup(GameMatcher.AllOf(GameMatcher.Player));

            player.OnEntityAdded += InitializePlayer;
            var instantiatiedPlayer = contexts.game.GetGroup(GameMatcher.AllOf(GameMatcher.Player, GameMatcher.GameObject));

            instantiatiedPlayer.OnEntityAdded += OnPlayerInstantiated;
        }
 public EndGameSystem(Contexts contexts) :
     base(contexts.game)
 {
     _contexts         = contexts;
     _playerCharacters = contexts.game.GetGroup(GameMatcher.AllOf(
                                                    GameMatcher.PlayerCharacter,
                                                    GameMatcher.Health));
     _enemyCharacters = contexts.game.GetGroup(GameMatcher.AllOf(
                                                   GameMatcher.EnemyCharacter,
                                                   GameMatcher.Health));
 }
Example #27
0
 public void Initialize()
 {
     _game.isAnimating = false;
     _game.SetAnimationQueue(new Queue <GameEntity>());
     _animations = _game.animationQueue.value;
     _immediate  = _game.GetGroup(GameMatcher.AllOf(
                                      GameMatcher.Animation,
                                      GameMatcher.Immediate
                                      ));
     _all = _game.GetGroup(GameMatcher.Animation);
 }
Example #28
0
 public CreateNewCreatureSystem(IGameContext context, MonsterFactory factory, RandomPositionGenerator randomPositionGenerator, Grid grid)
 {
     _factory     = factory;
     _grid        = grid;
     _attackGroup = context.GetGroup(GameMatcher.AllOf(
                                         GameMatcher.Creator,
                                         GameMatcher.Calldown,
                                         GameMatcher.InitialCalldown,
                                         GameMatcher.Target));
     _randomPositionGenerator = randomPositionGenerator;
 }
 public ItemPickupTooltipSystem(Contexts contexts)
 {
     _contexts = contexts;
     _pickable = contexts.game.GetGroup(GameMatcher.AllOf(
             GameMatcher.Item,
             GameMatcher.Position)
         .NoneOf(GameMatcher.StorageSource));
     _players = contexts.game.GetGroup(
         GameMatcher.AllOf(GameMatcher.Actor, GameMatcher.Player, GameMatcher.Position));
     _tooltip = contexts.ui.CreateEntity();
 }
Example #30
0
 private GameEntity GetEntityAtPos(int x, int y)
 {
     foreach (GameEntity entity in _context.GetEntities(GameMatcher.AllOf(GameMatcher.Position, GameMatcher.FieldElement)))
     {
         if (entity.position.x == x && entity.position.y == y)
         {
             return(entity);
         }
     }
     return(null);
 }