Ejemplo n.º 1
0
 void ForceForJump()
 {
     if (_lockJump)
     {
         return;
     }
     if (!_player.isJump)
     {
         return;
     }
     // when jumping, the gravity value is not zero
     _rb.gravityScale = _player.gravity;
     if (!_isOnGround && _extraJump > 0)
     {
         ControlLock.ReleaseLock("Move");
         StateHandling.Handle("KickDown", "Off");
         _rb.velocity = new Vector2(_rb.velocity.x, jumpForce);
         _extraJump--;
     }
     else if (_extraJump <= 0 && _jumpByWall)
     {
         _rb.velocity = new Vector2(_rb.velocity.x, jumpForce); //Vector2.up * jumpForce;
     }
     else if (_isOnGround)
     {
         ControlLock.ReleaseLock("Move");
         _anim.SetBool("isKickDown", false);
         _rb.velocity = new Vector2(_rb.velocity.x, jumpForce); //Vector2.up * jumpForce;
     }
 }
Ejemplo n.º 2
0
    void SetWallSlidingState()
    {
        var isWallSlidingState = IsWallSlidingState();

        _anim.SetBool("isWallSliding", isWallSlidingState);
        if (isWallSlidingState)
        {
            _extraJump = extraJumpCount;
            // Flip when sliding
            if (!_flippedByWallSliding)
            {
                ControlLock.Lock("FlipX");
                _flippedByWallSliding = true;
                _sprite.flipX         = true;
            }
        }
        else
        {
            if (_flippedByWallSliding)
            {
                ControlLock.ReleaseLock("FlipX");
                _flippedByWallSliding = false;
                _sprite.flipX         = false;
            }
        }
    }
Ejemplo n.º 3
0
    IEnumerator StartPunching()
    {
        _isInCooldown = true;
        ControlLock.Lock("MoveOnGround");
        _anim.SetBool("isBunch", true);
        _anim.SetBool("isBunchOne", _isOne);
        var bunchName   = string.Empty;
        var bunchLength = 0f;

        if (_anim.GetBool("isWallSliding"))
        {
            bunchName   = "Wall Punch";
            bunchLength = Utility.GetAnimationLength(_anim, bunchName);
        }
        else
        {
            bunchName   = string.Format("Normal Bunch {0} {1}", _faceX < 0 ? "Left" : "Right", _isOne ? 1 : 2);
            bunchLength = Utility.GetAnimationLength(_anim, bunchName);
        }
        InstantiateEffect();
        if (!_anim.GetBool("isWallSliding"))
        {
            _isOne = !_isOne;
        }
        yield return(new WaitForSeconds(bunchLength));

        _anim.SetBool("isBunch", false);
        _isInCooldown = false;
        ControlLock.ReleaseLock("MoveOnGround", "Move");
    }
        protected override async Task Reset_Click()
        {
            using var _ = new ControlLock(Reset);

            await Initialize();

            IoC.Notif.ShowStatus("Reset complete");
        }
Ejemplo n.º 5
0
 void Start()
 {
     _rb              = GetComponent <Rigidbody2D>();
     _anim            = GetComponent <Animator>();
     _col             = GetComponent <BoxCollider2D>();
     _movement        = GetComponent <Movement2D>();
     _rb.gravityScale = gravity;
     faceX            = 1;
     ControlLock.Register("FlipX", this);
 }
Ejemplo n.º 6
0
    IEnumerator DoReflectiveForce()
    {
        ControlLock.Lock("Move");
        var vel = _rb.velocity;

        vel.x       -= .5f * _faceX;
        _rb.velocity = vel;
        yield return(new WaitForSeconds(.1f));

        ControlLock.ReleaseLock("Move");
    }
Ejemplo n.º 7
0
        protected override async Task Reset_Click()
        {
            using var _ = new ControlLock(Reset);

            await Initialize();

            RefreshOutfitList();

            IoC.Notif.ShowStatus("Reset complete");
            IoC.Notif.HideProgress();
        }
Ejemplo n.º 8
0
 void OnDetectedHit(HitDetector detector, Collider2D other)
 {
     if ("Ground".Equals(LayerMask.LayerToName(other.gameObject.layer)))
     {
         _anim.SetBool("isOnGround", true);
         // Shake the screen when character kicks on ground.
         StartCoroutine(Utility.Shaking2D(_shakingDuration, _shakingAmount, _theCamera.transform
                                          , () => ControlLock.Lock("Camera1")
                                          , () => ControlLock.ReleaseLock("Camera1")));
     }
     HandleState("KickDown", "Off");
 }
Ejemplo n.º 9
0
    IEnumerator StartKickDown()
    {
        _isInCooldown = true;
        ControlLock.Lock("Move");
        _anim.SetBool("isKickDown", true);
        var length = Utility.GetAnimationLength(_anim, "Kick Down");

        _rb.velocity = Vector2.up * -2.5f;
        // Create the shadow sample
        var shadowSample = Utility.CreateSpriteRendererBySample(_sprite.sprite, transform.position, transform.localScale, .25f);

        Destroy(shadowSample.gameObject, .075f);
        // Create the effect
        _curFx = InstantiateEffect();
        yield break;
    }
