Example #1
0
 public virtual void Initialize(Game1 gameReference, Player playerReference, Sadako sadakoReference, InventoryHandler inventoryHandler, LocationHandler locationHandler, EventHandler eventHandler, RoomDatabase roomDatabase, TileDatabase tileDatabase)
 {
     this.gameReference = gameReference;
     this.playerReference = playerReference;
     this.sadakoReference = sadakoReference;
     this.inventoryHandler = inventoryHandler;
     this.locationHandler = locationHandler;
     this.eventHandler = eventHandler;
     this.tileDatabase = tileDatabase;
     this.roomDatabase = roomDatabase;
 }
	public void Init(){
		//StartCoroutine_Auto (GetLocation ());

		if (Instance == null) {
			Instance = this;		
		}

		m_location = new Vector2 ();
		m_prevLocation = new Vector2 ();
		Input.gyro.enabled = true;
		//Input.gyro.updateInterval = 0.01F;
	}
Example #3
0
        public Location LoadMasterRoom()
        {
            Location returnData;

            returnData      = new Location();
            returnData.Name = "Master Room";
            bool defeatedScummyMurderer = Convert.ToBoolean(LocationHandler.GetLocationStateValue(Ankou.LOCATION_STATE_KEY, AnkouMurderShack.DEFEATED_SCUMMY_MURDERER));
            bool openedChest            = Convert.ToBoolean(LocationHandler.GetLocationStateValue(Ankou.LOCATION_STATE_KEY, AnkouMurderShack.OPENED_CHEST));

            if (!defeatedScummyMurderer)
            {
                returnData.Description = "A large room with a torn up bed in the corner. The Scummy Murderer is sitting on the bed, staring at the door.";

                //Actions
                List <LocationAction> locationActions = new List <LocationAction>();

                List <Mob> scummyMurderer = new List <Mob>();
                scummyMurderer.Add(new ScummyMurderer());
                CombatAction combatAction = new CombatAction("Scummy Murderer", scummyMurderer);
                combatAction.PostCombat += ScummyMurderer;

                locationActions.Add(combatAction);

                returnData.Actions = locationActions;
            }
            if (defeatedScummyMurderer)
            {
                if (!openedChest)
                {
                    returnData.Description = "A large room with a torn up bed in the corner. There is a chest at the front of the bed waiting to be opened. The Scummy Murderer's body lays mangled and strewn across his bed.";
                    List <LocationAction> locationActions = new List <LocationAction>();
                    TreasureChestAction   itemAction      = new TreasureChestAction(3);
                    locationActions.Add(itemAction);
                    itemAction.PostItem += Chest;
                    returnData.Actions   = locationActions;
                }
                else
                {
                    returnData.Description = "A large room with a torn up bed in the corner. There is an open chest at the front of the bed. The Scummy Murderer's body lays mangled and strewn across his bed.";
                }
            }

            // Adjacent Locations
            Dictionary <string, LocationDefinition> adjacentLocationDefinitions = new Dictionary <string, LocationDefinition>();

            // Town Center
            LocationDefinition locationDefinition = AnkouMurderShack.GetTownInstance().GetDinningRoomDefinition();

            adjacentLocationDefinitions.Add(locationDefinition.LocationKey, locationDefinition);

            if (defeatedScummyMurderer)
            {
                locationDefinition = Ankou.GetTownInstance().GetTownCenterDefinition();
                adjacentLocationDefinitions.Add(locationDefinition.LocationKey, locationDefinition);
            }


            returnData.AdjacentLocationDefinitions = adjacentLocationDefinitions;

            return(returnData);
        }
Example #4
0
        public Location LoadLargeClearing()
        {
            Location returnData;

            returnData      = new Location();
            returnData.Name = "Necromancer Living Area";
            bool defeatedMobs = Convert.ToBoolean(LocationHandler.GetLocationStateValue(BeachTower.LOCATION_STATE_KEY, BeachTowerHiddenCamp.LARGE_CLEARING_MOBS));

            if (!defeatedMobs)
            {
                returnData.Description = "A large clearing in the camp. On the otherside you can see a large tent that clearly belongs to whoever is in charge of the necromancers in this camp. Unfortunately, the clearing is full of a mob of angry skeletons intent on blood.";

                List <LocationAction> locationActions = new List <LocationAction>();
                List <Mob>            mobs            = new List <Mob>();
                mobs.Add(new Skeleton());
                mobs.Add(new Skeleton());
                mobs.Add(new Skeleton());
                mobs.Add(new Skeleton());
                mobs.Add(new Skeleton());
                mobs.Add(new Skeleton());
                mobs.Add(new Skeleton());
                mobs.Add(new Skeleton());
                mobs.Add(new Skeleton());
                mobs.Add(new Skeleton());
                mobs.Add(new Skeleton());
                mobs.Add(new Skeleton());
                mobs.Add(new Skeleton());
                mobs.Add(new Skeleton());
                mobs.Add(new Skeleton());
                mobs.Add(new Skeleton());
                mobs.Add(new Skeleton());
                mobs.Add(new Skeleton());
                mobs.Add(new Skeleton());
                mobs.Add(new Skeleton());
                CombatAction combatAction = new CombatAction("Skeletons", mobs);
                combatAction.PostCombat += LargeAreaMobs;
                locationActions.Add(combatAction);
                returnData.Actions = locationActions;
            }
            else
            {
                returnData.Description = "A large clearing in the camp. On the otherside you can see a large tent that clearly belongs to whoever is in charge of the necromancers in this camp. Smoke rises from the bones of skeletons in the clearing as their spirits are freed from battle.";
            }

            //Adjacent Locations
            Dictionary <string, LocationDefinition> adjacentLocationDefintions = new Dictionary <string, LocationDefinition>();

            //Town Center
            LocationDefinition locationDefinition = BeachTowerHiddenCamp.GetTownInstance().GetNecroLivingAreaDefinition();

            adjacentLocationDefintions.Add(locationDefinition.LocationKey, locationDefinition);

            if (defeatedMobs)
            {
                locationDefinition = BeachTowerHiddenCamp.GetTownInstance().GetNecroIntelligenceDefinition();
                adjacentLocationDefintions.Add(locationDefinition.LocationKey, locationDefinition);
            }

            returnData.AdjacentLocationDefinitions = adjacentLocationDefintions;

            return(returnData);
        }
        public Location LoadRoomFour()
        {
            Location returnData;
            bool     defeatedNecromancerLeader = Convert.ToBoolean(LocationHandler.GetLocationStateValue(Watertown.LOCATION_STATE_KEY, WatertownForestCabin.DEFEATED_NECROMANCER_LEADER));
            bool     openedChest = Convert.ToBoolean(LocationHandler.GetLocationStateValue(Watertown.LOCATION_STATE_KEY, WatertownForestCabin.OPENED_BOSS_CHEST_ROOM_SIX));
            bool     takeLetter  = Convert.ToBoolean(LocationHandler.GetLocationStateValue(Watertown.LOCATION_STATE_KEY, WatertownForestCabin.TOOK_LETTER));

            returnData      = new Location();
            returnData.Name = "Bedroom";

            //Actions

            if (defeatedNecromancerLeader == false)
            {
                returnData.Description = "A small bedroom. The necromancer leader sits in the middle of the room with his legs crossed, dark energy swirling around him.";
                // Location Actions
                List <LocationAction> locationActions = new List <LocationAction>();

                List <Mob> necro = new List <Mob>();
                necro.Add(new NecromancerLeader());
                CombatAction combatAction = new CombatAction("Necromancer Leader", necro);
                combatAction.PostCombat += NecromancerLeaderBattle;

                locationActions.Add(combatAction);

                returnData.Actions = locationActions;
            }
            if (defeatedNecromancerLeader)
            {
                if (openedChest == false)
                {
                    if (!takeLetter)
                    {
                        returnData.Description = "A small bedroom. The necromancer leader lays dead and broken on the ground. His unopened chest is against the far wall. A letter fell out of his pocket.";
                    }
                    else
                    {
                        returnData.Description = "A small bedroom. The necromancer leader lays dead and broken on the ground. His unopened chest is against the far wall.";
                    }
                    List <LocationAction> locationActions = new List <LocationAction>();
                    TreasureChestAction   itemAction      = new TreasureChestAction(3);
                    locationActions.Add(itemAction);
                    itemAction.PostItem += NecroChest;
                    returnData.Actions   = locationActions;
                }
                if (openedChest && takeLetter)
                {
                    returnData.Description = "A small bedroom. The necromancer leader lays dead and broken on the ground. His opened chest is against the far wall.";
                }

                if (!takeLetter && openedChest)
                {
                    returnData.Description = "A small bedroom. The necromancer leader lays dead and broken on the ground. His opened chest is against the far wall. A letter fell out of his pocket.";
                    List <LocationAction> locationActions = new List <LocationAction>();
                    TakeItemAction        letterAction    = new TakeItemAction("Letter");
                    letterAction.PostItem += NecroLetter;
                    locationActions.Add(letterAction);
                    returnData.Actions = locationActions;
                }
            }

            // Adjacent Locations
            Dictionary <string, LocationDefinition> adjacentLocationDefinitions = new Dictionary <string, LocationDefinition>();

            // Town Center
            LocationDefinition locationDefinition = WatertownForestCabin.GetTownInstance().GetRoomThreeDefinition();

            adjacentLocationDefinitions.Add(locationDefinition.LocationKey, locationDefinition);

            if (takeLetter)
            {
                locationDefinition = Watertown.GetTownInstance().GetTownCenterDefinition();
                adjacentLocationDefinitions.Add(locationDefinition.LocationKey, locationDefinition);
            }

            returnData.AdjacentLocationDefinitions = adjacentLocationDefinitions;

            return(returnData);
        }
Example #6
0
        public override void Fire()
        {
            Task.Run(async() =>
            {
                DateTime sunriseMonitor = ConfigBuilder.Config.Sunrise;
                DateTime sunsetMonitor  = ConfigBuilder.Config.Sunset;
                if (ConfigBuilder.Config.Location.Enabled)
                {
                    LocationHandler.GetSunTimesWithOffset(ConfigBuilder, out sunriseMonitor, out sunsetMonitor);
                }

                //the time between sunrise and sunset, aka "day"
                if (Extensions.NowIsBetweenTimes(sunriseMonitor.TimeOfDay, sunsetMonitor.TimeOfDay))
                {
                    if (SuntimeIsWithinSpan(sunsetMonitor))
                    {
                        if (!PostponeDark)
                        {
                            Logger.Info($"starting GPU usage monitoring, theme switch pending within {Math.Abs(ConfigBuilder.Config.GPUMonitoring.MonitorTimeSpanMin)} minute(s)");
                            State.PostponeSwitch = true;
                            PostponeDark         = true;
                        }
                    }
                    // if it's already light, check if the theme switch from dark to light should be delayed
                    else if (PostponeLight && DateTime.Now >= sunriseMonitor)
                    {
                        var result = await CheckForPostpone();
                        if (result != ThreshHigh)
                        {
                            PostponeLight = false;
                        }
                    }
                    else
                    {
                        if (PostponeDark || PostponeLight)
                        {
                            Logger.Info($"ending GPU usage monitoring");
                            PostponeDark         = false;
                            PostponeLight        = false;
                            State.PostponeSwitch = false;
                        }
                    }
                }
                // the time between sunset and sunrise, aka "night"
                else
                {
                    if (SuntimeIsWithinSpan(sunriseMonitor))
                    {
                        if (!PostponeLight)
                        {
                            Logger.Info($"starting GPU usage monitoring, theme switch pending within {Math.Abs(ConfigBuilder.Config.GPUMonitoring.MonitorTimeSpanMin)} minute(s)");
                            State.PostponeSwitch = true;
                            PostponeLight        = true;
                        }
                    }
                    // if it's already dark, check if the theme switch from light to dark should be delayed
                    else if (PostponeDark && DateTime.Now >= sunsetMonitor)
                    {
                        var result = await CheckForPostpone();
                        if (result != ThreshHigh)
                        {
                            PostponeDark = false;
                        }
                    }
                    else
                    {
                        if (PostponeDark || PostponeLight)
                        {
                            Logger.Info($"ending GPU usage monitoring");
                            PostponeDark         = false;
                            PostponeLight        = false;
                            State.PostponeSwitch = false;
                        }
                    }
                }
            });
        }
        public Location LoadRitualRoom()
        {
            Location returnData;

            returnData      = new Location();
            returnData.Name = "Ritual Room";
            bool   defeatedEliteGuards  = Convert.ToBoolean(LocationHandler.GetLocationStateValue(Banken.LOCATION_STATE_KEY, BankenInconspicousCave.RITUAL_ROOM_GUARDS));
            bool   defeatedNormalNecros = Convert.ToBoolean(LocationHandler.GetLocationStateValue(Banken.LOCATION_STATE_KEY, BankenInconspicousCave.RITUAL_ROOM_NECRO));
            bool   defeatedZulien       = Convert.ToBoolean(LocationHandler.GetLocationStateValue(Banken.LOCATION_STATE_KEY, BankenInconspicousCave.ZULIEN));
            bool   takeTreasure         = Convert.ToBoolean(LocationHandler.GetLocationStateValue(Banken.LOCATION_STATE_KEY, BankenInconspicousCave.TREASURE));
            string before = "Zulien stops his ritual and turns his head toward you. As he sees you, his eyes flash with fury. He turns his full attention toward you. " +
                            "\nHe lets out a strong magical blast that leaves you kneeling on the ground, arm covering your head. He shouts, \"You dare interupt my ritual? Die, mortal!\"";
            string after = "Zulien collapses to the ground, dead. Bload trickling out of his mouth. The world is a slightly better place.";

            if (!defeatedEliteGuards)
            {
                returnData.Description = "A large room with magic symbols painted on the ground with blood. There are several necromancer guards along with the rank and file protecting a vile necromancer performing a blood ritual";

                List <LocationAction> locationActions = new List <LocationAction>();
                List <Mob>            mobs            = new List <Mob>();
                mobs.Add(new NecromancerEliteGuard());
                mobs.Add(new NecromancerEliteGuard());
                mobs.Add(new NecromancerEliteGuard());
                mobs.Add(new NecromancerEliteGuard());
                mobs.Add(new NecromancerEliteGuard());
                mobs.Add(new NecromancerEliteGuard());
                CombatAction combatAction = new CombatAction("Necromancer Elite Guards", mobs);
                combatAction.PostCombat += RitualRoomEliteNecroGuard;
                locationActions.Add(combatAction);
                returnData.Actions = locationActions;
            }
            if (defeatedEliteGuards && !defeatedNormalNecros)
            {
                returnData.Description = "A large room with magic symbols painted on the ground with blood. The elite necromancer guard is dead, leaving only normal necromancers to protect the vile necromancer performing a blood ritual";

                List <LocationAction> locationActions = new List <LocationAction>();
                List <Mob>            mobs            = new List <Mob>();
                mobs.Add(new Necromancer());
                mobs.Add(new Necromancer());
                mobs.Add(new Necromancer());
                mobs.Add(new Necromancer());
                mobs.Add(new Necromancer());
                mobs.Add(new Necromancer());
                mobs.Add(new Necromancer());
                mobs.Add(new Necromancer());
                CombatAction combatAction = new CombatAction("Necromancers", mobs);
                combatAction.PostCombat += RitualRoomNecro;
                locationActions.Add(combatAction);
                returnData.Actions = locationActions;
            }
            if (defeatedEliteGuards && defeatedNormalNecros && !defeatedZulien)
            {
                returnData.Description = "A large room with magic symbols painted on the ground with blood. There are several necromancer guards along with the rank and file protecting a vile necromancer performing a blood ritual";

                List <LocationAction> locationActions = new List <LocationAction>();
                List <Mob>            mobs            = new List <Mob>();
                mobs.Add(new Zulien());
                CombatAction combatAction = new CombatAction("Zulien", mobs, before, after);
                combatAction.PostCombat += RitualRoomZulien;
                locationActions.Add(combatAction);
                returnData.Actions = locationActions;
            }
            else
            {
                returnData.Description = "A large room with magic symbols painted on the ground with blood.";
            }

            if (defeatedZulien && !takeTreasure)
            {
                List <LocationAction> locationActions = new List <LocationAction>();
                TreasureChestAction   itemAction      = new TreasureChestAction(5);
                locationActions.Add(itemAction);
                itemAction.PostItem += Treasure;
                returnData.Actions   = locationActions;
            }

            //Adjacent Locations
            Dictionary <string, LocationDefinition> adjacentLocationDefintions = new Dictionary <string, LocationDefinition>();

            //Will need a change
            LocationDefinition locationDefinition = BankenInconspicousCave.GetTownInstance().GetDimilyLitHallway2Definition();

            adjacentLocationDefintions.Add(locationDefinition.LocationKey, locationDefinition);

            if (defeatedZulien)
            {
                locationDefinition = Banken.GetTownInstance().GetTownCenterDefinition();
                adjacentLocationDefintions.Add(locationDefinition.LocationKey, locationDefinition);
            }

            returnData.AdjacentLocationDefinitions = adjacentLocationDefintions;

            return(returnData);
        }
