Exemple #1
0
    /// <summary>
    /// Starts the safe coroutine.
    /// </summary>
    /// <returns>The safe coroutine.</returns>
    /// <param name="a_MonoBehaviour">A mono behaviour.</param>
    /// <param name="a_SafeCoroutine">A safe coroutine.</param>
    public static SafeCoroutine StartSafeCoroutine(this MonoBehaviour a_MonoBehaviour, IEnumerator a_SafeCoroutine)
    {
        SafeCoroutine l_Result = new SafeCoroutine(a_SafeCoroutine, a_MonoBehaviour.gameObject);

        a_MonoBehaviour.StartCoroutine(l_Result.WrappedCoroutine);
        return(l_Result);
    }
Exemple #2
0
Fichier : Enemy.cs Projet : rbrt/pk
 public void TakeDamage(float damage, AttackEffect[] attackEffects)
 {
     if (enemyState != EnemyStates.Dead)
     {
         behaviourCoroutine = this.StartSafeCoroutine(Damaged(damage, attackEffects));
     }
 }
Exemple #3
0
    public void Idle()
    {
        float animationSpeed = .1f;

        CancelCurrentAnimation();
        animationCoroutine = this.StartSafeCoroutine(Animate(idleSprites, animationSpeed, true));
    }
Exemple #4
0
    public void Dead()
    {
        float animationSpeed = .025f;

        CancelCurrentAnimation();
        animationCoroutine = this.StartSafeCoroutine(Animate(deadSprites, animationSpeed));
    }
Exemple #5
0
        public IEnumerator MoveTile(Tile tile, uint row, uint col)
        {
            if (tile.IsMoving)
            {
                return(null);
            }

            var dst_tile = GetTile(row, col);

            if (tile == dst_tile)
            {
                return(null);
            }

            tile.IsMoving = true;
            if (dst_tile.ValidateMove(tile))
            {
                var routine = new SafeCoroutine(dst_tile.BeginTrigger(tile));
                yield return(routine);

                var result = (bool)routine.Result;
                if (result == true)
                {
                    routine = new SafeCoroutine(tile.MoveTo(row, col));
                    yield return(routine);
                }
            }
            tile.IsMoving = false;

            return(null);
        }
Exemple #6
0
    public void Move()
    {
        float animationSpeed = .025f;

        CancelCurrentAnimation();
        animationCoroutine = this.StartSafeCoroutine(Animate(movementSprites, animationSpeed, true));
    }
Exemple #7
0
 void KillCoroutine(SafeCoroutine target)
 {
     if (target != null && target.IsRunning)
     {
         target.Stop();
     }
 }
Exemple #8
0
    public void Thrown()
    {
        float animationSpeed = .25f;

        CancelCurrentAnimation();
        animationCoroutine = this.StartSafeCoroutine(Animate(thrownSprites, animationSpeed));
    }
Exemple #9
0
Fichier : Enemy.cs Projet : rbrt/pk
    void Start()
    {
        player       = GameObject.Find("PlayerCharacter").GetComponent <PlayerController>();
        enemyState   = EnemyStates.Idle;
        animateEnemy = GetComponentInChildren <AnimateEnemy>();

        behaviourCoroutine = this.StartSafeCoroutine(Primer());
    }
    public void StopSafeCoroutine(SafeCoroutine c)
    {
        if (c == null)
        {
            return;
        }

        mCoroutines.Remove(c);
    }
Exemple #11
0
    IEnumerator OuterExampleCoroutine()
    {
        m_InnerCoroutine = Controller.StartSafeCoroutine(InnerExampleCoroutine());
        yield return(m_InnerCoroutine);

        while (finishOuterCoroutine)
        {
            yield return(null);
        }
    }
