Esempio n. 1
0
    static void Try2SpawnKabezuri(HeroMover hero)
    {
        if (hero.velocity.Y > 0)
        {
            return;
        }

        bool dir_is_R;

        if (hero.CanKickFromWallR && hero.CanKickFromWallL)
        {
            dir_is_R = hero.WantsToGoRight;
        }
        else if (hero.CanKickFromWallR)
        {
            dir_is_R = true;
        }
        else if (hero.CanKickFromWallL)
        {
            dir_is_R = false;
        }
        else
        {
            return;
        }

        hero.ObjsHolderForStates.KabezuriPool.ActivateOne(dir_is_R ? "r" : "l");
    }
Esempio n. 2
0
    public static void HorizontalMoveInAir(this HeroMover hero, MoveInAirParams params_, float deltatime)
    {
        switch (hero.KeyDirection)
        {
        case 1:
            hero.velocity.X = Mathf.Min(
                hero.velocity.X + params_.HorizontalForce * deltatime,
                params_.HorizontalSpeedMax);
            break;

        case -1:
            hero.velocity.X = Mathf.Max(
                hero.velocity.X - params_.HorizontalForce * deltatime,
                -params_.HorizontalSpeedMax);
            break;

        case 0:
            if (hero.velocity.X > 0)
            {
                hero.velocity.X = Mathf.Max(
                    hero.velocity.X - params_.HorizontalResistance * deltatime,
                    0);
            }
            else
            {
                hero.velocity.X = Mathf.Min(
                    hero.velocity.X + params_.HorizontalResistance * deltatime,
                    0);
            }
            break;
        }
    }
Esempio n. 3
0
    void PhantomAndDissolve(HeroMover hero)
    {
        SpriteRenderer phantom = hero.ObjsHolderForStates.PhantomRenderer;

        phantom.gameObject.SetActive(true);
        phantom.transform.position = hero.transform.position;
        phantom.sprite             = hero.SpriteRenderer.sprite;

        Material heroMat    = hero.SpriteRenderer.material;
        Material phantomMat = phantom.material;

        heroMat.SetFloat("_DisThreshold0", 1);
        heroMat.SetFloat("_DisThreshold1", 1.1f);
        phantomMat.SetFloat("_DisThreshold0", -1);
        phantomMat.SetFloat("_DisThreshold1", 0);

        DOVirtual.DelayedCall(0.2f, () =>
        {
            float heroAppearSec = 0.3f;
            heroMat.To("_DisThreshold0", -1, heroAppearSec);
            heroMat.To("_DisThreshold1", 0, heroAppearSec);
        }, ignoreTimeScale: false)
        .AsHeros();

        float phantomDisappearSec = 0.3f;

        phantomMat.To("_DisThreshold0", 1, phantomDisappearSec).AsHeros();
        phantomMat.To("_DisThreshold1", 1.1f, phantomDisappearSec).AsHeros()
        .onComplete = () => phantom.gameObject.SetActive(false);
    }
Esempio n. 4
0
    public static bool IsReady2Kick2Left(this HeroMover hero, IInput input)
    {
        if (!input.GetButtonDown(ButtonCode.Jump))
        {
            return(false);
        }
        if (!hero.CanKickFromWallR)
        {
            return(false);
        }

        switch (hero.Parameters.KickParams.KickKey)
        {
        case KickKey.DirAgainstWall:
            return(input.GetButton(ButtonCode.Left));

        case KickKey.DirOfWall:
            return(input.GetButton(ButtonCode.Right));

        case KickKey.Any:
            return(true);

        default:
            throw new NotImplementedException();
        }
    }
Esempio n. 5
0
 public override void Exit(HeroMover hero)
 {
     hero.MutekiManager.RemoveMutekiFilter("Jet");
     hero.CanMove = true;
     hero.GetDPinEnemy.GetComponent <Collider2D>().enabled = false;
     _OnJetCompleted.OnNext(Unit.Default);
 }
Esempio n. 6
0
    public override void Enter(HeroMover hero)
    {
        hero.MutekiManager.AddMutekiFilter("Jet");
        hero.CanMove = false;
        hero.SetAnim("fall");

        PhantomAndDissolve(hero);

        GameObject.Instantiate(hero.ObjsHolderForStates.JetstreamPrefab, DraftManager.CurrentInstance.GameMasterTF)
        .Init(hero);

        hero.GetDPinEnemy.GetComponent <Collider2D>().enabled = true;

        JetParams params_ = hero.Parameters.JetParams;

        float jetSeconds = Mathf.Lerp(
            params_.JetSecondsMin,
            params_.JetSecondsMax,
            charge_0_1
            );
        float jetDistance = Mathf.Lerp(
            params_.MinDistance,
            params_.MaxDistance,
            charge_0_1
            );

        hTween = new HeroTween(
            hero.WantsToGoRight ? jetDistance : -jetDistance,
            jetSeconds,
            hero.Parameters.JetParams.TweenLinearRate
            );
    }
