本文整理汇总了C#中Coroutine类的典型用法代码示例。如果您正苦于以下问题:C# Coroutine类的具体用法?C# Coroutine怎么用?C# Coroutine使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Coroutine类属于命名空间,在下文中一共展示了Coroutine类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: WaitForSeconds
public WaitForSeconds(Coroutine coroutine, double seconds)
{
this.coroutine = coroutine;
TimeoutEvent e = new TimeoutEvent { Key = this };
token = Flow.Bind(e, OnTimeout);
TimeFlow.Default.Reserve(e, seconds);
}
示例2: Restart
public void Restart()
{
if(Hazards.Count > 0)
{
spawn_coroutine = StartCoroutine(SpawnRandomHazard());
}
}
示例3: Move
void Move(Vector3 newPos, float duration, float delay)
{
if (_moveCoroutine != null)
StopCoroutine(_moveCoroutine);
_moveCoroutine = StartCoroutine(MoveRoutine(newPos, duration, delay));
}
示例4: Update
// Update is called once per frame
void Update()
{
if(Input.GetKeyUp (KeyCode.Space)){
switchAlly = !switchAlly;
}
//Raycasting
if (Input.GetMouseButtonUp (0)) {
Ray r = Camera.main.ScreenPointToRay (Input.mousePosition);
RaycastHit hit;
if (Physics.Raycast (r, out hit, float.MaxValue)) {
//Debug.Log ("hit: " + hit.collider.name );
if(hit.collider.name == "Ground" ){
if(switchAlly == true && quantity_player_a < 3){
clone = Instantiate (ally_a, hit.point, allyTransform_a.rotation) as GameObject;
quantity_player_a++;
c = StartCoroutine (DeleteAlly(clone));
}else if(switchAlly == false && quantity_player_b < 3){
clone = Instantiate (ally_b, hit.point, allyTransform_b.rotation) as GameObject;
quantity_player_b++;
c = StartCoroutine (DeleteAlly(clone));
}
}
}
}
}
示例5: animateBlock
public void animateBlock(int currentBlockCount,int maxCount)
{
if (co != null)
StopCoroutine(co);
if(currentBlockCount > maxCount / 2)//more then half
{
mySR.color = new Color(1,1,1,1);//white
}
else if (currentBlockCount == 1)
{
mySR.color = new Color(1, 0, 0, 1);//red
}
//else if (currentBlockCount == 0)//block count is 0
//{
// mySR.color = new Color(mySR.color.r, mySR.color.g, mySR.color.b, 0);
//}
else
{
mySR.color = new Color(1, 1, 0, 1);//yellow
}
//mySR.color = new Color(mySR.color.r, mySR.color.g, mySR.color.b, 1);
alpha = mySR.color.a;
myanimator.enabled = true;
co = StartCoroutine(fadeOut());
}
示例6: Close
public void Close(float time, Action onFinish)
{
if (m_Coroutine != null)
StopCoroutine(m_Coroutine);
m_Coroutine = StartCoroutine(MoveEyelidsCoroutine(0.0f, 0.0f, time, onFinish));
}
示例7: Update
// Update is called once per frame
void Update () {
if(dialogManager.getID() >= startAtDialogNumber && dialogManager.getID() < endAtDialogNumber && !audioSource.isPlaying && !activate)
{
coroutineSound = StartCoroutine(WaitAndPlay(secondsToStart));
activate = true;
}
if(dialogManager.getID() >= endAtDialogNumber && activate)
{
StopCoroutine(coroutineSound);
}
if(dialogManager.getID() >= endAtDialogNumber && audioSource.isPlaying && !activateEnd)
{
audioSource.loop = false;
activateEnd = true;
if(trailSource != null)
{
trailSource.PlayScheduled( AudioSettings.dspTime + audioSource.clip.length - audioSource.time);
}
}
//if(dialogManager.getID() >= endAtDialogNumber && !audioSource.isPlaying && activateEnd && !activateTrail)
//{
// trailSource.Play();
// activateTrail = true;
//}
}
示例8: PanelTransition
protected IEnumerator PanelTransition(bool isShowing)
{
//Init
float timeLeft = 0f;
JEngine.Instance.uiManager.nbPanelInTransition++;
//Process
yield return new WaitForEndOfFrame();
if (isShowing)
{
while (canvasGroup.alpha < 1f)
{
timeLeft += Time.unscaledDeltaTime;
canvasGroup.alpha = transitionCurve.Evaluate(timeLeft / transitionDuration);
yield return new WaitForEndOfFrame();
}
}
else
{
while (canvasGroup.alpha > 0f)
{
timeLeft += Time.unscaledDeltaTime;
canvasGroup.alpha = transitionCurve.Evaluate(1f - (timeLeft / transitionDuration));
yield return new WaitForEndOfFrame();
}
canvasGroup.blocksRaycasts = false;
}
transitionCoroutine = null;
JEngine.Instance.uiManager.nbPanelInTransition--;
}
示例9: Start
//--------------------------------------------------------------------------------------------
void Start ()
{
// get handle on player script
playerScript = GetComponent<Player> ();
if(playerScript.chassisQuick)
{
rechargeRate *= playerScript.cooldownBoost;
}
//get handle on energy bar
energyBar = GameObject.Find("EnergyBar").GetComponent<RectTransform>();
origin = energyBar.localPosition;
energySprites = Resources.LoadAll<Sprite>("GUI_Assets/EnergyIcons");
energyImg = GameObject.Find("EnergyImg").GetComponent<Image>();
blinkCoroutine = null;
meshList = playerScript.GetComponentsInChildren<MeshRenderer>();
currEnergy = maxEnergy;
isActive = false;
isOnCooldown = false;
isOnCooldownDelay = false;
isOnInitialActivate = false;
//get handle on audio source for secondary ready
AudioSource[] sources = GetComponents<AudioSource>();
readyAudio = sources[1];
//audio source for phase on and off
onSound = sources[2];
offSound = sources[3];
}
示例10: Start
//--------------------------------------------------------------------------------------------
void Start()
{
//get handle on energy bar
energyBar = GameObject.Find("EnergyBar").GetComponent<RectTransform>();
origin = energyBar.localPosition;
energySprites = Resources.LoadAll<Sprite>("GUI_Assets/EnergyIcons");
energyImg = GameObject.Find("EnergyImg").GetComponent<Image>();
blinkCoroutine = null;
//init prefabs
teslaPrefabPhase_1 = Resources.Load<GameObject>("PlayerBullets/TeslaPhase_1");
teslaPrefabPhase_2 = Resources.Load<GameObject>("PlayerBullets/TeslaPhase_2");
forwardPos = transform.Find ("GunF");
currEnergy = maxEnergy;
storedDamage = 0f;
isCharging = false;
isOnInitialActivate = false;
isOnCooldownDelay = false;
isOnCooldown = false;
//get handle on audio source for secondary ready
readyAudio = GetComponents<AudioSource>()[1];
}
示例11: Start
// Use this for initialization
void Start () {
spriteRenderer = GetComponent<SpriteRenderer> ();
if (start)
{
currentCoroutine = StartCoroutine (ChangeSprite ());
}
}
示例12: OnFailure
private void OnFailure()
{
if (m_DisplayFailureCoroutine != null)
StopCoroutine(m_DisplayFailureCoroutine);
m_DisplayFailureCoroutine = StartCoroutine(DisplayFailure());
}
示例13: JumpTo
public void JumpTo(WorldMapArea area)
{
Debug.Assert(jumpRoutine == null, "jump routine must not already be in progress");
jumpTarget = area;
jumpRoutine = StartCoroutine(JumpRoutine());
}
示例14: longPressHandle
private void longPressHandle(object sender, System.EventArgs e)
{
if (MenuMaster.musicVolume > 0 && MenuMaster.musicVolume < 100)
{
fastChanger = StartCoroutine(fastChange());
}
}
示例15: Activate
public void Activate()
{
textMesh.text = changeText;
if( coRoutine != null )
StopCoroutine( "resetText" );
coRoutine = StartCoroutine( "resetText" );
}