Exemple #12
0
    /// <summary>
    /// Starts the safe coroutine.
    /// </summary>
    /// <returns>The safe coroutine.</returns>
    /// <param name="a_MonoBehaviour">A mono behaviour.</param>
    /// <param name="a_SafeCoroutine">A safe coroutine.</param>
    /// <typeparam name="TResult">The result type parameter.</typeparam>
    public static SafeCoroutine <TResult> StartSafeCoroutine <TResult> (this MonoBehaviour a_MonoBehaviour, IEnumerator a_SafeCoroutine)
    {
        SafeCoroutine <TResult> l_Result;

        try {
            l_Result = new SafeCoroutine <TResult> (a_SafeCoroutine, a_MonoBehaviour.gameObject);
        } catch {
            throw;
        }
        a_MonoBehaviour.StartCoroutine(l_Result.WrappedCoroutine);
        return(l_Result);
    }
Exemple #13
0
Fichier : Enemy.cs Projet : rbrt/pk
    IEnumerator WaitForAttackEffects(AttackEffect[] attackEffects)
    {
        SafeCoroutine[] coroutines = new SafeCoroutine[attackEffects.Length];
        for (int i = 0; i < attackEffects.Length; i++)
        {
            coroutines[i] = attackEffects[i].InvokeEffect(gameObject);
        }

        while (coroutines.Any(x => x.IsRunning))
        {
            yield return(null);
        }
    }
Exemple #14
0
    private IEnumerator WrappingCoroutine(IEnumerator a_Coroutine)
    {
        State = SafeCoroutineState.Running;
        while (true)
        {
            if (State == SafeCoroutineState.Paused)
            {
                yield return(null);
            }
            else
            {
                if (State == SafeCoroutineState.Stopped)
                {
                    m_WrappedCoroutine = null;
                    yield break;
                }

                object        l_Yield = a_Coroutine.Current;
                SafeCoroutine l_EncapsulatedSafeCoroutine    = l_Yield as SafeCoroutine;
                bool          l_HasEncapsulatedSafeCoroutine =
                    (l_EncapsulatedSafeCoroutine != null &&
                     l_EncapsulatedSafeCoroutine.m_WrappedCoroutine != null);

                if (!l_HasEncapsulatedSafeCoroutine)
                {
                    try {
                        if (!a_Coroutine.MoveNext())
                        {
                            State = SafeCoroutineState.Finished;
                            m_WrappedCoroutine = null;
                            yield break;
                        }
                    } catch (Exception l_Exception) {
                        State       = SafeCoroutineState.ThrewException;
                        m_Exception = l_Exception;

                        Debug.LogError("SafeCoroutine threw exception:\n" + m_Exception.Message + "\nWith stack trace:\n" + m_Exception.StackTrace,
                                       invokingGameObject);

                        m_WrappedCoroutine = null;
                        yield break;
                    }
                    yield return(a_Coroutine.Current);
                }
                else
                {
                    yield return(null);
                }
            }
        }
    }
Exemple #15
0
    private IEnumerator WrappingCoroutine(IEnumerator a_Coroutine)
    {
        State = SafeCoroutineState.Running;
        while (true)
        {
            if (State == SafeCoroutineState.Paused)
            {
                yield return(null);
            }
            else
            {
                if (State == SafeCoroutineState.Stopped)
                {
                    m_WrappedCoroutine = null;
                    yield break;
                }

                object        l_Yield = a_Coroutine.Current;
                SafeCoroutine l_EncapsulatedSafeCoroutine    = l_Yield as SafeCoroutine;
                bool          l_HasEncapsulatedSafeCoroutine =
                    (l_EncapsulatedSafeCoroutine != null &&
                     l_EncapsulatedSafeCoroutine.m_WrappedCoroutine != null);

                if (!l_HasEncapsulatedSafeCoroutine)
                {
                    try {
                        if (!a_Coroutine.MoveNext())
                        {
                            State = SafeCoroutineState.Finished;
                            m_WrappedCoroutine = null;
                            yield break;
                        }
                    } catch (Exception l_Exception) {
                        State              = SafeCoroutineState.ThrewException;
                        m_Exception        = l_Exception;
                        m_WrappedCoroutine = null;
                        if (!CatchExceptions)
                        {
                            throw;
                        }
                        yield break;
                    }
                    yield return(a_Coroutine.Current);
                }
                else
                {
                    yield return(null);
                }
            }
        }
    }
