Exemple #1
0
            public override PuzzleInfo CreateIt(List <Portal> Portals, int?keyLockId = null, bool isSkippable = false)
            {
                GroundLevels = BasicCircuitCreators.CreateGroundLevels(Grid);


                if (PortalsOnGroundLevels(GetHorizontalPortals(Portals, Grid), Grid))
                {
                    BasicCircuitCreators.CreateCircuitFractured(Grid, Random);
                }
                else
                {
                    BasicCircuitCreators.CreateCircuit(Grid, Random);
                }

                var hEntrances = GetHorizontalPortals(Portals.Where(x => x.IsEntrance()).ToList(), Grid);
                var vEntrances = GetVerticalPortals(Portals.Where(x => x.IsEntrance()).ToList(), Grid);
                var vExits     = GetVerticalPortals(Portals.Where(x => !x.IsEntrance()).ToList(), Grid);
                var hExits     = GetHorizontalPortals(Portals.Where(x => !x.IsEntrance()).ToList(), Grid);

                foreach (var entrance in hEntrances)
                {
                    BasicCircuitCreators.CreateHorizontalEntrancePath(Grid, entrance.point.X, entrance.point.Y);
                }
                //Grid.Commit();
                foreach (var entrance in hExits)
                {
                    BasicCircuitCreators.CreateHorizontalExitPath(Grid, entrance.point.X, entrance.point.Y);
                }
                //Creators.CreateHorizontalExitPath(Grid, Exits.X, Exits.Y);
                foreach (var entrance in vEntrances)
                {
                    BasicCircuitCreators.CreateVerticalEntrancePath(Grid, entrance.point.X, entrance.point.Y);
                }
                foreach (var exit in vExits)
                {
                    BasicCircuitCreators.CreateVerticalExitPath(Grid, exit.point.X, exit.point.Y);
                }
                //Grid.Commit();
                BasicCircuitCreators.CreateToggleExitDoor(Grid, Portals.Where(x => !x.IsEntrance() && !x.IsDestinationSkippable()).ToList());
                //Grid.Commit();
                BasicCircuitCreators.CreateToggleExitDoorButton(Grid, Random);
                //Grid.Commit();
                BasicCircuitCreators.CreateBoxButtonSection(Grid, Random);

                BasicCircuitCreators.CreateRopeSection(Grid, Random);

                BasicCircuitCreators.CreateShooterSection(Grid, Random);

                BasicCircuitCreators.CreateEnemy(Grid, Random);

                BasicCircuitCreators.CreateBorder(Grid, Random);

                BasicCircuitCreators.BlanketNonDynamic(Grid, Random);

                var result = Helpers.ApplyIntentionToGrid(Grid, WcfGrid, TilesConfig, Converter);

                return(new PuzzleInfo()
                {
                    TileMap = Helpers.ToBitmap(WcfGrid, TilesConfig),
                    Grid = Grid,
                    Success = result
                });
            }