Ejemplo n.º 10
0
 public void HandleState(string name, string state)
 {
     if (name == "KickDown")
     {
         if (state == "Off")
         {
             if (_curFx != null || _curFx is Object && !_curFx.Equals(null))
             {
                 ControlLock.ReleaseLock("Move");
                 _anim.SetBool("isKickDown", false);
                 _isInCooldown = false;
                 _rb.velocity  = Vector2.zero;
                 Destroy(_curFx.gameObject);
             }
         }
     }
 }
Ejemplo n.º 11
0
    IEnumerator StartPunchUp()
    {
        _isInCooldown = true;
        ControlLock.Lock("Move");
        _anim.SetBool("isPunchUp", true);
        var length   = Utility.GetAnimationLength(_anim, "Punch Up");
        var fx       = InstantiateEffect();
        var fxAnim   = fx.GetComponent <Animator>();
        var fxLength = fxAnim.GetCurrentAnimatorStateInfo(0).length;

        Destroy(fx.gameObject, fxLength);
        yield return(new WaitForSeconds(length));

        _isInCooldown = false;
        ControlLock.ReleaseLock("Move");
        _anim.SetBool("isPunchUp", false);
    }
        private async Task btnArchiver_Click(object sender, EventArgs e)
        {
            using var _ = new ControlLock(btnArchiver);

            if (!UpdateGameDirStatus())
            {
                return;
            }

            IoC.Notif.ShowStatus("Copying Oodle library...");
            await IoC.Archiver.GetLibrary();

            IoC.Notif.ShowStatus("Oodle updated");

            if (UpdateArchiverStatus())
            {
                SettingsOkay?.Invoke();
            }
        }
Ejemplo n.º 13
0
 public override void Update()
 {
     base.Update();
     if (_lockThis)
     {
         return;
     }
     if ((_player.isFrontCollision && _player.GetInputX() != 0) && !_anim.GetBool("isOnGround"))
     {
         ControlLock.Lock("Move");
         if (_rb.velocity.y < 0)
         {
             _rb.velocity += Vector2.up * frictionY;
         }
     }
     else
     {
         ControlLock.ReleaseLock("Move");
     }
 }
Ejemplo n.º 14
0
 public override void Update()
 {
     if (_player.GetInputY() != 0)
     {
         if (!_firstInput)
         {
             _firstInput = true;
             _start      = Time.time;
             return;
         }
         if (!_handled)
         {
             if (_start + _holdIn <= Time.time)
             {
                 ControlLock.Lock("Camera");
                 var edge = Utility.CameraBoundEdge(_theCamera, _bound, _theCamera.transform.position);
                 if (edge.y == 0 && _player.GetInputY() == 1)
                 {
                     return;
                 }
                 else if (edge.y == 1 && _player.GetInputY() == -1)
                 {
                     return;
                 }
                 StartCoroutine(Looking(_player.GetInputY()));
                 _handled = true;
             }
         }
     }
     else
     {
         _firstInput = false;
         _handled    = false;
         _start      = 0f;
         ControlLock.ReleaseLock("Camera");
     }
 }
Ejemplo n.º 15
0
    IEnumerator StartDashing()
    {
        var percent = 0f;

        while (percent <= 1f)
        {
            percent += Time.deltaTime / _timeDirection;
            yield return(null);
        }
        _isInCooldown = true;
        ControlLock.Lock("Move", "FlipX", "NormalPunch", "Jump", "KickDown");
        _rb.gravityScale = .0f;
        _isDashing       = true;
        _anim.SetBool("isDashing", true);
        var length = Utility.GetAnimationLength(_anim, "Dashing Right");

        _rb.velocity = Vector2.right * transform.localScale.x * dashingForce;
        yield return(new WaitForSeconds(length));

        _isDashing = false;
        _anim.SetBool("isDashing", false);
        _rb.gravityScale = _player.gravity;
        ControlLock.ReleaseLock("Move", "FlipX", "NormalPunch", "Jump", "KickDown");
    }
Ejemplo n.º 16
0
 public override void Start()
 {
     base.Start();
     ControlLock.Register(this, "KickDown");
     StateHandling.Register(this, "KickDown");
 }
Ejemplo n.º 17
0
 void Start()
 {
     theCamera = GetComponent <Camera>();
     ControlLock.Register(this, "Camera");
 }
Ejemplo n.º 18
0
 public override void Start()
 {
     base.Start();
     ControlLock.Register("NormalPunch", this);
 }
Ejemplo n.º 19
0
 void OnDetectedHit(HitDetector detector, Collider2D other)
 {
     // StartCoroutine(DoReflectiveForce());
     ControlLock.Lock("Move");
     _player.extraForceX -= .5f * _faceX;
 }
Ejemplo n.º 20
0
 public override void Start()
 {
     base.Start();
     ControlLock.Register(this, "WallSlidingController");
 }
Ejemplo n.º 21
0
 public override void Start()
 {
     base.Start();
     ControlLock.Register(this, "Move", "MoveOnGround", "Jump");
     _extraJump = extraJumpCount;
 }