Esempio n. 7
0
    public override HeroState HandleInput(HeroMover hero, IInput input)
    {
        if (hero.IsReady2Kick2Left(input))
        {
            return(new StateKick(toRight: false));
        }
        if (hero.IsReady2Kick2Right(input))
        {
            return(new StateKick(toRight: true));
        }

        if (input.GetButtonDown(ButtonCode.Jump))
        {
            if (hero.CanJumpInAir)
            {
                return(new StateJump(fromGround: false));
            }
        }

        if (hero.KeyDirection == 1 && !right)
        {
            right = true;
            hero.SetAnim("fall");
        }
        else if (hero.KeyDirection == -1 && right)
        {
            right = false;
            hero.SetAnim("fall");
        }

        return(this);
    }
Esempio n. 8
0
    public void Init(HeroMover hero)
    {
        this.hero          = hero;
        posWhenJet         = hero.transform.position;
        transform.position = hero.transform.position;

        hero.JetManager.JetEnded
        .Subscribe(_ => Destroy(gameObject))
        .AddTo(this);
    }
Esempio n. 9
0
 public static void ApplyFriction(this HeroMover hero, float friction, float deltatime)
 {
     if (hero.velocity.X > 0)
     {
         hero.velocity.X = Mathf.Max(hero.velocity.X - friction * deltatime, 0);
     }
     if (hero.velocity.X < 0)
     {
         hero.velocity.X = Mathf.Min(hero.velocity.X + friction * deltatime, 0);
     }
 }
Esempio n. 10
0
    public override void Enter(HeroMover hero)
    {
        Start_(hero);

        HeroVelocity vel = hero.Parameters.BendParams.BendBackForce.ToHeroVel();

        if (!hero.WantsToGoRight)
        {
            vel.X *= -1;
        }
        hero.velocity = vel;
    }
Esempio n. 11
0
 public override HeroState HandleInput(HeroMover hero, IInput input)
 {
     if (input.GetButtonDown(ButtonCode.Jump))
     {
         return(new StateJump());
     }
     if (input.GetButton(ButtonCode.Right) || input.GetButton(ButtonCode.Left))
     {
         return(new StateRun());
     }
     return(this);
 }
Esempio n. 12
0
    void OnTriggerEnter2D(Collider2D other)
    {
        if (other.CompareTag(Tags.Hero) && !gotten)
        {
            gotten = true;

            HeroMover hero = other.GetComponentInParent <HeroMover>();
            hero.GetDP(DPperDPCD);

            GottenAnimation();
            GetComponent <SoundGroup>().Play("Got");
        }
    }
Esempio n. 13
0
    public static void ApplySakamichi(this HeroMover hero)
    {
        float absVx  = Mathf.Abs(hero.velocity.X);
        float offset = 10;

        if (hero.SakamichiSensors.OnSakamichiL)
        {
            hero.velocity.Y = (hero.WantsToGoRight ? -absVx :  absVx) - offset;
        }
        else if (hero.SakamichiSensors.OnSakamichiR)
        {
            hero.velocity.Y = (hero.WantsToGoRight ?  absVx : -absVx) - offset;
        }
    }
Esempio n. 14
0
 public void Init(IInput input, HeroMover hero)
 {
     (this.input, this.hero) = (input, hero);
     hero.OnDamaged.Subscribe(hp =>
     {
         if (state == State.Ready)
         {
             state         = State.Inactive;
             chargeSeconds = 0;
             coolTimeLeft  = 0;
             EffectOnExit();
         }
     });
 }
Esempio n. 15
0
    public override HeroState Update_(HeroMover hero, float deltatime)
    {
        hero.HorizontalMoveInAir(hero.Parameters.MoveInAirParams, deltatime);

        var params_ = hero.Parameters.MoveInAirParams;

        hero.ApplyGravity(params_.Gravity, params_.FallSpeedMax, deltatime);

        if (hero.velocity.Y < 0)
        {
            return(new StateFall());
        }

        return(this);
    }
