| 일 | 월 | 화 | 수 | 목 | 금 | 토 |
|---|---|---|---|---|---|---|
| 1 | 2 | 3 | 4 | 5 | 6 | |
| 7 | 8 | 9 | 10 | 11 | 12 | 13 |
| 14 | 15 | 16 | 17 | 18 | 19 | 20 |
| 21 | 22 | 23 | 24 | 25 | 26 | 27 |
| 28 | 29 | 30 | 31 |
Tags
- Lua 설명
- 게임제작
- c++ 등차수열 합
- 비주얼 스튜디오 다운로드
- lua download
- C언어 달력
- LUA
- Lua language
- 메이플스토리
- c#온라인
- c샾 헬로우 월드
- N Queen Coordinates
- c언어 콘서트 배열 2번
- for문
- 온라인 비주얼 스튜디오
- 루아다운로드
- c언어 콘서트 배열
- c sharp hello world
- c언어 배열 programming
- 유니티
- Lua란
- N Queen 문제
- 비주얼 스튜디오
- lua 다운로드
- N Queens Problem
- c샾 hello world
- 루아
- 2중 반복문
- c언어 버블정렬
- c언어 최대최소
Archives
- Today
- Total
Ln Go
Shop 본문
using System.Collections;
using UnityEngine;
using UnityEngine.UI;
public class Shop : MonoBehaviour
{
public RectTransform uiGroup;
public Animator anim;
public GameObject[] itemObj;
public int[] itemPrice;
public Transform[] itemPos;
public string[] talkData;
public Text talkText;
Player enterPlayer;
void Awake()
{
enterPlayer = null;
}
public void Enter(Player player)
{
enterPlayer = player;
uiGroup.anchoredPosition = Vector3.zero;
}
public void Exit()
{
anim.SetTrigger("doHello");
uiGroup.anchoredPosition = Vector3.down * 1000;
}
void Update()
{
EscEscape();
}
void EscEscape()
{
if (Input.GetKey(KeyCode.Escape))
uiGroup.anchoredPosition = Vector3.down * 1000;
}
public void Buy(int index)
{
int price = itemPrice[index];
if (price > enterPlayer.coin)
{
StopCoroutine(Talk());
StartCoroutine(Talk());
return;
}
enterPlayer.coin -= price;
Vector3 ranVec = Vector3.right * Random.Range(-3, 3) + Vector3.forward * Random.Range(-3, 3);
Instantiate(itemObj[index], itemPos[index].position + ranVec, itemPos[index].rotation);
}
IEnumerator Talk()
{
talkText.text = talkData[1];
yield return new WaitForSeconds(2f);
talkText.text = talkData[0];
}
}
Comments