Example #8
0
        // -- Countries ---
        public ActionResult LocationManagment()
        {
            List <Country> countries = new LocationHandler().GetCountries();

            return(View(countries));
        }
Example #9
0
        public Location LoadMasterBedroom()
        {
            Location returnData;

            returnData      = new Location();
            returnData.Name = "Master Bedroom";
            bool defeatedMobs = Convert.ToBoolean(LocationHandler.GetLocationStateValue(BeachTower.LOCATION_STATE_KEY, BeachTowerMayorHouse.DEFEAT_BANDIT_RAID_LEADER));
            bool freeMayor    = Convert.ToBoolean(LocationHandler.GetLocationStateValue(BeachTower.LOCATION_STATE_KEY, BeachTowerMayorHouse.CAPTURED_MAYOR));
            bool tookTreasure = Convert.ToBoolean(LocationHandler.GetLocationStateValue(BeachTower.LOCATION_STATE_KEY, BeachTowerMayorHouse.TREASURE_CHEST));

            if (!defeatedMobs)
            {
                returnData.Description = "A large bedroom with a large elegent bed in the center of the fall wall. There are several bookshelves full of a wide variety of literature. There is a desk against a side wall with several documents and parchment scattered about it. It is clear the Mayor is quite a scholar. The Mayor is tied up to the front of his bed post, and a Bandit Raid Leader is standing in front of him with his sword drawn and pointed to the Mayor's neck.";

                List <LocationAction> locationActions = new List <LocationAction>();
                List <Mob>            mobs            = new List <Mob>();
                mobs.Add(new BanditRaidLeader());
                CombatAction combatAction = new CombatAction("Bandit Raid Leader", mobs);
                combatAction.PostCombat += BanditRaidLeader;
                locationActions.Add(combatAction);
                returnData.Actions = locationActions;
            }

            else if (defeatedMobs && !freeMayor)
            {
                returnData.Description = "A large bedroom with a large elegent bed in the center of the fall wall. There are several bookshelves full of a wide variety of literature. There is a desk against a side wall with several documents and parchment scattered about it. It is clear the Mayor is quite a scholar. The Mayor is tied up to the front of his bed post.";
                List <LocationAction> locationActions = new List <LocationAction>();
                TakeItemAction        itemAction      = new TakeItemAction("Free", "Mayor", "You cut the ties that are binding the mayor to the bed. He thanks you and promptly leaves the house to asses the damage done to his town. You should report back to Mike at the Beach Tower to let him know that the Mayor is free and the town has been completely liberated.");
                itemAction.PostItem += FreeMayor;
                locationActions.Add(itemAction);
                returnData.Actions = locationActions;
            }

            else if (defeatedMobs && freeMayor && !tookTreasure)
            {
                returnData.Description = "A large bedroom with a large elegent bed in the center of the fall wall. There are several bookshelves full of a wide variety of literature. There is a desk against a side wall with several documents and parchment scattered about it. It is clear the Mayor is quite a scholar.";
                List <LocationAction> locationActions = new List <LocationAction>();
                TreasureChestAction   itemAction      = new TreasureChestAction(5);
                locationActions.Add(itemAction);
                itemAction.PostItem += TreasureChest;
                returnData.Actions   = locationActions;
            }
            returnData.Description = "A large bedroom with a large elegent bed in the center of the fall wall. There are several bookshelves full of a wide variety of literature. There is a desk against a side wall with several documents and parchment scattered about it. It is clear the Mayor is quite a scholar. The Mayor is tied up to the front of his bed post.";

            //Adjacent Locations
            Dictionary <string, LocationDefinition> adjacentLocationDefintions = new Dictionary <string, LocationDefinition>();

            //Town Center
            LocationDefinition locationDefinition = BeachTowerMayorHouse.GetTownInstance().GetUpstairsHallwayDefinition();

            adjacentLocationDefintions.Add(locationDefinition.LocationKey, locationDefinition);

            if (defeatedMobs && freeMayor)
            {
                locationDefinition = BeachTower.GetTownInstance().GetTownCenterDefinition();
                adjacentLocationDefintions.Add(locationDefinition.LocationKey, locationDefinition);
            }

            returnData.AdjacentLocationDefinitions = adjacentLocationDefintions;

            return(returnData);
        }
Example #10
0
 public override void Initialize(Game1 gameReference, Player playerReference, Sadako sadakoReference, InventoryHandler inventoryHandler, LocationHandler locationHandler, EventHandler eventHandler, RoomDatabase roomDatabase, TileDatabase tileDatabase)
 {
     base.Initialize(gameReference, playerReference, sadakoReference, inventoryHandler, locationHandler, eventHandler, roomDatabase, tileDatabase);
 }
        public Location LoadRoomSix()
        {
            Location returnData;
            bool     defeatedNecromancerLeader = Convert.ToBoolean(LocationHandler.GetLocationStateValue(Watertown.LOCATION_STATE_KEY, WatertownBanditHouse.DEFATED_BANDIT_SPY));
            bool     openedChest = Convert.ToBoolean(LocationHandler.GetLocationStateValue(Watertown.LOCATION_STATE_KEY, WatertownBanditHouse.OPENED_SPY_CHEST));
            bool     takeLetter  = Convert.ToBoolean(LocationHandler.GetLocationStateValue(Watertown.LOCATION_STATE_KEY, WatertownBanditHouse.TOOK_SPY_LETTER));

            returnData      = new Location();
            returnData.Name = "Bedroom";

            //Actions

            if (defeatedNecromancerLeader == false)
            {
                returnData.Description = "A large luxurious bedroom with a large comfortable bed against the back wall. A bandit spy is sitting on the bed playing with one of his knives..";
                // Location Actions
                List <LocationAction> locationActions = new List <LocationAction>();

                List <Mob> spy = new List <Mob>();
                spy.Add(new BanditSpy());
                CombatAction combatAction = new CombatAction("Bandit Spy", spy);
                combatAction.PostCombat += BanditSpyBattle;

                locationActions.Add(combatAction);

                returnData.Actions = locationActions;
            }
            if (defeatedNecromancerLeader)
            {
                if (openedChest == false)
                {
                    if (!takeLetter)
                    {
                        returnData.Description = "A large luxurious bedroom with a large comfortable bed against the back wall. The bandit spy lays dead on his bed with a letter on his night stand and a chest under his bed";
                    }
                    else
                    {
                        returnData.Description = "A large luxurious bedroom with a large comfortable bed against the back wall. The bandit spy lays dead on his bed with a chest under his bed";
                    }
                    List <LocationAction> locationActions = new List <LocationAction>();
                    TreasureChestAction   itemAction      = new TreasureChestAction(3);
                    locationActions.Add(itemAction);
                    itemAction.PostItem += SpyChest;
                    returnData.Actions   = locationActions;
                }
                if (openedChest && takeLetter)
                {
                    returnData.Description = "A large luxurious bedroom with a large comfortable bed against the back wall. The bandit spy lays dead on his bed with a chest under his bed";
                }

                if (!takeLetter && openedChest)
                {
                    returnData.Description = "A large luxurious bedroom with a large comfortable bed against the back wall. The bandit spy lays dead on his bed with a letter on his night stand and a chest under his bed";
                    List <LocationAction> locationActions = new List <LocationAction>();
                    TakeItemAction        letterAction    = new TakeItemAction("Letter");
                    letterAction.PostItem += SpyLetter;
                    locationActions.Add(letterAction);
                    returnData.Actions = locationActions;
                }
            }

            // Adjacent Locations
            Dictionary <string, LocationDefinition> adjacentLocationDefinitions = new Dictionary <string, LocationDefinition>();

            // Town Center
            LocationDefinition locationDefinition = WatertownBanditHouse.GetTownInstance().GetRoomFiveDefinition();

            adjacentLocationDefinitions.Add(locationDefinition.LocationKey, locationDefinition);

            if (takeLetter)
            {
                locationDefinition = Watertown.GetTownInstance().GetTownCenterDefinition();
                adjacentLocationDefinitions.Add(locationDefinition.LocationKey, locationDefinition);
            }

            returnData.AdjacentLocationDefinitions = adjacentLocationDefinitions;

            return(returnData);
        }
        ///<summary>
        ///Method to place order by passing business logic order object to data handler
        ///</summary>
        private void AddOrder()
        {
            OrderHandler    oh = new OrderHandler();
            LocationHandler lh = new LocationHandler();
            Customer        c  = new Customer();

            Console.WriteLine("New Customer? \n Y^(YES) N^(NO))");
            string input = Console.ReadLine();

            switch (input)
            {
            case "Y":
                AdminCustomer ac = new AdminCustomer();
                c = ac.AddNewCustomer();
                break;

            case "N":
                c = EnterCustomerDetails();
                break;

            default:
                ErrorHandler err = new ErrorHandler();
                err.InvalidInputMsg();
                AddOrder();
                break;
            }

            Location         l = EnterLocationDetails();
            string           choice;
            List <Inventory> custOrder = new List <Inventory>();

            do
            {
                Console.WriteLine("Choose Product to Order (Enter Index Number):");
                List <Inventory> availInvent = lh.GetAvailInventory(l);
                int j = 0;
                foreach (Inventory i in availInvent)
                {
                    Console.WriteLine("[" + j + "] " + " Name: " + i.Prod.Name + "\n Price: " + i.Prod.Price + "\n Remaining Stock: " + i.Stock);
                    j++;
                }
                input = Console.ReadLine();
                Console.WriteLine("Enter Quantity: ");
                string amount = Console.ReadLine();
                try
                {
                    lh.UpdateInventory(new Inventory()
                    {
                        Prod = availInvent[int.Parse(input)].Prod, Stock = int.Parse(amount)
                    }, l);
                }
                catch (InsufficientStockException ex)
                {
                    Console.WriteLine(ex.Message);
                    choice = "";
                    Log.Error("Insufficient Stock Exception. User tried to buy products more than available inventory");
                    continue;
                }
                catch (FormatException ex)
                {
                    Console.WriteLine(ex.Message);
                    choice = "";
                    Log.Error("Format Exception. User tried to input invalid format");
                    continue;
                }
                catch (ArgumentOutOfRangeException ex)
                {
                    Console.WriteLine(ex.Message);
                    choice = "";
                    Log.Error(ex.Message);
                    continue;
                }
                catch (InvalidStockException ex)
                {
                    Console.WriteLine(ex.Message);
                    choice = "";
                    Log.Error(ex.Message);
                    continue;
                }
                custOrder.Add(new Inventory()
                {
                    Prod = availInvent[int.Parse(input)].Prod, Stock = int.Parse(amount)
                });
                do
                {
                    Console.WriteLine("Would you like to order another product? \n N^(NO) Y^(YES)");
                    choice = Console.ReadLine();
                } while (ErrorHandler.InvalidInput(choice));
            } while (choice != "N");
            Orders o = new Orders()
            {
                Cust      = c,
                Stor      = l,
                Date      = DateTime.Now,
                CustOrder = custOrder
            };

            oh.AddOrder(o);
            oh.PrintOrderDetails(o);
            Log.Information("Order Added");
            Log.Information($"Order was made by customer {c.FirstName} {c.LastName} at {l.BranchName} store");
            Menu();
        }
        public void displayView(Puser user)
        {
            this.user = user;

            Console.WriteLine("===================== ADMINISTRATOR ==================");
            Console.WriteLine();
            Console.WriteLine($"Choose from the options below from 1 to {menuAdmin.Length}");
            Console.WriteLine();

            int listCount = 1;
            int option;


            for (int i = 0; i < menuAdmin.Length - 1; listCount++, i++)
            {
                Console.WriteLine($" ({listCount}) \t {menuAdmin[i]}");
            }

            Console.WriteLine();

            do
            {
                option = base.GetValidatedOption(menuAdmin.Length - 1);
            } while (option == -1);

            //Load Locations from domainusing
            List <Plocation> locations = LocationHandler.GetLocationData();

            switch (option - 1)
            {
            case (int)menuAdminConst.Stores:
            {
                LocationView.DisplayLocationsOptions(locations);

                break;
            }

            case (int)menuAdminConst.Pizzas:
            {
                LocationView.DisplayLocationsOptions(locations);

                do
                {
                    option = base.GetValidatedOption(locations.Count - 1);
                } while (option == -1);

                //Load Pizzas from domain
                List <Pizza> pizzas = PizzaHandler.GetPizzasFromLocation(locations[option - 1]);

                //Display pizzas
                PizzaView.DisplayPizzas(pizzas);

                break;
            }

            case (int)menuAdminConst.Order:

            {
                List <Porder> orders = OrderHandler.GetOrders();
                OrderView.DisplayOrders(orders);

                break;
            }

            case (int)menuAdminConst.Customer:

            {
                List <Customer> customers = CustomerHandler.GetCustomers();
                CustomerDetailsView.DisplayCustomerDetails(customers);

                break;
            }

            case (int)menuAdminConst.Sales:

            {
                break;
            }

            case (int)menuAdminConst.Users:
            {
                List <Puser> users = UserHandler.GetUsers();
                UserDetailsView.DisplayUserDetails(users);

                break;
            }
            }

            string option1;

            do
            {
                option1 = base.GetInput("Type in YES to continue or NO to quit. ");

                if (option1.ToLower().Equals("yes"))
                {
                    displayView(user);
                }
                else if (option1.ToLower().Equals("no"))
                {
                    Console.WriteLine("Thank you for choosing PizaBox");
                    Environment.Exit(0);
                }
                else
                {
                    Console.WriteLine("Incorrect Option, pls try again.");
                    Console.WriteLine();
                }
            } while (option1.ToLower().Equals("yes") || option1.ToLower().Equals("no"));

            Console.WriteLine();
        }