Exemple #2
0
            public override PuzzleInfo CreateIt(List <Portal> portals, int?keyLockId = null, bool isSkippable = false)
            {
                int[] GroundLevels;
                if (Random.NextDouble() >= .9d)
                {
                    GroundLevels = BasicCircuitCreators.CreateGroundLevels(Grid);
                }
                else
                {
                    GroundLevels = BasicCircuitCreators.CreateMinimalGroundLevels(Grid);
                }


                if (PortalsOnGroundLevels(GetHorizontalPortals(portals, Grid), Grid))
                {
                    BasicCircuitCreators.CreateCircuitFractured(Grid, Random);
                }
                else
                {
                    BasicCircuitCreators.CreateCircuit(Grid, Random);
                }

                var hEntrances = GetHorizontalPortals(portals.Where(p => p.IsEntrance()).ToList(), Grid);
                var vEntrances = GetVerticalPortals(portals.Where(p => p.IsEntrance()).ToList(), Grid);
                var vExits     = GetVerticalPortals(portals.Where(p => !p.IsEntrance()).ToList(), Grid);
                var hExits     = GetHorizontalPortals(portals.Where(p => !p.IsEntrance()).ToList(), Grid);

                foreach (var entrance in hEntrances)
                {
                    BasicCircuitCreators.CreateHorizontalEntrancePath(Grid, entrance.point.X, entrance.point.Y);
                }
                //Grid.Commit();
                foreach (var entrance in hExits)
                {
                    BasicCircuitCreators.CreateHorizontalExitPath(Grid, entrance.point.X, entrance.point.Y);
                }
                //Creators.CreateHorizontalExitPath(Grid, Exits.X, Exits.Y);
                foreach (var entrance in vEntrances)
                {
                    BasicCircuitCreators.CreateVerticalEntrancePath(Grid, entrance.point.X, entrance.point.Y);
                }
                foreach (var exit in vExits)
                {
                    BasicCircuitCreators.CreateVerticalExitPath(Grid, exit.point.X, exit.point.Y);
                }

                BasicCircuitCreators.CreateToggleExitDoor(Grid, portals.Where(x => !x.IsEntrance() && !x.IsDestinationSkippable()).ToList());

                BasicCircuitCreators.CreateToggleExitDoorButton(Grid, Random);


                if (Random.NextDouble() < .1f)
                {
                    //just first one
                    foreach (var bigExecute in CreatorAbstractorFactory.GetAll(Random))
                    {
                        bigExecute.Execute(Grid, Random, null);
                        break;
                    }
                }

                BasicCircuitCreators.CreateBoxButtonSection(Grid, Random);
                //box Impede door
                var boxImpedePoint = BasicCircuitCreators.CreateBoxPathImpedingExtraDoor(Grid, Random);

                if (boxImpedePoint != null)
                {
                    var buttonResult = BasicCircuitCreators.CreateExtraDoorButton(Grid, Random, boxImpedePoint.Value);
                    if (buttonResult == false)
                    {
                        //undo last door creation if needed
                        Grid.Positions[boxImpedePoint.Value.X, boxImpedePoint.Value.Y].Intentions = Grid.Positions[boxImpedePoint.Value.X, boxImpedePoint.Value.Y].Intentions.Where(x => x.Meaning != Meaning.ToggleDoor).ToList();
                    }
                }
                BasicCircuitCreators.AddConveyorToBoxPath(Grid, Random);
                BasicCircuitCreators.LengthenExistingConveyor(Grid, Random);
                BasicCircuitCreators.LengthenExistingConveyor(Grid, Random);
                //big just first

                /*if (Random.NextDouble() < .1f)
                 * {
                 *  //just first one
                 *  foreach (var bigExecute in CreatorAbstractorFactory.GetAll(Random))
                 *  {
                 *      bigExecute.Execute(Grid, Random, null);
                 *      break;
                 *  }
                 * }
                 *
                 * BasicCircuitCreators.CreateBoxButtonSection(Grid, Random);
                 * //box Impede door
                 * boxImpedePoint = BasicCircuitCreators.CreateBoxPathImpedingExtraDoor(Grid, Random);
                 * if (boxImpedePoint != null)
                 * {
                 *  var buttonResult = BasicCircuitCreators.CreateExtraDoorButton(Grid, Random, boxImpedePoint.Value);
                 *  if (buttonResult == false)
                 *  {
                 *      //undo last door creation if needed
                 *      Grid.Positions[boxImpedePoint.Value.X, boxImpedePoint.Value.Y].Intentions = Grid.Positions[boxImpedePoint.Value.X, boxImpedePoint.Value.Y].Intentions.Where(x => x.Meaning != Meaning.ToggleDoor).ToList();
                 *  }
                 * }
                 * BasicCircuitCreators.AddConveyorToBoxPath(Grid, Random);
                 * BasicCircuitCreators.LengthenExistingConveyor(Grid, Random);
                 * BasicCircuitCreators.LengthenExistingConveyor(Grid, Random);*/

                //big all - just attempt it
                if (Random.NextDouble() < .5f)
                {
                    //just first one
                    foreach (var bigExecute in CreatorAbstractorFactory.GetAll(Random))
                    {
                        bigExecute.Execute(Grid, Random, null);
                    }
                }

                ////big
                ////conveyor jump
                //if (Random.NextDouble() < .666f)
                //{
                //    BasicCircuitCreators.AddConveyorJumpToHiddenPlace(Grid, Random);
                //    if (Random.NextDouble() >= .5d)
                //        BasicCircuitCreators.LengthenExistingConveyor(Grid, Random);
                //}

                ////big
                ////rope cube
                //if (Random.NextDouble() < .666f)
                //    BasicCircuitCreators.CreateRopeCube(Grid, Random);

                ////big
                ////conveyor jump to nothing maybe
                //if (Random.NextDouble() < .666f)
                //{
                //    BasicCircuitCreators.AddConveyorJump(Grid, Random);
                //    if (Random.NextDouble() >= .5d)
                //        BasicCircuitCreators.LengthenExistingConveyor(Grid, Random);
                //}

                ////big
                ////box push to button
                //if (Random.NextDouble() < .666f)
                //    BasicCircuitCreators.CreateBoxButtonSection(Grid, Random);

                //shooters
                if (Random.NextDouble() < .333f)
                {
                    BasicCircuitCreators.CreateShooterSection(Grid, Random);
                }
                if (Random.NextDouble() < .333f)
                {
                    BasicCircuitCreators.CreateShooterSection(Grid, Random);
                }

                //add random conveyor
                if (Random.NextDouble() < .666f)
                {
                    BasicCircuitCreators.AddConveyor(Grid, Random);
                    if (Random.NextDouble() >= .1d)
                    {
                        BasicCircuitCreators.LengthenExistingConveyor(Grid, Random);
                    }
                }

                //add conveyor to box path

                /*if(Random.NextDouble() < .777f)
                 * {*/


                //}

                ////add conveyor toggle button
                if (Random.NextDouble() < .3f)
                {
                    BasicCircuitCreators.AddConveyorToggleButton(Grid, Random);
                }
                ////add conveyor toggle button
                if (Random.NextDouble() < .3f)
                {
                    BasicCircuitCreators.AddConveyorToggleButton(Grid, Random);
                }

                //add shooter toggle button
                if (Random.NextDouble() < .3f)
                {
                    BasicCircuitCreators.AddShooterToggleButton(Grid, Random);
                }
                //add shooter toggle button
                if (Random.NextDouble() < .3f)
                {
                    BasicCircuitCreators.AddShooterToggleButton(Grid, Random);
                }

                //enemy
                if (Random.NextDouble() < .75f)
                {
                    BasicCircuitCreators.CreateEnemy(Grid, Random);
                }

                ////impede box door
                //if (Random.NextDouble() < 1.0f)
                //{
                //    //box Impede door
                //    var boxImpedePoint = BasicCircuitCreators.CreateBoxPathImpedingExtraDoor(Grid, Random);
                //    if (boxImpedePoint != null)
                //    {
                //        var buttonResult = BasicCircuitCreators.CreateExtraDoorButton(Grid, Random, boxImpedePoint.Value);
                //        if (buttonResult == false)
                //        {
                //            //undo last door creation if needed
                //            Grid.Positions[boxImpedePoint.Value.X, boxImpedePoint.Value.Y].Intentions = Grid.Positions[boxImpedePoint.Value.X, boxImpedePoint.Value.Y].Intentions.Where(x => x.Meaning != Meaning.ToggleDoor).ToList();
                //        }
                //    }
                //}

                ////random extra door
                //if (Random.NextDouble() < .666f)
                //{
                //    //create extra door
                //    var doorloopsuccess = true;
                //    var maxAmount = 1;
                //    while (doorloopsuccess && maxAmount > 0)
                //    {
                //        var resultingPoint = BasicCircuitCreators.CreateExtraDoor(Grid, Random);
                //        if (resultingPoint != null)
                //        {
                //            var buttonResult = BasicCircuitCreators.CreateExtraDoorButton(Grid, Random, resultingPoint.Value);
                //            if (buttonResult == false)
                //            {
                //                //undo last door creation if needed
                //                Grid.Positions[resultingPoint.Value.X, resultingPoint.Value.Y].Intentions = Grid.Positions[resultingPoint.Value.X, resultingPoint.Value.Y].Intentions.Where(x => x.Meaning != Meaning.ToggleDoor).ToList();
                //                doorloopsuccess = false;
                //            }
                //        }
                //        else
                //        {
                //            doorloopsuccess = false;
                //        }
                //        maxAmount -= 1;
                //    }
                //}

                BasicCircuitCreators.CompleteConveyors(Grid, Random);

                if (keyLockId != null)
                {
                    BasicCircuitCreators.PlaceKey(Grid, Random, keyLockId.Value);
                }

                if (isSkippable)
                {
                    BasicCircuitCreators.PlaceLoot(Grid, Random);
                }

                BasicCircuitCreators.CreateBorder(Grid, Random);
                BasicCircuitCreators.AddSolidToSidesOfCircuit(Grid, Random);
                BasicCircuitCreators.BlanketNonDynamic(Grid, Random);
                BasicCircuitCreators.CleanUpBoxPathShit(Grid, Random);

                var result = Helpers.ApplyIntentionToGrid(Grid, WcfGrid, TilesConfig, Converter);

                return(new PuzzleInfo()
                {
                    TileMap = Helpers.ToBitmap(WcfGrid, TilesConfig),
                    Grid = Grid,
                    Success = result
                });
            }