public void OnFingerDown(LeanFinger finger) { // Does the prefab exist? if (partPrefab != null) { // Get the RaycastResults under this finger's current position var results = LeanTouch.RaycastGui(finger.ScreenPosition); if (results.Count > 0) { // Is this finger over this UI element? if (results[0].gameObject == gameObject) { // Spawn prefab var partInstance = Instantiate(partPrefab); // Position partInstance.transform.position = ScreenDepth.Convert(finger.ScreenPosition, Camera, gameObject); Contraption currentContraption = ContraptionsManager.instance.GetCurrentContraption(); currentContraption.AddPart(partInstance.GetComponent <Part>()); LeanSelectable.DeselectAll(); // Select partInstance.GetComponent <LeanSelectable>().Select(finger); } } } }
public static bool ContraptionHasGluedParts(Contraption contraption) { foreach (BasePart x in contraption.Parts) { if (x.GetComponent <Glue>() != null) { return(true); } } return(false); }
void UpdateSize(Contraption contraption) { SizeBind.text = "--"; if (contraption != null) { if (contraption.Root.EquipedPart != null) { SizeBind.text = contraption.Root.EquipedPart.Size == Part.SizeType.None ? "--" : contraption.Root.EquipedPart.Size.ToString(); } } }
public static void ShowSuperGlue(Contraption contraption, Type type) { if (type == Glue.Type.None) { return; } if (contraption.CurrentGlue != Glue.Type.None || contraption.CurrentGlue != type) { Glue.RemoveSuperGlue(contraption); } Glue.ShowSuperGlue(contraption, type, contraption.Parts); }
void UpdateType(Contraption contraption) { TypeBind.text = "--- | --- | --- | ---"; if (contraption != null) { if (contraption.Root.EquipedPart != null) { string text = ""; for (int i = 0; i < 4; i++) { string typeName = ""; switch (i) { case 0: typeName = "Lnd"; break; case 1: typeName = "Air"; break; case 2: typeName = "Art"; break; case 3: typeName = "Sup"; break; default: typeName = "Null"; break; } if (i > 0 && i < 4) { text += " | "; } if (contraption.Root.EquipedPart.BDMask.HasFlag(i)) { text += typeName; } else { text += "---"; } } TypeBind.text = text; } } }
private void CreateContraption() { GameObject gameObject = UnityEngine.Object.Instantiate <GameObject>(this.m_menuContraptionControllerPrefab.gameObject); gameObject.transform.parent = base.transform; gameObject.transform.localPosition = Vector3.zero; this.m_contraptionController = gameObject.GetComponent <MenuContraptionController>(); Contraption contraption = gameObject.GetComponent <MenuContraptionController>().CreateContraption(this.m_contraptionAssets[this.m_contraptionIndex]); this.m_contraption = contraption; this.m_cameraTarget = contraption.FindPig().gameObject; this.m_contraptionIndex++; if (this.m_contraptionIndex >= this.m_contraptionAssets.Count) { this.m_contraptionIndex = 0; this.ShuffleContraptions(); } }
void OnPreview(string path) { CurrentPreviewPath = path; if (!string.IsNullOrEmpty(path)) { if (Calculator.instance.Parts.ContainsKey(path)) { Contraption contraption = Calculator.instance.Parts[path]; PartSection.gameObject.SetActive(true); NameBind.text = Path.GetFileNameWithoutExtension(path); LocationBind.text = path; DateBind.text = File.GetLastWriteTime(path).ToString("MMM d, yyyy"); ExBind.text = contraption.ExTuneCount.ToString(); UpdateType(contraption); HPBind.text = contraption.TotalStats.HP.ToString(); UpdateSize(contraption); CostBind.text = contraption.TotalStats.COST.ToString(); CapaBind.text = contraption.TotalStats.CAPA.ToString(); UpdateBarStat(contraption.TotalStats.STR, StrBarBind, StrBind); UpdateBarStat(contraption.TotalStats.TEC, TecBarBind, TecBind); UpdateBarStat(contraption.TotalStats.WLK, WlkBarBind, WlkBind); UpdateBarStat(contraption.TotalStats.FLY, FlyBarBind, FlyBind); UpdateBarStat(contraption.TotalStats.TGH, TghBarBind, TghBind); LevelBind.text = contraption.MaxLevel.ToString(); ClearCartridgeSlots(); for (int i = 0; i < contraption.Cartridges.Count; i++) { AddCartridgeSlot(contraption.Cartridges[i]); } } else { PartSection.gameObject.SetActive(false); } } else { PartSection.gameObject.SetActive(false); } TabFitter.Resize(); ListViewSectionFitter.Resize(); }
private void AddBirdsToBoundingBox(ref Rect box) { if (this.m_birdsCache == null) { this.m_birdsCache = GameObject.FindGameObjectsWithTag("Bird"); } if (this.m_birdsCache != null) { for (int i = 0; i < this.m_birdsCache.Length; i++) { GameObject gameObject = this.m_birdsCache[i]; if (gameObject.GetComponent <Bird>().IsDisturbed() && ((Mathf.Abs(gameObject.transform.position.y - this.currentPos.y) < 20f && Mathf.Abs(gameObject.transform.position.x - this.currentPos.x) < 20f * (float)Screen.width / (float)Screen.height) || gameObject.GetComponent <Bird>().IsAttacking())) { Vector3 position = gameObject.transform.position; Vector2 min = new Vector2(position.x - 8f, position.y - 2f); Vector2 max = new Vector2(position.x + 4f, position.y + 2f); Contraption.AddToBoundingBox(ref box, min, max); } } } }
public static void ShowSuperGlue(Contraption contraption, Type type, List <BasePart> parts) { foreach (BasePart basePart in parts) { if (Glue.IsPartTypeRequireGlue(basePart.m_partType)) { BasePart anotherPart = contraption.FindPartAt(basePart.m_coordX - 1, basePart.m_coordY); BasePart anotherPart2 = contraption.FindPartAt(basePart.m_coordX + 1, basePart.m_coordY); BasePart anotherPart3 = contraption.FindPartAt(basePart.m_coordX, basePart.m_coordY - 1); BasePart anotherPart4 = contraption.FindPartAt(basePart.m_coordX, basePart.m_coordY + 1); Glue exists = basePart.GetComponent <Glue>(); if (exists == null) { exists = basePart.gameObject.AddComponent <Glue>(); } Glue.CheckSideAndAppendGlue(basePart, anotherPart, Glue.Direction.Left, type); Glue.CheckSideAndAppendGlue(basePart, anotherPart2, Glue.Direction.Right, type); Glue.CheckSideAndAppendGlue(basePart, anotherPart4, Glue.Direction.Up, type); Glue.CheckSideAndAppendGlue(basePart, anotherPart3, Glue.Direction.Down, type); } } }
public void SetContraption(Contraption contraption) { this.contraption = contraption; }
public static void RemoveSuperGlue(Contraption contraption) { Glue.RemoveSuperGlue(contraption.Parts); }
public void SetCurrentContraption(Contraption contraption) { currrentContraption = contraption; }
public void SetCurrentContraption(Contraption contraption) { currentContraption = contraption; PartsManager.instance.SetCurrentContraption(contraption); }