コード例 #1
0
        private void BuildStageForHero(HeroSave currentHeroState)
        {
            throw new NotImplementedException();
            //if (GameState.Instance.HeroSave == null)
            //{
            //    GameState.Instance.HeroSave = currentHeroState;
            //    GameState.Instance.GameLevel = currentHeroState.CurrentStage;
            //}

            //// Has the game be initialised?
            //if (GameState.Instance.Game == null || GameState.Instance.Game.CurrentStage == null)
            //{
            //    GameState.Instance.Game = new Game(currentHeroState.CurrentStage, currentHeroState);
            //    if (GameState.Instance.Game.CurrentStage.IsDirty)
            //    {
            //        currentHeroState.CurrentStage = currentHeroState.CurrentStage;
            //        currentHeroState.Position = GameState.Instance.Game.Hero.Position;
            //        // Todo: find where this shoud have been set already
            //        if (GameState.Instance.Game.CurrentStage.LastHeroPosition == null)
            //        {
            //            GameState.Instance.Game.CurrentStage.LastHeroPosition = currentHeroState.Position;
            //        }

            //        Storage.Save();
            //    }
            //    GameState.Instance.Game.CurrentStage.SetTileExplored(false);
            //}
            //else
            //{
            //    throw new NotImplementedException();
            //    //// reset the current stage
            //    //GameState.Instance.game.CurrentStage = null;
            //    //GameState.Instance.Game.LoadLevel(GameState.Instance.GameLevel);
            //}
        }
コード例 #2
0
 private void LoadCurrentStageForHero(HeroSave currentHeroState)
 {
     if (!currentHeroState.Stages.Any())
     {
         // Need to build the level.
         BuildStageForHero(currentHeroState);
     }
     else
     {
         LoadStageForHero(currentHeroState);
     }
 }
コード例 #3
0
ファイル: StageFactory.cs プロジェクト: scossgrove/RougeTiler
        private static Stage LoadExistingStage(int stageNumber, HeroSave heroSave)
        {
            Stage stage = heroSave.Stages[stageNumber];

            // Remove the old hero as we will add them back in below.
            stage.Actors.RemoveAll(x => x is Hero);
            foreach (var actor in stage.Actors)
            {
                if (actor is Hero)
                {
                    throw new ApplicationException("There should not be any heroes in the list.");
                }
            }

            return(stage);
        }
コード例 #4
0
ファイル: GameConent.cs プロジェクト: scossgrove/RougeTiler
        //public List<Shop> get shops => Shops.all;

        public HeroSave createHero(string name, HeroClass heroClass)
        {
            var hero = new HeroSave(name, heroClass);

            // Starting Items
            var startingItems = new List <ItemType>();

            startingItems.Add(ItemTypeFactory.Instance.ItemTypes["Mending Salve"]);
            startingItems.Add(ItemTypeFactory.Instance.ItemTypes["Scroll of Sidestepping"]);
            startingItems.Add(ItemTypeFactory.Instance.ItemTypes["Stick"]);

            foreach (var itemType in startingItems)
            {
                hero.Inventory.tryAdd(Affixes.Instance.CreateItem(itemType));
            }

            // Starting Stats
            hero.Health = new Stat(Option.HeroHealthStart, Option.HeroHealthStart);
            hero.Charge = new Stat(0, Option.HeroChargeStart);
            hero.Gold   = Option.HeroGoldStart;

            return(hero);
        }
コード例 #5
0
        private void LoadStageForHero(HeroSave currentHeroState)
        {
            throw new NotImplementedException();

            //if (GameState.Instance.HeroSave == null)
            //{
            //    GameState.Instance.HeroSave = currentHeroState;
            //    GameState.Instance.GameLevel = currentHeroState.CurrentStage;
            //}

            //// Has the game be initialised?
            //if (GameState.Instance.Game == null || GameState.Instance.Game.CurrentStage == null)
            //{
            //    GameState.Instance.Game = new Game(currentHeroState.CurrentStage, currentHeroState);
            //    if (GameState.Instance.Game.CurrentStage.IsDirty)
            //    {
            //        Storage.Save();
            //    }
            //}
            //else
            //{
            //    GameState.Instance.Game.LoadLevel(currentHeroState.CurrentStage, currentHeroState);
            //}
        }