Exemple #16
0
    private void ResumeChildCoroutines()
    {
        IEnumerator l_Enumerator = m_WrappedCoroutine;

        while (l_Enumerator != null)
        {
            object l_Yield = l_Enumerator.Current;
            if (l_Yield != null)
            {
                if (l_Yield is IEnumerator)
                {
                    l_Enumerator = l_Yield as IEnumerator;
                }
                else if (l_Yield is SafeCoroutine)
                {
                    SafeCoroutine l_SafeCoroutine = l_Yield as SafeCoroutine;

                    if (l_SafeCoroutine.IsPaused)
                    {
                        l_SafeCoroutine.m_IsParentPaused = false;
                        if (l_SafeCoroutine.IsSelfPaused)
                        {
                            l_Enumerator = null;
                        }
                        else
                        {
                            l_SafeCoroutine.State = SafeCoroutineState.Running;
                            l_Enumerator          = l_SafeCoroutine.m_WrappedCoroutine;
                        }
                    }
                    else
                    {
                        l_Enumerator = null;
                    }
                }
                else
                {
                    // Stop the loop.
                    l_Enumerator = null;
                }
            }
            else
            {
                // Stop the loop.
                l_Enumerator = null;
            }
        }
    }
Exemple #17
0
 IEnumerator FlickerLights()
 {
     while (true)
     {
         if (lightFlickerA == null || !lightFlickerA.IsRunning)
         {
             flickerA      = GetRandomLight(flickerA);
             lightFlickerA = this.StartSafeCoroutine(FlickerLight(flickerA, Random.Range(2, 5)));
         }
         if (lightFlickerB == null || !lightFlickerB.IsRunning)
         {
             flickerB      = GetRandomLight(flickerB);
             lightFlickerB = this.StartSafeCoroutine(FlickerLight(flickerB, Random.Range(2, 5)));
         }
         yield return(null);
     }
 }
Exemple #18
0
    void Awake()
    {
        baseAttacks = new Dictionary <AttackInputType, PlayerAttack>
        {
            { AttackInputType.Attack1, attack1 },
            { AttackInputType.Attack2, attack2 }
        };

        behaviourCoroutine = this.StartSafeCoroutine(Primer());

        if (handleInputFlash == null)
        {
            handleInputFlash = GameObject.Find("PlayerCharacter").GetComponent <HandlePlayerInputFlash>();
        }

        InitializeAttackDictionary();
    }
Exemple #19
0
    private void PauseChildCoroutines()
    {
        IEnumerator l_Enumerator = m_WrappedCoroutine;

        while (l_Enumerator != null)
        {
            object l_Yield = l_Enumerator.Current;
            if (l_Yield != null)
            {
                if (l_Yield is IEnumerator)
                {
                    l_Enumerator = l_Yield as IEnumerator;
                }
                else if (l_Yield is SafeCoroutine)
                {
                    SafeCoroutine l_SafeCoroutine = l_Yield as SafeCoroutine;
                    if (l_SafeCoroutine.State == SafeCoroutineState.Running)
                    {
                        l_SafeCoroutine.m_IsParentPaused = true;
                        l_SafeCoroutine.State            = SafeCoroutineState.Paused;
                        l_Enumerator = l_SafeCoroutine.m_WrappedCoroutine;
                    }
                    else if (l_SafeCoroutine.State == SafeCoroutineState.Paused)
                    {
                        // Paused means in that context self paused.
                        l_SafeCoroutine.m_IsParentPaused = true;
                        l_Enumerator = null;
                    }
                    else
                    {
                        l_Enumerator = null;
                    }
                }
                else
                {
                    // Stop the loop.
                    l_Enumerator = null;
                }
            }
            else
            {
                // Stop the loop.
                l_Enumerator = null;
            }
        }
    }
    public SafeCoroutine StartSafeCoroutine(IEnumerator iterator)
    {
        if (iterator == null)
        {
            return(null);
        }

        SafeCoroutine c = new SafeCoroutine(iterator);

        if (mIsUpdating)
        {
            mSalvageCoroutines.Add(c);
        }
        else
        {
            mCoroutines.Add(c);
        }

        return(c);
    }
