陳列View修正
This commit is contained in:
		
							parent
							
								
									cf9022e6e6
								
							
						
					
					
						commit
						ee7abea2bb
					
				|  | @ -18,16 +18,14 @@ public class MarketCartView : MonoBehaviour | ||||||
|     { |     { | ||||||
|         ResetDisplay(); |         ResetDisplay(); | ||||||
|         // 陳列 |         // 陳列 | ||||||
|         var i = 0; |         for (int i = 0; i < shopStock.Count; i++) | ||||||
|         foreach (var flavor in shopStock) |  | ||||||
|         { |         { | ||||||
|             var popcorn = popcornPositions[i]; |             var popcorn = popcornPositions[i]; | ||||||
|             popcorn.ChangeSkin(flavor); |             popcorn.ChangeSkin(shopStock[i]); | ||||||
|             this.CallWaitForSeconds(.05f * i, () => |             this.CallWaitForSeconds(.05f * i, () => | ||||||
|             { |             { | ||||||
|                 popcorn.gameObject.SetActive(true); |                 popcorn.gameObject.SetActive(true); | ||||||
|             }); |             }); | ||||||
|             i++; |  | ||||||
|         } |         } | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
|  | @ -1,9 +1,16 @@ | ||||||
|  | using System; | ||||||
| using UnityEngine; | using UnityEngine; | ||||||
| 
 | 
 | ||||||
| public class MarketPopcornView : MonoBehaviour | public class MarketPopcornView : MonoBehaviour | ||||||
| { | { | ||||||
|     [SerializeField] private SpriteRenderer popcornRenderer; |     [SerializeField] private SpriteRenderer popcornRenderer; | ||||||
|     [SerializeField] private Sprite caramelSprite; |     [SerializeField] private Sprite caramelSprite; | ||||||
|  |     private Sprite defaultSkin; | ||||||
|  | 
 | ||||||
|  |     private void Awake() | ||||||
|  |     { | ||||||
|  |         defaultSkin = popcornRenderer.sprite; | ||||||
|  |     } | ||||||
| 
 | 
 | ||||||
|     public void ChangeSkin(int flavor) |     public void ChangeSkin(int flavor) | ||||||
|     { |     { | ||||||
|  | @ -11,5 +18,9 @@ public class MarketPopcornView : MonoBehaviour | ||||||
|         { |         { | ||||||
|             popcornRenderer.sprite = caramelSprite; |             popcornRenderer.sprite = caramelSprite; | ||||||
|         } |         } | ||||||
|  |         else | ||||||
|  |         { | ||||||
|  |             popcornRenderer.sprite = defaultSkin; | ||||||
|  |         } | ||||||
|     } |     } | ||||||
| } | } | ||||||
|  |  | ||||||
		Loading…
	
		Reference in New Issue