void PlaceSelect(PositionAndState heroPositionAndState) { if (heroPositionAndState.IsAtPosition) { if (heroFeedbackImageInstance != null) { Destroy(parentGameObject); } Destroy(heroFeedbackImageInstance); return; } if (heroFeedbackImageInstance != null) { parentGameObject.transform.position = heroPositionAndState.Position; } else { parentGameObject = new GameObject(); parentGameObject.transform.position = heroPositionAndState.Position; heroFeedbackImageInstance = (GameObject)Instantiate(heroFeedbackImage, heroPositionAndState.Position, Quaternion.identity); heroFeedbackImageInstance.transform.SetParent(parentGameObject.transform); heroFeedbackImageInstance.GetComponent <Animation>().Play(); } }
private void Awake() { characterAnimatorScript = GetComponentInChildren <IsometricCharacterAnimator> (); heroColider = GetComponentInChildren <CapsuleCollider2D> (); heroRigidbody = GetComponent <Rigidbody2D> (); heroTransform = GetComponent <Transform> (); pathFinding = GetComponent <PathFinding> (); targetPosition = heroTransform.position; heroPositionAndState = new PositionAndState(targetPosition, false); tilemapHandler = GameObject.Find("TilemapHandler").GetComponent <TilemapHandler> (); }