Inheritance: YieldInstruction
        public IEnumerator Start()
        {
            pool = new InventoryPool<InventoryUIItemWrapper>(wrapperPrefab, 8);
            queue = new Queue<ItemHolder>(8);
            destroyTimer = new WaitForSeconds(slideAnimation.length - 0.025f);
            offsetTimer = new WaitForSeconds(offsetTimerSeconds);

            foreach (var inv in InventoryManager.GetLootToCollections())
            {
                inv.OnAddedItem += (items, amount, cameFromCollection) =>
                {
                    if (cameFromCollection == false)
                    {
                        queue.Enqueue(new ItemHolder() { item = items.FirstOrDefault(), stackSize = amount});
                    }
                };
            }

            while (true)
            {
                if (queue.Count > 0)
                {
                    ShowItem(queue.Peek().item, queue.Peek().stackSize);
                    queue.Dequeue(); // Remove it
                }

                yield return offsetTimer;
            }
        }
	/// <summary>
	/// Loop the specified action periodically by the interval.
	/// </summary>
	/// <param name="action">Action.</param>
	/// <param name="interval">Interval.</param>
	IEnumerator Loop(Action action,float interval){
		WaitForSeconds waitForSeconds = new WaitForSeconds (interval);
		while (true) {
			action ();
			yield return waitForSeconds;//new WaitForSeconds (interval);
		}
	}
 void Start()
 {
     rb = GetComponent<Rigidbody2D>();
     audioSource = GetComponent<AudioSource>();
     if (rb != null) { hasRb = true; }
     audioCooldown = new WaitForSeconds(Random.Range(0.2f, 0.5f));
 }
    private void Start()
    {
        m_StartWait = new WaitForSeconds(m_StartDelay);
        m_EndWait = new WaitForSeconds(m_EndDelay);

        StartCoroutine(GameLoop());
    }
Esempio n. 5
0
    private IEnumerator runTest()
    {
        var waiter = new WaitForSeconds( 1.0f );

        while( true )
        {
            for( var i = 0; i < cubes.Length; i++ )
            {
                timex = updateChange * 0.1365143f;
                timey = updateChange * 0.3365143f;
                timez = updateChange * 2.5564f;

                endPt.x = noise.Noise( timex ) * (100+x) + origPos[i].x;
                endPt.y = noise.Noise( timey ) * (100+y) + origPos[i].y;
                endPt.z = noise.Noise( timez ) * (100+z) + origPos[i].z;

                var tween = tweens[i];
                props[i].resetWithNewEndValue( endPt );
                tween.restart( true );

                updateChange += Time.deltaTime *5;
            }

            yield return waiter;
        }
    }
Esempio n. 6
0
        IEnumerator PingLoop(DuplexStreamingResult <Nil, Nil> streaming, CancellationToken token)
        {
            var waiter = new UnityEngine.WaitForSeconds(pingSecond);

            while (true)
            {
                if (token.IsCancellationRequested)
                {
                    yield break;
                }
                yield return(waiter);

                if (token.IsCancellationRequested)
                {
                    yield break;
                }

                var r = streaming.RequestStream.WriteAsync(Nil.Default).ToYieldInstruction(false);
                yield return(r);

                if (r.HasError)
                {
                    yield break;
                }
            }
        }
Esempio n. 7
0
    private IEnumerator runTest()
    {
        var waiter = new WaitForSeconds( 1.0f );
        var targetPoint = Vector3.zero;
        var goKitLite = GoKitLite.instance;

        while( true )
        {
            for( var i = 0; i < _cubes.Length; i++ )
            {
                _timeX = _updateDelta * 0.15f;
                _timeY = _updateDelta * 0.3f;
                _timeZ = _updateDelta * 3.0f;

                targetPoint.x = _perlinNoiseGenerator.Noise( _timeX ) * 100 + _originalPositions[i].x;
                targetPoint.y = _perlinNoiseGenerator.Noise( _timeY ) * 100 + _originalPositions[i].y;
                targetPoint.z = _perlinNoiseGenerator.Noise( _timeZ ) * 100 + _originalPositions[i].z;

                goKitLite.positionTo( _cubes[i], 1.0f, targetPoint );

                _updateDelta += Time.deltaTime * 100;
            }

            yield return waiter;
        }
    }
