コード例 #1
0
 //电脑AI,战斗时
 private void fightNpcAI(GameNpc tNpc, GameNpc tNpc2)
 {
     if (tNpc.isCanFight)
     {
         tNpc.speedTime = 0;
         FightEvent[] fight = tNpc.GetComponents <FightEvent>();
         fight[(int)Random.Range(0, fight.Length)].runEvent();
     }
 }
コード例 #2
0
    /******************************
    *对外开放的接口
    *
    *
    ******************************/
    public static int saveNpc(GameNpc npc, int id)
    {
        if (npc == null)
        {
            return(0);
        }
        string sId = id.ToString();

        //存储基本信息
        PlayerPrefs.SetInt(sId + "_id", id);
        PlayerPrefs.SetString(sId + "_name", npc.npcName);
        PlayerPrefs.SetFloat(sId + "_x", npc.transform.position.x);
        PlayerPrefs.SetFloat(sId + "_y", npc.transform.position.y);
        PlayerPrefs.SetFloat(sId + "_z", npc.transform.position.z);
        PlayerPrefs.SetFloat(sId + "_hp", npc.hp);
        PlayerPrefs.SetFloat(sId + "_maxHp", npc.maxHp);
        PlayerPrefs.SetFloat(sId + "_mp", npc.mp);
        PlayerPrefs.SetFloat(sId + "_maxMp", npc.maxMp);
        PlayerPrefs.SetFloat(sId + "_pAttlow", npc.pAttLow);
        PlayerPrefs.SetFloat(sId + "_pAttHigh", npc.pAttHigh);
        PlayerPrefs.SetFloat(sId + "_mAttlow", npc.mAttLow);
        PlayerPrefs.SetFloat(sId + "_mAttHigh", npc.mAttHigh);
        PlayerPrefs.SetFloat(sId + "_pDefPower", npc.pDefPower);
        PlayerPrefs.SetFloat(sId + "_mDefPower", npc.mDefPower);
        PlayerPrefs.SetInt(sId + "_lvl", npc.lvl);
        PlayerPrefs.SetInt(sId + "_maxLvl", npc.maxLvl);
        PlayerPrefs.SetFloat(sId + "_exp", npc.exp);
        PlayerPrefs.SetFloat(sId + "_maxExp", npc.maxExp);
        PlayerPrefs.SetFloat(sId + "_money", npc.money);
        PlayerPrefs.SetFloat(sId + "_maxMoney", npc.maxMoney);
        PlayerPrefs.SetInt(sId + "_liliang", npc.liliang);
        PlayerPrefs.SetInt(sId + "_minjie", npc.minjie);
        PlayerPrefs.SetInt(sId + "_zhili", npc.zhili);
        PlayerPrefs.SetInt(sId + "_tizhi", npc.tizhi);
        PlayerPrefs.SetFloat(sId + "_norFightSpeed", npc.norFightSpeed);
        PlayerPrefs.SetFloat(sId + "_fightSpeedAmp", npc.fightSpeedAmp);
        PlayerPrefs.SetFloat(sId + "_pVioHurtAmp", npc.pVioHurtAmp);
        PlayerPrefs.SetFloat(sId + "_pVioHurtAdd", npc.pVioHurtAdd);
        PlayerPrefs.SetFloat(sId + "_pVioHurtOdds", npc.pVioHurtOdds);
        PlayerPrefs.SetFloat(sId + "_pVioHurtMissDefAmp", npc.pVioHurtMissDefAmp);
        PlayerPrefs.SetFloat(sId + "_pVioHurtMissDefAdd", npc.pVioHurtMissDefAdd);
        PlayerPrefs.SetFloat(sId + "_pVioHurtMissDefOdds", npc.pVioHurtMissDefOdds);
        PlayerPrefs.SetFloat(sId + "_doeOdds", npc.doeOdds);
        PlayerPrefs.SetFloat(sId + "_recoverHpPerSecond", npc.recoverHpPerSecond);
        PlayerPrefs.SetFloat(sId + "_recoverMpPerSecond", npc.recoverMpPerSecond);
        PlayerPrefs.SetFloat(sId + "_recoverHpPerHit", npc.recoverHpPerHit);
        PlayerPrefs.SetFloat(sId + "_recoverMpPerHit", npc.recoverMpPerHit);
        PlayerPrefs.SetFloat(sId + "_extraItemOdds", npc.extraItemOdds);
        PlayerPrefs.SetFloat(sId + "_extraExpOdds", npc.extraExpOdds);
        PlayerPrefs.SetFloat(sId + "_extraMoneyOdds", npc.extraMoneyOdds);

        //存储技能
        FightEvent[] f = npc.GetComponents <FightEvent>();
        for (int i = 0; i < f.Length; i++)
        {
            PlayerPrefs.SetInt(sId + "_Skill" + "_" + f[i].id, f[i].id);
            PlayerPrefs.SetString(sId + "_Skill" + "_" + f[i].id + "_name", f[i].skillName);
            PlayerPrefs.SetString(sId + "_Skill" + "_" + f[i].id + "_text", f[i].skillText);
            PlayerPrefs.SetInt(sId + "_Skill" + "_" + f[i].id + "_lvl", f[i].skillLvl);
            PlayerPrefs.SetInt(sId + "_Skill" + "_" + f[i].id + "_maxLvl", f[i].skillMaxLvl);
            PlayerPrefs.SetFloat(sId + "_Skill" + "_" + f[i].id + "_exp", f[i].skillExp);
            PlayerPrefs.SetFloat(sId + "_Skill" + "_" + f[i].id + "_maxExp", f[i].skillMaxExp);
            PlayerPrefs.SetFloat(sId + "_Skill" + "_" + f[i].id + "_hurtAmp", f[i].skillHurtAmp);
            PlayerPrefs.SetFloat(sId + "_Skill" + "_" + f[i].id + "_hurtAdd", f[i].skillHurtAdd);
        }
        return(1);
    }