Ejemplo n.º 1
0
    //true 被击中 false 则闪避
	public static bool checkIsHitted(DRoleData fightrole,DRoleData beatonrole)
    {
        float hitrate = fightrole.getSubAttrByType(ESubAttr.Hit) / (fightrole.getSubAttrByType(ESubAttr.Hit) + beatonrole.getSubAttrByType(ESubAttr.Dodge));

        float rand = Random.Range(0, 1f);

        if (rand <= hitrate)
            return true;
        else
            return false;
    }
Ejemplo n.º 2
0
    // phyplus 物理攻击加成,magplus 法术攻击加成
    public static int calculateHarm(DRoleData fightrole, DRoleData beatonrole,int phyplus = 0,int magplus = 0)
    {
        float phyHarm = phyplus + fightrole.getBaseAttrByType(EBaseAttr.Phy_Attack) - beatonrole.getBaseAttrByType(EBaseAttr.PhyDef);
        float magHarm = magplus + fightrole.getBaseAttrByType(EBaseAttr.Mag_Attack) - beatonrole.getBaseAttrByType(EBaseAttr.MagDef);

        float total = phyHarm + magHarm;
        if (total <= 0)
            total = 1;
        return (int)(total*0.5f);      

    }
Ejemplo n.º 3
0
    public void setSide(int fside,int roleid,Vector3 pos,Vector3 rotate)
    {
        side = fside;

        roledata = new DRoleData(roleid);

       // GameObject rolemodel = UnityEditor.AssetDatabase.LoadAssetAtPath("Assets/RPG/actors/" + roledata.defaultRoledata.modelUrl + ".prefab",typeof(GameObject)) as GameObject;

        GameObject rolemodel = ResourceManager.loadAsset<GameObject>("Assets/RPG/actors/" + roledata.defaultRoledata.modelUrl + ".prefab");
        roleModel = GameObject.Instantiate(rolemodel) as GameObject;
        //agent = roleModel.GetComponent<NavMeshAgent>();
        roleModel.transform.position = pos;
        roleModel.transform.parent = transform;
        //if(fside == 0)
       // roleModel.tag = Tags.enemy;

        rolelastpos = pos;
        roleModel.transform.localEulerAngles = rotate;
       // roleModel.transform.localScale = new Vector3(8, 8, 8);
        animatorControl = roleModel.AddComponent<DAnimatorController>();
        cc = roleModel.GetComponent<CharacterController>();
        bodyRadius = cc.radius;
        bodyHeight = cc.height;
        cc.enabled = false;

        agent = roleModel.AddComponent<NavMeshAgent>();
       // obstacle = roleModel.AddComponent<NavMeshObstacle>();
        agent.obstacleAvoidanceType = ObstacleAvoidanceType.NoObstacleAvoidance;
        agent.autoRepath = true;
        agent.radius = bodyRadius;
        agent.height = bodyHeight;
      //  obstacle.radius = bodyRadius;
       // obstacle.carving = true;
        skillManager = gameObject.AddComponent<FightRoleSkill>();
        skillManager.initSkill(roledata.defaultRoledata.skillIdList);

        followfight = gameObject.AddComponent<FollowFighter>();

        hpbarui = gameObject.AddComponent<HpBarControl>();

        StartCoroutine(resetModelPos());
        

    }
Ejemplo n.º 4
0
    //被击伤害

    IEnumerator beantonBlood(DRoleData castRoleData, DSkillBaseData baseskilldata, float delayTime)
    {
        yield return new WaitForSeconds(delayTime);

        int phyPlus = 0;
        int magPlus = 0;
        if (ConfigManager.intance.skillDefaultDic.ContainsKey(baseskilldata.id))
        {
            DSkillDefaultData defaultskill = ConfigManager.intance.skillDefaultDic[baseskilldata.id];
            if (defaultskill.attack_plus.ContainsKey((int)EBaseAttr.Phy_Attack))
            {
                phyPlus = (int)castRoleData.getBaseAttrByType(EBaseAttr.Phy_Attack) * defaultskill.attack_plus[(int)EBaseAttr.Phy_Attack]/100;
            }
            if (defaultskill.attack_plus.ContainsKey((int)EBaseAttr.Mag_Attack))
            {
                magPlus = (int)castRoleData.getBaseAttrByType(EBaseAttr.Mag_Attack) * defaultskill.attack_plus[(int)EBaseAttr.Mag_Attack]/100;
            }
        }
        int harm = FightCalculateTool.calculateHarm(castRoleData, roledata, phyPlus, magPlus);
        roledata.addBaseBuffAttr(EBaseAttr.Hp, -harm);

        hpbarui.updateHp();
        if (roledata.getBaseAttrByType(EBaseAttr.Hp) <=0 )
        {
            isDead = true;
            doDead();
        }
    }