public override bool onInit(unitControler unit, Buff[] Repetitive, Dictionary <string, object> args) { int num = (int)args["num"]; float time = (float)args["time"]; creater = (BasicControler)args["creater"]; if (Repetitive.Length > 0) { buff_slowHealing buff = (buff_slowHealing)Repetitive[0]; if (buff.number < num) { buff.number = num; } if (buff.TimeLeft < time) { buff.timeLeft = time; } return(false); } else { timeLeft = time; number = num; GameObject prafeb = objectList.main.prafebList[43]; effection = Instantiate(prafeb, gameObject.transform); effection.transform.localPosition = prafeb.transform.position; effection.transform.localScale = prafeb.transform.localScale; this.unit = unit; return(true); } }
public override void trigger(Dictionary <string, object> args) { //Debug.Log("攻擊被觸發"); unitControler[] tragets = (unitControler[])args["tragets"]; if (!(bool)args["miss"]) { //BasicControler traget = (BasicControler)args["tragets"]; //Debug.Log("traget:"+traget); //Debug.Log("traget type:" + (args["tragets"].GetType())); foreach (unitControler traget in tragets) { BasicControler nowTraget = (BasicControler)traget; //Debug.Log("製造傷害時傷害數值為:" + damage.num); Debug.Log("traget 為:" + ((BasicControler)traget).gameObject.name); bool haveBuff = (((BasicControler)traget).GetComponent <buff_chill>() != null);//如果目標有寒冷狀態,則暴擊 traget.takeDamage(createDamage(args, haveBuff)); ActionForTraget(traget); //Debug.Log("冷卻時間:" + CoolDown); //Debug.Log("自身位置:" + transform.position + "相對位置:" + transform.TransformDirection(offset)); GameObject mislobj = Instantiate(objectList.main.prafebList[missileNo], ((BasicControler)traget).transform.position, transform.rotation); GameObject effobj = Instantiate(objectList.main.prafebList[effNo_hit], ((BasicControler)traget).gameObject.transform); effobj.transform.localPosition = Vector2.zero; } } else { BasicControler traget = (BasicControler)tragets[0]; NumberCreater.main.CreateMissing(traget.transform.position); } setTime(args); }
public override bool onInit(unitControler unit, Buff[] Repetitive, Dictionary <string, object> args) { if (Repetitive.Length == 0) { timeLeft = (float)args["time"]; shieldNum = (int)args["num"]; creater = (BasicControler)args["creater"]; this.unit = (BasicControler)unit; GameObject prefab = effection_prefab; if (prefab != null) { effection = Instantiate(prefab, ((BasicControler)this.unit).transform); effection.transform.localPosition = prefab.transform.position; } ((BasicControler)unit)._befTakeDamage += beforeTakeDamage; return(true); } else { if (((buff_shieldTemplate)Repetitive[0]).TimeLeft < (float)args["time"]) { ((buff_shieldTemplate)Repetitive[0]).timeLeft = (float)args["time"]; } if (((buff_shieldTemplate)Repetitive[0]).shieldNum < (int)args["num"]) { ((buff_shieldTemplate)Repetitive[0]).shieldNum = (int)args["num"]; } return(false); } }
public override void trigger(Dictionary <string, object> args) { unitControler[] tragets = (unitControler[])args["tragets"]; if (!(bool)args["miss"]) { //BasicControler traget = (BasicControler)args["tragets"]; //Debug.Log("traget:"+traget); //Debug.Log("traget type:" + (args["tragets"].GetType())); foreach (unitControler traget in tragets) { //Debug.Log("製造傷害時傷害數值為:" + damage.num); ((BasicControler)traget).traget = this.owner; } } else { BasicControler traget = (BasicControler)tragets[0]; NumberCreater.main.CreateMissing(traget.transform.position); } Dictionary <string, object> barg = new Dictionary <string, object>(); barg["creater"] = owner; barg["time"] = 5f; barg["num"] = 30; owner.addBuff("buff_heavySkin", barg); setTime(args); }
public override void trigger(Dictionary <string, object> args) { unitControler[] tragets = (unitControler[])args["tragets"]; float multipe = 1; BasicControler firstOne = (BasicControler)tragets[0]; Quaternion rotate; if (firstOne.playerNo == 0) { rotate = Quaternion.Euler(0, 0, 90); } else { rotate = Quaternion.Euler(0, 0, -90); } GameObject missile = Instantiate(objectList.main.prafebList[17], firstOne.transform.position, rotate); missile.transform.rotation = rotate; foreach (unitControler traget in tragets) { Damage d = createDamage(args, multipe); traget.takeDamage(d); multipe *= decay; } setTime(args); }
public override void trigger(Dictionary <string, object> args) { unitControler[] tragets = (unitControler[])args["tragets"]; if (!(bool)args["miss"]) { //BasicControler traget = (BasicControler)args["tragets"]; //Debug.Log("traget:"+traget); //Debug.Log("traget type:" + (args["tragets"].GetType())); foreach (unitControler traget in tragets) { BasicControler nowTraget = (BasicControler)traget; //Debug.Log("製造傷害時傷害數值為:" + damage.num); Debug.Log("traget 為:" + ((BasicControler)traget).gameObject.name); traget.takeDamage(createDamage(args)); //Debug.Log("冷卻時間:" + CoolDown); //Debug.Log("自身位置:" + transform.position + "相對位置:" + transform.TransformDirection(offset)); GameObject effobj = Instantiate(objectList.main.prafebList[19], nowTraget.transform); effobj.transform.localPosition = Vector2.zero; Dictionary <string, object> buffArgs = new Dictionary <string, object>(); buffArgs["time"] = 3.0f; buffArgs["layer"] = 1; buffArgs["creater"] = owner; nowTraget.addBuff("buff_palsy", buffArgs); } } else { BasicControler traget = (BasicControler)tragets[0]; NumberCreater.main.CreateMissing(traget.transform.position); } setTime(args); }
public override void trigger(Dictionary <string, object> args) { //Debug.Log("攻擊被觸發"); if (!(bool)args["miss"]) { //BasicControler traget = (BasicControler)args["tragets"]; //Debug.Log("traget:"+traget); //Debug.Log("traget type:" + (args["tragets"].GetType())); unitControler[] tragets = (unitControler[])args["tragets"]; BasicControler nowTraget = (BasicControler)tragets[0]; //Debug.Log("製造傷害時傷害數值為:" + damage.num); //Debug.Log("traget 為:" + ((BasicControler)tragets[0]).gameObject.name); tragets[0].takeDamage(createDamage(args)); //Debug.Log("冷卻時間:" + CoolDown); //Debug.Log("自身位置:" + transform.position + "相對位置:" + transform.TransformDirection(offset)); Vector2 toTraget = nowTraget.transform.position - transform.position; float z_rotate = Vector2.Angle(Vector2.up, toTraget); GameObject mislobj = Instantiate(objectList.main.prafebList[missileNo], transform.TransformDirection(offset), transform.rotation); Vector2 relat_pos = Quaternion.Euler(0, 0, z_rotate) * offset; mislobj.transform.position = (Vector2)transform.position + relat_pos; //Debug.Log("目標:" + ((BasicControler)tragets[0]).gameObject); mislobj.GetComponent <missile>().traget = ((BasicControler)tragets[0]).gameObject; if (effNo_hit >= 0) { mislobj.GetComponent <missile>().on_missile_hited += misslieHit; } } setTime(args); }
public virtual void addBuff(string buffName, Dictionary <string, object> dict) { BasicControler creater = null; if (dict.ContainsKey("creater")) { creater = (BasicControler)dict["creater"]; } //Debug.Log("buffname:"+buffName+","+GetComponents(Type.GetType(buffName))); Component[] comps = GetComponents(Type.GetType(buffName)); Buff buff = (Buff)gameObject.AddComponent(Type.GetType(buffName)); Buff[] before = new Buff[comps.Length]; for (int i = 0; i < comps.Length; i++) { before[i] = (Buff)comps[i]; } buff.onfail += buffFail_callback; if (buff.onInit(this, before, dict)) { buffList.Add(buff); if (creater != null && creater._onCreateBuff != null) { creater._onCreateBuff(buff, this); } if (_onGetBuff != null) { _onGetBuff(buff, creater); } } else { Destroy(buff); } }
public override unitControler[] findTraget(Environment env) { unitControler[] team = ((ChessBoard)env).teammateOf(owner); List <BasicControler> tragets = new List <BasicControler>(); if (team.Length > 0) { foreach (BasicControler unit in team) { if ((float)unit.data.Now_Life / (float)unit.data.Now_Max_Life <= 0.6f) { tragets.Add(unit); } } if (tragets.Count == 0) { BasicControler min = (BasicControler)team[0]; for (int i = 1; i < team.Length; i++) { BasicControler unit = (BasicControler)team[i]; if ((float)unit.data.Now_Life / (float)unit.data.Now_Max_Life < (float)unit.data.Now_Life / (float)unit.data.Now_Max_Life) { min = unit; } } tragets.Add(min); } } return(tragets.ToArray()); }
public override bool onInit(unitControler unit, Buff[] Repetitive, Dictionary <string, object> args) { int selfLayer = (int)args["layer"]; //Debug.Log("總共有" + Repetitive.Length + "個重複Buff"); creater = (BasicControler)args["creater"]; if (Repetitive.Length == 0) { layer = selfLayer; timeLeft = (float)args["time"]; this.unit = (BasicControler)unit; ((BasicControler)unit).data.Now_Attack_Speed -= layer * ATK_SLOW_PER_LAYER; ((BasicControler)unit).data.Now_Cooldown_Reinforce -= layer * SKILL_SLOW_PER_LAYER; GameObject prefab = objectList.main.prafebList[26]; effection = Instantiate(prefab, ((BasicControler)this.unit).transform); effection.transform.localPosition = prefab.transform.position; return(true); } else { buff_chill before = ((buff_chill)Repetitive[0]); if (before.layer > selfLayer)//之前的燃燒層數比較高 { return(false); } else if (before.layer == selfLayer) { if (before.TimeLeft < (float)args["time"]) { before.timeLeft = (float)args["time"]; return(false); } else { return(false); } } else { before.deleteSelf(); layer = selfLayer; timeLeft = (float)args["time"]; this.unit = (BasicControler)unit; ((BasicControler)unit).data.Now_Attack_Speed -= layer * ATK_SLOW_PER_LAYER; ((BasicControler)unit).data.Now_Cooldown_Reinforce -= layer * SKILL_SLOW_PER_LAYER; GameObject prefab = objectList.main.prafebList[26]; effection = Instantiate(prefab, ((BasicControler)this.unit).transform); effection.transform.localPosition = prefab.transform.position; return(true); } } }
public void befSkill(SkillInf skillInf, Dictionary <string, object> args, ref unitControler[] tragets) { BasicControler traget = (BasicControler)tragets[0]; if (skillInf.attack && ((float)traget.data.Now_Life / (float)traget.data.Now_Max_Life) <= 0.5f) { args["phy_damage_multiple"] = (float)args["phy_damage_multiple"] + 0.5f; args["critical"] = true; } }
public override bool onInit(unitControler unit, Buff[] Repetitive, Dictionary <string, object> args) { int selfLayer = (int)args["layer"]; //Debug.Log("總共有" + Repetitive.Length + "個重複Buff"); creater = (BasicControler)args["creater"]; if (Repetitive.Length == 0) { layer = selfLayer; trigger_time_left = TriggerCycle; timeLeft = (float)args["time"]; this.unit = (BasicControler)unit; ((BasicControler)unit)._befHealing += befHeal; GameObject prefab = objectList.main.prafebList[15]; effection = Instantiate(prefab, ((BasicControler)this.unit).transform); effection.transform.localPosition = new Vector2(0, -0.67f); return(true); } else { buff_burn before = ((buff_burn)Repetitive[0]); if (before.layer > selfLayer)//之前的燃燒層數比較高 { return(false); } else if (before.layer == selfLayer) { if (before.TimeLeft < (float)args["time"]) { before.timeLeft = (float)args["time"]; return(false); } else { return(false); } } else { before.deleteSelf(); layer = selfLayer; trigger_time_left = TriggerCycle; timeLeft = (float)args["time"]; this.unit = (BasicControler)unit; ((BasicControler)unit)._befHealing += befHeal; GameObject prefab = objectList.main.prafebList[15]; effection = Instantiate(prefab, ((BasicControler)this.unit).transform); effection.transform.localPosition = new Vector2(0, -0.67f); return(true); } } }
public override void trigger(Dictionary <string, object> args) { unitControler[] tragets = (unitControler[])args["tragets"]; BasicControler traget = (BasicControler)((unitControler[])args["tragets"])[0]; GameObject effection = Instantiate(objectList.main.prafebList[11], traget.transform.position, Quaternion.Euler(0, 0, 0)); effection.GetComponent <decisionArea>().time = 2 * unitData.STAND_ATK_INTERVAL; Dictionary <string, object> arg = new Dictionary <string, object>(); arg["time"] = 2 * unitData.STAND_ATK_INTERVAL; foreach (BasicControler control in tragets) { control.addBuff("buff_blindness", arg); } setTime(args); }
public override unitControler[] findTraget(Environment env) { BasicControler[] teammate = (BasicControler[])((ChessBoard)env).teammateOf(owner); BasicControler best = teammate[0]; int bestHurt = best.data.Now_Max_Life - best.data.Now_Life; foreach (BasicControler traget in teammate) { int hurt = traget.data.Now_Max_Life - traget.data.Now_Life; if (hurt > bestHurt) { best = traget; bestHurt = hurt; } } return(((ChessBoard)env).getDist1Of(best, true)); }
public override unitControler[] findTraget(Environment env) { unitControler[] teammates = ((ChessBoard)env).teammateOf(owner); BasicControler traget = (BasicControler)teammates[0]; int traget_buff_num = 0; foreach (Buff b in traget.buffList) { int buff_num = 0; if (b.kind == Buff.NEGATIVE) { buff_num++; } traget_buff_num = buff_num; } for (int i = 1; i < teammates.Length; i++) { foreach (Buff b in ((BasicControler)teammates[i]).buffList) { int buff_num = 0; if (b.kind == Buff.NEGATIVE) { buff_num++; } if (buff_num > traget_buff_num) { traget = (BasicControler)teammates[i]; traget_buff_num = buff_num; } } } ; if (traget_buff_num == 0) { return(new unitControler[0]); } else { return(new unitControler[1] { traget }); } }
public override void trigger(Dictionary <string, object> args) { unitControler[] tragets = (unitControler[])args["tragets"]; if (!(bool)args["miss"]) { for (int i = 0; i < tragets.Length; i++) { BasicControler traget = (BasicControler)tragets[i]; int num = (int)(SUB_HEALING_POINT * (float)args[Skill.ARG_HEAL_MUL]) + (int)args[Skill.ARG_HEAL_ADD]; if (i == 0) { num = (int)(MAIN_HEALING_POINT * (float)args[Skill.ARG_HEAL_MUL]) + (int)args[Skill.ARG_HEAL_ADD]; Instantiate(objectList.main.prafebList[39], traget.transform.position, traget.transform.rotation); } traget.heal(num, owner); } } setTime(args); }
public override void trigger(Dictionary <string, object> args) { unitControler[] tragets = (unitControler[])args["tragets"]; if (!(bool)args["miss"]) { foreach (BasicControler traget in tragets) { Dictionary <string, object> barg = new Dictionary <string, object>(); barg["time"] = 2.5f; traget.addBuff("buff_disarm", barg); } } else { BasicControler traget = (BasicControler)tragets[0]; NumberCreater.main.CreateMissing(traget.transform.position); } setTime(args); }
public override void trigger(Dictionary <string, object> args) { unitControler[] tragets = (unitControler[])args["tragets"]; if (tragets == null) { return; } foreach (unitControler traget in tragets) { BasicControler nowTraget = (BasicControler)traget; Dictionary <string, object> buff_arg = new Dictionary <string, object>(); buff_arg["num"] = (int)(SHIELD_NUMBER * ((BasicControler)owner).data.Now_Mag_Multiple); //Debug.LogWarning("arg[num]設置為:" + buff_arg["num"]); buff_arg["time"] = 4 * unitData.STAND_ATK_INTERVAL; buff_arg["creater"] = owner; nowTraget.addBuff("buff_flameShield", buff_arg); //Debug.LogWarning("加上buff_flameShield"); } setTime(args); }
public override void trigger(Dictionary <string, object> args) { //Debug.Log("攻擊被觸發"); unitControler[] tragets = (unitControler[])args["tragets"]; if (!(bool)args["miss"]) { //BasicControler traget = (BasicControler)args["tragets"]; //Debug.Log("traget:"+traget); //Debug.Log("traget type:" + (args["tragets"].GetType())); foreach (unitControler traget in tragets) { BasicControler nowTraget = (BasicControler)traget; //Debug.Log("製造傷害時傷害數值為:" + damage.num); Debug.Log("traget 為:" + ((BasicControler)traget).gameObject.name); bool haveBuff = (((BasicControler)traget).GetComponent <buff_chill>() != null);//如果目標有寒冷狀態,則暴擊 ActionForTraget(traget); //Debug.Log("冷卻時間:" + CoolDown); //Debug.Log("自身位置:" + transform.position + "相對位置:" + transform.TransformDirection(offset)); GameObject mislobj = Instantiate(objectList.main.prafebList[missileNo], ((BasicControler)traget).transform.position, transform.rotation, ((BasicControler)traget).transform); GameObject effobj = Instantiate(objectList.main.prafebList[effNo_hit], ((BasicControler)traget).gameObject.transform); effobj.transform.localPosition = Vector2.zero; float multip = (float)args["control_multiple"]; float time = 1.5f * unitData.STAND_ATK_INTERVAL * multip; if (haveBuff) { time *= 2; } Dictionary <string, object> buffArg = new Dictionary <string, object>(); buffArg["time"] = time; traget.addBuff("buff_stun", buffArg); } } else { BasicControler traget = (BasicControler)tragets[0]; NumberCreater.main.CreateMissing(traget.transform.position); } setTime(args); }
public void forRoleDeath(GameObject gobj) { Debug.LogWarning(gobj.name + " dead"); gobj.AddComponent <fadeOut>(); BasicControler control = gobj.GetComponent <BasicControler>(); int[] coor = chessBoard.getPosFor(control); chessBoard.removeAt(coor[0], coor[1]); Timer.main.loginOutTimer(control.action); int enemyCount = 0; int playerCount = 0; foreach (unitControler unit in chessBoard.units) { if (control == ((BasicControler)unit).traget) { Debug.LogWarning("control == ((BasicControler)unit).traget"); ((BasicControler)unit).traget = null; } if (((BasicControler)unit).playerNo == 0) { enemyCount += 1; } else if (((BasicControler)unit).playerNo == 1) { playerCount += 1; } } if (playerCount == 0)//只要全隊陣亡就輸了,就算同歸於盡也沒用 { TimerDriver.main.pause = true; failedPanel.SetActive(true); return; } if (enemyCount == 0) //勝利 { TimerDriver.main.pause = true; successPanel.SetActive(true); successPanel.GetComponent <rewardPanel>().init(dataWarehouse.main.levelReward); } }
public override unitControler[] findTraget(Environment env) { int[] pos = ((ChessBoard)env).getPosFor(owner.traget); List <unitControler> list = new List <unitControler>(); for (int y = 0; y < 3; y++) { for (int x = 0; x < 3; x++) { if (pos[1] - 1 + y < ((ChessBoard)env).Y && pos[1] - 1 + y >= 0 && pos[0] - 1 + x < ((ChessBoard)env).X && pos[0] - 1 + x >= 0) { BasicControler unit = (BasicControler)((ChessBoard)env).board[pos[1] - 1 + y, pos[0] - 1 + x]; if (unit != null && unit.playerNo != owner.playerNo) { list.Add(unit); } } } } return(list.ToArray()); }
public virtual void takeDamage(Damage damage) { Debug.Log("before _befTakeDamage"); _befTakeDamage(damage); BasicControler from = (BasicControler)damage.creater; damage.creater = this; from._befCauseDamage(damage); damage.creater = from; Debug.Log("after _befTakeDamage"); if (damage.vaild && !data.Dead) { int hurt = damage.num; if (damage.kind == Damage.KIND_PHYSICAL && !state.ImmunePhysics) { //Debug.Log("計算傷害時Physical_Reduce_Multiple為:" + data.Physical_Reduce_Multiple); hurt = (int)(data.Physical_Reduce_Multiple * (float)damage.num); //Debug.Log("計算傷害時hurt為:"+hurt); //Debug.Log("計算傷害時Now_Life為:" + data.Now_Life); } else if (damage.kind == Damage.KIND_MAGICAL && !state.ImmuneMagic) { hurt = (int)(data.Magic_Reduce_Multiple * damage.num); } data.Now_Life -= hurt; //Debug.Log("計算結束"); damage.num = hurt; _aftTakeDamage(damage); createDamageNum(damage); damage.creater = this;//將creater改成自己來告訴傷害的造成者傷害目標是誰 if (damage.creater != null) { from._aftCauseDamage(damage); } } }
public override bool onInit(unitControler unit, Buff[] Repetitive, Dictionary <string, object> args) { int selfLayer = (int)args["layer"]; //Debug.Log("總共有" + Repetitive.Length + "個重複Buff"); creater = (BasicControler)args["creater"]; if (Repetitive.Length == 0) { layer = selfLayer; trigger_time_left = TriggerCycle; timeLeft = (float)args["time"]; this.unit = (BasicControler)unit; ((BasicControler)unit)._befHealing += befHeal; GameObject prefab = objectList.main.prafebList[33]; effection = Instantiate(prefab, ((BasicControler)this.unit).transform); effection.transform.localPosition = new Vector2(0, -0.67f); return(true); } else { buff_poison before = ((buff_poison)Repetitive[0]); if (selfLayer + before.layer <= MAX_LAYER) { before.layer += selfLayer; } else { before.layer = MAX_LAYER; } if ((float)args["time"] > before.timeLeft) { before.timeLeft = (float)args["time"]; } return(false); } }
public override bool onInit(unitControler unit, Buff[] Repetitive, Dictionary <string, object> args) { //Debug.Log("總共有" + Repetitive.Length + "個重複Buff"); if (Repetitive.Length == 0) { timeLeft = (float)args["time"]; this.unit = (BasicControler)unit; this.unit.state.CanAttack = false; this.unit.state.CanSkill = false; GameObject prefab = objectList.main.prafebList[6]; effection = Instantiate(prefab, this.unit.transform); effection.transform.localPosition = prefab.transform.position; return(true); } else { if (((buff_stun)Repetitive[0]).TimeLeft < (float)args["time"]) { ((buff_stun)Repetitive[0]).timeLeft = (float)args["time"]; } return(false); } }
public override void trigger(Dictionary <string, object> args) { //Debug.Log("攻擊被觸發"); //BasicControler traget = (BasicControler)args["tragets"]; //Debug.Log("traget:"+traget); //Debug.Log("traget type:" + (args["tragets"].GetType())); unitControler[] tragets = (unitControler[])args["tragets"]; if (!(bool)args["miss"]) { //Debug.Log("製造傷害時傷害數值為:" + damage.num); actionTo(tragets, args); nowTraget = ((BasicControler)tragets[0]).gameObject; Debug.LogWarning("技能名:" + name); if (effection.rushMainStart(animTime, stayTime, nowTraget, Effection)) { Debug.LogWarning("effection.rushMainStart true animTime:" + animTime + "stayTime:" + stayTime + "nowTraget:" + nowTraget); } else { Debug.Log("強制觸發Effection"); Effection(); } //anim_time = 0; //stay_time = 0; // //count = 0; //triggerEff = false; //Timer.main.logInTimer(Anim); } else { BasicControler traget = (BasicControler)tragets[0]; NumberCreater.main.CreateMissing(traget.transform.position); } setTime(args); }
public override void trigger(Dictionary <string, object> args) { Vector2 stoneOffset = new Vector2(2, 2); unitControler[] tragets = (unitControler[])args["tragets"]; if (!(bool)args["miss"]) { //BasicControler traget = (BasicControler)args["tragets"]; //Debug.Log("traget:"+traget); //Debug.Log("traget type:" + (args["tragets"].GetType())); foreach (unitControler traget in tragets) { BasicControler nowTraget = (BasicControler)traget; //Debug.Log("製造傷害時傷害數值為:" + damage.num); Debug.Log("火焰雨 traget 為:" + ((BasicControler)traget).gameObject.name); traget.takeDamage(createDamage(args)); //Debug.Log("冷卻時間:" + CoolDown); //Debug.Log("自身位置:" + transform.position + "相對位置:" + transform.TransformDirection(offset)); GameObject mislobj = Instantiate(objectList.main.prafebList[14], (Vector2)((BasicControler)traget).transform.position + stoneOffset, transform.rotation); mislobj.GetComponent <missile>().traget = ((BasicControler)traget).gameObject; mislobj.GetComponent <missile>().on_missile_hited += misslieHit; } } else { foreach (BasicControler traget in tragets) { NumberCreater.main.CreateMissing(traget.transform.position); } } setTime(args); }
public override unitControler[] findTraget(Environment env) { BasicControler[] traget = new BasicControler[1]; traget[0] = owner; return(traget); }
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); } }