Esempio n. 16
0
    IEnumerator Tsuchihokori(ObjectPool <Tsuchihokori> pool, HeroParameters params_, HeroMover hero)
    {
        while (true)
        {
            pool.ActivateOne(right ? "r" : "l");

            float time = 0;
            yield return(null);

            while ((time += hero.TimeManager.DeltaTimeAroundHero) < params_.RunParams.TsuchihokoriInterval)
            {
                yield return(null);
            }
        }
    }
Esempio n. 17
0
 Dir CalcDir(HeroMover hero)
 {
     if (hero.KeyDirection == 1)
     {
         return(Dir.FR);
     }
     if (hero.KeyDirection == -1)
     {
         return(Dir.FL);
     }
     if (hero.WantsToGoRight)
     {
         return(Dir.UR);
     }
     return(Dir.UL);
 }
Esempio n. 18
0
 public override HeroState Update_(HeroMover hero, float deltatime)
 {
     (float move, bool completed) = hTween.Update(deltatime);
     hero.velocity = new HeroVelocity(move, 0);
     if (completed)
     {
         if (hero.IsOnGround)
         {
             return(new StateWait());
         }
         else
         {
             return(new StateFall());
         }
     }
     return(this);
 }
Esempio n. 19
0
    public Vector2 UpdateVel(Vector2 currentVeclocity, float deltatime, HeroMover hero)
    {
        if (secondsToDie < 0)
        {
            return(currentVeclocity);
        }

        Vector2 ans = currentVeclocity + new Vector2(CurrendAdditionalVelocity(), 0);

        secondsToDie -= deltatime;
        if (secondsToDie < 0)
        {
            _IsActive = false;
        }

        return(ans);
    }
Esempio n. 20
0
    public static IEnumerator SpawnKabezuris(this HeroMover hero, MoveInAirParams params_)
    {
        Try2SpawnKabezuri(hero);

        while (true)
        {
            float time = 0;
            yield return(null);

            while ((time += hero.TimeManager.DeltaTimeAroundHero) < params_.KabezuriInterval)
            {
                yield return(null);
            }

            Try2SpawnKabezuri(hero);
        }
    }
Esempio n. 21
0
    public override HeroState Update_(HeroMover hero, float deltatime)
    {
        var params_ = hero.Parameters;

        hero.ApplyGravity(params_.BendParams.Gravity, params_.MoveInAirParams.FallSpeedMax, deltatime);

        if (hero.IsOnGround)
        {
            hero.ApplyFriction(hero.Parameters.RunParams.Friction, deltatime);
        }

        secondsAfterEnter += deltatime;
        if (secondsAfterEnter >= hero.Parameters.BendParams.BendBackSeconds)
        {
            return(new StateFall());
        }

        return(this);
    }
Esempio n. 22
0
    public override void Enter(HeroMover hero)
    {
        hero.velocity.Y = force == -1 ? hero.Parameters.JumpForce : force;

        Start(hero);

        if (isFromGround)
        {
            hero.ObjsHolderForStates.JumpEffectPool.ActivateOne(hero.WantsToGoRight ? "r" : "l");
        }
        else
        {
            hero.ObjsHolderForStates.JumpEffectInAirPool.ActivateOne(hero.WantsToGoRight ? "r" : "l");
        }
        kabezuriCoroutine = hero.SpawnKabezuris(hero.Parameters.MoveInAirParams);
        hero.StartCoroutine(kabezuriCoroutine);

        hero.Jumped(isFromGround, isKick: false);
    }
Esempio n. 23
0
    void SetDir(Dir dir, HeroMover hero)
    {
        if (dir == _dir)
        {
            return;
        }

        _dir = dir;
        switch (dir)
        {
        case Dir.FR: hero.SetAnimManually("jumpfr"); break;

        case Dir.FL: hero.SetAnimManually("jumpfl"); break;

        case Dir.UR: hero.SetAnimManually("jumpur"); break;

        case Dir.UL: hero.SetAnimManually("jumpul"); break;
        }
    }
Esempio n. 24
0
    public override HeroState HandleInput(HeroMover hero, IInput input)
    {
        if (hero.IsReady2Kick2Left(input))
        {
            return(new StateKick(toRight: false));
        }
        if (hero.IsReady2Kick2Right(input))
        {
            return(new StateKick(toRight: true));
        }

        if (hero.CanJumpInAir && input.GetButtonDown(ButtonCode.Jump))
        {
            return(new StateJump(fromGround: false));
        }

        SetDir(CalcDir(hero), hero);

        return(this);
    }
