| 일 | 월 | 화 | 수 | 목 | 금 | 토 |
|---|---|---|---|---|---|---|
| 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 |
Tags
- c샾 헬로우 월드
- 유니티
- C언어 달력
- 루아다운로드
- for문
- c언어 배열 programming
- c언어 콘서트 배열 2번
- c언어 콘서트 배열
- Lua란
- Lua language
- N Queens Problem
- 루아
- N Queen Coordinates
- N Queen 문제
- 2중 반복문
- lua download
- 비주얼 스튜디오
- 비주얼 스튜디오 다운로드
- 게임제작
- Lua 설명
- 메이플스토리
- c#온라인
- LUA
- c++ 등차수열 합
- c언어 버블정렬
- c언어 최대최소
- lua 다운로드
- 온라인 비주얼 스튜디오
- c샾 hello world
- c sharp hello world
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