public bool onSelectedFurniture(ViewController sender, FurnitureEntry selectedEntry) { Furniture furniture = Catalog.getCatalog().createFurniture(selectedEntry.id, new Vector3(0, 0, 0), 0).GetComponent <Furniture> (); tempcSt.Execute(new SwapFurnitureCommand( focusedObject.gameObject, furniture.gameObject, controller.GetComponentInChildren <Room> ())); this.gameObject.GetComponentInChildren <Room> ().swapFurniture(focusedObject.GetComponent <Furniture> (), furniture); focusedObject = furniture.gameObject.transform; furniture.gameObject.name = focusedObjectName; return(false); }
protected virtual bool onFurnitureDragged(ViewController sender, FurnitureEntry entry, Vector2 screenPosition) { Debug.Log("drag reported from standby"); GameObject f = Catalog.getCatalog().createFurniture(entry.id, new Vector3(0, 0, 0), 0); if (f != null) { controller.GetComponentInChildren <Room> ().addFurniture(f.GetComponent <Furniture> ()); f.GetComponent <MovableObject> ().place(screenPosition); nextState = createNextState <AddObjectState> (); ((AddObjectState)nextState).focusedObject = f.transform; shouldPop = false; dismiss(nextState, shouldPop); die(nextState, shouldPop); } return(false); }
// Use this for initialization protected override void Start() { base.Start(); catalog = Catalog.getCatalog(); furnitureEntry = catalog.entries [PlayerPrefs.GetString("modelViewer_modelid")]; GameObject furniture = catalog.createFurniture(furnitureEntry.id, new Vector3(0, 0, 0), 0); GameObject floor = (GameObject)GameObject.Instantiate(Resources.Load <GameObject> ("FloorPlane")); //floor.transform.SetParent (furniture.transform); floor.GetComponent <Floor> ().Height = furnitureEntry.depth * 3.0f; floor.GetComponent <Floor> ().Width = furnitureEntry.width * 3.0f; GameObject.Find("boldButton").GetComponent <Image> ().color = preferences.secondaryColor; GameObject.Find("MainBar").GetComponent <Image> ().color = preferences.primaryColor; GameObject.Find("FurnitureTitle").GetComponent <Text>().color = preferences.primaryTextColor; GameObject.Find("FurnitureTitle").GetComponent <Text>().font = preferences.primaryTextFont; GameObject.Find("FurnitureTitle").GetComponent <Text>().text = furnitureEntry.name; GameObject.Find("MainBar").transform.FindChild("BackButton").GetComponent <Button> ().onClick.AddListener(() => backPressed()); }
private void loadToDict(string filename, Dictionary <int, FurnitureEntry> entries) { TextAsset content = Resources.Load <TextAsset> (filename); StringReader reader = new StringReader(content.text); string s = reader.ReadLine(); while (s != null) { try { string[] fields = s.Split('='); if (fields.Length == 2) { string[] field_id = fields[0].Split('#'); string tagname = field_id[0]; int code = Convert.ToInt32(field_id[1]); string value = fields[1]; if (tagname.Equals("id")) { FurnitureEntry entry = new FurnitureEntry(); entry.id = value; entries.Add(code, entry); } else if (tagname.Equals("name")) { entries[code].name = value; } else if (tagname.Equals("icon")) { string[] p = value.Split('/'); entries[code].image = p[p.Length - 1].Split('.')[0]; } else if (tagname.Equals("category")) { entries[code].category = value; } else if (tagname.Equals("depth")) { entries[code].depth = (float)Convert.ToDouble(value) * scale; } else if (tagname.Equals("width")) { entries[code].width = (float)Convert.ToDouble(value) * scale; } else if (tagname.Equals("height")) { entries[code].height = (float)Convert.ToDouble(value) * scale; } else if (tagname.Equals("model")) { //string[] path = value.Split('/'); //entries[code].model = path[path.Length - 1]; entries[code].model = value; } else if (tagname.Equals("modelRotation")) { string[] values = value.Split(' '); entries[code].modelRotation[0, 0] = (float)Convert.ToDouble(values[0]); entries[code].modelRotation[1, 0] = (float)Convert.ToDouble(values[1]); entries[code].modelRotation[2, 0] = (float)Convert.ToDouble(values[2]); entries[code].modelRotation[0, 1] = (float)Convert.ToDouble(values[3]); entries[code].modelRotation[1, 1] = (float)Convert.ToDouble(values[4]); entries[code].modelRotation[2, 1] = (float)Convert.ToDouble(values[5]); entries[code].modelRotation[0, 2] = (float)Convert.ToDouble(values[6]); entries[code].modelRotation[1, 2] = (float)Convert.ToDouble(values[7]); entries[code].modelRotation[2, 2] = (float)Convert.ToDouble(values[8]); } } }catch (Exception e) { Debug.Log(e); }finally { s = reader.ReadLine(); } } }
public Furniture(FurnitureEntry type) { this.type = type; }
public void setFurnitureType(FurnitureEntry type) { this.type = type; }