示例#1
0
    public void create(int uid)
    {
        unitData data = unitDefault.Instance.data;

        iSet(UIA.fullDec, data.fullDec);
        iSet(UIA.energyMax, data.energyMax);
        iSet(UIA.energyDec, data.energyDec);
        Debug.Log("data.energyReg=" + data.energyReg);
        iSet(UIA.energyReg, data.energyReg);
        iSet(UIA.energyDecNight, data.energyDecNight);
        iSet(UIA.energyRegSec, data.energyRegSec);
        iSet(UIA.fullMax, data.fullMax);

        iSet(UIA.hungry_slight, data.hungry_slight);
        iSet(UIA.hungry_medium, data.hungry_medium);
        iSet(UIA.hungry_extream, data.hungry_extream);
        iSet(UIA.tired_slight, data.tired_slight);
        iSet(UIA.tired_medium, data.tired_medium);
        iSet(UIA.tired_extream, data.tired_extream);

        id          = uid;
        typeId      = 1;
        skinColorId = Globals.rd.Next(utils.Instance.maxColors);
        headSkin    = 1000;
        bodySkin    = 1000;
        skinColor   = utils.Instance.getSkinColor(skinColorId);
        name        = "human";
        runSpeed    = data.runSpeed;
        hpMax       = data.hpMax;
        mood        = data.mood;
        hp          = data.hpMax;
        energy      = data.energy;
        full        = data.full;
    }
 public override void onInit(unitControler owner, Callback4Unit deleg)
 {
     data             = ((BasicControler)owner).data;
     this.information = new SkillInf(true, false, false, new List <string>()
     {
     });
     deleg._onHpChange += onHpChange;
 }
 public RoleRecord_profile(int race, unitData unit, List <int> careers, List <int> skills, List <int> items, vec2i pos)
 {
     this.race     = race;
     unit_profile  = unit.getProflie();
     this.careers  = careers;
     this.skills   = skills;
     this.items    = items;
     this.location = pos;
 }
示例#4
0
 public RoleRecord(RoleRecord_profile profile)
 {
     race     = profile.race;
     careers  = profile.careers;
     skillNos = profile.skills;
     itemNos  = profile.items;
     data     = new unitData(profile.unit_profile);
     location = profile.location;
 }
示例#5
0
 // public
 public void initInf(int no, string name, unitData data, int ownerIdx, int index)
 {
     Debug.Log("name:" + name);
     itemInf = (item_representation)System.Activator.CreateInstance(System.Type.GetType(name));
     itemInf.init(data);
     ownerIndex = ownerIdx;
     itemIndex  = index;
     itemNo     = no;
 }
示例#6
0
 public void init(AI ai, Environment env, unitData data, HpBar hpbar)
 {
     this.ai    = ai;
     this.env   = env;
     this.data  = data;
     this.state = new unitState();
     this.hpbar = hpbar;
     this.data._onLifeChange += hpbarCallBack;
     this.data._onDeath       = onUnitDeath;
 }
示例#7
0
    public beast_wildBoar()
    {
        race               = 5;
        data               = new unitData();
        data.Remote        = false;
        data.Now_Attack   += 5;
        data.Now_Armor    += 20;
        data.Now_Max_Life += 30;

        skillNos.Add(0);
        skillNos.Add(35);
    }
示例#8
0
 public unitData(unitData another)
 {
     this.base_attack            = another.base_attack;
     this.attack_speed_reinforce = another.attack_speed_reinforce;
     this.max_life_point         = another.max_life_point;
     this.now_life_recover       = another.now_life_recover;
     this.magic_strength         = another.magic_strength;
     this.cooldown_reinforce     = another.cooldown_reinforce;
     this.armor            = another.armor;
     this.magic_resistance = another.magic_resistance;
     now_life_point        = max_life_point;
 }
示例#9
0
    // Use this for initialization
    void Start()
    {
        PlayerInf pinf = new PlayerInf();

        pinf.lv        = 10;
        pinf.moneyLeft = 66;
        pinf.itemInBag = new List <int>()
        {
            0, 2, 3, 4, 19
        };
        unitData unit1 = new unitData();

        unit1.Now_Attack       = 20;
        unit1.Now_Attack_Speed = 90;
        unit1.Now_Max_Life     = 199;
        RoleRecord role1 = new RoleRecord(2);

        role1.data = unit1;
        Debug.Log("role1.data: NowAtk:" + unit1.Now_Attack);
        unitData_Profile ud_pf = unit1.getProflie();

        Debug.Log("unitData: baseAttack:" + ud_pf.base_attack + " atkSpeed:" + ud_pf.attack_speed_reinforce + " maxLife:" + ud_pf.max_life_point);
        role1.itemNos = new List <int>()
        {
            1, 1, 2, 3
        };


        unitData unit2 = new unitData();

        unit2.Now_Mag_Reinforce  = 50;
        unit2.Now_Mag_Resistance = 97;
        unit2.Now_Armor          = 35;
        RoleRecord role2 = new RoleRecord(0);

        role2.data     = unit2;
        role2.skillNos = new List <int>()
        {
            1, 2, 26, 10
        };
        role2.location = new vec2i(1, 1);

        pinf.army.Add(role1);
        pinf.army.Add(role2);
        pinf.saveInf();

        PlayerInf newInf = PlayerInf.loadInf();

        newInf.printInf();
    }
