public bool RemoveFurniture() { Vector3 mousePos = camera.ScreenToWorldPoint(Input.mousePosition); Collider2D collider = Physics2D.OverlapCircle(mousePos, 0.2f); if (collider != null) { GameObject itemGO = collider.gameObject; string itemName = GetRootItemNameFromGO(itemGO); Item.TypeItem typeItem = GetTypeItemFromName(itemName); if (typeItem != Item.TypeItem.unknown) { Item itemI = new Item(typeItem); im.AddItem(itemI); indexSprite = 0; StartCoroutine(DestroyFurniture(itemGO.transform.position)); return(true); } else { Debug.LogWarning("Furniture Manager : TypeItem " + itemName + " Not Found, Can't Remove it to Inventory"); } } return(false); }
void TargetAddFurniture(NetworkConnection networkConnection, NetworkObjectInfos objectInfos) { Scene actualScene = SceneManager.GetActiveScene(); GameObject[] sceneObjects = actualScene.GetRootGameObjects(); Transform parent = null; foreach (GameObject go in sceneObjects) { if (go.name == "prefabs group") { parent = go.transform; } } Item.TypeItem itemToSpawnType = (Item.TypeItem)objectInfos.idItem; Furniture furniture = GetFurnitureFromType(itemToSpawnType); if (furniture != null) { Vector3 position = Vector3.zero; position.x = objectInfos.posX; position.y = objectInfos.posY; GameObject prefab = GetPrefabFromFurniture(furniture); string saveFile = actualScene.name; GameObject furnitureGO = Instantiate(prefabsProps[(int)itemToSpawnType][objectInfos.direction], position, Quaternion.identity); furnitureGO.GetComponent <SpriteRenderer>().sprite = SpriteManager.GetSpriteManager.GetFurnitureSprite(furnitureGO.name.Substring(0, furnitureGO.name.IndexOf("_")), objectInfos.indexSprite, (E_FurnitureDirection)objectInfos.direction); props.Add(furnitureGO); furnitureGO.transform.SetParent(parent); } }
/// <summary> /// Generate path from the item type and it's direction /// and searching for the prefab to Instaciate in the Resources/Prefabs/Furniture /// </summary> /// <param name="_direction">the top/bot/right/left direction to spawn the item</param> /// <param name="_position">the position in world where spawns the item</param> /// <returns></returns> public bool AddFurniture() { if (inventory.GetItem(inventoryIndex, 0) != null) { Item.TypeItem itemToSpawnType = inventory.GetItem(inventoryIndex, 0).ItemType; Furniture furniture = GetFurnitureFromType(itemToSpawnType); if (furniture != null) { Vector3 position = GetPositionFromFurnitureSnap(furniture); GameObject prefab = GetPrefabFromFurniture(furniture); if (!CheckPropsAtPos(position, prefab, furniture)) { Scene actualScene = SceneManager.GetActiveScene(); if (furniture == null) { Debug.LogWarning("FurnitureManager : Item to spawn not found in Resources "); //ne pas retirer de l'inventaire im.UpdateInventory(); } else { im.RemoveItem(inventory.GetItem(inventoryIndex, 0)); im.UpdateInventory(); } NetworkObjectInfos objectInfos; objectInfos.direction = (int)furDir; objectInfos.idItem = (int)itemToSpawnType; objectInfos.indexSprite = indexSprite; objectInfos.posX = position.x; objectInfos.posY = position.y; StartCoroutine(IAddFuniture(objectInfos)); } } } //StartCoroutine(SpawnFurniture()); return(true); }
public CraftInfo(Item.TypeItem itemCraft, List <CraftResources> resourcesToCraft) { this.itemCraft = itemCraft; this.resourcesToCraft = resourcesToCraft; }
public CraftInfo(Item.TypeItem itemCraft) { this.itemCraft = itemCraft; resourcesToCraft = new List <CraftResources>(); }
public CraftInfo() { itemCraft = Item.TypeItem.unknown; resourcesToCraft = new List <CraftResources>(); }
public CraftInfo(List <CraftResources> resourcesToCraft) { this.resourcesToCraft = resourcesToCraft; itemCraft = Item.TypeItem.unknown; }
public Furniture GetFurnitureFromType(Item.TypeItem _type) { return(furnitures[_type]); }
//////////////////////////////////////////////////////////////////////////// START (IEnumerator) IEnumerator Start() { Directory.CreateDirectory(pathSave); camera = GameObject.Find("Main Camera").GetComponent <Camera>();//Camera.main; props = new List <GameObject>(); while (im == null) { yield return(null); im = InventoryManager.GetInventoryManager;//dans addItem } this.enabled = false; InventoryManager.GetInventoryManager.InventoryIsUpdate += UpdateInventory; while (pc == null) { yield return(null); pc = PlayerManager.GetPlayerManager.playerController; } Instantiate(housingCanvas).GetComponent <FurnitureCanvas>().fm = this;//canvas inventoryIndex = -1; furnitureClose += DestroyPreview; furnitureUpdateSelector += UpdatePreview; furnitureUpdate += UpdatePreview; if (PersonalNetworkManager.isSERVER) { listFunituresPerScenes = new Dictionary <int, List <NetworkObjectInfos> >(); } prefabsProps = new List <GameObject[]>(); for (Item.TypeItem i = 0; i < Item.TypeItem.nbItem; i++) { prefabsProps.Add(new GameObject[4]); if ((furnitures[i].nbrDirections / 1000) % 2 > 0) { string prefabPath = pathInResources + furnitures[i].prefab + "_top"; prefabsProps[(int)i][(int)E_FurnitureDirection.DIR_TOP] = Resources.Load <GameObject>(prefabPath); } if ((furnitures[i].nbrDirections / 100) % 2 > 0) { string prefabPath = pathInResources + furnitures[i].prefab + "_bot"; prefabsProps[(int)i][(int)E_FurnitureDirection.DIR_BOT] = Resources.Load <GameObject>(prefabPath); } if ((furnitures[i].nbrDirections / 10) % 2 > 0) { string prefabPath = pathInResources + furnitures[i].prefab + "_right"; prefabsProps[(int)i][(int)E_FurnitureDirection.DIR_RIGHT] = Resources.Load <GameObject>(prefabPath); } if (furnitures[i].nbrDirections % 2 > 0) { string prefabPath = pathInResources + furnitures[i].prefab + "_left"; prefabsProps[(int)i][(int)E_FurnitureDirection.DIR_LEFT] = Resources.Load <GameObject>(prefabPath); } } string saveFile = Application.persistentDataPath + "/NoobSaves/OwnersHouse.save"; LoadOwnerHouse(saveFile); }
void Awake() { if (GetSpriteManager == null) { GetSpriteManager = this; } else if (GetSpriteManager != this) { Destroy(gameObject); } DontDestroyOnLoad(gameObject); whiteTransparentColor = Color.white; whiteTransparentColor.a = 0; hairList = new List <Sprite> [(int)Sex.nbSex, (int)TypeHair.nbHair, (int)ColorHair.nbHair]; for (int i = 0; i < (int)Sex.nbSex; i++) { for (int k = 0; k < (int)TypeHair.nbHair; k++) { for (int j = 0; j < (int)ColorHair.nbHair; j++) { hairList[i, k, j] = Resources.LoadAll <Sprite>("Sprites/Characters/" + (Sex)i + "/Hair/" + (TypeHair)k + "/" + (ColorHair)j).ToList(); } } } armorList = new List <Sprite> [(int)Sex.nbSex, (int)Archetype.nbArchetype, (int)ColorArmor.nbColorArmor, (int)PartBody.nbPart]; for (int i = 0; i < (int)Sex.nbSex; i++) { for (int j = 0; j < (int)Archetype.nbArchetype; j++) { for (int k = 0; k < (int)ColorArmor.nbColorArmor; k++) { for (int l = 0; l < (int)PartBody.nbPart; l++) { armorList[i, j, k, l] = Resources.LoadAll <Sprite>("Sprites/Characters/" + (Sex)i + "/Classe/" + (Archetype)j + "/" + (ColorArmor)k + "/" + (PartBody)l).ToList(); } } } } bodyList = new List <Sprite> [(int)ColorBody.nbColorBody]; for (int k = 0; k < (int)ColorBody.nbColorBody; k++) { bodyList[k] = Resources.LoadAll <Sprite>("Sprites/Characters/Body/" + (ColorBody)k).ToList(); } beardList = new List <Sprite> [(int)TypeBeard.nbBeard, (int)ColorBeard.nbBeards]; for (int i = 0; i < (int)TypeBeard.nbBeard; i++) { for (int j = 0; j < (int)ColorBeard.nbBeards; j++) { beardList[i, j] = Resources.LoadAll <Sprite>("Sprites/Characters/Man/Beards/" + (TypeBeard)i + "/" + (ColorBeard)j).ToList(); } } scarsList = new List <Sprite> [(int)Scars.nbScars]; for (int i = 0; i < (int)Scars.nbScars; i++) { scarsList[i] = Resources.LoadAll <Sprite>("Sprites/Characters/Scars/" + (Scars)i).ToList(); } accessoriesList = new List <Sprite> [(int)Cape.nbCape, (int)ColorCape.nbColor]; for (int i = 0; i < (int)Cape.nbCape; i++) { for (int j = 0; j < (int)ColorCape.nbColor; j++) { accessoriesList[i, j] = Resources.LoadAll <Sprite>("Sprites/Characters/Accessories/Cape/" + (Cape)i + "/" + (ColorCape)j).ToList(); } } furnitureSprite = new Dictionary <string, List <Sprite>[]>(); for (Item.TypeItem i = 0; i < Item.TypeItem.nbItem; i++) { furnitureSprite[i.ToString()] = new List <Sprite> [(int)FurnitureManager.E_FurnitureDirection.NB_DIR]; for (FurnitureManager.E_FurnitureDirection j = 0; j < FurnitureManager.E_FurnitureDirection.NB_DIR; j++) { furnitureSprite[i.ToString()][(int)j] = Resources.LoadAll <Sprite>("Sprites/Furnitures/" + i.ToString() + "/" + j.ToString()).ToList(); } } factionButtonMenu = new Sprite[3, 2]; for (int i = 0; i < 3; i++) { factionButtonMenu[i, 0] = Resources.Load <Sprite>("Sprites/HUD/Buttons/Menu/" + i + "/Basic/0"); factionButtonMenu[i, 1] = Resources.Load <Sprite>("Sprites/HUD/Buttons/Menu/" + i + "/Highlighted/0"); } spritesCrate = new List <Sprite>(); spritesCrate = Resources.LoadAll <Sprite>("Sprites/Crate").ToList(); smourbiffList = new List <Sprite> [nbSmourbiff]; for (int i = 0; i < nbSmourbiff; i++) { smourbiffList[i] = Resources.LoadAll <Sprite>("Sprites/Pets/" + i).ToList(); } specialsCharacters = new List <Sprite> [(int)SpecialsCharacters.nbSpecial]; for (int i = 0; i < (int)SpecialsCharacters.nbSpecial; i++) { specialsCharacters[i] = Resources.LoadAll <Sprite>("Sprites/Characters/Specials/" + (SpecialsCharacters)i).ToList(); } }