コード例 #6
0
ファイル: Area.cs プロジェクト: scossgrove/RougeTiler
        /// <summary>
        /// This will build a stage.
        ///
        /// This involves:
        /// 1. Generating TileTypeFactory, Shadows & Explored matrixes.
        /// 2. Generating Items/Loot
        /// 3. Generating and placing Breeds.
        ///
        /// This DOES NOT invole:
        /// 1. placing of the hero.
        /// </summary>
        /// <param name="depth"></param>
        /// <param name="hasExitUp"></param>
        /// <param name="hasExitDown"></param>
        /// <returns></returns>
        public Stage BuildStage(Game game, int depth, bool hasExitUp, bool hasExitDown)
        {
            var level = Levels[depth];

            var stage = new Stage(Width, Height);

            stage.HasExitUp   = hasExitUp;
            stage.HasExitDown = hasExitDown;
            level.BuildStage(stage);


            // Allocate a Hero Position in order to do calculations below
            var heroPosition = stage.StairUpPosition;

            if (heroPosition == null)
            {
                heroPosition = stage.FindOpenTile();
            }
            var tmpHeroSave = new HeroSave("temp", new Warrior());
            var tempHero    = new Hero(game, heroPosition, tmpHeroSave, null, tmpHeroSave.Name);

            stage.CurrentHero = tempHero;
            stage.AddActor(tempHero);
            stage.LastHeroPosition = heroPosition;


            // Place the items.
            var numItems = Rng.Instance.taper(level.NumItems.Value, 3);

            for (var i = 0; i < numItems; i++)
            {
                var itemDepth = PickDepth(depth);
                var drop      = Levels[itemDepth].FloorDrop;

                Action <Item> myAddItem = delegate(Item item)
                {
                    item.Position = stage.FindOpenTile();
                    stage.Items.Add(item);
                };

                drop.SpawnDrop(new AddItem(myAddItem));
            }

            // Place the monsters.
            var numMonsters      = Rng.Instance.taper(level.NumMonsters.Value, 3);
            var placesOfMonsters = new List <VectorBase>();

            for (var i = 0; i < numMonsters; i++)
            {
                var monsterDepth = PickDepth(depth);

                // Place strong monsters farther from the hero.
                var tries = 1;
                if (monsterDepth > depth)
                {
                    tries = 1 + (monsterDepth - depth) * 2;
                }

                VectorBase pos = null;
                for (var attempts = 0; attempts < 5; attempts++)
                {
                    pos = stage.FindDistantOpenTile(tries);
                    if (placesOfMonsters.Contains(pos))
                    {
                        continue;
                    }

                    if (pos != null)
                    {
                        break;
                    }
                }

                if (pos == null)
                {
                    throw new ApplicationException("Invalid position found....");
                }

                var breed = Rng.Instance.Item(Levels[monsterDepth].Breeds);
                stage.SpawnMonster(game, breed, pos);
                placesOfMonsters.Add(pos);
            }

            // TODO: no quest system....
            //game.quest = level.quest.generate(stage);
            //game.quest.announce(game.log);

            // TODO: Temp. Wizard light it.

            /*
             * for (var pos in stage.bounds) {
             * for (var dir in Direction.all) {
             *  if (stage.bounds.contains(pos + dir) &&
             *      stage[pos + dir].isTransparent) {
             *    stage[pos].visible = true;
             *    break;
             *  }
             * }
             * }
             */

            return(stage);
        }
コード例 #7
0
ファイル: SaveClass.cs プロジェクト: Veto1023404/CommunityTap
 public void Save(List<GameObject> heroesList)
 {
     foreach (var component in heroesList)
     {
         HeroSave tmp = new HeroSave();
         Hero htmp = component.GetComponent<Hero>();
         tmp.cost = htmp.cost;
         tmp.amount = htmp.amount;
         tmp.dps = htmp.dps;
         tmp.name = htmp.name;
         tmp.baseCost = htmp.baseCost;
         tmp.baseDPS = htmp.baseDPS;
         heroes.Add(tmp);
     }
 }