示例#10
0
    public virtual Dictionary <string, object> createSkillArg(unitData data)
    {
        Dictionary <string, object> arg = new Dictionary <string, object>();

        arg["miss"]                = false;
        arg["bonus"]               = false;//因為技能效果所而額外觸發的技能
        arg["dice"]                = Randomer.main.getInt();
        arg["critical"]            = false;
        arg["phy_damage_multiple"] = 1f;
        arg["phy_damage_addition"] = 0;
        arg["mag_damage_multiple"] = data.Now_Mag_Multiple;
        arg["mag_damage_addition"] = 0;
        arg["healing_multiple"]    = data.Now_Mag_Multiple;
        arg["healing_addition"]    = 0;
        arg["control_multiple"]    = 1f;
        arg["control_addition"]    = 0;
        arg["cooldown_multiple"]   = 1f;
        return(arg);
    }
示例#11
0
 public RoleRecord()
 {
     race = 0;
     data = new unitData();
 }
示例#12
0
 public void init(unitData data)
 {
 }
示例#13
0
 public abstract void init(unitData nowdata);
示例#14
0
 public void init()
 {
     data = new unitData();
 }
示例#15
0
 private void UpgradeUnitStat(unitData stat)
 {
     UnitUpgrades [(int) UpgradingUnit][(int)stat] *= (float) 1.25;
     InShop = 0;
     UpgradingUnit = unitTypes.none;
 }
示例#16
0
 public void initInf(string name, unitData data)
 {
     Debug.Log("initInf name:" + name);
     skillInf = (skill_representation)System.Activator.CreateInstance(System.Type.GetType(name));
     skillInf.init(data);
 }
示例#17
0
 public RoleRecord(int kind)
 {
     race = kind;
     data = new unitData();
 }
 public void init(unitData nowdata)
 {
     data = nowdata;
 }
 public override void init(unitData nowdata)
 {
 }
示例#20
0
 public void init(unitData nowdata)
 {
 }
示例#21
0
    public unitControler createUnit(Dictionary <string, object> unitInf)
    {
        Debug.Log("創建新的單位");
        int posX = (int)unitInf["position_x"];
        int posY = (int)unitInf["position_y"];

        RoleRecord inf      = ((RoleRecord)unitInf["information"]);
        int        unitNo   = inf.race;
        int        playerNo = (int)unitInf["player_no"];
        List <int> skillnos = inf.skillNos;
        List <int> itemnos  = inf.itemNos;
        unitData   data     = inf.data;
        int        realX    = 0;
        int        realY    = 0;
        GameObject newone   = Instantiate(objectList.main.mainUnit);

        newone.name = "隨機" + UnityEngine.Random.Range(0, 100);
        Debug.Log("playerNo:" + playerNo + " chessx:" + chessBoard.X + " chessy:" + chessBoard.Y);
        //Debug.Log("realY")
        if (playerNo % 2 == 0)
        {
            realX = posX;
            realY = chessBoard.Y / 2 - 1 - posY;
        }
        else if (playerNo % 2 == 1)
        {
            realX = posX;
            realY = chessBoard.Y / 2 + posY;
        }
        newone.transform.position = new Vector2(INIT_X + realX * X_INTERVAL, INIT_Y + realY * Y_INTERVAL);
        BasicControler controler = newone.AddComponent <BasicControler>();

        controler.playerNo = playerNo;
        newone.GetComponent <SpriteRenderer>().sprite = ImageList.main.headIcons[unitNo];
        bool result = chessBoard.enter(controler, realX, realY);

        Debug.Log("result:" + result);
        if (result)
        {
            GameObject hpbar = Instantiate(objectList.main.hpBar, newone.transform);
            hpbar.transform.localPosition        = objectList.main.hpBar.transform.position;
            hpbar.GetComponent <HpBar>().HpColor = playerColor[playerNo];
            //要複製一個新的unitData,不然在戰鬥中的技能可能會永久地改變角色屬性
            controler.init(new BasicAI(), chessBoard, new unitData(data), hpbar.GetComponent <HpBar>());
            controler._onDeath = forRoleDeath;
            Timer.main.logInTimer(controler.action);
            newone.AddComponent <sp_effection>();
            SkillBelt belt = newone.AddComponent <SkillBelt>();
            controler.skillBelt = belt;
            belt.init(controler, skillnos);
            itemBelt item_belt = newone.AddComponent <itemBelt>();
            item_belt.init(controler, itemnos);
            //是否要用字串來儲存技能名?
            return(controler);
        }
        else
        {
            Destroy(newone);
            return(null);
        }
    }