Esempio n. 8
0
        public void Start()
        {
            waitTime = new WaitForSeconds(shootInterval);
            damageHander = behaviorTree.GetVariable("Target") as SharedDamageHandler;

            StartCoroutine(Shoot());
        }
Esempio n. 9
0
    IEnumerator DoFire() {
        WaitForSeconds fireW = new WaitForSeconds(fireWait);
        WaitForSeconds fireD = new WaitForSeconds(fireDelay);

        while((EntityState)state == EntityState.Normal) {
            yield return fireW;

            mFiring = true;

            rigidbody.velocity = Vector3.zero;

            fireSignalGO.SetActive(true);
            yield return fireD;
            fireSignalGO.SetActive(false);

            Vector3 pos = fireSignalGO.transform.position; pos.z = 0;
            Vector3 dir = Player.instance.collider.bounds.center - pos; dir.z = 0;
            dir.Normalize();

            Projectile proj = Projectile.Create(projGroup, fireProjType, pos, dir, null);
            proj.applyDirToUp.up = dir;

            mFiring = false;

            FollowChangePoint();
        }
    }
Esempio n. 10
0
 public IEnumerator CauseDamageCoroutine(WaitForSeconds delay)
 {
     while (true) {
         CauseDamage();
         yield return delay;
        }
 }
Esempio n. 11
0
 private void Start()
 {
     m_Ball = FindObjectOfType<Ball>();
     m_StartWait = new WaitForSeconds(3.0f);
     m_EndWait = new WaitForSeconds(3.0f);
     StartCoroutine(GameLoop());
 }
 static public int constructor(IntPtr l)
 {
     try {
                     #if DEBUG
         var    method     = System.Reflection.MethodBase.GetCurrentMethod();
         string methodName = GetMethodName(method);
                     #if UNITY_5_5_OR_NEWER
         UnityEngine.Profiling.Profiler.BeginSample(methodName);
                     #else
         Profiler.BeginSample(methodName);
                     #endif
                     #endif
         UnityEngine.WaitForSeconds o;
         System.Single a1;
         checkType(l, 2, out a1);
         o = new UnityEngine.WaitForSeconds(a1);
         pushValue(l, true);
         pushValue(l, o);
         return(2);
     }
     catch (Exception e) {
         return(error(l, e));
     }
             #if DEBUG
     finally {
                     #if UNITY_5_5_OR_NEWER
         UnityEngine.Profiling.Profiler.EndSample();
                     #else
         Profiler.EndSample();
                     #endif
     }
             #endif
 }
	void Awake()
	{
		Debug.Log("PossibleMatchesController awake");
		instance = this;
		
		waitPollTime = new WaitForSeconds(0.5f);
	}
Esempio n. 14
0
 void Start()
 {
     delay = new WaitForSeconds(blinkSpeed);
     text = GetComponent<Text>();
     canvasGroup = GetComponent<CanvasGroup>();
     StartCoroutine(Blink());
 }