Example #14
0
        public Location LoadSewerEntranceFinal()
        {
            Location returnData;
            bool     defeatedSewerKing = Convert.ToBoolean(LocationHandler.GetLocationStateValue(Watertown.LOCATION_STATE_KEY, WatertownSewer.DEFEATED_SEWER_KING));

            returnData      = new Location();
            returnData.Name = "Sewer Entrance Corridor Final";
            Accomplishment exploredAccomplishment = Watertown.GetWatertownAccomplishments().Find(x => x.Name.Contains("Defeated Sewer King"));

            if (defeatedSewerKing)
            {
                returnData.Description = "The corridor ends here but the mud and slime and poopoo continues (yuck!)."; //There is a door to the right and left (add back in later)
            }
            // Location Actions
            List <LocationAction> locationActions = new List <LocationAction>();

            if (!defeatedSewerKing)
            {
                returnData.Description = "The corridor ends here but the mud and slime and poopoo continues (yuck!). The Sewer King stands in the middle of the room";

                List <Mob> sewerKing = new List <Mob>();
                sewerKing.Add(new SewerKing());


                CombatAction combatAction = new CombatAction("Sewer King", sewerKing);
                combatAction.PostCombat += SewerKingResults;
                locationActions.Add(combatAction);
                returnData.Actions = locationActions;
            }

            // Adjacent Locations
            Dictionary <string, LocationDefinition> adjacentLocationDefinitions = new Dictionary <string, LocationDefinition>();

            LocationDefinition locationDefinition = GetSewerEntranceCorridorDefinition();

            adjacentLocationDefinitions.Add(locationDefinition.LocationKey, locationDefinition);

            if (GameState.Hero.Accomplishments.Contains(exploredAccomplishment))
            {
                //Sewer Left
                locationDefinition = WatertownSewerLeft.GetTownInstance().GetStartingLocationDefinition();
                adjacentLocationDefinitions.Add(locationDefinition.LocationKey, locationDefinition);

                //Sewer Right
                locationDefinition = WatertownSewerRight.GetTownInstance().GetStartingLocationDefinition();
                adjacentLocationDefinitions.Add(locationDefinition.LocationKey, locationDefinition);
            }

            if (defeatedSewerKing)
            {
                //Town
                locationDefinition = Watertown.GetTownInstance().GetTownCenterDefinition();
                adjacentLocationDefinitions.Add(locationDefinition.LocationKey, locationDefinition);

                LocationHandler.SetLocationStateValue(Watertown.LOCATION_STATE_KEY, DEFEATED_SEWER_KING, true);
                LocationHandler.ResetLocation(Watertown.INN_KEY); // Need to reload Inn so that new conversation can be set.
            }

            returnData.AdjacentLocationDefinitions = adjacentLocationDefinitions;

            return(returnData);
        }
