public ShopStageData GetShopStageData(string id) { ShopStageData data = null; _worldShopStageData.TryGetValue(id, out data); return(data); }
public void InitializeAsShopStage(string id, Vector3 position, ShopStageData stageData, MapNodeTappedCallback callback) { BaseInitialize(id, position); Data.ShopStageDataId = stageData.name; _shopStageData = stageData; _callback = callback; }
public void InitializeFromData(MapNodeData data, MapNodeTappedCallback callback) { Data = data; if (data.BattleStageDataId != null) { _battleStageData = Database.Instance.GetBattleStageData(data.BattleStageDataId); } else if (data.ShopStageDataId != null) { _shopStageData = Database.Instance.GetShopStageData(data.ShopStageDataId); } transform.position = Data.Coordinates; _callback = callback; }
public void Initialize(ShopStageData shopData) { List <InventoryItemData> shopWeaponInventory = new List <InventoryItemData>(); for (int i = 0, count = shopData.Weapons.Count; i < count; i++) { shopWeaponInventory.Add( new InventoryItemData() { DataId = shopData.Weapons[i].name, Count = 1 } ); } _weaponInventory.Initialize(shopWeaponInventory); }
public WorldData LoadWorldStageData(int worldId) { //temp string worldName = "World" + worldId.ToString(); if (_worldData != null && _worldData.name == worldName) { return(_worldData); } string worldPath = WORLD_PATH; worldPath = worldPath.Replace("{worldNum}", worldId.ToString()); _worldData = Resources.Load(worldPath) as WorldData; string stagesPath = WORLD_STAGES_PATH; stagesPath = stagesPath.Replace("{worldNum}", worldId.ToString()); Object[] stages = Resources.LoadAll(stagesPath); for (int i = 0, count = stages.Length; i < count; i++) { // Test if the stage data is a battle stage BattleStageData battleStage = stages[i] as BattleStageData; if (battleStage != null) { _worldBattleStageData.Add(battleStage.name, battleStage); } ShopStageData shopData = stages[i] as ShopStageData; if (shopData != null) { _worldShopStageData.Add(shopData.name, shopData); } } return(_worldData); }
private MapNode GenerateGraph(WorldData worldData) { List <Vector2> points = new List <Vector2>(); MapNode startingNode = null; // world data says... maybe 8 battle stages, 2 shops, 1 quest int numBattleStages = UnityEngine.Random.Range(worldData.MinNumBattleStages, worldData.MaxNumBattleStages + 1); int numShopStages = UnityEngine.Random.Range(worldData.MinNumShopStages, worldData.MaxNumShopStages + 1); // Create battle stage nodes for (int i = 0; i < numBattleStages; i++) { Vector3 position; if (i == 0) { position = FindStartingPosition(); } else if (i == numBattleStages) { position = FindEndingPosition(); } else { position = FindOpenPosition(); } BattleStageData stageData = Database.Instance.GetRandomBattleStageData(); string nodeId = GetNodeIdFromVector3(position); MapNode mapNode = CreateMapNode(nodeId); mapNode.InitializeAsBattleStage(nodeId, position, stageData, MapNodeTappedCallback); points.Add(new Vector2(position.x, position.y)); if (i == 0) { // save current node startingNode = mapNode; } } // Create shop nodes for (int i = 0; i < numShopStages; i++) { Vector3 position = FindOpenPosition(); // depending on the world data, we need to pick from a random set ShopStageData stageData = Database.Instance.GetRandomShopStageData(); string nodeId = GetNodeIdFromVector3(position); MapNode mapNode = CreateMapNode(nodeId); mapNode.InitializeAsShopStage(nodeId, position, stageData, MapNodeTappedCallback); points.Add(new Vector2(position.x, position.y)); } GenerateEdges(points); return(startingNode); }