Esempio n. 15
0
    private IEnumerator Generate()
    {
        WaitForSeconds wait = new WaitForSeconds (1f);

        GetComponent<MeshFilter>().mesh = mesh = new Mesh ();
        mesh.name = "Procedural Grid";

        #region Vertices Creation
        totalVertices = (sizeX + 1) * (sizeY + 1);

        vertices = new Vector3[totalVertices];

        for (int i = 0, y = 0; y <= sizeY; y++) {
            for (int x = 0; x <= sizeX; x++, i++) {

                vertices[i] = new Vector3(x,y);

            }
        }

        mesh.vertices = vertices;
        #endregion

        int[] triangles = new int[6 * sizeX * sizeY];

        for (int ti = 0, vi = 0, y = 0; y < sizeY; y++, vi++) {
            for (int x = 0; x < sizeX; x++, ti += 6, vi++) {
                triangles [ti] = vi;
                triangles [ti+3] = triangles [ti+2] = vi+1;
                triangles [ti+4] = triangles [ti+1] = vi+sizeX + 1;
                triangles [ti+5] = vi+sizeX + 2;

                mesh.triangles = triangles;
                yield return wait;
            }
        }

        mesh.RecalculateNormals ();

        Vector2[] uv = new Vector2[vertices.Length];
        for (int i = 0, y = 0; y <= sizeY; y++) {
            for (int x = 0; x <= sizeX; x++, i++) {
                uv[i] = new Vector2((float)x / sizeX,  (float)y / sizeY);
            }
        }

        mesh.uv = uv;

        Vector4[] tangents = new Vector4[vertices.Length];
        Vector4 tangent = new Vector4 (1f, 0f, 0f, -1f);
        for (int i = 0, y = 0; y <= sizeY; y++) {
            for (int x = 0; x <= sizeX; x++, i++) {
                tangents[i] = tangent;
            }
        }
        mesh.tangents = tangents;

        mesh.MarkDynamic ();
    }
    public IEnumerator Instructions()
    {
        WaitForSeconds wait = new WaitForSeconds(2f);

        yield return wait;

        instructions.GetComponent<Animator>().SetBool("showing", false);
    }
 void Start()
 {
     myTransform = transform;
     audio = GetComponent<AudioSource>();
     bulletLayer = gameObject.layer;
     shootRateWFS = new WaitForSeconds(shootRate);
     canShoot = true;
 }
Esempio n. 18
0
 private void Awake()
 {
     _startWait = new WaitForSeconds(Game.StartDelay);
     _endWait = new WaitForSeconds(Game.EndDelay);
     SpawnAllTanks();
     SetCameraTargets();
     StartCoroutine(GameLoop());
 }
Esempio n. 19
0
	// Update is called once per frame
	void Update () {
        if (Input.GetKeyDown("g"))
        {
            Transform g = (Transform)Instantiate(amm, transform.position, transform.rotation);
            g.GetComponent<Rigidbody>().AddForce(transform.localPosition*speed);
            WaitForSeconds wait = new WaitForSeconds(1f);
        }
    }
Esempio n. 20
0
	IEnumerator UpdateTimer()
	{
		WaitForSeconds waiter = new WaitForSeconds(0.05f);
		
		while (LivesSystem.lives < 5) {
			myLabel.text = LivesSystem.GetTimerString();
			yield return waiter;
		}
	}
Esempio n. 21
0
File: Enemy.cs Progetto: EgoTeam/Ego
 override protected void Awake () {
     Navigation              = GetComponent<NavMeshAgent>();
     _state                  = GetComponent<EnemyState>();
     _animator               = GetComponent<Animator>();
     _audioSources           = GetComponentsInChildren<AudioSource>();
     _dieTimeWait            = new WaitForSeconds(_deathClip.length + 5f);
     _capsuleCollider        = GetComponent<CapsuleCollider>();
     _rigidbody              = GetComponent<Rigidbody>();
 }
 IEnumerator checkRoutine()
 {
     WaitForSeconds wf = new WaitForSeconds(1);
     while (true)
     {
         checkFunctionality();
         yield return wf;
     }
 }
Esempio n. 23
0
 private IEnumerator log()
 {
     var delay = new WaitForSeconds(1f);
     while (true)
     {
         yield return delay;
         if (num > 0) UnityEngine.Debug.Log("Last time: " + (float)last/Stopwatch.Frequency*1000f + "ms. Average time: " + (float)(total/num)/Stopwatch.Frequency*1000f + "ms.");
     }
 }
Esempio n. 24
0
 override protected void Awake(){
     base.Awake();
     _animator = GetComponent<Animator>();
     _audioSources = GetComponentsInChildren<AudioSource>();
     _dieTimeWait = new WaitForSeconds(_deathClip.length + 5f);
     _capsuleCollider = GetComponent<CapsuleCollider>();
     _rigidbody = GetComponent<Rigidbody>();
     _damageTexture.enabled = false;
 }
Esempio n. 25
0
 // Update is called once per frame
 IEnumerator UpdateHealthRoutine()
 {
     var wait = new WaitForSeconds(Period);
     while (!_destructible.IsDestroyed)
     {
         yield return wait;
         _destructible.Heal(Amount);
     }
 }