Exemple #21
0
 static void CoroutineGUI(string a_Name, SafeCoroutine a_SafeCoroutine)
 {
     GUILayout.BeginHorizontal();
     GUI.enabled = a_SafeCoroutine.IsPause;
     if (GUILayout.Button("Resume " + a_Name))
     {
         a_SafeCoroutine.Resume();
     }
     GUI.enabled = a_SafeCoroutine.CanPause;
     if (GUILayout.Button("Pause " + a_Name))
     {
         a_SafeCoroutine.Pause();
     }
     GUI.enabled = a_SafeCoroutine.IsRunning || a_SafeCoroutine.IsPause;
     if (GUILayout.Button("Stop " + a_Name))
     {
         a_SafeCoroutine.Stop();
     }
     GUILayout.EndHorizontal();
 }
Exemple #22
0
    private void StopChildRoutines()
    {
        IEnumerator l_Enumerator = m_WrappedCoroutine;

        while (l_Enumerator != null)
        {
            object l_Yield = l_Enumerator.Current;
            if (l_Yield != null)
            {
                if (l_Yield is IEnumerator)
                {
                    l_Enumerator = l_Yield as IEnumerator;
                }
                else if (l_Yield is SafeCoroutine)
                {
                    SafeCoroutine l_SafeCoroutine = l_Yield as SafeCoroutine;
                    if
                    (l_SafeCoroutine.State == SafeCoroutineState.Running ||
                     l_SafeCoroutine.State == SafeCoroutineState.Paused)
                    {
                        l_SafeCoroutine.Stop();
                    }

                    // The safe coroutine takes care of further child coroutines.
                    l_Enumerator = null;
                }
                else
                {
                    // Stop the loop.
                    l_Enumerator = null;
                }
            }
            else
            {
                // Stop the loop.
                l_Enumerator = null;
            }
        }
    }
Exemple #23
0
 public void Attack(Sprite[] attackSprites)
 {
     CancelCurrentAnimation();
     animationCoroutine = this.StartSafeCoroutine(Animate(attackSprites));
 }
Exemple #24
0
Fichier : Enemy.cs Projet : rbrt/pk
 public void TakeDamage(float damage, AttackEffect[] attackEffects)
 {
     if (enemyState != EnemyStates.Dead){
         behaviourCoroutine = this.StartSafeCoroutine(Damaged(damage, attackEffects));
     }
 }
Exemple #25
0
Fichier : Enemy.cs Projet : rbrt/pk
    IEnumerator WaitForAttackEffects(AttackEffect[] attackEffects)
    {
        SafeCoroutine[] coroutines = new SafeCoroutine[attackEffects.Length];
        for (int i = 0; i < attackEffects.Length; i++){
            coroutines[i] = attackEffects[i].InvokeEffect(gameObject);
        }

        while (coroutines.Any(x => x.IsRunning)){
            yield return null;
        }
    }
Exemple #26
0
Fichier : Enemy.cs Projet : rbrt/pk
    void Start()
    {
        player = GameObject.Find("PlayerCharacter").GetComponent<PlayerController>();
        enemyState = EnemyStates.Idle;
        animateEnemy = GetComponentInChildren<AnimateEnemy>();

        behaviourCoroutine = this.StartSafeCoroutine(Primer());
    }
