Exemple #1
0
 private void BuildPipeViewModels(Pipeline pipeline)
 {
     foreach (var source in pipeline.Targets)
     {
         foreach (var target in source.Targets)
         {
             Pipes.Add(new PipeViewModel(source, target));
         }
     }
 }
Exemple #2
0
        void ManagePipes()
        {
            if (!Pipes.Any() || Pipes.Last().DistanceFromleft <= 250)
            {
                Pipes.Add(new PipeModel());
            }

            if (Pipes.First().IsOffScreen())
            {
                Pipes.Remove(Pipes.First());
            }
        }
Exemple #3
0
        private void ManagePipes()
        {
            if (!Pipes.Any() || Pipes.Last().DistanceFromLeft < GameWidth / 2)
            {
                Pipes.Add(new PipeModel(GameWidth));
            }

            if (Pipes.First().IsOffScreen())
            {
                Pipes.Remove(Pipes.First());
            }
        }
        private void ManagePipes()
        {
            if (Pipes.Count == 0 || Pipes.Last().DistanceFromLeft <= 250)
            {
                Pipes.Add(new PipeModel());
            }

            if (Pipes[0].IsOffScreen())
            {
                Pipes.Remove(Pipes[0]);
            }
        }
Exemple #5
0
        internal void AddPipe(BaseProcessor source, BaseProcessor target)
        {
            var sourceHasTarget = source.Targets.Any(t => Equals(t, target));
            var targetHasSource = target.Sources.Any(s => Equals(s, source));

            // Do not pipe only once
            if (sourceHasTarget && targetHasSource)
            {
                return;
            }

            source.Targets.Add(target);
            target.Sources.Add(source);

            Pipes.Add(new PipeViewModel(source, target));
        }
        public void ManagePipes()
        {
            //if the list of pipes don't have any objects in it...
            //OR if the last pipe in the list is halfway across the screen...
            if (!Pipes.Any() || Pipes.Last().DistanceFromLeft <= 250)
            {
                //add another pipe to the list
                Pipes.Add(new PipeModel());
            }

            //if it is true that the first pipe in the list if off the screen...
            if (Pipes.First().IsOffScreen())
            {
                //remove the pipe from the list of pipes
                Pipes.Remove(Pipes.First());
            }
        }
Exemple #7
0
        private void RegisterWorkerToWC <T>(T w, WorkerContainer wc) where T : IWorker
        {
            if ((w.WorkerType & IWorkerType.Reusable) != 0)
            {
                wc.Copy = Core.ToJSON(w);
                // RWorkers.Add(wc);
                UI.Log($"Saved reusable {wc.Name}");
            }

            if ((w.WorkerType & IWorkerType.Pipe) != 0)
            {
                Pipes.Add(wc);
                UI.Log($"Added Pipe {wc.Name}");
            }
            else if ((w.WorkerType & IWorkerType.Service) != 0)
            {
                Services.Add(wc);
                UI.Log($"Added Service {wc.Name}");
            }
            else
            {
                UI.LogError(new Exception(), $"{wc.Name} does not fall into either Pipe or Service");
            }
        }
        private void BuildLevel(List <string[]> levelData)
        {
            // iterate through lines
            for (int i = 0; i < levelData.Count(); i++)
            {
                switch (levelData[i][0])
                {
                case "00":
                    // mario
                    Mario.Instance.PlayableObjectState = new SmallRightIdleMario(Mario.Instance);
                    Mario.Instance.Position            = new Vector2(StringToInt(i, 1) * levelCellSize, StringToInt(i, 2) * levelCellSize);
                    break;

                case "01":
                    // floor tiles
                    StaticObjects.Add(new FloorTile(new Vector2(StringToInt(i, 1) * levelCellSize, StringToInt(i, 2) * levelCellSize), new Vector2(StringToInt(i, 3), StringToInt(i, 4)), levelData[i][5]));
                    break;

                case "02":
                    // blocks
                    Blocks.Add(new Block(new Vector2(StringToInt(i, 1) * levelCellSize, StringToInt(i, 2) * levelCellSize), levelData[i][3], levelData[i][4]));
                    break;

                case "03":
                    // floating coins
                    Coins.Add(new Item(new Vector2((StringToInt(i, 1) * levelCellSize) + (levelCellSize / 4), StringToInt(i, 2) * levelCellSize), "FloatingCoin"));
                    break;

                case "04":
                    // pipes
                    Pipes.Add(new Pipe(new Vector2(StringToInt(i, 1) * levelCellSize, StringToInt(i, 2) * levelCellSize), StringToInt(i, 3), Convert.ToBoolean(levelData[i][4]), levelData[i][5]));
                    break;

                case "05":
                    // enemies
                    Enemies.Add(new Enemy(new Vector2(StringToInt(i, 1) * levelCellSize, StringToInt(i, 2) * levelCellSize - 10), levelData[i][3]));
                    break;

                case "06":
                    // hills
                    BackgroundItems.Add(new Hill(new Vector2(StringToInt(i, 1) * levelCellSize, StringToInt(i, 2) * levelCellSize), StringToInt(i, 3)));
                    break;

                case "07":
                    // bushes
                    BackgroundItems.Add(new Bush(new Vector2(StringToInt(i, 1) * levelCellSize, StringToInt(i, 2) * levelCellSize), StringToInt(i, 3)));
                    break;

                case "08":
                    // clouds
                    BackgroundItems.Add(new Cloud(new Vector2(StringToInt(i, 1) * levelCellSize, StringToInt(i, 2) * levelCellSize), StringToInt(i, 3)));
                    break;

                case "09":
                    // castle
                    Castle = new Castle(new Vector2(StringToInt(i, 1) * levelCellSize, StringToInt(i, 2) * levelCellSize));
                    break;

                case "10":
                    // flag pole
                    Flagpoles.Add(new Flagpole(new Vector2(StringToInt(i, 1) * levelCellSize, StringToInt(i, 2) * levelCellSize), levelCellSize));
                    break;

                case "11":
                    // check point
                    Checkpoints.Add(new CheckPoint(new Vector2(StringToInt(i, 1) * levelCellSize, StringToInt(i, 2) * levelCellSize)));
                    break;

                case "12":
                    // coin room
                    CoinRoomPosition = new Vector2(StringToInt(i, 1) * levelCellSize + (levelCellSize / 8), StringToInt(i, 2) * levelCellSize);
                    break;
                }
            }

            DynamicObjects.Add(Mario.Instance);

            foreach (Block block in Blocks)
            {
                DynamicObjects.Add(block);
                DynamicObjects.Add(block.Item); // Add items in each block too.
            }

            foreach (Item coin in Coins)
            {
                DynamicObjects.Add(coin);
            }

            foreach (Enemy enemy in Enemies)
            {
                // Added such that the Koopa spawns in a correct position before any updates are made, otherwise he spawns in the floor to start.
                if (enemy.EnemyState.ToString() == "SuperMario.EnemyStates.LeftWalkingKoopa" || enemy.EnemyState.ToString() == "SuperMario.EnemyStates.RightWalkingKoopa")
                {
                    enemy.Position = new Vector2(enemy.Position.X, enemy.Position.Y - GameValues.KoopaPositionOffset);
                }
                DynamicObjects.Add(enemy);
            }

            foreach (Pipe pipe in Pipes)
            {
                StaticObjects.Add(pipe);
            }

            foreach (Flagpole flagpole in Flagpoles)
            {
                StaticObjects.Add(flagpole);
            }

            if (Flagpoles.Count > 0)
            {
                Flag.Position = new Vector2(Flagpoles[0].CollisionRectangle.X - GameValues.FlagPositionOffsetVector.X, Flagpoles[0].CollisionRectangle.Y + GameValues.FlagPositionOffsetVector.Y);
            }
        }