Esempio n. 26
0
    private void Start()
    {
        // Create the delays so they only have to be made once.
        m_StartWait = new WaitForSeconds(m_StartDelay);
        m_EndWait = new WaitForSeconds(m_EndDelay);

        // Once the tanks have been created and the camera is using them as targets, start the game.
        StartCoroutine(GameLoop());
    }
Esempio n. 27
0
    // Use this for initialization
    void Start()
    {
        enemyLogic.SetEnemyHealth(health);
        enemyLogic.SetEnemyType(type);
        enemyLogic.SetEnemyDPS(dps);

        WaitForSeconds delay = new WaitForSeconds(1f);
        StartCoroutine(enemyLogic.CauseDamageCoroutine(delay));
    }
Esempio n. 28
0
 // Use this for initialization
 void OnEnable()
 {
     fpsMove = new WaitForSeconds(1.0f / FPSWhenMoveCamera);
     fpsStatic = new WaitForSeconds(1.0f / FPSWhenStaticCamera);
     canUpdateCamera = true;
     if(FPSWhenMoveCamera > 0) StartCoroutine(RepeatCameraMove());
     if(FPSWhenStaticCamera > 0) StartCoroutine(RepeatCameraStatic());
     StartCoroutine(Initialize());
 }
	public void Awake() {
        _wfsGunfireDuration = new WaitForSeconds(0.035f);
		if (_firstPelletDelay > 0f) {
			_wfsFirstPellek = new WaitForSeconds(_firstPelletDelay);
		}
		if(_nextPelletDelay > 0f) {
			_wfsNextPellek = new WaitForSeconds(_nextPelletDelay);
		}
		_wfsExplosionDuration = new WaitForSeconds(0.085f);
	}
Esempio n. 30
0
	public IEnumerator generate(){
		WaitForSeconds delay = new WaitForSeconds (generateDelay);
		cells = new MazeCell[size.x, size.z];
		List<MazeCell> activeCells = new List<MazeCell>();
		DoFirstGenerationStep (activeCells);
		while (activeCells.Count > 0) {
			yield return delay;
			DoNextGenerationStep (activeCells);
		}
	}
Esempio n. 31
0
	IEnumerator PlaySound()
	{
		SoundEffectController soundEffect = SoundManager.Instance["hourglass_sfx"];
		WaitForSeconds waitTime = new WaitForSeconds(soundEffect.SoundClip.length / soundEffect.sound.pitch);
		
		for (int i = 0; i < soundPlays; ++i) {
			soundEffect.Play();
			yield return waitTime;
		}
	}
Esempio n. 32
0
    private void Start()
    {
        m_StartWait = new WaitForSeconds(m_StartDelay);
        m_EndWait = new WaitForSeconds(m_EndDelay);

        SpawnAllTanks();
        SetCameraTargets();

        StartCoroutine(GameLoop());
    }
 static public int constructor(IntPtr l)
 {
     try {
         UnityEngine.WaitForSeconds o;
         System.Single a1;
         checkType(l, 2, out a1);
         o = new UnityEngine.WaitForSeconds(a1);
         pushValue(l, o);
         return(1);
     }
     catch (Exception e) {
         return(error(l, e));
     }
 }
    static int _CreateUnityEngine_WaitForSeconds(IntPtr L)
    {
        try
        {
            int count = LuaDLL.lua_gettop(L);

            if (count == 1)
            {
                float arg0 = (float)LuaDLL.luaL_checknumber(L, 1);
                var   obj  = new UnityEngine.WaitForSeconds(arg0);
                ToLua.PushSealed(L, obj);
                return(1);
            }
            else
            {
                return(LuaDLL.luaL_throw(L, "invalid arguments to ctor method: UnityEngine.WaitForSeconds.New"));
            }
        }
        catch (Exception e)
        {
            return(LuaDLL.toluaL_exception(L, e));
        }
    }
Esempio n. 35
0
 public ExWaitForSeconds(UnityEngine.WaitForSeconds waitForSeconds)
 {
     m_Seconds = waitForSeconds.GetPrivateField <float>("m_Seconds");
 }