Example #15
0
        //private static readonly ComponentManager cm = ComponentManager.Instance();

        /// <summary>
        /// Parses a command message and invokes a callback function delegate for status reporting
        /// </summary>
        /// <param name="msg">list of messages to parse</param>
        /// <param name="SendResponse">Callback taking a string as parameter to report return values back to sender</param>
        /// <param name="service">Service class for invoking application exit</param>
        public static void Parse(List <string> msg, Action <string> SendResponse, Service service)
        {
            //WaitForConfigUpdateCompletion();
            _ = state.ConfigIsUpdatingWaitHandle.WaitOne();
            msg.ForEach(message =>
            {
                switch (message)
                {
                    #region Switch
                case Command.Switch:
                    Logger.Info("signal received: invoke theme switch");
                    //cm.ForceAll();
                    ThemeManager.RequestSwitch(builder, new(SwitchSource.Manual));
                    SendResponse(new ApiResponse()
                    {
                        StatusCode = StatusCode.Ok
                    }.ToString());
                    break;
                    #endregion

                    #region Swap
                case Command.Swap:
                    Logger.Info("signal received: swap themes");
                    if (RegistryHandler.AppsUseLightTheme())
                    {
                        ThemeManager.UpdateTheme(builder.Config, Theme.Dark, new(SwitchSource.Manual));
                    }
                    else
                    {
                        ThemeManager.UpdateTheme(builder.Config, Theme.Light, new(SwitchSource.Manual));
                    }
                    SendResponse(new ApiResponse()
                    {
                        StatusCode = StatusCode.Ok
                    }.ToString());
                    break;
                    #endregion

                    #region AddAutoStart
                case Command.AddAutostart:
                    Logger.Info("signal received: add service to autostart");
                    SendResponse(AutoStartHandler.AddAutostart().ToString());
                    break;
                    #endregion

                    #region RemoveAutostart
                case Command.RemoveAutostart:
                    Logger.Info("signal received: remove service from autostart");
                    SendResponse(AutoStartHandler.RemoveAutostart().ToString());
                    break;
                    #endregion

                    #region GetAutostartState
                case Command.GetAutostartState:
                    Logger.Info("signal recevied: get autostart state");
                    SendResponse(AutoStartHandler.GetAutostartState().ToString());
                    break;
                    #endregion

                    #region ValidateAutostartAutostart
                case string s when s.StartsWith(Command.ValidateAutostart):
                    Logger.Info("signal received: validate autostart entries");
                    string[] split = s.Split(" ");
                    if (split.Length > 1)
                    {
                        SendResponse(AutoStartHandler.Validate(true).ToString());
                    }
                    else
                    {
                        SendResponse(AutoStartHandler.Validate(false).ToString());
                    }
                    break;
                    #endregion

                    #region LocationAccess
                case Command.LocationAccess:
                    Logger.Info("signal received: checking location access permissions");
                    Task <bool> geoTask = Task.Run(async() => await LocationHandler.HasLocation());
                    geoTask.Wait();
                    var result = geoTask.Result;
                    if (result)
                    {
                        SendResponse(new ApiResponse()
                        {
                            StatusCode = StatusCode.Ok
                        }.ToString());
                    }
                    else
                    {
                        SendResponse(new ApiResponse()
                        {
                            StatusCode = StatusCode.NoLocAccess,
                            Message    = "location service needs to be enabled"
                        }.ToString());
                    }
                    break;
                    #endregion

                    #region GeoloatorIsUpdating
                case Command.GeolocatorIsUpdating:
                    Logger.Info("signal received: check if geolocator is busy");
                    if (state.GeolocatorIsUpdating)
                    {
                        SendResponse(new ApiResponse()
                        {
                            StatusCode = StatusCode.InProgress
                        }.ToString());
                    }
                    else
                    {
                        SendResponse(new ApiResponse()
                        {
                            StatusCode = StatusCode.Ok
                        }.ToString());
                    }
                    break;
                    #endregion

                    #region CheckForUpdates
                case Command.CheckForUpdate:
                    Logger.Info("signal received: checking for update");
                    SendResponse(UpdateHandler.CheckNewVersion().ToString());
                    break;
                    #endregion

                    #region CheckForUpdateNotify
                case Command.CheckForUpdateNotify:
                    Logger.Info("signal received: checking for update and requesting notification");
                    ApiResponse updateCheckData = UpdateHandler.CheckNewVersion();
                    updateCheckData             = UpdateHandler.CanUseUpdater();
                    if (updateCheckData.StatusCode == StatusCode.New)
                    {
                        ToastHandler.InvokeUpdateToast();
                    }
                    else if (updateCheckData.StatusCode == StatusCode.UnsupportedOperation || updateCheckData.StatusCode == StatusCode.Disabled)
                    {
                        ToastHandler.InvokeUpdateToast(canUseUpdater: false);
                    }
                    SendResponse(updateCheckData.ToString());
                    break;
                    #endregion

                    #region Update
                case Command.Update:
                    Logger.Info("signal received: update adm");
                    if (!UpdateHandler.Updating)
                    {
                        ApiResponse response = UpdateHandler.CanUseUpdater();
                        if (response.StatusCode == StatusCode.New)
                        {
                            SendResponse(response.ToString());
                            // this is run sync, as such it will block the ZMQ thread!
                            _ = Task.Run(() => UpdateHandler.Update());
                        }
                        else
                        {
                            SendResponse(response.ToString());
                        }
                    }
                    else
                    {
                        SendResponse(new ApiResponse()
                        {
                            StatusCode = StatusCode.InProgress,
                            Message    = "Update already in progress",
                            Details    = $"Download Progress: {UpdateHandler.Progress}"
                        }.ToString());
                    }
                    //_ = UpdateHandler.CheckNewVersion();

                    break;
                    #endregion

                    #region CheckForDowngradeNotify
                case Command.CheckForDowngradeNotify:
                    Logger.Info("signal received: checking for downgrade and requesting notification");
                    ApiResponse downgradeCheckData = UpdateHandler.CheckDowngrade();
                    updateCheckData = UpdateHandler.CanUseUpdater();
                    if (updateCheckData.StatusCode == StatusCode.Downgrade)
                    {
                        ToastHandler.InvokeUpdateToast(downgrade: true);
                    }
                    else if (updateCheckData.StatusCode == StatusCode.UnsupportedOperation || updateCheckData.StatusCode == StatusCode.Disabled)
                    {
                        ToastHandler.InvokeUpdateToast(downgrade: true, canUseUpdater: false);
                    }
                    SendResponse(updateCheckData.ToString());
                    break;
                    #endregion

                    #region Shutdown
                case Command.Shutdown:
                    Logger.Info("signal received, exiting");
                    SendResponse(new ApiResponse()
                    {
                        StatusCode = StatusCode.Ok
                    }.ToString());
                    service.RequestExit(null, null);
                    break;
                    #endregion

                    #region Restart
                case Command.Restart:
                    Logger.Info("signal received, restarting");
                    SendResponse(new ApiResponse()
                    {
                        StatusCode = StatusCode.Ok
                    }.ToString());
                    service.Restart(null, new ExitEventArgs(false));
                    break;
                    #endregion

                    #region TestError
                case Command.TestError:
                    Logger.Info("signal received: test error");
                    Thread.Sleep(5000);
                    SendResponse(new ApiResponse()
                    {
                        StatusCode = StatusCode.Err
                    }.ToString());
                    break;
                    #endregion

                    #region Alive
                case Command.Alive:
                    Logger.Info("signal received: request for running status");
                    SendResponse(new ApiResponse()
                    {
                        StatusCode = StatusCode.Ok
                    }.ToString());
                    break;
                    #endregion

                    #region Light
                case Command.Light:
                    Logger.Info("signal received: force light theme");
                    state.ForcedTheme = Theme.Light;
                    ThemeHandler.EnforceNoMonitorUpdates(builder, state, Theme.Light);
                    ThemeManager.UpdateTheme(builder.Config, Theme.Light, new(SwitchSource.Manual));
                    SendResponse(new ApiResponse()
                    {
                        StatusCode = StatusCode.Ok
                    }.ToString());
                    break;
                    #endregion

                    #region Dark
                case Command.Dark:
                    Logger.Info("signal received: force dark theme");
                    state.ForcedTheme = Theme.Dark;
                    ThemeHandler.EnforceNoMonitorUpdates(builder, state, Theme.Dark);
                    ThemeManager.UpdateTheme(builder.Config, Theme.Dark, new(SwitchSource.Manual));
                    SendResponse(StatusCode.Ok);
                    break;
                    #endregion

                    #region NoForce
                case Command.NoForce:
                    Logger.Info("signal received: resetting forced modes");
                    state.ForcedTheme = Theme.Unknown;
                    ThemeManager.RequestSwitch(builder, new(SwitchSource.Manual));
                    SendResponse(new ApiResponse()
                    {
                        StatusCode = StatusCode.Ok
                    }.ToString());
                    break;
                    #endregion

                    #region DetectMonitors
                case Command.DetectMonitors:
                    Logger.Info("signal received: detecting new monitors");
                    DisplayHandler.DetectMonitors();
                    SendResponse(new ApiResponse()
                    {
                        StatusCode = StatusCode.Ok
                    }.ToString());
                    break;
                    #endregion

                    #region CleanMonitors
                case Command.CleanMonitors:
                    Logger.Info("signal received: removing disconnected monitors");
                    DisplayHandler.CleanUpMonitors();
                    SendResponse(new ApiResponse()
                    {
                        StatusCode = StatusCode.Ok
                    }.ToString());
                    break;
                    #endregion

                    #region UpdateFailed
                case Command.UpdateFailed:
                    Logger.Info("signal received: notify about failed update");
                    ToastHandler.InvokeFailedUpdateToast();
                    SendResponse(StatusCode.Ok);
                    break;
                    #endregion

                    #region TestNotifications
                case Command.TestNotifications:
                    Logger.Info("signal received: test notifications");
                    ToastHandler.InvokeUpdateInProgressToast("TestVersion");
                    SendResponse(new ApiResponse()
                    {
                        StatusCode = StatusCode.Ok
                    }.ToString());
                    break;
                    #endregion

                    #region TestNotifications2
                case Command.TestNotifications2:
                    Logger.Info("signal received: test notifications");
                    //ToastHandler.InvokeUpdateToast(true, true);
                    //ToastHandler.RemoveUpdaterToast();
                    //ToastHandler.UpdateProgressToast("0.5", "test");
                    SendResponse(new ApiResponse()
                    {
                        StatusCode = StatusCode.Ok
                    }.ToString());
                    break;
                    #endregion

                    #region Test
                case Command.Test:
                    ThemeFile tf = new(@"C:\Users\Sam\AppData\Local\Microsoft\Windows\Themes\solid_test.theme");
                    tf.Save();
                    SendResponse(new ApiResponse()
                    {
                        StatusCode = StatusCode.Ok,
                        Message    = "it works"
                    }.ToString());
                    break;
                    #endregion

                default:
                    Logger.Debug("unknown message received");
                    SendResponse(new ApiResponse()
                    {
                        StatusCode = StatusCode.Err,
                        Message    = "requested command does not exist"
                    }.ToString());
                    break;
                }
            });
        }
        public Location LoadBurntOpening()
        {
            Location returnData;

            returnData      = new Location();
            returnData.Name = "Burnt Opening";
            bool hiddenRanger = Convert.ToBoolean(LocationHandler.GetLocationStateValue(Banken.LOCATION_STATE_KEY, BankenAshenForestRangerPaths.HIDING_RANGER));
            bool lookForPath  = Convert.ToBoolean(LocationHandler.GetLocationStateValue(Banken.LOCATION_STATE_KEY, BankenAshenForestRangerPaths.LOOK_FOR_PATH));
            bool defeatedMobs = Convert.ToBoolean(LocationHandler.GetLocationStateValue(Banken.LOCATION_STATE_KEY, BankenAshenForestRangerPaths.BURNT_OPENING_SHADOW_DEMONS));

            returnData.Description = "There is a burnt opening in a thick cluster of trees. Within the opening there is a secret ranger path that leads deeper within the forest. Hidden amongst the trees is one of Banken's rangers.";

            List <LocationAction> locationActions = new List <LocationAction>();
            TakeItemAction        itemAction      = new TakeItemAction("Talk to", "the hidden ranger", "You walk up to the ranger and signal that you're a friend and ask, 'What's going on here? Where's the rest of your company, ranger?' The ranger speaks from his hidden position, 'I don't know where everyone else went. Those spirits came with the darkness. I was knocked out. Next thing I knew everyone was gone and the spirits were still here. I need to stay and see if anyone returns. There is a path nearby. Find it and you should find the answers we both seek.'");

            locationActions.Add(itemAction);
            itemAction.PostItem += HiddenRanger;
            returnData.Actions   = locationActions;

            if (hiddenRanger && !lookForPath)
            {
                locationActions = new List <LocationAction>();
                TakeItemAction lookActiopn = new TakeItemAction("Look for ", "the path", "You search around the burnt opening for the path that the ranger spoke of. You find it and make to walk toward it but instead you're assaulted by shadow demons from all sides.");
                locationActions.Add(lookActiopn);
                lookActiopn.PostItem += LookForPath;
                returnData.Actions    = locationActions;
            }

            else if (lookForPath && !defeatedMobs)
            {
                locationActions = new List <LocationAction>();
                List <Mob> mobs = new List <Mob>();
                mobs.Add(new ShadowDemon());
                mobs.Add(new ShadowDemon());
                mobs.Add(new ShadowDemon());
                mobs.Add(new ShadowDemon());
                mobs.Add(new ShadowDemon());
                CombatAction combatAction = new CombatAction("Shadow Demons", mobs);
                combatAction.PostCombat += BurntOpeningShadowDemons;
                locationActions.Add(combatAction);
                returnData.Actions = locationActions;
            }

            //Adjacent Locations
            Dictionary <string, LocationDefinition> adjacentLocationDefintions = new Dictionary <string, LocationDefinition>();

            //Town Center
            LocationDefinition locationDefinition = BankenAshenForestRangerPaths.GetTownInstance().GetRangerCampDefinition();

            adjacentLocationDefintions.Add(locationDefinition.LocationKey, locationDefinition);

            if (hiddenRanger && lookForPath && defeatedMobs)
            {
                locationDefinition = BankenAshenForestRangerPaths.GetTownInstance().GetTwistingPathDefinition();
                adjacentLocationDefintions.Add(locationDefinition.LocationKey, locationDefinition);
            }

            returnData.AdjacentLocationDefinitions = adjacentLocationDefintions;

            return(returnData);
        }
        public async Task <IActionResult> PostFighting([FromBody] PassedGameData <bool> passedData)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }
            DateTime now = DateTime.UtcNow;

            if (passedData.UserToken == null || passedData.ActionToken == null)
            {
                return(BadRequest(new DataError("securityErr", "No authorization controll.")));
            }
            UserToken dbtoken = Security.CheckUserToken(this._context, passedData.UserToken);

            if (dbtoken == null)
            {
                return(BadRequest(new DataError("securityErr", "Your data has probably been stolen or modified manually. We suggest password's change.")));
            }
            else
            {
                if (!dbtoken.IsTimeValid(now))
                {
                    return(BadRequest(new DataError("timeoutErr", "You have been too long inactive. Relogin is required.")));
                }
                else
                {
                    dbtoken.UpdateToken(now);
                }
            }
            Heros       hero      = _context.Heros.FirstOrDefault(e => e.Name == passedData.ActionToken.HeroName);
            ActionToken gametoken = Security.CheckActionToken(_context, passedData.ActionToken, hero.HeroId);

            if (gametoken == null)
            {
                return(BadRequest(new DataError("securityErr", "Your data has probably been stolen or modified manually. We suggest password's change.")));
            }
            else
            {
                if (!gametoken.IsTimeValid(now))
                {
                    return(BadRequest(new DataError("timeoutErr", "You have been too long inactive. Relogin is required.")));
                }
                else
                {
                    gametoken.UpdateToken(now);
                }
            }
            // now do your stuff...
            if (hero.Status == 3)
            {
                // to pass
                object statusData = null;
                var    Added      = new List <EquipmentModifyResult.EquipmentModification>();
                var    newItems   = new List <ItemResult>();

                var fight = _context.Fighting.FirstOrDefault(e => e.HeroId == hero.HeroId);
                if (fight == null)
                {
                    return(BadRequest(new DataError("fightErr", "Hero has no fight data.")));
                }
                if (!fight.IsOver)
                {
                    return(BadRequest(new DataError("fightErr", "Fight has not been finished.")));
                }
                if (hero.Hp > 0)
                {
                    hero.Status = 0;
                    if (fight.Loot.HasValue && passedData.Data)
                    {
                        var Item = _context.Items.FirstOrDefault(e => e.ItemId == fight.Loot.Value);
                        if (Item == null)
                        {
                            return(BadRequest(new DataError("itemErr", "Looted item not found.")));
                        }
                        newItems.Add((ItemResult)Item);
                        var heroBackpack = _context.Backpack.Where(e => e.HeroId == hero.HeroId);
                        int count        = heroBackpack.Count();
                        if (count > 0)
                        {
                            var Equipment = _context.Equipment.FirstOrDefault(e => e.HeroId == hero.HeroId);
                            if (Equipment == null)
                            {
                                return(BadRequest(new DataError("heroErr", "Hero without equipment.")));
                            }
                            if (Equipment.BackpackSize <= count)
                            {
                                return(BadRequest(new DataError("backpackErr", "In order to add this reward, you need to remove one item from backpack or resign from reward.")));
                            }
                            if (heroBackpack.Where(e => e.SlotNr == 0).Count() > 0)
                            {
                                var preSlot = heroBackpack.FirstOrDefault(e => heroBackpack.Where(f => f.SlotNr == e.SlotNr + 1).Count() == 0);
                                _context.Backpack.Add(new Backpack()
                                {
                                    HeroId = hero.HeroId,
                                    ItemId = fight.Loot.Value,
                                    SlotNr = preSlot.SlotNr + 1,
                                });
                                Added.Add(new EquipmentModifyResult.EquipmentModification()
                                {
                                    ItemID = fight.Loot.Value, Target = "Backpack" + (preSlot.SlotNr + 1)
                                });
                            }
                            else
                            {
                                _context.Backpack.Add(new Backpack()
                                {
                                    HeroId = hero.HeroId,
                                    ItemId = fight.Loot.Value,
                                    SlotNr = 0,
                                });
                                Added.Add(new EquipmentModifyResult.EquipmentModification()
                                {
                                    ItemID = fight.Loot.Value, Target = "Backpack" + 0
                                });
                            }
                        }
                        else
                        {
                            _context.Backpack.Add(new Backpack()
                            {
                                HeroId = hero.HeroId,
                                ItemId = fight.Loot.Value,
                                SlotNr = 0,
                            });
                            Added.Add(new EquipmentModifyResult.EquipmentModification()
                            {
                                ItemID = fight.Loot.Value, Target = "Backpack" + 0
                            });
                        }
                    }
                    var enemy = _context.Enemies.FirstOrDefault(e => e.EnemyId == fight.EnemyId);
                    if (enemy == null)
                    {
                        return(BadRequest(new DataError("fightErr", "Enemy not found.")));
                    }
                    hero.Experience += HeroCalculator.ExpForFight(hero.Lvl, enemy.Lvl);
                    bool update = false;
                    while (hero.Experience >= HeroCalculator.ExpToLevel(hero.Lvl + 1))
                    {
                        hero.Lvl += 1;
                        update    = true;
                    }
                    if (update)
                    {
                        var(hp, sl) = HeroCalculator.HPSLmax(hero, _context);
                        hero.Hp     = hp;
                    }
                }
                else
                {
                    hero.Status = 2;
                    var(hp, sl) = HeroCalculator.HPSLmax(hero, _context);
                    if (hero.Hp >= hp)
                    {
                        hero.Hp = hp;
                        try
                        {
                            await _context.SaveChangesAsync();
                        }
                        catch (DbUpdateException)
                        {
                            return(BadRequest(new DataError("databaseErr", "Failed to update tokens.")));
                        }
                    }
                    int     time = HeroCalculator.RecoveryTime(hp, hero.Hp, hero.Lvl) / hero.VelocityFactor;
                    Healing heal = new Healing()
                    {
                        EndTime    = now.AddSeconds(time),
                        HeroId     = hero.HeroId,
                        StartHp    = hero.Hp,
                        StartHpmax = hp,
                        StartTime  = now,
                    };
                    this._context.Healing.Add(heal);

                    statusData = heal.GenHealingResult(now);
                }
                // TODO update map!
                _context.Fighting.Remove(fight);
                try
                {
                    var location = LocationHandler.InstanceClearCurrent(_context, hero);
                    try
                    {
                        await _context.SaveChangesAsync();
                    }
                    catch (DbUpdateException)
                    {
                        return(BadRequest(new DataError("databaseErr", "Failed to update tokens.")));
                    }
                    return(Ok(new { success = true, heroStatus = hero.Status, newHP = hero.Hp, newHPmax = HeroCalculator.BaseHP(hero.Lvl), newLvl = hero.Lvl, newExp = hero.Experience, location, statusData, added = Added.ToArray(), newItems = newItems.ToArray() }));
                }
                catch (OperationException e)
                {
                    return(BadRequest(new DataError(e.ErrorClass, e.Message)));
                }
            }
            else
            {
                return(BadRequest(new DataError("LocationErr", "Hero is not in the fight.")));
            }
        }
