| | 1 | | using System.Collections; |
| | 2 | | using System.Collections.Generic; |
| | 3 | | using TMPro; |
| | 4 | | using UnityEngine; |
| | 5 | | using UnityEngine.UI; |
| | 6 | |
|
| | 7 | | public class ActionAdapter : MonoBehaviour |
| | 8 | | { |
| | 9 | | public Image actionImg, notDoneImg; |
| | 10 | |
|
| | 11 | | public Sprite moveSprite, |
| | 12 | | rotateSprite, |
| | 13 | | scaleSprite, |
| | 14 | | createdSprite; |
| | 15 | |
|
| | 16 | | public TextMeshProUGUI actionTitle; |
| | 17 | | public System.Action<BuildInWorldCompleteAction, ActionAdapter> OnActionSelected; |
| | 18 | |
|
| | 19 | | BuildInWorldCompleteAction action; |
| | 20 | |
|
| | 21 | | public void SetContent(BuildInWorldCompleteAction action) |
| | 22 | | { |
| 0 | 23 | | this.action = action; |
| | 24 | |
|
| 0 | 25 | | switch (this.action.actionType) |
| | 26 | | { |
| | 27 | | case BuildInWorldCompleteAction.ActionType.MOVE: |
| 0 | 28 | | actionImg.sprite = moveSprite; |
| 0 | 29 | | break; |
| | 30 | | case BuildInWorldCompleteAction.ActionType.ROTATE: |
| 0 | 31 | | actionImg.sprite = rotateSprite; |
| 0 | 32 | | break; |
| | 33 | | case BuildInWorldCompleteAction.ActionType.SCALE: |
| 0 | 34 | | actionImg.sprite = scaleSprite; |
| 0 | 35 | | break; |
| | 36 | | case BuildInWorldCompleteAction.ActionType.CREATE: |
| 0 | 37 | | actionImg.sprite = createdSprite; |
| 0 | 38 | | break; |
| | 39 | |
|
| | 40 | | default: |
| 0 | 41 | | actionImg.enabled = false; |
| | 42 | | break; |
| | 43 | | } |
| | 44 | |
|
| 0 | 45 | | actionTitle.text = this.action.actionType.ToString().Replace("_", " "); |
| 0 | 46 | | RefreshIsDone(); |
| 0 | 47 | | } |
| | 48 | |
|
| 0 | 49 | | public void RefreshIsDone() { notDoneImg.enabled = !action.isDone; } |
| | 50 | |
|
| 0 | 51 | | public void Selected() { OnActionSelected?.Invoke(action, this); } |
| | 52 | | } |