public void InitItemFromData(template_item itemData) { ItemData = itemData; if (ItemData != null) { Asset iconAsset = ItemData.Template.item_data.item_icon as Asset; if (iconAsset != null && iconAsset != null) { Renderer.sprite = iconAsset.LoadAssetAsSprite(); // scale uniformly (or something?) //var bounds = Renderer.sprite.bounds; //var factor = 3 / bounds.size.y; //gameObject.transform.localScale = new Vector3(factor, factor, factor); } //TextPrice.text = ItemData.Template.item_data.item_price_value.ToString("F0"); if (ItemData == ShopManager.instance.MirrorTemplate) { Collider.offset = new Vector2(Collider.offset.x, -1.69f); } Renderer.sortingOrder = ItemData.Template.item_data.item_slot_number == 1 ? 2 : 3; } }
public template_item GetItemTemplate() { if (ItemTemplate == null) { if (ItemTemplateReference.HasReference) { ItemTemplate = ItemTemplateReference.GetObject <template_item>(); } } return(ItemTemplate); }
public template_item GetSinBulbTemplate() { if (SinBulbTemplate == null) { if (SinBulbTemplateReference.HasReference) { SinBulbTemplate = SinBulbTemplateReference.GetObject <template_item>(); } } return(SinBulbTemplate); }
private void StartNewGame() { Debug.Log("New Game started, clear save"); SaveManager.instance.ClearSave(); SaveManager.instance.GetCurrentPlayerState().SetSpawnCounter(Random.Range(10, 100)); SaveManager.instance.GetCurrentCarryoverPlayerState().SetGameStartedOnce(true); SaveManager.instance.GetCurrentCarryoverPlayerState().SetGameStarted(true); SaveManager.instance.GetCurrentCarryoverPlayerState().SetGameFinished(false); template_item starterBody = ShopManager.instance.GetStarterBody(); template_item starterHead = ShopManager.instance.GetStarterHead(); if (starterBody != null) { //SaveManager.instance.GetCurrentCarryoverPlayerState().AddOwnedItemID(starterBody.Id); starterBody.Template.item_data.item_instruction_onbuy.CallScript(); List <template_item_variation> variations = ShopManager.instance.GetItemVariations(starterBody); for (int i = 0; i < variations.Count; ++i) { SaveManager.instance.GetCurrentCarryoverPlayerState().AddOwnedBodyID(variations[i].Id); } } if (starterHead != null) { //SaveManager.instance.GetCurrentCarryoverPlayerState().AddOwnedItemID(starterHead.Id); starterHead.Template.item_data.item_instruction_onbuy.CallScript(); List <template_item_variation> variations = ShopManager.instance.GetItemVariations(starterHead); for (int i = 0; i < variations.Count; ++i) { SaveManager.instance.GetCurrentCarryoverPlayerState().AddOwnedHeadID(variations[i].Id); } } if (InputDebugDay != null && InputDebugDay.text != "") { SceneManager.LoadScene("Game"); int day = int.Parse(InputDebugDay.text); for (int i = 0; i < day - 1; ++i) { SaveManager.instance.GetCurrentPlayerState().IncrementDayIndex(); } DesktopManager.instance.StartDay(); SaveManager.instance.GetCurrentPlayerState().SetIntroDone(true); ElevatorManager.instance.SwitchScene(EScene.Elevator); } else { ElevatorManager.instance.SwitchScene(EScene.Comic); } }
private void SpawnItem(template_item rolledItem, Vector3 position) { ShopItem newItem = Instantiate(ShopItemTemplate); newItem.InitItemFromData(rolledItem); newItem.transform.SetParent(Shop.instance.GetShelf().gameObject.transform); newItem.transform.position = position; if (rolledItem.Template.item_data.item_name.Contains("REFLECTOR")) { newItem.transform.position = newItem.transform.position + new Vector3(0, 2.84f, 0); } SpawnedItems.Add(newItem); }
public void UpdateArticyCurrentBody() { template_item parentItem = GetCurrentBodyItem().Template.item_accessory_variation.item_parent_reference as template_item; if (parentItem.Template.item_data.item_name.Contains("GRIM CAPE")) { ArticyGlobalVariables.Default.inventory.current_body = "cape"; } else if (parentItem.Template.item_data.item_name.Contains("A FANCY SUIT (REGULAR EDITION)")) { ArticyGlobalVariables.Default.inventory.current_body = "tie"; } else if (parentItem.Template.item_data.item_name.Contains("A FANCY SUIT (BOWTIE EDITION)")) { ArticyGlobalVariables.Default.inventory.current_body = "bowtie"; } Debug.Log("Current Body: " + ArticyGlobalVariables.Default.inventory.current_body); }
public void AddItemDataToPlayer(template_item data) { if (AreAllAccessoriesOwned()) { GetCurrentCarryoverPlayerState().bRIPFashion = true; } // if (!GetCurrentCarryoverPlayerState().IsItemOwnedByID(data.Id)) if (!data.Template.item_data.item_variable.CallScript()) { data.Template.item_data.item_instruction_onbuy.CallScript(); //GetCurrentCarryoverPlayerState().AddOwnedItemID(data.Id); switch (data.Template.item_data.item_type_category) { case item_type_category.ItemVisualAccessory: List <template_item_variation> variations = ShopManager.instance.GetItemVariations(data); for (int i = 0; i < variations.Count; ++i) { switch (variations[i].Template.item_accessory_variation.item_accessory_type) { case item_accessory_type.item_head: GetCurrentCarryoverPlayerState().AddOwnedHeadID(variations[i].Id); break; case item_accessory_type.item_body: GetCurrentCarryoverPlayerState().AddOwnedBodyID(variations[i].Id); break; } } break; case item_type_category.ItemToy: break; case item_type_category.ItemInfoTool: break; } } else { Debug.LogError("Trying to add item that is already owned! Tell Ott that " + data.DisplayName + " is trying to break stuff!"); } }
public List <template_item_variation> GetItemVariations(template_item item) { List <template_item_variation> variations = new List <template_item_variation>(); for (int k = 0; k < item.Template.item_data.item_variations.Count; ++k) { template_item_variation variation = item.Template.item_data.item_variations[k] as template_item_variation; switch (variation.Template.item_accessory_variation.item_accessory_type) { case item_accessory_type.item_head: variations.Add(variation); break; case item_accessory_type.item_body: variations.Add(variation); break; } } return(variations); }
public void UpdateArticyCurrentHead() { template_item parentItem = GetCurrentHeadItem().Template.item_accessory_variation.item_parent_reference as template_item; if (parentItem.Template.item_data.item_name.Contains("THE FACE OF THE GREAT OLD ONE")) { ArticyGlobalVariables.Default.inventory.current_head = "cthulhu"; } else if (parentItem.Template.item_data.item_name.Contains("REGULAR BONEHEAD")) { ArticyGlobalVariables.Default.inventory.current_head = "bonehead"; } else if (parentItem.Template.item_data.item_name.Contains("THE CALAVERA")) { ArticyGlobalVariables.Default.inventory.current_head = "sugarskull"; } else if (parentItem.Template.item_data.item_name.Contains("THE PLAGUE DOCTOR")) { ArticyGlobalVariables.Default.inventory.current_head = "plague"; } else if (parentItem.Template.item_data.item_name.Contains("EYE OF ANPU")) { ArticyGlobalVariables.Default.inventory.current_head = "anubis"; } else if (parentItem.Template.item_data.item_name.Contains("EARS OF THE BEAST")) { ArticyGlobalVariables.Default.inventory.current_head = "kitty"; } else if (parentItem.Template.item_data.item_name.Contains("UNHOLY SMOKES")) { ArticyGlobalVariables.Default.inventory.current_head = "john"; } else if (parentItem.Template.item_data.item_name.Contains("ACADEMIC VISAGE")) { ArticyGlobalVariables.Default.inventory.current_head = "jane"; } Debug.Log("Current Head: " + ArticyGlobalVariables.Default.inventory.current_head); }
private void ReadItemData(template_item item) { if (item.Template.item_data.item_variable.RawScript == "") { Debug.Log("No item variable for item: " + item.Template.item_data.item_name); return; } if (item.Template.item_data.item_slot_number == -1 && item != GetStarterBody() && item != GetStarterHead()) { Debug.Log("Item set to be not listed in shop: " + item.Template.item_data.item_name); return; } switch (item.Template.item_data.item_type_category) { case item_type_category.ItemVisualAccessory: if (item.Template.item_data.item_variations.Count > 0) { int slotNum = item.Template.item_data.item_slot_number; if (item == GetStarterBody() || item == GetStarterHead()) { slotNum = 0; } ItemDictionary[slotNum].Add(item); } else { Debug.Log("Skipping visual accessory without variations: " + item.DisplayName); } for (int k = 0; k < item.Template.item_data.item_variations.Count; ++k) { template_item_variation variation = item.Template.item_data.item_variations[k] as template_item_variation; switch (variation.Template.item_accessory_variation.item_accessory_type) { case item_accessory_type.item_head: if (!BaseHeadList.Contains(item)) { BaseHeadList.Add(item); } HeadList.Add(variation); break; case item_accessory_type.item_body: if (!BaseBodyList.Contains(item)) { BaseBodyList.Add(item); } BodyList.Add(variation); break; } } //HeadList.Add(item); //BodyList.Add(item); break; case item_type_category.ItemToy: ItemDictionary[item.Template.item_data.item_slot_number].Add(item); break; case item_type_category.ItemInfoTool: ItemDictionary[item.Template.item_data.item_slot_number].Add(item); break; } }
public template_item GetRandomBody() { template_item look = BaseBodyList[Random.Range(0, BaseBodyList.Count)]; return(look); }
public template_item GetRandomHead() { template_item look = BaseHeadList[Random.Range(0, BaseHeadList.Count)]; return(look); }
public void PopulateShop(bool restoreFromSave) { List <template_item> unOwnedItems = new List <template_item>(); PlayerState player = SaveManager.instance.GetCurrentPlayerState(); if (restoreFromSave) { bool toySlotUsed = false; for (int i = 0; i < player.GetCurrentDayItems().Count; ++i) { template_item item = ArticyDatabase.GetObject(player.GetCurrentDayItems()[i]) as template_item; if (toySlotUsed && item.Template.item_data.item_slot_number == 2) { GameObject marker = Shop.instance.GetShopItemSpawnMarkerForPosition(1); SpawnItem(item, marker.transform.position); } else { GameObject marker = Shop.instance.GetShopItemSpawnMarkerForPosition(item.Template.item_data.item_slot_number); SpawnItem(item, marker.transform.position); if (item.Template.item_data.item_slot_number == 2) { toySlotUsed = true; } } //if (i >= shopItemSpawnMarkers.Count) //{ // Debug.LogError("Invalid number of items in savegame! Contact Ott!"); //} //else //{ //} } } else { bool isInfoToolSlotEmpty = true; template_item substituteItem = null; for (int j = 0; j < 3; ++j) { unOwnedItems.Clear(); for (int i = 0; i < ItemDictionary[j].Count; ++i) { //if (!SaveManager.instance.GetCurrentCarryoverPlayerState().IsItemOwnedByID(ItemDictionary[j][i].Id)) //{ // unOwnedItems.Add(ItemDictionary[j][i]); //} if (!ItemDictionary[j][i].Template.item_data.item_variable.CallScript() && substituteItem != ItemDictionary[j][i]) { if (j == 1) { isInfoToolSlotEmpty = false; } if (ItemDictionary[j][i] != GetStarterBody() && ItemDictionary[j][i] != GetStarterHead()) { unOwnedItems.Add(ItemDictionary[j][i]); } } } if (isInfoToolSlotEmpty && j == 1) { for (int i = 0; i < ItemDictionary[2].Count; ++i) { if (!ItemDictionary[2][i].Template.item_data.item_variable.CallScript()) { if (ItemDictionary[2][i] != GetStarterBody() && ItemDictionary[2][i] != GetStarterHead()) { unOwnedItems.Add(ItemDictionary[2][i]); } } } } if (unOwnedItems.Count > 0) { if (isInfoToolSlotEmpty && j == 1) { GameObject marker = Shop.instance.GetShopItemSpawnMarkerForPosition(1); template_item rolledItem = unOwnedItems[Random.Range(0, unOwnedItems.Count)]; substituteItem = rolledItem; unOwnedItems.Remove(rolledItem); SpawnItem(rolledItem, marker.transform.position); player.AddCurrentDayItem(rolledItem.Id); } else { GameObject marker = Shop.instance.GetShopItemSpawnMarkerForPosition(j); template_item rolledItem = unOwnedItems[Random.Range(0, unOwnedItems.Count)]; unOwnedItems.Remove(rolledItem); SpawnItem(rolledItem, marker.transform.position); player.AddCurrentDayItem(rolledItem.Id); } } } } }
public override void InitManager() { base.InitManager(); instance = this; if (MirrorReference.HasReference) { MirrorTemplate = MirrorReference.GetObject <template_item>(); } if (EraserReference.HasReference) { EraserTemplate = EraserReference.GetObject <template_item>(); } if (ShopKeeperAltGreetReference.HasReference) { List <SortingHelper> sorts = new List <SortingHelper>(); Dialogue altGreetDialogue = ShopKeeperAltGreetReference.GetObject <Dialogue>(); for (int i = 0; i < altGreetDialogue.Children.Count; ++i) { DialogueFragment frag = altGreetDialogue.Children[i] as DialogueFragment; if (frag != null) { IObjectWithPosition positionObject = frag as IObjectWithPosition; SortingHelper sort = new SortingHelper(); sort.Fragment = frag; sort.PositionY = positionObject.Position.y; sorts.Add(sort); } } sorts.OrderBy(f => f.PositionY); for (int i = 0; i < sorts.Count; ++i) { AltGreetFragments.Add(sorts[i].Fragment); } } for (int i = 0; i < 3; ++i) { ItemDictionary.Add(i, new List <template_item>()); } if (StarterBodyReference.HasReference) { StarterBody = StarterBodyReference.GetObject <template_item>(); } if (StarterHeadReference.HasReference) { StarterHead = StarterHeadReference.GetObject <template_item>(); } if (ItemFolderReference.HasReference) { UserFolder itemFolder = ItemFolderReference.GetObject <UserFolder>(); if (itemFolder != null) { for (int i = 0; i < itemFolder.Children.Count; ++i) { UserFolder childFolder = itemFolder.Children[i] as UserFolder; for (int j = 0; j < childFolder.Children.Count; ++j) { template_item item = childFolder.Children[j] as template_item; UserFolder childSubfolder = childFolder.Children[j] as UserFolder; if (childSubfolder != null) { for (int y = 0; y < childSubfolder.Children.Count; ++y) { template_item subfolderItem = childSubfolder.Children[y] as template_item; if (subfolderItem != null) { ReadItemData(subfolderItem); } } } if (item != null) { ReadItemData(item); } } } } Debug.Log("Found " + ItemDictionary[0].Count + " Slot 0 items"); Debug.Log("Found " + ItemDictionary[1].Count + " Slot 1 items"); Debug.Log("Found " + ItemDictionary[2].Count + " Slot 2 items"); Debug.Log("Found " + HeadList.Count + " heads"); Debug.Log("Found " + BodyList.Count + " bodies"); } }