Example #18
0
        public Location LoadRuinedCastle()
        {
            Location returnData;

            returnData      = new Location();
            returnData.Name = "Ruined Castle";
            bool   defeatedShades = Convert.ToBoolean(LocationHandler.GetLocationStateValue(Banken.LOCATION_STATE_KEY, BankenSwampland.RUINED_CASTLE_SHADES));
            bool   defeatedNecros = Convert.ToBoolean(LocationHandler.GetLocationStateValue(Banken.LOCATION_STATE_KEY, BankenSwampland.RUINED_CASTLE_NECROS));
            bool   defeatedMarzen = Convert.ToBoolean(LocationHandler.GetLocationStateValue(Banken.LOCATION_STATE_KEY, BankenSwampland.MARZEN));
            bool   treasure       = Convert.ToBoolean(LocationHandler.GetLocationStateValue(Banken.LOCATION_STATE_KEY, BankenSwampland.TREASURE));
            string beforeShades   = "The shades take notice of you and descend, ready to end your existence.";
            string afterShades    = "The last of the shades has vanished, sending forth a burst of dark energy vaporizing the first section of the ruins.";
            string beforeMarzen   = "As you move toward the inside of the ruins, the chanting suddenly stops. The world grows cold. Slowly, a necromancer in elaborate robes calmly walks out of the ruins. He draws a sword and slings a bolt of dark energy toward you. You leap to the side, dodging it and then draw your weapon.";
            string afterMarzen    = "As Marzen falls to the ground dead, the darkness fades away and warmth once again floods your body.";

            if (!defeatedShades)
            {
                returnData.Description = "The ruins of a once great castle. Shades stand protecting the ruins. You can hear chanting just behind the stones.";

                List <LocationAction> locationActions = new List <LocationAction>();
                List <Mob>            mobs            = new List <Mob>();
                mobs.Add(new Shade());
                mobs.Add(new Shade());
                mobs.Add(new Shade());
                mobs.Add(new Shade());
                mobs.Add(new Shade());
                mobs.Add(new Shade());
                mobs.Add(new Shade());
                mobs.Add(new Shade());
                CombatAction combatAction = new CombatAction("Shades", mobs, beforeShades, afterShades);
                combatAction.PostCombat += RuinedCastleShades;
                locationActions.Add(combatAction);
                returnData.Actions = locationActions;
            }
            else if (!defeatedNecros)
            {
                returnData.Description = "The ruins of a once great castle. The necromancers now stand exposed, vulnerable to attack as they frantically continue their ritual";

                List <LocationAction> locationActions = new List <LocationAction>();
                List <Mob>            mobs            = new List <Mob>();
                mobs.Add(new Necromancer());
                mobs.Add(new Necromancer());
                mobs.Add(new Necromancer());
                mobs.Add(new Necromancer());
                CombatAction combatAction = new CombatAction("Necromancers", mobs, beforeShades, afterShades);
                combatAction.PostCombat += RuinedCastleNecros;
                locationActions.Add(combatAction);
                returnData.Actions = locationActions;
            }
            else if (!defeatedMarzen)
            {
                returnData.Description = "The ruins of a once great castle. One necromancer remains, just out of sight. You can feel the darkness swirl as his ritual nears completion";

                List <LocationAction> locationActions = new List <LocationAction>();
                List <Mob>            mobs            = new List <Mob>();
                mobs.Add(new Marzen());
                CombatAction combatAction = new CombatAction("Marzen, High Necromancer", mobs, beforeMarzen, afterMarzen);
                combatAction.PostCombat += Marzen;
                locationActions.Add(combatAction);
                returnData.Actions = locationActions;
            }
            else
            {
                returnData.Description = "The ruins of a once great castle.";
            }

            if (defeatedMarzen && !treasure)
            {
                List <LocationAction> locationActions = new List <LocationAction>();
                TreasureChestAction   itemAction      = new TreasureChestAction(5);
                locationActions.Add(itemAction);
                itemAction.PostItem += Treasure;
                returnData.Actions   = locationActions;
            }


            //Adjacent Locations
            Dictionary <string, LocationDefinition> adjacentLocationDefintions = new Dictionary <string, LocationDefinition>();

            //Will need a change
            LocationDefinition locationDefinition = BankenSwampland.GetTownInstance().GetSwampyAreaThreeDefinition();

            adjacentLocationDefintions.Add(locationDefinition.LocationKey, locationDefinition);

            if (defeatedMarzen)
            {
                locationDefinition = Banken.GetTownInstance().GetTownCenterDefinition();
                adjacentLocationDefintions.Add(locationDefinition.LocationKey, locationDefinition);
            }

            returnData.AdjacentLocationDefinitions = adjacentLocationDefintions;

            return(returnData);
        }
        protected void drpCategory_SelectedIndexChanged1(object sender, EventArgs e)
        {
            chkMeeting.Checked = false;
            chkMeeting_CheckedChanged(sender, e);
            if ((drpCategory.SelectedIndex == 1) || (drpCategory.SelectedIndex == 2) || (drpCategory.SelectedIndex == 3))
            {
                if (drpCategory.SelectedIndex == 1)
                {
                    txtCapacity.Text     = 1.ToString();
                    txtCapacity.ReadOnly = true;
                }
                else
                {
                    txtCapacity.ReadOnly = false;
                }
                trOptions.Visible   = true;
                chblOptions.Enabled = true;
                drpLocation.Enabled = true;
                LocationHandler locH = new LocationHandler();
                drpLocation.Items.Clear();
                drpLocation.DataSource     = locH.GetLocationListByCatID(Convert.ToInt32(drpCategory.SelectedValue)).Distinct();
                drpLocation.DataTextField  = "name";
                drpLocation.DataValueField = "ID";
                drpLocation.DataBind();
                drpLocation.Items.Insert(0, "انتخاب کنید");
                OptionHandler opt = new OptionHandler();
                optlist = opt.GetOptionListByCatID(Convert.ToInt32(drpCategory.SelectedValue));
                chblOptions.Items.Clear();
                chblOptions.DataSource     = optlist;
                chblOptions.DataTextField  = "name";
                chblOptions.DataValueField = "ID";
                chblOptions.DataBind();

                trDaneshkadeh.Visible = userID == 1;
                Daneshkade item = new Daneshkade();
                item.NameDanesh = "--انتخاب کنید--";
                item.ID         = -1;
                DaneshkadeHandler dnsh = new DaneshkadeHandler();
                dnshList = dnsh.GetAllDaneshkade();
                dnshList.Insert(0, item);
                drpChooseDanshkade.Items.Clear();
                drpChooseDanshkade.DataSource     = dnshList;
                drpChooseDanshkade.DataTextField  = "NameDanesh";
                drpChooseDanshkade.DataValueField = "ID";
                drpChooseDanshkade.DataBind();


                if (drpCategory.SelectedIndex == 3 || drpCategory.SelectedIndex == 2)
                {
                    chkMeeting.Visible = true;
                    if (drpCategory.SelectedIndex == 2)
                    {
                        chkMeeting.Text = "بدون استاد";
                    }
                    else
                    {
                        chkMeeting.Text = " تخصیص سالن کنفرانس جهت برگزاری جلسات";
                    }
                }
                else
                {
                    chkMeeting.Visible = false;
                }
            }
            else
            {
                trOptions.Visible   = false;
                chblOptions.Enabled = false;
                drpLocation.Enabled = false;
                chkMeeting.Visible  = false;
            }
            ////////////////////////////////////////////
            RadComboBoxField.Enabled = true;
            RC_UserHandler usrH      = new RC_UserHandler();
            List <RC_User> listostad = usrH.GetOstadListByDaneshID(Convert.ToInt32(Session["DaneshId"]));

            if (listostad != null)
            {
                for (int i = 0; i <= listostad.Count - 1; i++)
                {
                    listostad[i].Name = listostad[i].Name.Replace("ي", "ی");
                }
            }
            RadComboBoxField.Items.Clear();
            RadComboBoxField.DataSource     = listostad;
            RadComboBoxField.DataTextField  = "name";
            RadComboBoxField.DataValueField = "ID";
            RadComboBoxField.DataBind();
            RadComboBoxField.Items.Insert(0, new Telerik.Web.UI.RadComboBoxItem("جستجو و انتخاب کنید"));


            ///////////////////////////////////////////
        }
        public Location LoadGuardRoom()
        {
            Location returnData;

            returnData      = new Location();
            returnData.Name = "Guard Room";
            bool defeatedMobs  = Convert.ToBoolean(LocationHandler.GetLocationStateValue(Banken.LOCATION_STATE_KEY, BankenInconspicousCave.GUARD_ROOM_MOBS_ONE));
            bool defeatedMobs2 = Convert.ToBoolean(LocationHandler.GetLocationStateValue(Banken.LOCATION_STATE_KEY, BankenInconspicousCave.GUARD_ROOM_MOBS_TWO));

            if (!defeatedMobs)
            {
                returnData.Description = "The guard room is rather cramped, but that doesn't seem to be much of a bother to the necromancers within.";

                List <LocationAction> locationActions = new List <LocationAction>();
                List <Mob>            mobs            = new List <Mob>();
                mobs.Add(new NecromancerEliteGuard());
                mobs.Add(new NecromancerEliteGuard());
                mobs.Add(new NecromancerEliteGuard());
                mobs.Add(new NecromancerEliteGuard());
                CombatAction combatAction = new CombatAction("Necromancer Elite Guards", mobs, "You move to engage the deadly Necromancer Elite Guards", "As you kill the last necromancer, two re-animated statues burst the door and charge at you head on");
                combatAction.PostCombat += GuardRoomMobsOne;
                locationActions.Add(combatAction);
                returnData.Actions = locationActions;
            }
            if (defeatedMobs && !defeatedMobs2)
            {
                returnData.Description = "The guard room is rather cramped, the re-animated statues are barreling at you.";

                List <LocationAction> locationActions = new List <LocationAction>();
                List <Mob>            mobs            = new List <Mob>();
                mobs.Add(new ReAnimatedStatue());
                mobs.Add(new ReAnimatedStatue());
                CombatAction combatAction = new CombatAction("Re-Animated Statues", mobs);
                combatAction.PostCombat += GuardRoomMobsTwo;
                locationActions.Add(combatAction);
                returnData.Actions = locationActions;
            }
            else
            {
                returnData.Description = "The guard room is rather cramped, now also full of dead bodies and crumbled stone.";
            }

            //Adjacent Locations
            Dictionary <string, LocationDefinition> adjacentLocationDefintions = new Dictionary <string, LocationDefinition>();

            LocationDefinition locationDefinition = BankenInconspicousCave.GetTownInstance().GetPassageWayDefinition();

            adjacentLocationDefintions.Add(locationDefinition.LocationKey, locationDefinition);

            if (defeatedMobs && defeatedMobs2)
            {
                locationDefinition = BankenInconspicousCave.GetTownInstance().GetStorageRoomDefinition();
                adjacentLocationDefintions.Add(locationDefinition.LocationKey, locationDefinition);

                locationDefinition = BankenInconspicousCave.GetTownInstance().GetDimilyLitHallwayDefinition();
                adjacentLocationDefintions.Add(locationDefinition.LocationKey, locationDefinition);
            }

            returnData.AdjacentLocationDefinitions = adjacentLocationDefintions;

            return(returnData);
        }