Esempio n. 25
0
    public override HeroState Update_(HeroMover hero, float deltatime)
    {
        if (hero.IsOnGround)
        {
            fromNoGround = 0f;
        }
        else
        {
            fromNoGround += deltatime;
            if (fromNoGround >= hero.Parameters.RunParams.CoyoteTime)
            {
                return(new StateFall());
            }
        }

        hero.velocity.Y = 0;

        hero.ApplyFriction(hero.Parameters.RunParams.Friction, deltatime);

        return(this);
    }
Esempio n. 26
0
    public override HeroState Update_(HeroMover hero, float deltatime)
    {
        hero.velocity.Y = 0;

        if (hero.IsOnGround)
        {
            fromNoGround = 0f;
        }
        else
        {
            fromNoGround += deltatime;
            if (fromNoGround >= hero.Parameters.RunParams.CoyoteTime)
            {
                return(new StateFall());
            }
        }

        if (hero.KeyDirection == 0)
        {
            return(new StateWait());
        }

        if (hero.KeyDirection == 1)
        {
            hero.velocity.X = Mathf.Min(
                hero.velocity.X + hero.Parameters.RunParams.ForceOnGround * deltatime,
                hero.Parameters.RunParams.GroundSpeedMax);
        }
        else if (hero.KeyDirection == -1)
        {
            hero.velocity.X = Mathf.Max(
                hero.velocity.X - hero.Parameters.RunParams.ForceOnGround * deltatime,
                -hero.Parameters.RunParams.GroundSpeedMax);
        }

        hero.ApplySakamichi();

        return(this);
    }
Esempio n. 27
0
    public override HeroState Update_(HeroMover hero, float deltatime)
    {
        hero.HorizontalMoveInAir(hero.Parameters.MoveInAirParams, deltatime);

        var params_ = hero.Parameters.MoveInAirParams;

        hero.ApplyGravity(params_.Gravity, params_.FallSpeedMax, deltatime);

        if (hero.IsOnGround)
        {
            hero.SoundGroup.Play("Land");
            if (hero.KeyDirection == 0)
            {
                return(new StateWait());
            }
            else
            {
                return(new StateRun());
            }
        }

        return(this);
    }
Esempio n. 28
0
    public override void Enter(HeroMover hero)
    {
        HeroVelocity firstSpeed = hero.Parameters.KickParams.KickForce.ToHeroVel();

        if (!right)
        {
            firstSpeed.X *= -1;
        }
        hero.velocity = firstSpeed;
        hero.CanMove  = false;

        hero.SetAnimManually(right ? "jumpfr" : "jumpfl");
        if (hero.KeyDirection == 0)
        {
            hero.ForceChangeWantsToGoRight(right);                        //しっくりこない
        }
        hero.SoundGroup.Play("Jump");
        hero.ObjsHolderForStates.JumpEffectPool.ActivateOne(right ? "kr" : "kl");
        kabezuriCoroutine = hero.SpawnKabezuris(hero.Parameters.MoveInAirParamsAfterKick);
        hero.StartCoroutine(kabezuriCoroutine);

        hero.Jumped(isFromGround: false, isKick: true);
    }
Esempio n. 29
0
    public override HeroState HandleInput(HeroMover hero, IInput input)
    {
        if (input.GetButtonDown(ButtonCode.Jump))
        {
            return(new StateJump());
        }
        if (!(input.GetButton(ButtonCode.Right) || input.GetButton(ButtonCode.Left)))
        {
            return(new StateWait());
        }

        if (hero.KeyDirection == 1 && !right)
        {
            right = true;
            hero.SetAnim("run");
        }
        if (hero.KeyDirection == -1 && right)
        {
            right = false;
            hero.SetAnim("run");
        }

        return(this);
    }
Esempio n. 30
0
    public override HeroState Update_(HeroMover hero, float deltatime)
    {
        if (fromKick < hero.Parameters.KickParams.FromKickToInputEnabled)
        {
            fromKick += deltatime;
            if (fromKick >= hero.Parameters.KickParams.FromKickToInputEnabled)
            {
                hero.CanMove = true;
            }
        }

        hero.HorizontalMoveInAir(hero.Parameters.MoveInAirParamsAfterKick, deltatime);

        var params_ = hero.Parameters.MoveInAirParamsAfterKick;

        hero.ApplyGravity(params_.Gravity, params_.FallSpeedMax, deltatime);

        if (hero.velocity.Y < 0)
        {
            return(new StateFall());
        }

        return(this);
    }