Exemple #27
0
    void HandleInput()
    {
        if (Input.GetKeyDown(KeyCode.A)){
            turningRight = false;
            turningLeft = true;
        }
        else if (Input.GetKeyDown(KeyCode.D)){
            turningLeft = false;
            turningRight = true;
        }

        if (Input.GetKeyDown(KeyCode.W)){
            accelerating = true;
        }

        if (Input.GetKeyUp(KeyCode.A)){
            turningLeft = false;
        }
        else if (Input.GetKeyUp(KeyCode.D)){
            turningRight = false;
        }

        if (Input.GetKeyUp(KeyCode.W)){
            if (turningRight || turningLeft){
                if (inertiaForceCoroutine == null || !inertiaForceCoroutine.IsRunning){
                    inertiaForce = carRigidbody.velocity;
                    inertiaForceCoroutine = this.StartSafeCoroutine(InertiaFalloff());
                }
            }
            accelerating = false;
        }
    }
Exemple #28
0
 public void Dead()
 {
     CancelCurrentAnimation();
     animationCoroutine = this.StartSafeCoroutine(Animate(deadSprites));
 }
Exemple #29
0
 public void Move()
 {
     float animationSpeed = .025f;
     CancelCurrentAnimation();
     animationCoroutine = this.StartSafeCoroutine(Animate(movementSprites, animationSpeed, true));
 }
        private IEnumerator Wrap(CoroutineChainLink link)
        {
            SafeCoroutine safeCoroutine = new SafeCoroutine();
              safeCoroutine.Coroutine = StartCoroutine(safeCoroutine.RunCoroutine(link.CoOnStart()));
              yield return safeCoroutine.Coroutine;

              if (safeCoroutine.Exception != null) {
            link.OnFailure(safeCoroutine.Exception);
              }
        }
Exemple #31
0
 void Start()
 {
     animationCoroutine = this.StartSafeCoroutine(Primer());
     spriteRenderer = GetComponentInChildren<SpriteRenderer>();
 }
Exemple #32
0
 public void Damage()
 {
     float animationSpeed = .025f;
     CancelCurrentAnimation();
     animationCoroutine = this.StartSafeCoroutine(Animate(damageSprites, animationSpeed));
 }
Exemple #33
0
 public void HitGround()
 {
     float animationSpeed = .025f;
     CancelCurrentAnimation();
     animationCoroutine = this.StartSafeCoroutine(Animate(hitGroundSprites, animationSpeed));
 }
Exemple #34
0
    void Awake()
    {
        baseAttacks = new Dictionary<AttackInputType, PlayerAttack>
                            {
                                { AttackInputType.Attack1, attack1 },
                                { AttackInputType.Attack2, attack2 }
                            };

        behaviourCoroutine = this.StartSafeCoroutine(Primer());

        if (handleInputFlash == null){
            handleInputFlash = GameObject.Find("PlayerCharacter").GetComponent<HandlePlayerInputFlash>();
        }

        InitializeAttackDictionary();
    }
Exemple #35
0
 public void Thrown()
 {
     float animationSpeed = .25f;
     CancelCurrentAnimation();
     animationCoroutine = this.StartSafeCoroutine(Animate(thrownSprites, animationSpeed));
 }
Exemple #36
0
 public void Punch()
 {
     float animationSpeed = .025f;
     CancelCurrentAnimation();
     animationCoroutine = this.StartSafeCoroutine(Animate(punchSprites, animationSpeed));
 }
Exemple #37
0
	public void HighlightTile(Texture2D tex){
		targetRenderer.material.SetTexture("_MainTex", tex);
		hintDisplayCoroutine = this.StartSafeCoroutine(ShowHint());
	}
Exemple #38
0
 public void Idle()
 {
     CancelCurrentAnimation();
     animationCoroutine = this.StartSafeCoroutine(Animate(idleSprites));
 }
Exemple #39
0
 public void Damage()
 {
     CancelCurrentAnimation();
     animationCoroutine = this.StartSafeCoroutine(Animate(damageSprites));
 }