Example #21
0
        /// <summary>
        /// Parses a command message and invokes a callback function delegate for status reporting
        /// </summary>
        /// <param name="msg">list of messages to parse</param>
        /// <param name="SendResponse">Callback taking a string as parameter to report return values back to sender</param>
        /// <param name="service">Service class for invoking application exit</param>
        public static void Parse(List <string> msg, Action <string> SendResponse, Service service)
        {
            AdmConfigBuilder builder = AdmConfigBuilder.Instance();
            RuntimeConfig    rtc     = RuntimeConfig.Instance();

            msg.ForEach(message =>
            {
                switch (message)
                {
                case Command.Switch:
                    Logger.Info("signal received: time based theme switch");
                    ThemeManager.TimedSwitch(builder);
                    SendResponse(Response.Ok);
                    break;

                case Command.Swap:
                    Logger.Info("signal received: swap themes");
                    if (RegistryHandler.AppsUseLightTheme())
                    {
                        ThemeManager.SwitchTheme(builder.Config, Theme.Dark);
                    }
                    else
                    {
                        ThemeManager.SwitchTheme(builder.Config, Theme.Light);
                    }
                    SendResponse(Response.Ok);
                    break;

                case Command.AddAutostart:
                    Logger.Info("signal received: adding service to autostart");
                    bool regOk;
                    bool taskOk;
                    if (builder.Config.Tunable.UseLogonTask)
                    {
                        regOk  = RegistryHandler.RemoveAutoStart();
                        taskOk = TaskSchdHandler.CreateLogonTask();
                    }
                    else
                    {
                        taskOk = TaskSchdHandler.RemoveLogonTask();
                        regOk  = RegistryHandler.AddAutoStart();
                    }
                    if (regOk && taskOk)
                    {
                        SendResponse(Response.Ok);
                    }
                    else
                    {
                        SendResponse(Response.Err);
                    }
                    break;

                case Command.RemoveAutostart:
                    Logger.Info("signal received: removing service from autostart");
                    bool ok;
                    if (builder.Config.Tunable.UseLogonTask)
                    {
                        ok = TaskSchdHandler.RemoveLogonTask();
                    }
                    else
                    {
                        ok = RegistryHandler.RemoveAutoStart();
                    }
                    if (ok)
                    {
                        SendResponse(Response.Ok);
                    }
                    else
                    {
                        SendResponse(Response.Err);
                    }
                    break;

                case Command.Location:
                    Logger.Info("signal received: request location update");
                    Task <bool> geoTask = Task.Run(() => LocationHandler.UpdateGeoposition(AdmConfigBuilder.Instance()));
                    geoTask.Wait();
                    var result = geoTask.Result;
                    if (result)
                    {
                        SendResponse(Response.Ok);
                    }
                    else
                    {
                        SendResponse(Response.NoLocAccess);
                    }
                    break;

                case Command.UpdateConfig:
                    Logger.Info("signal received: updating configuration files");
                    try
                    {
                        AdmConfigBuilder.Instance().Load();
                        AdmConfigBuilder.Instance().LoadLocationData();
                        SendResponse(Response.Ok);
                    }
                    catch (Exception e)
                    {
                        Logger.Error(e, "could not read config file");
                        SendResponse(Response.Err);
                    }
                    break;

                case Command.Update:
                    Logger.Info("signal received: checking for update");
                    SendResponse(UpdateHandler.CheckNewVersion());
                    break;

                case Command.Shutdown:
                    Logger.Info("signal received, exiting");
                    SendResponse(Response.Ok);
                    service.Exit(null, null);
                    break;

                case Command.TestError:
                    Logger.Info("signal received: test error");
                    SendResponse(Response.Err);
                    break;

                case Command.Alive:
                    Logger.Info("signal received: request for running status");
                    SendResponse(Response.Ok);
                    break;

                case Command.Light:
                    Logger.Info("signal received: force light theme");
                    rtc.ForcedTheme = Theme.Light;
                    ThemeManager.SwitchTheme(builder.Config, Theme.Light);
                    SendResponse(Response.Ok);
                    break;

                case Command.Dark:
                    Logger.Info("signal received: force dark theme");
                    rtc.ForcedTheme = Theme.Dark;
                    ThemeManager.SwitchTheme(builder.Config, Theme.Dark);
                    SendResponse(Response.Ok);
                    break;

                case Command.NoForce:
                    Logger.Info("signal received: resetting forced modes");
                    rtc.ForcedTheme = Theme.Undefined;
                    ThemeManager.TimedSwitch(builder);
                    SendResponse(Response.Ok);
                    break;

                default:
                    Logger.Debug("unknown message received");
                    SendResponse(Response.Err);
                    break;
                }
            });
        }
Example #22
0
        public Location LoadSecretTomb()
        {
            Location returnData;

            returnData      = new Location();
            returnData.Name = "Secret Tomb";
            bool defeatedMobs   = Convert.ToBoolean(LocationHandler.GetLocationStateValue(BeachTower.LOCATION_STATE_KEY, BeachTowerCatacomb.DEFEAT_NECROMANCER));
            bool confrontBandit = Convert.ToBoolean(LocationHandler.GetLocationStateValue(BeachTower.LOCATION_STATE_KEY, BeachTowerCatacomb.CONFRONT_MASKED_BANDIT));
            bool openChest      = Convert.ToBoolean(LocationHandler.GetLocationStateValue(BeachTower.LOCATION_STATE_KEY, BeachTowerCatacomb.TREASURE_CHEST));

            string before = "Welcome, " + GameState.Hero.Identifier + ". What a welcome surprise to see you here. I assume you've tracked this fool before me. He obviously failed at his job. No matter, I'll finish you myself.";
            string after  = "The Necromancer gasp for air as you kneel over him, a dagger you found on the floor lodged in his chest. You can see into his hood and red eyes are staring back at you. As he takes his last breath a major burst of energy releases from his body, knocking you back onto the ground. You slowly stand up, hoping that broke the barrier to the Mayor's House. Either way, you need to report to the Captain of the Guard.";

            //Add action to confront masked bandit
            //After confronting the masked bandit a necromancer steps out from the shadows and kills the masked bandit
            //Fight the necromancer
            //Killing the necromancer releases the shield on the mayor's house stopping you from getting back.
            if (!confrontBandit)
            {
                returnData.Description = "A large room with a tomb against the back wall. There is a large mural painting behind the tomb depicting what appears to be a person of royalty. This tomb must belong to a very important person. The masked bandit is kneeling before the tomb, his back turned to you";
                List <LocationAction> locationActions = new List <LocationAction>();
                TakeItemAction        itemAction      = new TakeItemAction("Confront", "Masked Bandit", "You walk up behind the Masked Bandit. He stands upm turning around to face you. Just as he's about to say something his body is crushed by an invisible force and crumples to the ground, dead. Out from a darkened corner steps a necromancer, a dark hood covering his face. You feel trepidation as evil pours off his body like a waterfall.");
                itemAction.PostItem += ConfrontMaskedBandit;
                locationActions.Add(itemAction);
                returnData.Actions = locationActions;
            }

            else if (!defeatedMobs)
            {
                returnData.Description = "A large room with a tomb against the back wall. There is a large mural painting behind the tomb depicting what appears to be a person of royalty. This tomb must belong to a very important person. The masked bandit's body lays crumpled on the floor as the necromancer stands over it, glaring menacingly at you.";

                List <LocationAction> locationActions = new List <LocationAction>();
                List <Mob>            mobs            = new List <Mob>();
                mobs.Add(new CatacombsNecromancer());
                CombatAction combatAction = new CombatAction("Catacombs Necromancer", mobs, before, after);
                combatAction.PostCombat += LeftTombMobs;
                locationActions.Add(combatAction);
                returnData.Actions = locationActions;
            }

            else if (defeatedMobs && !openChest)
            {
                returnData.Description = "A large room with a tomb against the back wall. There is a large mural painting behind the tomb depicting what appears to be a person of royalty. This tomb must belong to a very important person. There is a treasure chest behind the tomb.";
                List <LocationAction> locationActions = new List <LocationAction>();
                TreasureChestAction   itemAction      = new TreasureChestAction(5);
                locationActions.Add(itemAction);
                itemAction.PostItem += TreasureChest;
                returnData.Actions   = locationActions;
            }
            else
            {
                returnData.Description = "A large room with a tomb against the back wall. There is a large mural painting behind the tomb depicting what appears to be a person of royalty. This tomb must belong to a very important person.";
            }


            //Adjacent Locations
            Dictionary <string, LocationDefinition> adjacentLocationDefintions = new Dictionary <string, LocationDefinition>();

            //Town Center
            LocationDefinition locationDefinition = BeachTowerCatacomb.GetTownInstance().GetSecretPassageWayDefinition();

            adjacentLocationDefintions.Add(locationDefinition.LocationKey, locationDefinition);


            //Figure out where you want the player to go after this
            //Maybe both
            if (openChest)
            {
                locationDefinition = BeachTowerCapturedVillage.GetTownInstance().GetEntranceDefinition();
                adjacentLocationDefintions.Add(locationDefinition.LocationKey, locationDefinition);

                locationDefinition = BeachTower.GetTownInstance().GetTownCenterDefinition();
                adjacentLocationDefintions.Add(locationDefinition.LocationKey, locationDefinition);
            }


            returnData.AdjacentLocationDefinitions = adjacentLocationDefintions;

            return(returnData);
        }
        public Location LoadLeaderTent()
        {
            Location returnData;

            returnData      = new Location();
            returnData.Name = "Necromancer Leader's Tent";
            bool defeatedNecros = Convert.ToBoolean(LocationHandler.GetLocationStateValue(Ankou.LOCATION_STATE_KEY, AnkouNecromancerCamp.DEFEATED_NECRO_LEADER));
            bool openedChest    = Convert.ToBoolean(LocationHandler.GetLocationStateValue(Ankou.LOCATION_STATE_KEY, AnkouNecromancerCamp.OPENED_CHEST));
            bool takeJournal    = Convert.ToBoolean(LocationHandler.GetLocationStateValue(Ankou.LOCATION_STATE_KEY, AnkouNecromancerCamp.TOOK_JOURNAL));

            if (!defeatedNecros)
            {
                returnData.Description = "A large tent, full of many dark items. The necromancer leader sits at his desk, twirling a long, sharp knife in his hand.";

                //Actions
                List <LocationAction> locationActions = new List <LocationAction>();

                List <Mob> necro = new List <Mob>();
                necro.Add(new AnkouNecroLeader());
                CombatAction combatAction = new CombatAction("Necromancer Leader", necro);
                combatAction.PostCombat += NecroLeader;

                locationActions.Add(combatAction);

                returnData.Actions = locationActions;
            }
            if (defeatedNecros)
            {
                if (!openedChest)
                {
                    if (!takeJournal)
                    {
                        returnData.Description = "A large tent, full of many dark items. The necromancer leader is dead on the ground. There is a journal on his desk and an unopened treasure chest.";
                    }
                    else
                    {
                        returnData.Description = "A large tent, full of many dark items. The necromancer leader is dead on the ground. There is an unopened treasure chest.";
                    }

                    List <LocationAction> locationActions = new List <LocationAction>();
                    TreasureChestAction   itemAction      = new TreasureChestAction(3);
                    locationActions.Add(itemAction);
                    itemAction.PostItem += Chest;
                    returnData.Actions   = locationActions;
                }
                if (openedChest && takeJournal)
                {
                    returnData.Description = "A large tent, full of many dark items. The necromancer leader is dead on the ground. There is a opened treasure chest.";
                }
                if (!takeJournal && openedChest)
                {
                    returnData.Description = "A large tent, full of many dark items. The necromancer leader is dead on the ground. There is a journal on his desk and an opened treasure chest.";
                    List <LocationAction> locationActions = new List <LocationAction>();
                    TakeItemAction        letterAction    = new TakeItemAction("Necromancer Leader's Journal");
                    letterAction.PostItem += LeaderJournal;
                    locationActions.Add(letterAction);
                    returnData.Actions = locationActions;
                }
            }

            // Adjacent Locations
            Dictionary <string, LocationDefinition> adjacentLocationDefinitions = new Dictionary <string, LocationDefinition>();

            // Town Center
            LocationDefinition locationDefinition = AnkouNecromancerCamp.GetTownInstance().GetLargeClearingDefinition();

            adjacentLocationDefinitions.Add(locationDefinition.LocationKey, locationDefinition);

            if (defeatedNecros && takeJournal)
            {
                locationDefinition = Ankou.GetTownInstance().GetTownCenterDefinition();
                adjacentLocationDefinitions.Add(locationDefinition.LocationKey, locationDefinition);
            }

            returnData.AdjacentLocationDefinitions = adjacentLocationDefinitions;

            return(returnData);
        }
Example #24
0
 public void RegisterLocationHandler(LocationHandler handler)
 {
     LocationHandlers.Add(handler);
 }