Exemple #9
0
 public void AddPipe(IPipe pipe)
 {
     Pipes.Add(pipe);
 }
Exemple #10
0
        private static void LoadMapProcessPipesTiles(int x, int y, Tile tile)
        {
            // Is this a pipes tile?
            if (tile.TileSet == Assets.GetTileSet("pipes"))
            {
                // Offsets for pipe openings
                var offset1 = new Vector();
                var offset2 = new Vector();

                var bounds = new Rectangle(Vector.Zero, Map.TileSize);

                // == Straight Pipes

                var VP = tile.Id == 88 || tile.Id == 100;
                var VG = tile.Id == 106; // vertical gold

                var HP = tile.Id == 89 || tile.Id == 101;
                var HG = tile.Id == 107; // horizontal gold

                // Vertical pipe
                if (VP || VG)
                {
                    offset1.Set(0, -1);
                    offset2.Set(0, +2);

                    // vertical pipes are 1x2
                    bounds.Size = (Size)((Vector)bounds.Size * (1, 2));
                }

                // Horizontal pipe
                if (HP || HG)
                {
                    offset1.Set(-1, 0);
                    offset2.Set(+2, 0);

                    // vertical pipes are 1x2
                    bounds.Size = (Size)((Vector)bounds.Size * (2, 1));
                }

                // Is this a gold (input/output) pipe?
                var isGoldPipe = HG || VG;
                var isGreyPipe = !isGoldPipe && (tile.Id > 99); // THIS IS BAD BUT FUNCTIONAL

                // == Corner Pipes

                var TR = tile.Id == 90 || tile.Id == 102;
                var TL = tile.Id == 91 || tile.Id == 103;
                var BL = tile.Id == 92 || tile.Id == 104;
                var BR = tile.Id == 93 || tile.Id == 105;

                if (TR)
                {
                    // Corner elbow is top-right
                    offset1.Set(-1, 0);
                    offset2.Set(+1, 2);
                }

                if (TL)
                {
                    // Corner elbow is top-left
                    offset1.Set(0, 2);
                    offset2.Set(2, 0);
                }

                if (BL)
                {
                    // Corner elbow is bottom-left
                    offset1.Set(0, -1);
                    offset2.Set(2, +1);
                }

                if (BR)
                {
                    // Corner elbow is bottom-right
                    offset1.Set(-1, +1);
                    offset2.Set(+1, -1);
                }

                // Corner pipes are 2x2
                if (TR || TL || BL || BR)
                {
                    bounds.Size *= 2;
                }

                // Compute Block Position
                var position = new Vector(x, y) * (Vector)Map.TileSize;
                position.Y += Map.TileSize.Height - tile.Image.Height; // weird tiled offset thing

                // Compute connection points in world space
                var points = new[] { offset1, offset2 }.Select(s => (35, 35) + (s * 70));

                // Generate pipe
                var pipe = AddEntity(new Pipe(tile.Image, bounds, points, isGreyPipe, isGoldPipe));
                pipe.Transform.Position = position;
                pipe.ComputeWorldSpace();

                Spatial.Add(pipe, pipe.Bounds);
                Pipes.Add(pipe);
            }
        }
Exemple #11
0
 private void GeneratePipe()
 {
     Pipes.Add(new PipeModel());
 }