Exemple #1
0
    private IEnumerator BlinkCoroutine(RetVoidTakeVoid cb)
    {
        int blinkCount = 0;
        int blinkTotal = 25;

        while (blinkCount < blinkTotal)
        {
            for (int i = 0; i < spriteRenderers.Length; i++)
            {
                if (blinkSprite[i])
                {
                    spriteRenderers[i].enabled = !spriteRenderers[i].enabled;
                }
            }
            blinkCount++;
            yield return(new WaitForSeconds(0.04f));
        }
        for (int i = 0; i < spriteRenderers.Length; i++)
        {
            spriteRenderers[i].enabled = true;
        }
        if (cb != null)
        {
            cb();
        }
    }
    void Start()
    {
        int moveActionCount = 2;

        marcoMoveActions    = new RetVoidTakeVoid[moveActionCount];
        marcoMoveActions[0] = () => { marcoMove.HorizontalMovement(Vector2.right); };
        marcoMoveActions[1] = () => { marcoMove.HorizontalMovement(Vector2.left); };
        //marcoMoveActions[2] = marcoMove.LookUp;
        //marcoMoveActions[3] = marcoMove.DownMovement;
        marcoMoveAction = marcoMoveActions[0];

        marcoAttackActions    = new RetVoidTakeVoid[2];
        marcoAttackActions[0] = () => { marcoAttack.PrimaryAttack(); };
        marcoAttackActions[1] = () => { marcoAttack.SecondaryAttack(); };
        marcoAttackAction     = marcoAttackActions[0];

        int actionIndex = 0;

        timeUtils.RepeatEvery(2, () => {
            marcoMoveAction   = marcoMoveActions[actionIndex];
            marcoAttackAction = marcoAttackActions[actionIndex];
            marcoJump.Jump();
            marcoAttackAction();

            actionIndex = (actionIndex + 1) % marcoMoveActions.Length;
            return(true);
        });
    }
    private IEnumerator FlashCoroutine(RetVoidTakeVoid cb = null)
    {
        int numberOfFlashes = 3;
        int flashCount      = 0;

        while (flashCount < numberOfFlashes)
        {
            for (int i = 0; i < spriteRenderers.Length; i++)
            {
                spriteRenderers[i].material = material;
            }
            yield return(new WaitForSeconds(flashDuration));

            for (int i = 0; i < spriteRenderers.Length; i++)
            {
                spriteRenderers[i].material = baseMaterial;
            }

            yield return(new WaitForSeconds(flashDuration));

            flashCount++;
        }
        if (cb != null)
        {
            cb();
        }
    }
Exemple #4
0
 public void StartShootAnim(RetVoidTakeVoid cb)
 {
     if (ShootCB == null)
     {
         ShootCB = cb;
     }
     anim.SetTrigger("shoot");
 }
 public void FlashSlugStyle(RetVoidTakeVoid cb = null)
 {
     if (cb == null)
     {
         cb = () => { };
     }
     StartCoroutine("FlashCoroutine", cb);
 }
 public void FlashForOneFrame(RetVoidTakeVoid cb = null)
 {
     if (cb == null)
     {
         cb = () => { };
     }
     StartCoroutine("FlashForOneFrameCoroutine", cb);
 }
Exemple #7
0
 public void TimeDelay(float delay, RetVoidTakeVoid cb)
 {
     if (coroutine != null)
     {
         StopCoroutine(coroutine);
     }
     coroutine = StartCoroutine(DelayCoroutine(delay, cb));
 }
Exemple #8
0
 public void BlinkPlease(RetVoidTakeVoid cb)
 {
     // if the sprite is initially hidden we will disregard it during the blinking
     for (int i = 0; i < spriteRenderers.Length; i++)
     {
         blinkSprite[i] = spriteRenderers[i].enabled;
     }
     StartCoroutine("BlinkCoroutine", cb);
 }
Exemple #9
0
 public void OpenTower(RetVoidTakeVoid OpenCB)
 {
     OpenAnimDoneCB = OpenCB;
     doors.SetActive(true);
     anim.enabled = true;
     timeUtils.TimeDelay(3, () => {
         doors.SetActive(false);
         anim.SetTrigger("open_curtain");
     }
                         );
 }
    private IEnumerator FlashForOneFrameCoroutine(RetVoidTakeVoid cb = null)
    {
        for (int i = 0; i < spriteRenderers.Length; i++)
        {
            spriteRenderers[i].material = material;
        }
        yield return(new WaitForSeconds(Time.deltaTime));

        for (int i = 0; i < spriteRenderers.Length; i++)
        {
            spriteRenderers[i].material = baseMaterial;
        }
        if (cb != null)
        {
            cb();
        }
    }
Exemple #11
0
    public void PlayDeathAnimation(ProjectileProperties proj, RetVoidTakeVoid cb)
    {
        string trigger;

        topAnimator.runtimeAnimatorController = deathAnimController;

        if (proj.type == ProjectileType.Grenade)
        {
            trigger = "explo";
            inExplosiveDeathAnim = true;
        }
        else if (proj.type == ProjectileType.Knife)
        {
            trigger = "slash";
            blood.Play("1");
        }
        else
        {
            trigger = "slash";
        }
        EndOfDeathCB = cb;
        topAnimator.SetTrigger(trigger);
    }
Exemple #12
0
    private IEnumerator DelayCoroutine(float delay, RetVoidTakeVoid cb)
    {
        yield return(new WaitForSeconds(delay));

        cb();
    }
 public void SetMgDownCB(RetVoidTakeVoid cb)
 {
     downCB = cb;
 }
 public void SetMgSittingCB(RetVoidTakeVoid cb)
 {
     sittingCB = cb;
 }
Exemple #15
0
 public void StartGrenadeAnim(RetVoidTakeVoid cb)
 {
     topAnimator.SetTrigger("grenade");
     grenadeCB = cb;
 }
Exemple #16
0
 public void FrameDelay(RetVoidTakeVoid cb)
 {
     StartCoroutine(DelayByFrameCoroutine(cb));
 }
Exemple #17
0
    private IEnumerator DelayByFrameCoroutine(RetVoidTakeVoid cb)
    {
        yield return(new WaitForFixedUpdate());

        cb();
    }
 public void SetMgUpCB(RetVoidTakeVoid cb)
 {
     upCB = cb;
 }
Exemple #19
0
    private IEnumerator WaitForPhysUpdate(RetVoidTakeVoid cb)
    {
        yield return(new WaitForFixedUpdate());

        cb();
    }
 public void SetMgHorizontalCB(RetVoidTakeVoid cb)
 {
     horizontalCB = cb;
 }