Example #25
0
 /// <summary>
 /// Keep track of cumulative transform adjustment, and pass on to client adjustment handler (if any).
 /// </summary>
 /// <remarks>
 /// See <see cref="IAttachmentPoint.ObjectAdjustment"/> and <see cref="AdjustLocationDelegate"/>
 /// </remarks>
 /// <param name="adjustment"></param>
 public void HandlePoseAdjustment(Pose adjustment)
 {
     ObjectPosition   = adjustment.Multiply(ObjectPosition);
     ObjectAdjustment = ObjectAdjustment.Multiply(adjustment);
     LocationHandler?.Invoke(adjustment);
 }
        public Location LoadEnclosedClearing()
        {
            Location returnData;
            bool     defeatedSkeletonKing = Convert.ToBoolean(LocationHandler.GetLocationStateValue(Watertown.LOCATION_STATE_KEY, WatertownForestAfterSewer.DEFEATED_POSSESED_GUARD));
            bool     openedChest          = Convert.ToBoolean(LocationHandler.GetLocationStateValue(Watertown.LOCATION_STATE_KEY, WatertownForestAfterSewer.OPENED_BOSS_CHEST_ENCLOSED_CLEARING));

            returnData      = new Location();
            returnData.Name = "Enclosed Clearing";

            //Actions

            if (defeatedSkeletonKing == false)
            {
                returnData.Description = "A small enclosed clearing. A cabin sits in the back of it, with a small walkway leading up to its front door. The walk way is lined in skulls and candles. A possesed village guard blocks the door.";
                // Location Actions
                List <LocationAction> locationActions = new List <LocationAction>();

                List <Mob> guard = new List <Mob>();
                guard.Add(new PossesedGuardBoss());
                CombatAction combatAction = new CombatAction("Possesed Guard", guard);
                combatAction.PostCombat += GuardBossBattle;

                locationActions.Add(combatAction);

                returnData.Actions = locationActions;
            }
            if (defeatedSkeletonKing)
            {
                if (openedChest == false)
                {
                    returnData.Description = "A small enclosed clearing. A cabin sits in the back of it, with a small walkway leading up to its front door. The walk way is lined in skulls and candles. The possesed guard lays to rest to the side of the path. His unopened chest appears off to the side.";
                    List <LocationAction> locationActions = new List <LocationAction>();
                    TreasureChestAction   itemAction      = new TreasureChestAction(3);
                    locationActions.Add(itemAction);
                    itemAction.PostItem += GuardChest;
                    returnData.Actions   = locationActions;
                }
                else if (openedChest)
                {
                    returnData.Description = "A small enclosed clearing. A cabin sits in the back of it, with a small walkway leading up to its front door. The walk way is lined in skulls and candles. The possesed guard lays to rest to the side of the path. His opened chest sits off to the side.";
                }
            }

            // Adjacent Locations
            Dictionary <string, LocationDefinition> adjacentLocationDefinitions = new Dictionary <string, LocationDefinition>();

            // Town Center
            LocationDefinition locationDefinition = WatertownForestAfterSewer.GetTownInstance().GetMeetingGroundsDefinition();

            adjacentLocationDefinitions.Add(locationDefinition.LocationKey, locationDefinition);

            if (defeatedSkeletonKing)
            {
                locationDefinition = WatertownForestCabin.GetTownInstance().GetEntranceDefinition();
                adjacentLocationDefinitions.Add(locationDefinition.LocationKey, locationDefinition);

                locationDefinition = Watertown.GetTownInstance().GetTownCenterDefinition();
                adjacentLocationDefinitions.Add(locationDefinition.LocationKey, locationDefinition);
            }

            returnData.AdjacentLocationDefinitions = adjacentLocationDefinitions;

            return(returnData);
        }
Example #27
0
        public async Task <IActionResult> PostTraveling([FromBody] PassedGameData <int> passedData)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }
            DateTime now = DateTime.UtcNow;

            if (passedData.UserToken == null || passedData.ActionToken == null)
            {
                return(BadRequest(new DataError("securityErr", "No authorization controll.")));
            }
            UserToken dbtoken = Security.CheckUserToken(this._context, passedData.UserToken);

            if (dbtoken == null)
            {
                return(BadRequest(new DataError("securityErr", "Your data has probably been stolen or modified manually. We suggest password's change.")));
            }
            else
            {
                if (!dbtoken.IsTimeValid(now))
                {
                    return(BadRequest(new DataError("timeoutErr", "You have been too long inactive. Relogin is required.")));
                }
                else
                {
                    dbtoken.UpdateToken(now);
                }
            }
            Heros       hero      = _context.Heros.FirstOrDefault(e => e.Name == passedData.ActionToken.HeroName);
            ActionToken gametoken = Security.CheckActionToken(_context, passedData.ActionToken, hero.HeroId);

            if (gametoken == null)
            {
                return(BadRequest(new DataError("securityErr", "Your data has probably been stolen or modified manually. We suggest password's change.")));
            }
            else
            {
                if (!gametoken.IsTimeValid(now))
                {
                    return(BadRequest(new DataError("timeoutErr", "You have been too long inactive. Relogin is required.")));
                }
                else
                {
                    gametoken.UpdateToken(now);
                }
            }
            // if can go there
            if (hero.Status == 0)
            {
                var location = _context.HerosLocations.FirstOrDefault(e => (e.HeroId == hero.HeroId) && (e.LocationIdentifier == hero.CurrentLocation));
                if (location == null)
                {
                    return(BadRequest(new DataError("LocationErr", "Location is not available.")));
                }
                var descr = _context.LocationsDb.FirstOrDefault(e => e.LocationIdentifier == location.LocationIdentifier);
                if (descr == null)
                {
                    return(BadRequest(new DataError("LocationErr", "LocationData is not available.")));
                }
                try
                {
                    // TODO check location type
                    AstarResult astar       = null;
                    int         TravelScale = 0;
                    int         Start       = -1;
                    string      StartName   = "";
                    int         Target      = -1;
                    string      TargetName  = "";

                    int LocationType = descr.LocationGlobalType;
                    if (LocationType != 2)
                    {
                        LocationDescription description = JsonConvert.DeserializeObject <LocationDescription>(descr.Sketch);
                        LocationState       state       = JsonConvert.DeserializeObject <LocationState>(location.Description);
                        description.LocationGlobalType = descr.LocationGlobalType;

                        int GlobalNodeID = description.GlobalMainNodeID(passedData.Data, state);
                        if (GlobalNodeID == state.CurrentLocation)
                        {
                            throw new Exception("Moving nowhere");
                        }
                        astar       = LocationHandler.DistanceToMove(description, state, passedData.Data);
                        TravelScale = description.TravelScale;
                        Start       = state.CurrentLocation;
                        StartName   = description.MainNodes.First(e => e.NodeID == state.CurrentLocation).Name;
                        Target      = GlobalNodeID;
                        TargetName  = description.MainNodes.First(e => e.NodeID == GlobalNodeID).Name;
                    }
                    else
                    {
                        InstanceDescription description = JsonConvert.DeserializeObject <InstanceDescription>(descr.Sketch);
                        InstanceState       state       = JsonConvert.DeserializeObject <InstanceState>(location.Description);
                        description.LocationGlobalType = descr.LocationGlobalType;

                        int GlobalNodeID = description.GlobalMainNodeID(passedData.Data, state);
                        if (GlobalNodeID == state.CurrentLocation)
                        {
                            throw new Exception("Moving nowhere");
                        }
                        astar       = LocationHandler.DistanceToMove(description, state, passedData.Data);
                        TravelScale = description.TravelScale;
                        Start       = state.CurrentLocation;
                        Target      = GlobalNodeID;
                        TargetName  = passedData.Data.ToString();
                    }

                    double TravelTime = LocationHandler.TimeTravel(astar.Distance, TravelScale, 18 * hero.VelocityFactor);

                    Traveling travel = new Traveling()
                    {
                        EndTime     = now.AddSeconds(TravelTime),
                        HeroId      = hero.HeroId,
                        IsReverse   = false,
                        ReverseTime = null,
                        Start       = Start,
                        StartName   = StartName,
                        StartTime   = now,
                        Target      = Target,
                        TargetName  = TargetName,
                    };
                    hero.Status = 1;
                    _context.Traveling.Add(travel);
                    TravelResult travelResult = travel.GenTravelResult(now);
                    try
                    {
                        await _context.SaveChangesAsync();

                        return(Ok(new { success = true, travel = travelResult }));
                    }
                    catch (DbUpdateException)
                    {
                        return(BadRequest(new DataError("databaseErr", "Failed to remember travel.")));
                    }
                }
                catch
                {
                    return(BadRequest(new DataError("LocationErr", "Location is not available.")));
                }
            }
            else
            {
                return(BadRequest(new DataError("LocationErr", "Hero is not able to travel.")));
            }
        }
Example #28
0
        public Location LoadNecroOfficerTent()
        {
            Location returnData;

            returnData      = new Location();
            returnData.Name = "Necromancer Intelligence Officer's Tent";
            bool   defeatedMobs             = Convert.ToBoolean(LocationHandler.GetLocationStateValue(BeachTower.LOCATION_STATE_KEY, BeachTowerHiddenCamp.NECRO_OFFICER));
            bool   openedChest              = Convert.ToBoolean(LocationHandler.GetLocationStateValue(BeachTower.LOCATION_STATE_KEY, BeachTowerHiddenCamp.NECRO_OFFICER_CHEST));
            bool   tookDocument             = Convert.ToBoolean(LocationHandler.GetLocationStateValue(BeachTower.LOCATION_STATE_KEY, BeachTowerHiddenCamp.DOCUMENT));
            string NecroOfficerSpeachBefore = GameState.Hero.Identifier + ", welcome to my humble adobe. You came here for information? How unfortunate. I will never reveal anything.";
            string NecroOfficerSpeachAfter  = "You kneel down over the Intelligence Officer's body and search him for any documents. You find a folded document that Mike might find interesting.";

            if (!defeatedMobs)
            {
                returnData.Description = "A large over the top tent. Inside of it there is a necromancer dressed in very expensive robes. The room is decorated with the most expensive pieces of furniture money can buy on this side of Ankou.";

                List <LocationAction> locationActions = new List <LocationAction>();
                List <Mob>            mobs            = new List <Mob>();
                mobs.Add(new NecroIntelligenceOfficer());

                CombatAction combatAction = new CombatAction("Necromancer Intelligence Officer", mobs, NecroOfficerSpeachBefore, NecroOfficerSpeachAfter);
                combatAction.PostCombat += NecroIntelligenceOfficer;
                locationActions.Add(combatAction);
                returnData.Actions = locationActions;
            }
            else
            {
                returnData.Description = "A large over the top tent. Inside of it there is a necromancer dressed in very expensive robes laying dead on the ground. The room is decorated with the most expensive pieces of furniture money can buy on this side of Ankou.";
            }

            if (defeatedMobs && !openedChest)
            {
                List <LocationAction> locationActions = new List <LocationAction>();
                TreasureChestAction   itemAction      = new TreasureChestAction(5);
                locationActions.Add(itemAction);
                itemAction.PostItem += NecroIntelligenceOfficerChest;
                returnData.Actions   = locationActions;
            }

            if (defeatedMobs && !tookDocument)
            {
                List <LocationAction> locationActions = new List <LocationAction>();
                TakeItemAction        itemAction      = new TakeItemAction("Document");
                locationActions.Add(itemAction);
                itemAction.PostItem += NecroIntelligenceOfficerDocument;
                returnData.Actions   = locationActions;
            }


            //Adjacent Locations
            Dictionary <string, LocationDefinition> adjacentLocationDefintions = new Dictionary <string, LocationDefinition>();

            //Town Center
            LocationDefinition locationDefinition = BeachTowerHiddenCamp.GetTownInstance().GetLargeClearingDefinition();

            adjacentLocationDefintions.Add(locationDefinition.LocationKey, locationDefinition);

            if (defeatedMobs)
            {
                locationDefinition = BeachTower.GetTownInstance().GetTownCenterDefinition();
                adjacentLocationDefintions.Add(locationDefinition.LocationKey, locationDefinition);
            }

            returnData.AdjacentLocationDefinitions = adjacentLocationDefintions;

            return(returnData);
        }
Example #29
0
        public Location LoadUpstairsHallway()
        {
            Location returnData;

            returnData      = new Location();
            returnData.Name = "Upstairs Hallway";
            bool defeatedMobs = Convert.ToBoolean(LocationHandler.GetLocationStateValue(BeachTower.LOCATION_STATE_KEY, BeachTowerMayorHouse.UPSTAIRS_HALLWAY_MOBS));
            bool haveKey      = Convert.ToBoolean(LocationHandler.GetLocationStateValue(BeachTower.LOCATION_STATE_KEY, BeachTowerMayorHouse.STOLEN_KEY_TO_MASTER_BEDROOM));
            bool doorUnlocked = Convert.ToBoolean(LocationHandler.GetLocationStateValue(BeachTower.LOCATION_STATE_KEY, BeachTowerMayorHouse.STOLEN_KEY_USED));

            if (!defeatedMobs)
            {
                returnData.Description = "A large hallway with only two rooms connected to it. There are some bandits standing guard at both doors.";

                List <LocationAction> locationActions = new List <LocationAction>();
                List <Mob>            mobs            = new List <Mob>();
                mobs.Add(new Bandit());
                mobs.Add(new Bandit());
                mobs.Add(new Bandit());
                mobs.Add(new Bandit());
                CombatAction combatAction = new CombatAction("Bandits", mobs);
                combatAction.PostCombat += HallwayMobs;
                locationActions.Add(combatAction);
                returnData.Actions = locationActions;
            }

            //Add an action to try and open the Master Bedroom Door for as long as player doesn't have the stolen key
            //i.e. if(!stolenKey) { //Open Door }
            //Once the player has the stolen key they will actually have to unlock it with an action
            //i.e. if(stolenKey && !stolenKeyUsed) { //Unlock Door }
            //Once the player unlocks the door an adjacent location for the Master Bedroom will appear

            else if (!haveKey && defeatedMobs)
            {
                returnData.Description = "A large hallway with only two rooms connected to it.";
                List <LocationAction> locationActions = new List <LocationAction>();
                TakeItemAction        itemAction      = new TakeItemAction("Open", "Door to Master Bedroom", "You try to open the door. It's locked. Maybe you should go find a key.");
                itemAction.PostItem += TryDoor;
                locationActions.Add(itemAction);
                returnData.Actions = locationActions;
            }

            else if (haveKey && defeatedMobs)
            {
                returnData.Description = "A large hallway with only two rooms connected to it.";
                List <LocationAction> locationActions = new List <LocationAction>();
                TakeItemAction        itemAction      = new TakeItemAction("Unlock", "Door to Master Bedroom", "You unlock the door to the master bedroom. You may now enter.");
                itemAction.PostItem += UnlockDoor;
                locationActions.Add(itemAction);
                returnData.Actions = locationActions;
            }

            else
            {
                returnData.Description = "A large hallway with only two rooms connected to it. The master bedroom is now unlocked.";
            }

            //Adjacent Locations
            Dictionary <string, LocationDefinition> adjacentLocationDefintions = new Dictionary <string, LocationDefinition>();

            //Town Center
            LocationDefinition locationDefinition = BeachTowerMayorHouse.GetTownInstance().GetStairsDefinition();

            adjacentLocationDefintions.Add(locationDefinition.LocationKey, locationDefinition);

            locationDefinition = BeachTowerMayorHouse.GetTownInstance().GetGuestBedroomDefinition();
            adjacentLocationDefintions.Add(locationDefinition.LocationKey, locationDefinition);

            if (defeatedMobs && doorUnlocked)
            {
                locationDefinition = BeachTowerMayorHouse.GetTownInstance().GetMasterBedroomDefinition();
                adjacentLocationDefintions.Add(locationDefinition.LocationKey, locationDefinition);
            }

            returnData.AdjacentLocationDefinitions = adjacentLocationDefintions;

            return(returnData);
        }
