public void OnBeginDrag(PointerEventData eventData) { GameObject ButtonScripts = GameObject.Find("ButtonsCanvas"); ButtonScripts buttonScripts = ButtonScripts.GetComponent <ButtonScripts> (); // GameObject GameController = GameObject.Find ("GameController"); // GameController gameController = GameController.GetComponent<GameController> (); GameController.control.TurnTruePlayerButtons(); buttonScripts.CheckDropZone(); placeholder = new GameObject(); placeholder.transform.SetParent(this.transform.parent); LayoutElement le = placeholder.AddComponent <LayoutElement>(); le.preferredWidth = this.GetComponent <LayoutElement>().preferredWidth; le.preferredHeight = this.GetComponent <LayoutElement>().preferredHeight; le.flexibleWidth = 0; le.flexibleHeight = 0; placeholder.transform.SetSiblingIndex(this.transform.GetSiblingIndex()); parentToReturnTo = this.transform.parent; // Debug.Log(parentToReturnTo); placeholderParent = parentToReturnTo; this.transform.SetParent(this.transform.parent.parent); GetComponent <CanvasGroup>().blocksRaycasts = false; }
public void TrapActivate() { GameObject ButtonScripts = GameObject.Find("ButtonsCanvas"); ButtonScripts buttonScripts = ButtonScripts.GetComponent <ButtonScripts> (); GameObject CardDropArea = GameObject.Find("CardDropArea"); DropZone dropZone = CardDropArea.GetComponent <DropZone>(); GameObject Enemy = GameObject.Find(map.selectedEnemy); BaseEnemy enemy = Enemy.GetComponent <BaseEnemy>(); HealthBar enemyHpBar = enemy.GetComponent <HealthBar> (); GameObject Tile = GameObject.Find("Hex_" + enemy.TileX + "_" + enemy.TileY); ClickableTile tile = Tile.GetComponent <ClickableTile>(); buttonScripts.CheckDropZone(); enemyHpBar.CurHealth -= (tile.trapDamage / enemy.HpPointsMax) * 100; enemyHpBar.SetHealthBarEnemy(); // map.CheckVisibleTiles(); enemyHpBar.parentName = map.selectedEnemy; enemyHpBar.KillUnit(); dropZone.effect = tile.trapEffect; dropZone.RunEffect(); }