コード例 #1
0
    void applyStats()
    {
        stats      plystats = ply.GetComponent <stats>();
        plyAttacks plyatt   = ply.GetComponent <plyAttacks>();

        PlayerPrefs.SetInt("plyhp", plystats.hp + lootSpw.transform.GetChild(kts.lootIndex).GetComponent <lootValues>().hp);
        PlayerPrefs.SetInt("plyammo", plyatt.ammo + lootSpw.transform.GetChild(kts.lootIndex).GetComponent <lootValues>().ammo);
        PlayerPrefs.SetInt("plymaxhp", plystats.maxhp + lootSpw.transform.GetChild(kts.lootIndex).GetComponent <lootValues>().maxhp);
        PlayerPrefs.SetInt("plyatt", plystats.att + lootSpw.transform.GetChild(kts.lootIndex).GetComponent <lootValues>().att);
        PlayerPrefs.SetInt("plydef", plystats.armor + lootSpw.transform.GetChild(kts.lootIndex).GetComponent <lootValues>().def);
        PlayerPrefs.SetInt("plycrit", plystats.critmod + lootSpw.transform.GetChild(kts.lootIndex).GetComponent <lootValues>().critmod);
        PlayerPrefs.SetInt("plyacc", plystats.acc + lootSpw.transform.GetChild(kts.lootIndex).GetComponent <lootValues>().acc);
        PlayerPrefs.SetInt("plyagi", plystats.agi + lootSpw.transform.GetChild(kts.lootIndex).GetComponent <lootValues>().agi);
        PlayerPrefs.SetInt("plycoin", plystats.coin + lootSpw.transform.GetChild(kts.lootIndex).GetComponent <lootValues>().coin);
    }
コード例 #2
0
    void HandleDirectAttacks()
    {
        //get attacker stats
        float _crit;
        int   _HP      = attacker.GetComponent <stats>().hp;
        int   _attMod  = attacker.GetComponent <stats>().att;
        int   _critmod = attacker.GetComponent <stats>().critmod;
        int   _accMod  = attacker.GetComponent <stats>().acc;

        if (attacker.tag == "ply")
        {
            plyAttacks _attacks = attacker.GetComponent <plyAttacks>();

            _baseAtt  = _attacks.baseDmg;
            _baseCrit = _attacks.basecrit;
        }
        else
        {
            attacks _attacks = attacker.GetComponent <attacks>();

            _baseAtt  = _attacks.baseDmg;
            _baseCrit = _attacks.basecrit;
            _baseAcc  = _attacks.baseacc;
        }


        if (target.GetComponent <isEnemu>())
        {
            // sets the accuracy to be based on what part is being attacked
            switch (target.GetComponent <stats>().bodyPart[attIndex].tag)
            {
            case "head":
                _baseAcc = target.GetComponent <stats>().bodyPart[attIndex].GetComponent <headBehaviour>().baseAcc;
                break;

            case "chest":
                _baseAcc = target.GetComponent <stats>().bodyPart[attIndex].GetComponent <chestBehaviour>().baseAcc;
                break;

            case "arm":
                _baseAcc = target.GetComponent <stats>().bodyPart[attIndex].GetComponent <armBehaviour>().baseAcc;
                break;

            case "leg":
                _baseAcc = target.GetComponent <stats>().bodyPart[attIndex].GetComponent <legBehaviour>().baseAcc;
                break;

            case "hat":
                _baseAcc = target.GetComponent <stats>().bodyPart[attIndex].GetComponent <hatBehaviour>().baseAcc;
                break;

            case "weapon":
                _baseAcc = target.GetComponent <stats>().bodyPart[attIndex].GetComponent <weaponBehaviour>().baseAcc;
                break;
            }
        }

        int _targetArm = target.GetComponent <stats>().armor;


        int _finalAcc = Mathf.Clamp((_baseAcc + (_accMod * 2)), 0, 100);

        int accChance = Random.Range(1, 100);


        if (accChance < _finalAcc)
        {
            if (_baseCrit != 0)
            {
                float _critChance = Mathf.Clamp(((_baseCrit / 100) + 1) * (_critmod + 25), 0, 100);

                int ccRoll = Random.Range(1, 100);
                if (Random.Range(1, 100) <= _critChance)
                {
                    Debug.Log("crit");
                    _crit    = 2f;
                    critAnim = true;
                }
                else
                {
                    _crit    = 1;
                    critAnim = false;
                }
            }
            else
            {
                _crit    = 1;
                critAnim = false;
            }

            int _bonusdmg = (_attMod / 10) * (_baseAtt / 2);
            _dmg = (int)((_baseAtt + _bonusdmg) * (_crit));

            _dmg = Mathf.Clamp((_dmg - _targetArm), 0, 200);

            // damage section

            // damages the part you selected
            if (target.GetComponent <isEnemu>())
            {
                switch (target.GetComponent <stats>().bodyPart[attacker.GetComponent <plyAttacks>().whereInd[hitStep]].tag)
                {
                case "head":
                    Debug.Log("head");
                    target.GetComponent <stats>().bodyPart[attacker.GetComponent <plyAttacks>().whereInd[hitStep]].GetComponent <headBehaviour>().partHP -= _dmg;
                    break;

                case "chest":
                    Debug.Log("chest");
                    target.GetComponent <stats>().bodyPart[attacker.GetComponent <plyAttacks>().whereInd[hitStep]].GetComponent <chestBehaviour>().partHP -= _dmg;

                    break;

                case "arm":
                    Debug.Log("arm");
                    target.GetComponent <stats>().bodyPart[attacker.GetComponent <plyAttacks>().whereInd[hitStep]].GetComponent <armBehaviour>().partHP -= _dmg;

                    break;

                case "leg":
                    Debug.Log("leg");
                    target.GetComponent <stats>().bodyPart[attacker.GetComponent <plyAttacks>().whereInd[hitStep]].GetComponent <legBehaviour>().partHP -= _dmg;

                    break;

                case "hat":
                    Debug.Log("hat");
                    target.GetComponent <stats>().bodyPart[attacker.GetComponent <plyAttacks>().whereInd[hitStep]].GetComponent <hatBehaviour>().partHP -= _dmg;

                    break;

                case "weapon":
                    Debug.Log("weapon");
                    target.GetComponent <stats>().bodyPart[attacker.GetComponent <plyAttacks>().whereInd[hitStep]].GetComponent <weaponBehaviour>().partHP -= _dmg;

                    break;
                }

                target.GetComponent <stats>().hp -= _dmg;
                summonDamage();
            }

            if (target.tag == "ply")
            {
                target.GetComponent <stats>().hp -= _dmg;
            }

            textLog.GetComponent <TextMeshPro>().text = attacker.GetComponent <stats>().name + " hit " + target.name + " for " + _dmg;

            //end of damage section
        }
        else
        {
            textLog.GetComponent <TextMeshPro>().text = attacker.GetComponent <stats>().name + " missed ";
        }
    }