Exemple #40
0
 public void Dead()
 {
     CancelCurrentAnimation();
     animationCoroutine = this.StartSafeCoroutine(Animate(deadSprites));
 }
Exemple #41
0
 public void Block()
 {
     CancelCurrentAnimation();
     animationCoroutine = this.StartSafeCoroutine(Animate(blockSprites));
 }
Exemple #42
0
 public void Damage()
 {
     CancelCurrentAnimation();
     animationCoroutine = this.StartSafeCoroutine(Animate(damageSprites));
 }
 public void RotateCharacterToFaceRight()
 {
     KillRotationCoroutine();
     rotationCoroutine = this.StartSafeCoroutine(AnimateFacingRight());
 }
Exemple #44
0
    // Use this for initialization
    void Start()
    {
//		m_InnerCoroutine = Controller.StartSafeCoroutine(InnerExampleCoroutine());
        m_OuterCoroutine = Controller.StartSafeCoroutine(OuterExampleCoroutine());
    }
Exemple #45
0
Fichier : Enemy.cs Projet : rbrt/pk
    void Update()
    {
        inDestinationRange = InRangeOfDestinationPosition();
        inAttackRange = InRangeForAttack();

        if (enemyState != EnemyStates.Dead){

            var pos = transform.localPosition;

            if (health <= 0 && enemyState != EnemyStates.Dead){
                enemyState = EnemyStates.Dead;

                CancelBehaviourCoroutine();
                this.StartSafeCoroutine(Dead());
            }

            if (enemyState == EnemyStates.Moving){
                // Check if close enough
                if (InRangeOfDestinationPosition() && InRangeForAttack()){
                    CancelBehaviourCoroutine();
                    enemyState = EnemyStates.Attacking;
                }
                else{
                    if (!moving){
                        CancelBehaviourCoroutine();
                        moving = true;
                        behaviourCoroutine = this.StartSafeCoroutine(Move());
                    }
                    // Move towards destination

                    if (destinationPosition.y <= pos.y + .01f){
                        pos.y -= vMoveSpeed;
                    }
                    else if (destinationPosition.y > pos.y - .01f){
                        pos.y += vMoveSpeed;
                    }

                    if (Mathf.Abs(pos.y - destinationPosition.y) < .03){
                        pos.y = destinationPosition.y;
                    }

                    if (destinationPosition.x <= pos.x){
                        pos.x -= hMoveSpeed;
                    }
                    else if (destinationPosition.x > pos.x){
                        pos.x += hMoveSpeed;
                    }
                }
            }
            else if (enemyState == EnemyStates.Attacking){
                if (InRangeForAttack()){
                    if (!punching){
                        CancelBehaviourCoroutine();
                        punching = true;
                        behaviourCoroutine = this.StartSafeCoroutine(Punch());
                    }
                }
                else{
                    enemyState = EnemyStates.Moving;
                }

            }
            else if (enemyState == EnemyStates.Damaged){
                return;
            }
            else if (enemyState == EnemyStates.Idle){
                if (!InRangeOfDestinationPosition()){
                    pos = Vector3.MoveTowards(transform.position, destinationPosition, .025f);
                }
                else{
                    if (!idle){
                        CancelBehaviourCoroutine();
                        idle = true;
                        behaviourCoroutine = this.StartSafeCoroutine(Idle());
                    }
                }
            }
            else if (enemyState == EnemyStates.Dead){

            }

            if (enemyState != EnemyStates.Dead){
                transform.rotation = player.transform.position.x < transform.position.x ?
                                     Quaternion.Euler(new Vector3(0, 180, 0)) :
                                     Quaternion.Euler(Vector3.zero);
            }

            transform.localPosition = Vector3.Lerp(transform.localPosition, pos, Time.deltaTime * generalMoveSpeed);
        }
    }
Exemple #46
0
 public void Block()
 {
     CancelCurrentAnimation();
     animationCoroutine = this.StartSafeCoroutine(Animate(blockSprites));
 }
