private void OnDecorationListSelectionChanged(object sender, SelectionChangedEventArgs e) { int index = listViewItems.SelectedIndex; if (index < pocket.SlotsUsed) { if (index != -1) { selectedIndex = index; } selectedDecoration = pocket[selectedIndex]; if (selectedIndex != -1) { DecorationData decorationData = pocket[selectedIndex].DecorationData; BitmapSource image = ItemDatabase.GetDecorationFullSizeImageFromID(decorationData.ID); imageDecoration.Source = image; imageDecoration.Width = image.Width; imageDecoration.Height = image.Height; labelDecorationName.Content = decorationData.Name; textBlockDecorationDescription.Text = decorationData.Description; buySellInfo.LoadBuySellInfo(decorationData); } else { labelDecorationName.Content = ""; textBlockDecorationDescription.Text = ""; imageDecoration.Source = null; buySellInfo.UnloadBuySellInfo(); } } }
public void LoadBuySellInfo(DecorationData decoration) { this.stackPanelContents.Children.Clear(); bool buyLabelSet = false; if (decoration.Price != 0) { AddPrice(false, !buyLabelSet, "$" + decoration.Price.ToString("#,0"), decoration.IsOnlyPurchasableDuringSale); buyLabelSet = true; } if (decoration.CoinsPrice != 0) { AddPrice(false, !buyLabelSet, decoration.CoinsPrice.ToString("#,0") + " Coins"); buyLabelSet = true; } if (decoration.BattlePointsPrice != 0) { AddPrice(false, !buyLabelSet, decoration.BattlePointsPrice.ToString("#,0") + " BP"); buyLabelSet = true; } if (decoration.VolcanicAshPrice != 0) { AddPrice(false, !buyLabelSet, decoration.VolcanicAshPrice.ToString("#,0") + " Soot"); buyLabelSet = true; } if (!buyLabelSet) { AddPrice(true); } AddSellPrice(true); }
public void RejectPurchase() { Debug.Log("" + PlayerData.playerData.playerMoney + " cost: " + cost); //CatfePlayerScript.script.PurchaseItem(false); gameObject.SetActive(false); data = null; }
private void UpdateDecorationMode() { comboBoxItems.Items.Clear(); ComboBoxItem comboBoxItem = new ComboBoxItem(); comboBoxItem.Content = "None"; comboBoxItem.Tag = (ushort)0; comboBoxItems.Items.Add(comboBoxItem); if (decorationMode) { for (int i = 1; ItemDatabase.GetDecorationAt(i) != null; i++) { DecorationData decorationData = ItemDatabase.GetDecorationAt(i); comboBoxItem = new ComboBoxItem(); comboBoxItem.Content = decorationData.Name; comboBoxItem.Tag = (ushort)decorationData.ID; comboBoxItems.Items.Add(comboBoxItem); } } else { for (int i = 1; ItemDatabase.GetItemAt(i) != null; i++) { ItemData itemData = ItemDatabase.GetItemAt(i); comboBoxItem = new ComboBoxItem(); comboBoxItem.Content = itemData.Name; comboBoxItem.Tag = itemData.ID; comboBoxItems.Items.Add(comboBoxItem); } } comboBoxItems.SelectedIndex = 0; }
void LoadData() { //string jsonString = Tools.ReadStringFromFile(Application.dataPath + "/" + decorationDataFile); decorationDataDic = Tools.LoadOneData <DecorationData>(Application.dataPath + "/" + "Resources_moved/Scripts/Decoration/DecorationList"); decorationDataList = decorationDataDic.Values.ToList(); currDecorationData = decorationDataList[0]; }
private static void LoadObjects(XmlDocument document) { XmlNodeList entities = document.GetElementsByTagName("object"); foreach (XmlElement element in entities) { string name = element.GetAttribute("name"); string shortName = element.GetAttribute("shortname"); string type = element.GetAttribute("type"); bool centerOnly = type == "centered"; bool cornerOnly = type == "corner"; bool floating = type == "floating"; bool tree = type == "tree"; bool bush = type == "bush"; Debug.Log("Loading object " + name); bool unique = VerifyShortName(shortName); if (!unique) { Debug.LogWarning("Shortname " + shortName + " already exists, aborting"); continue; } Model model = null; List <string[]> categories = new List <string[]>(); Materials materials = null; foreach (XmlElement child in element) { switch (child.LocalName) { case "model": model = new Model(child, LayerMasks.DecorationLayer); break; case "materials": materials = new Materials(child); break; case "category": categories.Add(child.InnerText.Split('/')); break; } } DecorationData data = ScriptableObject.CreateInstance <DecorationData>(); data.Initialize(model, name, shortName, type, centerOnly, cornerOnly, floating, tree, bush, materials); Database.Decorations[shortName] = data; foreach (string[] category in categories) { GuiManager.Instance.ObjectsTree.Add(data, category); } } }
public void AddDecor(DecorationData d) { GameObject dec = (GameObject)Instantiate(DecorInfoPrefab); dec.transform.SetParent(DecorPanel.transform, false); //as the first purchase, there will always only be one in the inventory d.numInInventory = 1; dec.GetComponent <Decoration>().data = d; decor.Add(dec); }
public void SetDecorationText(DecorationData d) { decorName.text = "" + d.name; decorCost.text = "Cost: " + d.cost; decorAtmosphere.text = "Atmosphere: " + d.atmosphere; decorLocation.text = "Location: " + d.location; decorDescription.text = "" + d.description; cost = d.cost; data = d; }
public void ReadyPurchase(DecorationData d, Recipe r) { storeConfirmation.SetActive(true); if (d != null) { decorToPurchase = d; storeConfirmation.GetComponent <ConfirmationPopup>().SetDecorationText(d); } if (r != null) { recipeToPurchase = r; //storeConfirmation.GetComponent<ConfirmationPopup>().UpdateText(null, r); } }
public MapData ToMapData() { MapData md = new MapData(); md.row = row; md.column = column; md.cellWidth = (double)cellSize.x; md.cellHeight = (double)cellSize.y; md.startPosX = (double)startPos.x; md.startPosY = (double)startPos.y; md.startPosZ = (double)startPos.z; for (int i = 0; i < row; i++) { for (int j = 0; j < column; j++) { if (null != cells [j, i]) { md.cells.Add(cells [j, i].CellData); } } } SpriteRenderer[] children = GetComponentsInChildren <SpriteRenderer> (); for (int i = 0; i < children.Length; i++) { if (children [i].gameObject.GetComponent <MapCellDisplay> () == null) { DecorationData dd = new DecorationData(); if (children [i].sprite != null) { dd.resName = children [i].sprite.name; } dd.sortLayer = children [i].sortingLayerName; dd.sortOrder = children [i].sortingOrder; Transform ddt = children [i].transform; dd.posX = (double)ddt.position.x; dd.posY = (double)ddt.position.y; dd.posZ = (double)ddt.position.z; dd.eulerX = (double)ddt.rotation.eulerAngles.x; dd.eulerY = (double)ddt.rotation.eulerAngles.y; dd.eulerZ = (double)ddt.rotation.eulerAngles.z; dd.scaleX = (double)ddt.lossyScale.x; dd.scaleY = (double)ddt.lossyScale.y; dd.scaleZ = (double)ddt.lossyScale.z; md.decorations.Add(dd); } } return(md); }
public void AddOwnedDecoration(DecorationData d, ItemInstance item) { for (int i = 0; i < notPurchasedDecor.Count; i++) { Decoration temp = notPurchasedDecor[i].GetComponent <Decoration>(); if (temp.data.IsEqual(d)) { d.numInInventory = (int)item.RemainingUses; temp.ResetData(d); } } GameObject inv = (GameObject)Instantiate(DecorInfoPrefab); inv.GetComponent <Decoration>().ResetData(d); inv.transform.SetParent(InventoryDecorPanel.transform); }
private void Decoration(int x, int y, int tile = 0) { DecorationData decoration = ItemDatabase.GetDecoration(tile); if (!decoration) { return; } for (int i = x; i < x + decoration.Width; i++) { for (int j = y; j < y + decoration.Height; j++) { world.SetTile(2, i, j, ushort.MaxValue); } } world.SetTile(2, x, y, tile); }
// Puts decoration into restaurant (can replace) public bool AddDecoration(DecorationData d) { //go through the decor and see if it will be replacing something, or not for (int i = 0; i < data.decor.Count; i++) { DecorationData decData = data.decor[i]; if (decData.location == d.location) { Debug.Log("Replaced " + decData.ToString()); data.decor.Remove(decData); CatfePlayerScript.script.SetDecorationSprites(); } } //we add the new decor here whether or not a decoration is being replaced data.decor.Add(d); return(true); }
public void CompletePurchase() { PurchaseItemRequest request = new PurchaseItemRequest(); request.ItemId = "" + data.id; request.CatalogVersion = "Items"; request.VirtualCurrency = "NM"; request.Price = data.cost; DecorationData d = data; PlayFabClientAPI.PurchaseItem(request, result => { Debug.Log("Purchased!"); PlayFabLogin.GetMoney(); CatInventory.catInv.SortChoice(); gameObject.SetActive(false); //result is a List<ItemInstance> object CatInventory.catInv.AddOwnedDecoration(d, result.Items[0]); }, error => { Debug.LogError(error.ErrorMessage); }); data = null; }
public void UpdateText(DecorationData d, Recipe r) { if (d != null) { name.text = d.name; atmosphere.text = "Atmosphere: " + d.atmosphere; restaurantType.text = ""; cost.text = "Cost: " + d.cost; starLevel.text = "Star level: " + d.starLevel; description.text = d.description; } if (r != null) { name.text = r.recipeName; atmosphere.text = ""; restaurantType.text = "Restaurant Type: " + r.foodType; cost.text = "Cost: " + r.cost; starLevel.text = "Star level: " + r.starLevel; description.text = r.description; } }
public void DeleteDecoration(Int2 pos) { Tile tile = currentWorld.GetTile(2, pos); DecorationData decoration = ItemDatabase.GetDecoration(tile.ID); if (!decoration) { return; } Destroy(decorations[pos].gameObject); decorations.Remove(pos); decoration.Delete(pos.x, pos.y); for (int x = pos.x; x < pos.x + decoration.Width; x++) { for (int y = pos.y; y < pos.y + decoration.Height; y++) { currentWorld.SetTile(2, x, y, 0); } } }
private Vector3 CalculateCorrectedPosition(Vector3 originalPosition, DecorationData data, bool snapToGrid) { Vector3 pos = originalPosition; if (data.CenterOnly) { pos.x = Mathf.Floor(originalPosition.x / 4f) * 4f + 2f; pos.z = Mathf.Floor(originalPosition.z / 4f) * 4f + 2f; } else if (data.CornerOnly) { pos.x = Mathf.Round(originalPosition.x / 4f) * 4f; pos.z = Mathf.Round(originalPosition.z / 4f) * 4f; } else if (snapToGrid) { float distToCornerX = 2f - Mathf.Abs(originalPosition.x % 4f - 2f); float distToCornerZ = 2f - Mathf.Abs(originalPosition.z % 4f - 2f); Vector2 distVector = new Vector2(distToCornerX, distToCornerZ); float magnitude = distVector.magnitude; if (magnitude < cornerSnapDistance) { pos.x = Mathf.Round(originalPosition.x / 4f) * 4f; pos.z = Mathf.Round(originalPosition.z / 4f) * 4f; } else { pos.x = Mathf.Floor(originalPosition.x / (4f / 3f)) * (4f / 3f) + (2f / 3f); pos.z = Mathf.Floor(originalPosition.z / (4f / 3f)) * (4f / 3f) + (2f / 3f); } } if (data.Floating) { pos.y = Mathf.Max(originalPosition.y, 0); } return(pos); }
public void ResetData(DecorationData newData) { data = newData; if (name != null) { name.text = newData.name; } if (cost != null) { cost.text = "" + newData.cost; if (newData.numInInventory > 0) { cost.text = "" + newData.cost + "\n(OWNED)"; } } if (starLevel != null) { starLevel.text = "StarLevel: " + newData.starLevel; } if (atmosphere != null) { atmosphere.text = "Atmosphere: " + newData.atmosphere; } if (type != null) { type.text = "Type: " + newData.location; } if (numInInventoryText != null) { numInInventoryText.text = "x" + newData.numInInventory; } if (sprite != null) { sprite.sprite = PlayerData.GetDecorSprite(newData.sprite); } }
private void Start() { if (drawDebugPlaneLines) { PlaneLine horizontalLine = Instantiate(GameManager.Instance.PlaneLinePrefab); horizontalLine.Alignment = PlaneAlignment.Horizontal; horizontalLine.TileCoords = new Vector2Int(5, 5); PlaneLine firstVerticalLine = Instantiate(GameManager.Instance.PlaneLinePrefab); firstVerticalLine.Alignment = PlaneAlignment.Vertical; firstVerticalLine.TileCoords = new Vector2Int(5, 5); PlaneLine secondVerticalLine = Instantiate(GameManager.Instance.PlaneLinePrefab); secondVerticalLine.Alignment = PlaneAlignment.Vertical; secondVerticalLine.TileCoords = new Vector2Int(15, 15); } if (preloadAllDecorations) { foreach (KeyValuePair <string, DecorationData> pair in Database.Decorations) { DecorationData data = pair.Value; CoroutineManager.Instance.QueueCoroutine(data.Model.CreateOrGetModel(Destroy)); } } }
private void Update() { bool snapToGrid = snapToGridToggle.isOn; bool rotationSnapping = rotationSnappingToggle.isOn; float rotationEditSensitivity = 1; float.TryParse(rotationSensitivityInput.text, NumberStyles.Any, CultureInfo.InvariantCulture, out rotationEditSensitivity); bool propertiesNeedSaving = false; if (Math.Abs(rotationEditSensitivity - Properties.Instance.DecorationRotationSensitivity) > float.Epsilon) { Properties.Instance.DecorationRotationSensitivity = rotationEditSensitivity; propertiesNeedSaving = true; } if (snapToGrid != Properties.Instance.DecorationSnapToGrid) { Properties.Instance.DecorationSnapToGrid = snapToGrid; propertiesNeedSaving = true; } if (rotationSnapping != Properties.Instance.DecorationRotationSnapping) { Properties.Instance.DecorationRotationSnapping = rotationSnapping; propertiesNeedSaving = true; } if (propertiesNeedSaving) { Properties.Instance.SaveProperties(); } RaycastHit raycast = LayoutManager.Instance.CurrentCamera.CurrentRaycast; if (!raycast.transform) { if (ghostObject) { ghostObject.SetActive(false); } return; } DecorationData data = (DecorationData)GuiManager.Instance.ObjectsTree.SelectedValue; bool dataChanged = data != lastFrameData; lastFrameData = data; if (!data) { return; } OverlayMesh overlayMesh = raycast.transform.GetComponent <OverlayMesh>(); GroundMesh groundMesh = raycast.transform.GetComponent <GroundMesh>(); TileEntity tileEntity = raycast.transform.GetComponent <TileEntity>(); Material ghostMaterial = GraphicsManager.Instance.GhostMaterial; if (dataChanged) { CoroutineManager.Instance.QueueCoroutine(data.Model.CreateOrGetModel(ghostMaterial, OnGhostCreated)); return; } if (!ghostObject) { return; } int targetFloor = LayoutManager.Instance.CurrentCamera.Floor; if (tileEntity && tileEntity.Valid && tileEntity.GetType() == typeof(Floor)) { targetFloor = tileEntity.Floor; } if (data.CenterOnly || data.Tree || data.Bush) { targetFloor = 0; } Map map = GameManager.Instance.Map; if (!placingDecoration) { position = CalculateCorrectedPosition(raycast.point, data, snapToGrid); targetedTile = null; if (overlayMesh) { int tileX = Mathf.FloorToInt(position.x / 4f); int tileY = Mathf.FloorToInt(position.z / 4f); targetedTile = map[tileX, tileY]; position.y = map.GetInterpolatedHeight(position.x, position.z); if (data.Floating) { position.y = Mathf.Max(position.y, 0); } else { float floorHeight = 3f; position.y += targetFloor * floorHeight; } } else if (tileEntity && tileEntity.Valid) { targetedTile = tileEntity.Tile; } } bool canPlaceNewObject = overlayMesh || groundMesh || (tileEntity && tileEntity.Valid && tileEntity.GetType() == typeof(Floor)); if (canPlaceNewObject || placingDecoration) { ghostObject.gameObject.SetActive(true); ghostObject.transform.position = position; } else { ghostObject.gameObject.SetActive(false); } bool placementAllowed = true; Vector2 position2d = new Vector2(position.x, position.z); IEnumerable <Decoration> nearbyDecorations = GetAllNearbyDecorations(targetedTile); foreach (Decoration decoration in nearbyDecorations) { Vector3 decorationPosition3d = decoration.transform.position; Vector2 decorationPosition2d = new Vector2(decorationPosition3d.x, decorationPosition3d.z); float distance = Vector2.Distance(position2d, decorationPosition2d); if (distance < minimumPlacementGap) { placementAllowed = false; break; } } ToggleGhostPropertyBlock(placementAllowed ? allowedGhostPropertyBlock : disabledGhostPropertyBlock); if (Input.GetMouseButtonDown(0) && placementAllowed) { placingDecoration = true; dragStartPos = LayoutManager.Instance.CurrentCamera.MousePosition; } if (Input.GetMouseButton(0) && placingDecoration) { Vector2 dragEndPos = LayoutManager.Instance.CurrentCamera.MousePosition; Vector2 difference = dragEndPos - dragStartPos; rotation = -difference.x * rotationEditSensitivity; if (rotationSnapping) { rotation = Mathf.Round(rotation / 45f) * 45f; } ghostObject.transform.localRotation = Quaternion.Euler(0, rotation, 0); } if (Input.GetMouseButtonUp(0) && placingDecoration) { float decorationPositionX = position.x - targetedTile.X * 4f; float decorationPositionY = position.z - targetedTile.Y * 4f; Vector2 decorationPosition = new Vector2(decorationPositionX, decorationPositionY); targetedTile.SetDecoration(data, decorationPosition, rotation * Mathf.Deg2Rad, targetFloor, data.Floating); map.CommandManager.FinishAction(); placingDecoration = false; ghostObject.transform.localRotation = Quaternion.identity; } if (Input.GetMouseButtonDown(1)) { placingDecoration = false; ghostObject.transform.localRotation = Quaternion.identity; } if (Input.GetMouseButtonDown(1) && !placingDecoration) { IEnumerable <Decoration> decorationsOnTile = targetedTile.GetDecorations(); foreach (Decoration decoration in decorationsOnTile) { targetedTile.SetDecoration(null, decoration.Position, decoration.Rotation, targetFloor); } map.CommandManager.FinishAction(); } }
public void LoadSecretBase(SecretBase secretBase) { this.secretBase = secretBase; foreach (Image image in decorationImages) { this.gridRoomContents.Children.Remove(image); } if (pocket != null) { pocket = secretBase.GameSave.Inventory.Decorations[pocket.PocketType]; } else { pocket = secretBase.GameSave.Inventory.Decorations[DecorationTypes.Desk]; } comboBoxPockets.SelectedIndex = (int)DecorationTypes.Desk - 1; OnPocketSelectionChanged(null, null); imageLocation.Source = LocationData.Image; imageTrainer.Margin = new Thickness(16 * RoomData.TrainerX, 16 * RoomData.TrainerY - 8, 0, 0); imageTrainer.Source = ResourceDatabase.GetImageFromName(secretBase.TrainerGender.ToString() + "SecretBase" + ((byte)secretBase.TrainerID % 5).ToString()); BitmapSource roomImage = RoomData.Image; gridRoomContents.Width = roomImage.PixelWidth; gridRoomContents.Height = roomImage.PixelHeight; imageRoom.Width = roomImage.PixelWidth; imageRoom.Height = roomImage.PixelHeight; imageRoom.Source = roomImage; imageRouteSign.Source = ResourceDatabase.GetImageFromName("RouteSign" + (RouteData.ID >= 124 ? "Water" : "Land")); labelRoute.Content = "Route " + RouteData.ID; /*if (RoomData.Type == SecretBaseRoomTypes.Tree || RoomData.Type == SecretBaseRoomTypes.Shrub) { * rectRoomBackground.Visibility = Visibility.Hidden; * } * else {*/ rectRoomBackground.Margin = new Thickness((1 - RoomData.Width % 2) * -8, (1 - RoomData.Height % 2) * -8, 0, 0); rectRoomBackground.Visibility = Visibility.Visible; (rectRoomBackground.Fill as ImageBrush).ImageSource = RoomData.BackgroundImage; //} foreach (PlacedDecoration decoration in secretBase.PlacedDecorations) { DecorationData decorationData = decoration.DecorationData; BitmapSource decorationImage = ItemDatabase.GetDecorationFullSizeImageFromID(decoration.ID); Image image = new OpaqueClickableImage(); image.Width = decorationImage.PixelWidth; image.Height = decorationImage.PixelHeight; image.Stretch = Stretch.None; image.Source = decorationImage; if (decoration.DecorationData.DataType == DecorationDataTypes.NoteMat && showNotes) { image.Source = ResourceDatabase.GetImageFromName("NoteMat" + (decoration.ID - 51).ToString()); } image.Margin = new Thickness(16 * (decoration.X - decorationData.OriginX), 16 * (decoration.Y - decorationData.OriginY), 0, 0); image.HorizontalAlignment = HorizontalAlignment.Left; image.VerticalAlignment = VerticalAlignment.Top; image.Tag = decoration; image.PreviewMouseDown += OnDecorationImageMouseDown; image.MouseEnter += OnDecorationImageMouseEnter; image.MouseLeave += OnDecorationImageMouseLeave; image.IsHitTestVisible = mode == PlaceModes.PutAway || mode == PlaceModes.Move; decorationImages.Add(image); this.gridRoomContents.Children.Add(image); } OrganizeZIndexes(); Grid.SetZIndex(imageTrainer, 16 * RoomData.TrainerY); routeTooltip = new ToolTip(); BitmapSource routeImage = RouteData.Image; Grid tooltip = new Grid(); tooltip.Width = routeImage.PixelWidth / 8 + 10; tooltip.Height = routeImage.PixelHeight / 8 + 10; Image route = new Image(); route.HorizontalAlignment = HorizontalAlignment.Left; route.VerticalAlignment = VerticalAlignment.Top; route.Width = routeImage.PixelWidth / 8; route.Height = routeImage.PixelHeight / 8; route.Margin = new Thickness(5, 5, 5, 5); route.Stretch = Stretch.Uniform; route.Source = routeImage; Image pinpoint = new Image(); pinpoint.HorizontalAlignment = HorizontalAlignment.Left; pinpoint.VerticalAlignment = VerticalAlignment.Top; pinpoint.Width = 12; pinpoint.Height = 12; pinpoint.Source = ResourceDatabase.GetImageFromName("RouteLocationSelector"); pinpoint.Margin = new Thickness(LocationData.MapX * 2, LocationData.MapY * 2, 0, 0); tooltip.Children.Add(route); tooltip.Children.Add(pinpoint); imageLocation.ToolTip = tooltip; UpdateDetails(); }
void OnGUI() { GUIStyle boxStyle = new GUIStyle("box"); var width = position.size.x - boxStyle.border.horizontal; var height = position.size.y - boxStyle.border.vertical; var innerBoxWidth = width - (boxStyle.padding.horizontal + boxStyle.border.horizontal); var innerBoxHeight = height - (boxStyle.padding.vertical + boxStyle.border.vertical); MyGUIExtend.Instance.ToolbarButton(new Dictionary <string, Action> { { "读取", LoadData }, { "保存", SaveData }, { "制作预制体", CreatePrefabs } }); EditorGUILayout.BeginVertical(boxStyle, GUILayout.Width(width), GUILayout.Height(height)); MyGUIExtend.Instance.Foldout("DcorationEditor", "路径信息", (() => { EditorGUILayout.BeginHorizontal(); EditorGUILayout.LabelField(decorationDataFile); excelPath = MyGUI.TextFieldWithTitle("表格路径", excelPath); if (MyGUI.Button("载入Excel")) { EditorTools.AnalyzeExcelToDic(excelPath, dic => { EquipType equipType = (EquipType)Convert.ToInt32(dic["EquipType"]); switch (equipType) { case EquipType.Decoration: case EquipType.Glove: case EquipType.Shoe: case EquipType.Ring: DecorationData newDecorationData = new DecorationData(); foreach (var item in dic) { switch (item.Key) { case "id": newDecorationData.id = Convert.ToString(item.Value); break; case "IconName": newDecorationData.icon = Convert.ToString(item.Value); break; case "name": newDecorationData.name = Convert.ToString(item.Value); break; case "Lv": newDecorationData.level = Convert.ToInt32(item.Value); break; case "desc": newDecorationData.desc = Convert.ToString(item.Value); break; case "Hp": newDecorationData.attrData.hpMax = Convert.ToSingle(item.Value); break; case "defence": newDecorationData.attrData.def = Convert.ToSingle(item.Value); break; case "ATK": newDecorationData.attrData.atk = Convert.ToSingle(item.Value); break; case "speed": newDecorationData.attrData.atkSpeedScale = Convert.ToSingle(item.Value); break; case "Critical": newDecorationData.attrData.criticalRate = Convert.ToSingle(item.Value); break; case "CriticalDamage": newDecorationData.attrData.criticalDamage = Convert.ToSingle(item.Value); break; case "move": newDecorationData.attrData.moveSpeedScale = Convert.ToSingle(item.Value); break; case "EquipType": newDecorationData.equipType = equipType; break; } } int index = decorationDataList.FindIndex((data) => { return(data.id == newDecorationData.id); }); if (index >= 0) { decorationDataList.RemoveAt(index); } decorationDataList.Add(newDecorationData); break; } }); } EditorGUILayout.EndHorizontal(); EditorGUILayout.BeginHorizontal(); EditorGUILayout.LabelField(prefabPath); EditorGUILayout.EndHorizontal(); })); // 编辑区域 add by TangJian 2017/11/15 16:28:19 EditorGUILayout.BeginHorizontal(); // // 列表框 add by TangJian 2017/11/15 16:27:46 EditorGUILayout.BeginVertical(boxStyle, GUILayout.Width(innerBoxWidth / 2), GUILayout.ExpandHeight(true)); listScrollViewPos = EditorGUILayout.BeginScrollView(listScrollViewPos); for (int i = decorationDataList.Count - 1; i >= 0; i--) { var item = decorationDataList[i]; EditorGUILayout.BeginHorizontal(); int Index = MyGUIExtend.Instance.ListSingleButton("DocrationEditor", item.id, i, (() => { currDecorationData = item; })); MyGUIExtend.Instance.Mouse_RightDrop(new Dictionary <string, Action> { { "删除", (() => { decorationDataList.RemoveAt(Index); }) }, { "复制", () => { var decorationData = Tools.Json2Obj <DecorationData>(Tools.Obj2Json(decorationDataList[Index], true)); decorationDataList.Add(decorationData); } } }); EditorGUILayout.EndHorizontal(); } if (MyGUI.Button("+")) { decorationDataList.Add(new DecorationData()); } GUILayout.Space(10); EditorGUILayout.EndScrollView(); EditorGUILayout.EndVertical(); // 编辑框 add by TangJian 2017/11/15 16:28:46 EditorGUILayout.BeginVertical(boxStyle, GUILayout.Width(innerBoxWidth / 2), GUILayout.ExpandHeight(true)); editScrollViewPos = EditorGUILayout.BeginScrollView(editScrollViewPos); if (currDecorationData != null) { MyGUI.ItemDataField(currDecorationData); } GUILayout.Space(10); EditorGUILayout.EndScrollView(); EditorGUILayout.EndVertical(); EditorGUILayout.EndHorizontal(); EditorGUILayout.EndVertical(); }
public void LoadSecretBase(SecretBase secretBase) { this.secretBase = secretBase; foreach (Image image in decorationImages) { this.gridRoomContents.Children.Remove(image); } gridRoomContents.Visibility = Visibility.Visible; imageTrainer.Margin = new Thickness(16 * RoomData.TrainerX, 16 * RoomData.TrainerY - 8, 0, 0); imageTrainer.Source = ResourceDatabase.GetImageFromName(secretBase.TrainerGender.ToString() + "SecretBase" + ((byte)secretBase.TrainerID % 5).ToString()); imageTrainer.Visibility = (secretBase.IsPlayerSecretBase ? Visibility.Hidden : Visibility.Visible); BitmapSource roomImage = RoomData.Image; gridRoomContents.Width = roomImage.PixelWidth; gridRoomContents.Height = roomImage.PixelHeight; imageRoom.Width = roomImage.PixelWidth; imageRoom.Height = roomImage.PixelHeight; imageRoom.Source = roomImage; /*if (RoomData.Type == SecretBaseRoomTypes.Tree || RoomData.Type == SecretBaseRoomTypes.Shrub) { * rectRoomBackground.Visibility = Visibility.Hidden; * } * else {*/ rectRoomBackground.Margin = new Thickness((1 - RoomData.Width % 2) * -8, (1 - RoomData.Height % 2) * -8, 0, 0); rectRoomBackground.Visibility = Visibility.Visible; (rectRoomBackground.Fill as ImageBrush).ImageSource = RoomData.BackgroundImage; //} foreach (PlacedDecoration decoration in secretBase.PlacedDecorations) { DecorationData decorationData = decoration.DecorationData; BitmapSource decorationImage = ItemDatabase.GetDecorationFullSizeImageFromID(decoration.ID); Image image = new OpaqueClickableImage(); image.Width = decorationImage.PixelWidth; image.Height = decorationImage.PixelHeight; image.Stretch = Stretch.None; image.Source = decorationImage; image.Margin = new Thickness(16 * (decoration.X - decorationData.OriginX), 16 * (decoration.Y - decorationData.OriginY), 0, 0); image.HorizontalAlignment = HorizontalAlignment.Left; image.VerticalAlignment = VerticalAlignment.Top; image.Tag = decoration; decorationImages.Add(image); this.gridRoomContents.Children.Add(image); } foreach (Image image in decorationImages) { PlacedDecoration decoration = image.Tag as PlacedDecoration; int zIndex = 16 * decoration.Y; if (decoration.DecorationData.DecorationType == DecorationTypes.Doll) { if (decoration.ID >= 111) // Big Doll { zIndex += 160; } else { zIndex += 162; } } else if (decoration.DecorationData.DecorationType == DecorationTypes.Cushion) { zIndex += 162; } Grid.SetZIndex(image, zIndex); } Grid.SetZIndex(imageTrainer, 16 * RoomData.TrainerY); }
public void SetPosition(DecorationData decorationData) { }
public bool IsEqual(DecorationData d) { return(this.name == d.name); }
public void GetPlayFabDecor() { Dictionary <string, ItemInstance> ownedItems = new Dictionary <string, ItemInstance>(); //getting the user's inventory GetUserInventoryRequest request = new GetUserInventoryRequest(); PlayFabClientAPI.GetUserInventory(request, result => { restaurants = new List <RestaurantData>(); foreach (ItemInstance i in result.Inventory) { if (i.ItemClass == "cat") { if (i.ItemId == "waiter_cat") { AddCat(null, new WaiterData(i)); } else if (i.ItemId == "chef_cat") { AddCat(new ChefData(i), null); } } else if (i.ItemClass == "Restaurant") { restaurants.Add(new RestaurantData(i)); } else { ownedItems.Add(i.ItemId, i); } } CatfePlayerScript.script.SetUpRestaurants(restaurants); }, error => {}); //getting the decor in the shop GetCatalogItemsRequest itemRequest = new GetCatalogItemsRequest(); itemRequest.CatalogVersion = "Items"; PlayFabClientAPI.GetCatalogItems(itemRequest, result => { List <CatalogItem> items = result.Catalog; foreach (CatalogItem i in items) { switch (i.ItemClass) { case "Decoration": DecorationData d = new DecorationData(i); GameObject newDecor = (GameObject)Instantiate(DecorPref); //if the item is owned, make sure the correct info is there if (ownedItems.ContainsKey(i.ItemId)) { decor.Add(newDecor); GameObject inv = (GameObject)Instantiate(DecorInfoPrefab); d.numInInventory = (int)ownedItems[i.ItemId].RemainingUses; inv.GetComponent <Decoration>().ResetData(d); inv.transform.SetParent(InventoryDecorPanel.transform); } else { notPurchasedDecor.Add(newDecor); } newDecor.GetComponent <Decoration>().ResetData(d); newDecor.transform.SetParent(DecorPanel.transform); break; case "Recipe": Recipe r = new Recipe(i); GameObject newRecipe = (GameObject)Instantiate(RecipeInfoPrefab); recipes.Add(newRecipe); //if the item is owned, make sure the correct info is there if (ownedItems.ContainsKey(i.ItemId)) { newRecipe.GetComponent <RecipePanelData>().ResetData(r); newRecipe.transform.SetParent(InventoryRecipePanel.transform); } //only put recipe panels in the store if they haven't been purchased else { newRecipe.GetComponent <RecipePanelData>().ResetData(r); newRecipe.transform.SetParent(RecipePanel.transform); } break; case "outfit": OutfitData o = new OutfitData(i); GameObject newOutfit = (GameObject)Instantiate(OutfitPrefab); //if the item is owned, make sure the correct info is there if (ownedItems.ContainsKey(i.ItemId)) { newOutfit.GetComponent <Outfits>().ResetData(o); newOutfit.transform.SetParent(InventoryOutfitPanel.transform); } else { newOutfit.GetComponent <Outfits>().ResetData(o); newOutfit.transform.SetParent(OutfitPanel.transform); } GameObject dress = (GameObject)Instantiate(outfitDressupPanel); dress.GetComponent <Outfits>().ResetData(o); if (i.Tags[0] == "shirt") { dress.transform.SetParent(dressupPanels[0].transform); } else if (i.Tags[0] == "hat") { dress.transform.SetParent(dressupPanels[1].transform); } else if (i.Tags[0] == "glasses") { dress.transform.SetParent(dressupPanels[2].transform); } else if (i.Tags[0] == "arms") { dress.transform.SetParent(dressupPanels[3].transform); } else if (i.Tags[0] == "pants") { dress.transform.SetParent(dressupPanels[4].transform); } else if (i.Tags[0] == "feet") { dress.transform.SetParent(dressupPanels[5].transform); } break; default: break; } } }, error => {} ); }
public bool SetDecoration(int x, int y, Tile tile) { DecorationData decoration = ItemDatabase.GetDecoration(tile.ID); switch (decoration.DecorationType) { case DecorationType.Grounded: for (int i = x; i < x + decoration.Width; i++) { if (!currentWorld.HasTile(0, i, y - 1)) { return(false); } for (int j = y; j < y + decoration.Height; j++) { if (currentWorld.HasTile(2, i, j) || currentWorld.HasTile(0, i, j)) { return(false); // Decoration spot occupied } } } break; case DecorationType.Mounted: for (int i = x; i < x + decoration.Width; i++) { for (int j = y; j < y + decoration.Height; j++) { if (currentWorld.HasTile(2, i, j) || currentWorld.HasTile(0, i, j)) { return(false); // Decoration spot occupied } } } bool blocksUnder = true; for (int i = x; i < x + decoration.Width; i++) { if (!currentWorld.HasTile(0, i, y - 1)) { blocksUnder = false; } } if (!blocksUnder) { for (int i = x; i < x + decoration.Width; i++) { for (int j = y; j < y + decoration.Height; j++) { if (!currentWorld.HasTile(1, i, j)) { return(false); // Decoration spot occupied } } } } break; default: for (int i = x; i < x + decoration.Width; i++) { for (int j = y; j < y + decoration.Height; j++) { if (currentWorld.HasTile(2, i, j) || currentWorld.HasTile(0, i, j)) { return(false); // Decoration spot occupied } } } break; } for (int i = x; i < x + decoration.Width; i++) { for (int j = y; j < y + decoration.Height; j++) { currentWorld.SetTile(2, i, j, ushort.MaxValue); } } currentWorld.SetTile(2, x, y, tile.ID); return(true); }