Example #30
0
        // set starttime based on user location
        public async void ActivateLocationMode()
        {
            //ui
            StackPanelTimePicker.Visibility   = Visibility.Collapsed;
            TextBlockDark.Visibility          = Visibility.Collapsed;
            TextBlockLight.Visibility         = Visibility.Collapsed;
            StackPanelLocationTime.Visibility = Visibility.Visible;
            SetOffsetVisibility(Visibility.Visible);
            locationBlock.Visibility = Visibility.Visible;
            locationBlock.Text       = Properties.Resources.msgSearchLoc;//Searching your location...
            userFeedback.Text        = Properties.Resources.msgSearchLoc;

            if (!init)
            {
                try
                {
                    builder.Save();
                }
                catch (Exception ex)
                {
                    ShowErrorMessage(ex);
                }
            }

            int  timeout = 2;
            bool loaded  = false;

            for (int i = 0; i < timeout; i++)
            {
                if (builder.LocationData.LastUpdate == DateTime.MinValue)
                {
                    try
                    {
                        var result = await messagingClient.SendMessageAndGetReplyAsync(Command.Location);

                        if (result == Response.NoLocAccess)
                        {
                            NoLocationAccess();
                            break;
                        }
                        builder.LoadLocationData();
                    }
                    catch (Exception ex)
                    {
                        ShowErrorMessage(ex);
                        loaded = true;
                        break;
                    }
                    await Task.Delay(1000);
                }
                else
                {
                    loaded = true;
                    break;
                }
            }

            LocationHandler locationHandler = new LocationHandler();
            var             accesStatus     = await Geolocator.RequestAccessAsync();

            switch (accesStatus)
            {
            case GeolocationAccessStatus.Allowed:
                //locate user + get sunrise & sunset times
                locationBlock.Text = Properties.Resources.lblCity + ": " + await locationHandler.GetCityName();

                break;

            case GeolocationAccessStatus.Denied:
                NoLocationAccess();
                loaded = false;
                break;

            case GeolocationAccessStatus.Unspecified:
                NoLocationAccess();
                loaded = false;
                break;
            }

            if (!loaded)
            {
                ShowErrorMessage(new TimeoutException("waiting for location data timed out"));
            }

            UpdateSuntimes();

            // ui controls
            lightStartBox.IsEnabled        = false;
            LightStartMinutesBox.IsEnabled = false;
            darkStartBox.IsEnabled         = false;
            DarkStartMinutesBox.IsEnabled  = false;
            userFeedback.Text = Properties.Resources.msgChangesSaved;

            return;
        }
Example #31
0
        public Location LoadGuestBedroom()
        {
            Location returnData;

            returnData      = new Location();
            returnData.Name = "Guest Bedroom";
            bool defeatedMobs  = Convert.ToBoolean(LocationHandler.GetLocationStateValue(BeachTower.LOCATION_STATE_KEY, BeachTowerMayorHouse.GUEST_BEDROOM_MOBS));
            bool freeVillagers = Convert.ToBoolean(LocationHandler.GetLocationStateValue(BeachTower.LOCATION_STATE_KEY, BeachTowerMayorHouse.CAPTURED_VILLAGERS_GUEST_BEDROOM));
            bool tookKey       = Convert.ToBoolean(LocationHandler.GetLocationStateValue(BeachTower.LOCATION_STATE_KEY, BeachTowerMayorHouse.STOLEN_KEY_TO_MASTER_BEDROOM));

            if (!defeatedMobs)
            {
                returnData.Description = "A rather simple bedroom. There is a bed in a corner with a nightstand next to it. There is a bookshelf on the wall next to the window. The bookshelf has a mix of books on this part of Asku and some fictional books. There are several villagers tied up and shoved in the corner next to the bookshelf.";

                List <LocationAction> locationActions = new List <LocationAction>();
                List <Mob>            mobs            = new List <Mob>();
                mobs.Add(new Bandit());
                mobs.Add(new Bandit());
                mobs.Add(new Bandit());
                mobs.Add(new Bandit());
                CombatAction combatAction = new CombatAction("Bandits", mobs);
                combatAction.PostCombat += GuestBedroomMobs;
                locationActions.Add(combatAction);
                returnData.Actions = locationActions;
            }

            //After defeating the mobs there will be an action to take a stolen key that you see on a bandit's body
            //Remember action to free prisoners

            else if (defeatedMobs && !freeVillagers)
            {
                returnData.Description = "A rather simple bedroom. There is a bed in a corner with a nightstand next to it. There is a bookshelf on the wall next to the window. The bookshelf has a mix of books on this part of Asku and some fictional books. There are several villagers tied up and shoved in the corner next to the bookshelf.";
                List <LocationAction> locationActions = new List <LocationAction>();
                TakeItemAction        itemAction      = new TakeItemAction("Free", "Captured Villagers", "You free the captured villagers. You inform them to head to the Beach Tower to recieve medical attention. You let them know that soldiers are stationed throughout the city helping with the clean up and that they will help escort them. As one of the villagers rushes to leave the room, she trips over a dead bandit's body, knocking it over and revealing a key tied to his belt.");
                itemAction.PostItem += TryDoor;
                locationActions.Add(itemAction);
                returnData.Actions = locationActions;
            }

            else if (defeatedMobs && freeVillagers && !tookKey)
            {
                returnData.Description = "A rather simple bedroom. There is a bed in a corner with a nightstand next to it. There is a bookshelf on the wall next to the window. The bookshelf has a mix of books on this part of Asku and some fictional books. One of the dead bandit's has a key tied to his belt.";
                List <LocationAction> locationActions = new List <LocationAction>();
                TakeItemAction        itemAction      = new TakeItemAction("Take", "Key from the dead Bandit", "You cut the piece of leather tying the key to the bandit's belt and put it in your pocket. This key might be useful later.");
                itemAction.PostItem += TakeKey;
                locationActions.Add(itemAction);
                returnData.Actions = locationActions;
            }
            else
            {
                returnData.Description = "A rather simple bedroom. There is a bed in a corner with a nightstand next to it. There is a bookshelf on the wall next to the window. The bookshelf has a mix of books on this part of Asku and some fictional books.";
            }

            //Adjacent Locations
            Dictionary <string, LocationDefinition> adjacentLocationDefintions = new Dictionary <string, LocationDefinition>();

            //Town Center
            LocationDefinition locationDefinition = BeachTowerMayorHouse.GetTownInstance().GetUpstairsHallwayDefinition();

            adjacentLocationDefintions.Add(locationDefinition.LocationKey, locationDefinition);

            returnData.AdjacentLocationDefinitions = adjacentLocationDefintions;

            return(returnData);
        }
Example #32
0
 public override void Initialize(Game1 gameReference, Player playerReference, Sadako sadakoReference, InventoryHandler inventoryHandler, LocationHandler locationHandler, EventHandler eventHandler, RoomDatabase roomDatabase, TileDatabase tileDatabase)
 {
     base.Initialize(gameReference, playerReference, sadakoReference, inventoryHandler, locationHandler, eventHandler, roomDatabase, tileDatabase);
 }
        public Location LoadAbandonedFortressGates()
        {
            Location returnData;

            returnData      = new Location();
            returnData.Name = "Abandoned Fortress Gates";
            bool           defeatedMobs      = Convert.ToBoolean(LocationHandler.GetLocationStateValue(Banken.LOCATION_STATE_KEY, BankenForestWilderness.ABANDONED_FORTRESS_MOBS));
            bool           defeatedShadeLord = Convert.ToBoolean(LocationHandler.GetLocationStateValue(Banken.LOCATION_STATE_KEY, BankenForestWilderness.SHADE_LORD));
            bool           inspectGate       = Convert.ToBoolean(LocationHandler.GetLocationStateValue(Banken.LOCATION_STATE_KEY, BankenForestWilderness.INSPECT_GATE));
            bool           tookTreasure      = Convert.ToBoolean(LocationHandler.GetLocationStateValue(Banken.LOCATION_STATE_KEY, BankenForestWilderness.TREASURE));
            Accomplishment abandonedFortressAccomplishment = Banken.GetBankenAccomplishments().Find(x => x.Name.Contains("Abandoned Fortress"));
            bool           abandonedFortress = GameState.Hero.Accomplishments.Contains(abandonedFortressAccomplishment);
            string         before            = GameState.Hero.Identifier + ", you dare enter my domain? This fortress stands as a testement to my masters. The void shall claim you!";
            string         after             = "The shade lord cries out a piercing scream as it fades back into the void that spawned it.";
            string         action            = "Inspect";
            string         itemName          = "Gate";
            string         actionText        = "You inspect the gate. It seems to be sealed by very powerful dark magic. You'll have to go back to Banken and see if the rangers know of any mages that could help you unseal the gates. \nBefore you can turn back around to head back to town a Shade Lord materializes at the entrance of the gates and terror fills your heart.";

            //Once the player defeats the shades, have him/her try to open the gate
            //That will fail and a Shade Lord will appear.
            //The player will have to report back to Gilan after defeating the Shade Lord
            //Gilan will then tell the player that (s)he will have to find
            //some very power mages to help him/her blast open the gate

            List <LocationAction> locationActions = new List <LocationAction>();

            if (!defeatedMobs)
            {
                returnData.Description = "Just beyond the creek landing are the gates to an abandoned fortress. The gates appear sealed shut by some dark magic. A large group of shades hover before the gate to vanquish any that dare approach it.";

                List <Mob> mobs = new List <Mob>();
                mobs.Add(new Shade());
                mobs.Add(new Shade());
                mobs.Add(new Shade());
                mobs.Add(new Shade());
                mobs.Add(new Shade());
                mobs.Add(new Shade());
                mobs.Add(new Shade());
                mobs.Add(new Shade());
                mobs.Add(new Shade());
                mobs.Add(new Shade());
                CombatAction combatAction = new CombatAction("Shades", mobs);
                combatAction.PostCombat += AbandonedFortressMobs;
                locationActions.Add(combatAction);
                returnData.Actions = locationActions;
            }
            else if (!inspectGate)
            {
                returnData.Description = "Just beyond the creek landing are the gates to an abandoned fortress. The gates appear sealed shut by some dark magic.";
                TakeItemAction itemAction = new TakeItemAction(action, itemName, actionText);
                locationActions.Add(itemAction);
                itemAction.PostItem += GateResults;
                returnData.Actions   = locationActions;
            }
            else if (!defeatedShadeLord)
            {
                returnData.Description = "Just beyond the creek landing are the gates to an abandoned fortress. The gates appear sealed shut by some dark magic. A Shade Lord hovers before the gates, dark energy radiating from its body in waves.";

                List <Mob> mobs = new List <Mob>();
                mobs.Add(new ShadeLord());
                CombatAction combatAction = new CombatAction("Shade Lord", mobs, before, after);
                combatAction.PostCombat += ShadeLord;
                locationActions.Add(combatAction);
                returnData.Actions = locationActions;
            }
            else if (!tookTreasure)
            {
                returnData.Description = "Just beyond the creek landing are the gates to an abandoned fortress. The gates appear sealed shut by some dark magic. There is a treasure chest in front of the gates.";
                TreasureChestAction itemAction = new TreasureChestAction(5);
                locationActions.Add(itemAction);
                itemAction.PostItem += TreasureChest;
                returnData.Actions   = locationActions;
            }
            else if (!abandonedFortress)
            {
                returnData.Description = "Just beyond the creek landing are the gates to an abandoned fortress. The gates appear sealed shut by some dark magic.";
            }
            else
            {
                returnData.Description = "Just beyond the creek landing lay the crumpled gates of the Abandoned Fortress. THe gates have crumpled to dust. Whatever magic was sustaining them has imploded on itself.";
            }

            //Once the player gets the mages there will be an action to begin unsealing the gate and then the player can proceed into the "abandoned" fortress

            //Adjacent Locations
            Dictionary <string, LocationDefinition> adjacentLocationDefintions = new Dictionary <string, LocationDefinition>();

            //Town Center
            LocationDefinition locationDefinition = BankenForestWilderness.GetTownInstance().GetCreekLandingDefinition();

            adjacentLocationDefintions.Add(locationDefinition.LocationKey, locationDefinition);

            if (defeatedMobs && inspectGate && defeatedShadeLord)
            {
                locationDefinition = Banken.GetTownInstance().GetTownCenterDefinition();
                adjacentLocationDefintions.Add(locationDefinition.LocationKey, locationDefinition);
            }

            if (abandonedFortress)
            {
                locationDefinition = BankenAbandonedFortress.GetTownInstance().GetEntranceDefinition();
                adjacentLocationDefintions.Add(locationDefinition.LocationKey, locationDefinition);
            }

            returnData.AdjacentLocationDefinitions = adjacentLocationDefintions;

            return(returnData);
        }