Exemple #47
0
Fichier : Enemy.cs Projet : rbrt/pk
 public void GoIdle()
 {
     enemyState = EnemyStates.Idle;
     behaviourCoroutine = this.StartSafeCoroutine(Idle());
 }
Exemple #48
0
 void StartGlitching(){
     glitching = true;
     glitchCoroutine = this.StartSafeCoroutine(GlitchOut());
 }
    /// <summary>
    /// 是否完成了
    /// 每帧调用
    /// </summary>
    /// <param name="delta_time"></param>
    /// <returns>完成了返回true</returns>
    public bool IsComplete(float delta_time)
    {
        if (mIterator == null)
        {
            return(finish());
        }

        if (IsPause)
        {
            return(false);
        }

        if (mIterator.Current == null)
        {
            if (!mIterator.MoveNext())
            {
                return(finish());
            }
        }
        else if ((mIterator.Current as SafeCoroutine) != null)
        {
            // 当前执行的是子协程
            // 子协程不需要在这里更新,它会在CoroutineController里更新
            var child = mIterator.Current as SafeCoroutine;
            if (mChildCoroutine == null)
            {
                // 第一次执行,设置父子关系
                mChildCoroutine        = child;
                child.mParentCoroutine = this;
            }
            else if (mChildCoroutine.IsFinish)
            {
                // 如果已经完成了,执行下一步
                mChildCoroutine = null;
                if (!mIterator.MoveNext())
                {
                    return(finish());
                }
            }
        }
        else if ((mIterator.Current as ISafeYieldInstruction) != null)
        {
            // 当前执行的是普通的yield指令
            ISafeYieldInstruction yieldBase = mIterator.Current as ISafeYieldInstruction;

            // 更新指令
            bool result = yieldBase.IsComplete(delta_time);
            if (result && !mIterator.MoveNext())
            {
                return(finish());
            }
        }
        else
        {
            if (!mIterator.MoveNext())
            {
                // 已经没有下一步了,设置完成状态
                mResult = mIterator.Current;
                return(finish());
            }
        }

        return(false);
    }
Exemple #50
0
 void Start()
 {
     animationCoroutine = this.StartSafeCoroutine(Primer());
     spriteRenderer     = GetComponentInChildren <SpriteRenderer>();
 }
Exemple #51
0
 public void LockMinAndMaxX(float targetX)
 {
     cameraScrollLocked = true;
     cameraMovementOverride = this.StartSafeCoroutine(CenterCameraOnFight(targetX));
 }
Exemple #52
0
 public void Attack(Sprite[] attackSprites)
 {
     CancelCurrentAnimation();
     animationCoroutine = this.StartSafeCoroutine(Animate(attackSprites));
 }
Exemple #53
0
 void Start()
 {
     playerTransform = PlayerController.Instance.transform;
     shootingCoroutine = this.StartSafeCoroutine(ShootAtPlayer());
 }
Exemple #54
0
 public void Idle()
 {
     CancelCurrentAnimation();
     animationCoroutine = this.StartSafeCoroutine(Animate(idleSprites));
 }
        private IEnumerator Wrap(Func<IEnumerator> coroutine)
        {
            SafeCoroutine safeCoroutine = new SafeCoroutine();

              IEnumerator i = null;

              try {
            i = coroutine();
              } catch (Exception exception) {
            Handle(exception);
              }

              if (i != null) {
            safeCoroutine.Coroutine = StartCoroutine(safeCoroutine.RunCoroutine(i));
            yield return safeCoroutine.Coroutine;
              }

              if (safeCoroutine.Exception != null) {
            Handle(safeCoroutine.Exception);
              }
        }
Exemple #56
0
 public void Idle()
 {
     float animationSpeed = .1f;
     CancelCurrentAnimation();
     animationCoroutine = this.StartSafeCoroutine(Animate(idleSprites, animationSpeed, true));
 }