/////////////////////////////////////////////////////////////////////////////////////
    //void TakeDamage(CharacterData.CharacterEntry, int float, bool                    //
    //Takes damage using the appropriate stats                                         //
    //CharacterData.CharacterEntry other - The CharacterEntry representing the attacker//
    //int otherWeapon - The attacker's weapon attack                                   //
    //float attackBase - The base attack multiplier of the attack                      //
    //bool isMagical - is the attack magical?                                          //
    /////////////////////////////////////////////////////////////////////////////////////
    public void TakeDamage(CharacterData.CharacterEntry other, float attackBase, bool isMagical)
    {
        int damage;

        if (isMagical)
        {
            damage = DamageCalculator.CalculateMagicalDamage(other.GetMATK(), attackBase, stats.enemyMDEF);
        }

        else
        {
            damage = DamageCalculator.CalculatePhysicalDamage(other.GetATK(), attackBase, stats.enemyDEF);
        }

        currentHP -= damage;
        Debug.Log("Damage Taken: " + damage);

        if (currentHP < 0)
        {
            currentHP = 0;
        }

        if (currentHP == 0)
        {
            Debug.Log("Enemy Defeated!");
        }
    }
Esempio n. 2
0
    // Start is called before the first frame update
    void Start()
    {
        master = MasterController.instance;
        rb     = gameObject.GetComponent <Rigidbody2D>();
        col    = gameObject.GetComponent <BoxCollider2D>();

        //jumpSpeed = 16.5f;
        jumpTime    = 0f;
        jumpTimeMax = 0.7f;
        grounded    = false;

        moveSpeed       = 3f;
        dashSpeed       = 5f;
        moving          = false;
        direction       = 1;
        dashing         = false;
        dashTimer       = 0f;
        changeDirection = false;

        crouching     = false;
        canStand      = true;
        sliding       = false;
        slideForce    = 5f;
        slideTimer    = 0f;
        slideTimerMax = 0.5f;

        weaponType     = currWeapon.type;
        weaponTimerMax = weaponType.speed;
        weaponTimer    = 0f;
        charging       = false;
        chargeTimer    = 0f;
        chargeTimeMax  = 2f;
        shortCharge    = 1f;

        underwater = false;
        waterDrag  = 0.5f;

        terrainLayer = LayerMask.GetMask("Solid");

        stats = new CharacterData.CharacterEntry(CharacterData.human, CharacterData.warrior, false, "Dummy");

        //skill1 = (ActionSkill)(stats.GetSkill1().GetSkill());
        skill2 = (ActionSkill)(stats.GetSkill2().GetSkill());

        maxHP        = stats.GetHP(true);
        maxMP        = stats.GetMP(true);
        currentHP    = maxHP;
        currentMP    = maxMP;
        iframes      = 1f;
        iframesTimer = 1f;

        hasDoubleJump  = true; //stats.HasDoubleJump();
        hasWallJump    = true; //stats.HasWallJump();
        hasRockBreaker = true; //stats.HasRockBreaker();
        hasSlide       = true; //stats.HasSlide();
        hasSwim        = true; //stats.HasSwim();
        hasKey         = stats.HasKey();

        jumpAgain      = false;
        againstWall    = false;
        wallJumped     = false;
        wallJumpFrames = 5;
        wallDirection  = direction;

        height = col.bounds.size.y / 2;
        width  = col.bounds.size.x / 2;

        gravity = 10f;

        CharacterData.currentChar = stats;
    }