Exemplo n.º 1
0
    public void SetPlayer(PlayerLand playerLand, GameObject playerObj)
    {
        this.playerLand = playerLand;
        this.playerObj  = playerObj;

        Vector2 playerVel = playerObj.GetComponent <Rigidbody2D>().velocity;
        float   yVel      = Mathf.Min(playerVel.y, 0) - SPEED;

        rb.velocity = new Vector2(0, yVel);
    }
Exemplo n.º 2
0
    public override void _Ready()
    {
        _collision_layer = 1;
        ((Area)FindNode("MeleAttackArea")).SetCollisionMaskBit(2, true);      // monitor only enemies
        AddToGroup("player");

        var st_ground = new PlayerGround();
        var st_air    = new PlayerAir();
        var st_skill1 = new PlayerSkill1();
        var st_skill3 = new PlayerSkill3();

        var tr_jump   = new PlayerJump(st_air);
        var tr_fall   = new PlayerFall(st_air);
        var tr_land   = new PlayerLand(st_ground);
        var tr_skill1 = new PlayerActivateSkill(st_skill1, 0, GD.KEY_Z);
        var tr_skill3 = new PlayerActivateSkill(st_skill3, 2, GD.KEY_C);

        st_ground.AddTransition(tr_jump);
        st_ground.AddTransition(tr_fall);
        st_ground.AddTransition(tr_skill1);
        st_ground.AddTransition(tr_skill3);
        st_air.AddTransition(tr_land);
        st_air.AddTransition(tr_skill1);
        st_air.AddTransition(tr_skill3);

        st_skill1.AddTransition(new FromOneShotAnim(st_ground, "skills"));
        st_skill3.AddTransition(new FromOneShotAnim(st_ground, "skills"));

        _fsm = new FSM(this, st_ground);

        // Attributes
        Attributes.Level               = 0;
        Attributes.RunSpeed            = 8;
        Attributes.JumpHeight          = 4;
        Attributes.MaxHealth           = 100;
        Attributes.Health              = Attributes.MaxHealth;
        Attributes.Damage              = 10;
        Attributes.CritChance          = 0.1f;
        Attributes.Experience          = 0.0f;
        Attributes.NextLevelExperience = 100;
    }