ºÇ½ª¹¹¿·¡§
orika_ex_miyako 2020ǯ05·î29Æü(¶â) 15:55:18ÍúÎò
¡¡¡ArrowGenerator¤Î½¤Àµ
¡¡¢ArrowGenerator¤ËÀ¸À®¤¹¤ë¥¢¥¤¥Æ¥à¥×¥ì¥Õ¥¡¥Ö¤ò¥¢¥µ¥¤¥ó¤·¡¢À¸À®Î¨¤òÆþÎÏ
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class ArrowGenerator : MonoBehaviour
{
public GameObject arrowPrefab;
[Header("¥¹¥Ô¡¼¥É¥¢¥Ã¥×¥¢¥¤¥Æ¥à¤Î¥×¥ì¥Õ¥¡¥Ö")] // ÄɲÃ
public GameObject speedItemPrefab; // ÄɲÃ
[Header("Ìð¤Î½Ð¸½Î¨")] // ÄɲÃ
public int arrowRate; // ÄɲÃ
[Header("¥¹¥Ô¡¼¥É¥¢¥Ã¥×¥¢¥¤¥Æ¥à¤Î½Ð¸½Î¨")] // ÄɲÃ
public int speedItemRate; // ÄɲÃ
float span = 1.0f;
float delta = 0;
public float minSpan = 0.5f;
public float decSpan;
// Start is called before the first frame update
void Start()
{
}
// Update is called once per frame
void Update()
{
// this.span -= this.span * Time.deltaTime;
// float·¿
this.delta += Time.deltaTime;
// Debug.Log(Time.deltaTime);
if(this.delta > this.span)
{
this.delta = 0;
/* ¤³¤³¤«¤éÄɲà */
// ¥¤¥ó¥¹¥¿¥ó¥¹¤·¤¿GameObject¤òÂåÆþ¤¹¤ë¤¿¤á¤ÎÊÑ¿ô¤ò¡¢¶õ¤ÇÍѰդ¹¤ë
GameObject go = null;
// Ìð¤ÎÀ¸À®Î¨¤È¥¢¥¤¥Æ¥à¤ÎÀ¸À®Î¨¤ò¹ç·×¤·¡¢¤½¤ÎÈÏ°ÏÆâ¤Ç¥é¥ó¥À¥à¤ÊÃͤò£±¤Ä¼èÆÀ
int randomValue = Random.Range(0, (arrowRate + speedItemRate));
// randomValue ¤ÎÃͤ¬ Ìð¤ÎÀ¸À®Î¨ÈÏ°ÏÆâ¤Ê¤é
if (randomValue < arrowRate) {
// Ìð¤òÀ¸À®¤·¡¢ÊÑ¿ô¤ËÂåÆþ
go = Instantiate(arrowPrefab);
}
// randomValue ¤ÎÃͤ¬Ìð¤ÎÀ¸À®Î¨Èϰϳ°¤Ê¤é
else
{
¥¢¥¤¥Æ¥à¤òÀ¸À®¤·¡¢ÊÑ¿ô¤ËÂåÆþ
go = Instantiate(speedItemPrefab);
}
/* ¤³¤³¤Þ¤Ç */
int px = Random.Range(-14, 15);
go.transform.position = new Vector3(px, 7, 0);
if(this.span > this.minSpan)
{
this.span -= this.decSpan;
//Debug.Log(this.span);
}
}
}
}
¡¡public ÊÑ¿ô¤¬¥¤¥ó¥¹¥Ú¥¯¥¿¡¼¤Ëɽ¼¨¤µ¤ì¤Þ¤¹¤Î¤Ç¡¢Àè¤Û¤ÉºîÀ®¤·¤¿SpeedUpItem¥×¥ì¥Õ¥¡¥Ö¤ò
ProjectÆâ¤ÎPrefab¥Õ¥©¥ë¥À¤«¤é¥É¥é¥Ã¥°¥¢¥ó¥É¥É¥í¥Ã¥×¤Ç¥¢¥µ¥¤¥ó¤·¤Þ¤¹¡£
¡¡Â³¤¤¤Æ¡¢Ìð¤ÎÀ¸À®Î¨¤È¥¢¥¤¥Æ¥à¤ÎÀ¸À®Î¨¤òÀßÄꤷ¤Þ¤¹¡£
¹ç·×¤¬100¤Ë¤Ê¤ë¤è¤¦¤Ë¤·¤Æ¤ª¤±¤Ð¡Ö100%¤Î¤¦¤Á¡¢Ì𤬲¿%¡¢¥¢¥¤¥Æ¥à¤¬²¿%¡×¤È¤¤¤¦¸«Êý¤¬½ÐÍè¤Þ¤¹¡£
¡¡¥Ç¥Ð¥Ã¥°¤ò·ó¤Í¤Æ¥²¡¼¥à¤ò¼Â¹Ô¤·¤Æ¤ß¤Þ¤·¤ç¤¦¡£
¤³¤³¤Ç¤Ï¿ôÃͤÎÊѲ½¤Ë¤è¤ë¥Ç¥Ð¥Ã¥°¤ÎÊýË¡¤â³Ð¤¨¤Æ¤¤¤¤Þ¤·¤ç¤¦¡£
¤Þ¤º¤ÏÌð100¡¢¥¢¥¤¥Æ¥à0¤ÇÆþÎϤ·¤Æ¤¢¤ë¾ì¹ç¡¢Ìð¤Î¤ßÀ¸À®¤µ¤ì¤ë¤«³Îǧ¤·¤Þ¤¹¡£
¼¡¤ÏÌð0¡¢¥¢¥¤¥Æ¥à100¤ÇÆþÎϤ·¤Æ¤¢¤ë¾ì¹ç¡¢¥¢¥¤¥Æ¥à¤Î¤ßÀ¸À®¤µ¤ì¤ë¤«³Îǧ¤·¤Þ¤¹¡£
Ìð50¡¢¥¢¥¤¥Æ¥à50¤ÇÆþÎϤ·¤Æ¤¢¤ë¾ì¹ç¡¢ÂçÂΡ¢¸ò¸ß°Ì¤Î³ÎΨ¤ÇÀ¸À®¤Ç¤¤ì¤ÐÀ®¸ù¤È¸À¤¨¤ë¤Ç¤·¤ç¤¦¡£
- ¥«¥Æ¥´¥ê¡§
- ¿Ê³Ø/¥¹¥¯¡¼¥ë
- Áí¹ç




¥³¥á¥ó¥È¤ò¤«¤¯