public void Loading() { int i; prfb = (GameObject)Resources.Load("Card/Card_controller"); //预设资源获取 for (i = 0; i < trans.p_amt; i++) //加载玩家方的卡牌实体并入队 { temporary = (GameObject)Instantiate(prfb); //加载预设生成实体 temporary.SetActive(true); temporary.GetComponent <Transform>().position = new Vector2(-17.8f + (i + 1) * 35.6f / (trans.p_amt + 1), -5f); //定位 cc = temporary.GetComponent <Card_controller>(); //加载乱七八糟的信息 cc.Set_lct(temporary.GetComponent <Transform>().position); cc.Gs_type = 0; cc.Gs_order = i; cc.Gs_eternal_order = i; cc.Gs_ctype = Deep_copy(trans.ci.card_information[trans.Get_card(i)]); player_queue.Add(temporary); //加入玩家队列 } for (i = 0; i < trans.e_amt; i++) //加载敌人的卡牌实体并入队 { temporary = (GameObject)Instantiate(prfb); temporary.SetActive(true); temporary.GetComponent <Transform>().position = new Vector2(-17.8f + (i + 1) * 35.6f / (trans.e_amt + 1), 5f); cc = temporary.GetComponent <Card_controller>(); cc.Set_lct(temporary.GetComponent <Transform>().position); cc.Gs_type = 1; cc.Gs_order = i; cc.Gs_eternal_order = i; cc.Gs_ctype = Deep_copy(trans.ci.card_information[trans.Get_enemy(i)]); enemy_queue.Add(temporary); } }
public void Loading() { int i; prfb = (GameObject)Resources.Load("Card/Card_controller"); for (i = 0; i < trans.p_amt; i++)//加载玩家的卡牌实体并入队 { temporary = (GameObject)Instantiate(prfb); temporary.SetActive(true); temporary.GetComponent <Transform>().position = new Vector2(-17.8f + (i + 1) * 35.6f / (trans.p_amt + 1), -5f); cc = temporary.GetComponent <Card_controller>(); cc.Set_lct(temporary.GetComponent <Transform>().position); cc.Gs_type = 0; cc.Gs_id = trans.ci.card_information[trans.Get_card(i)].ID; cc.Gs_describe = trans.ci.card_information[trans.Get_card(i)].Describe; cc.Gs_level = trans.ci.card_information[trans.Get_card(i)].Level; cc.Gs_atk = trans.ci.card_information[trans.Get_card(i)].ATK; cc.Gs_hp = trans.ci.card_information[trans.Get_card(i)].HP; cc.Gs_order = i; player_queue.Add(temporary); } for (i = 0; i < trans.e_amt; i++)//加载敌人的卡牌实体并入队 { temporary = (GameObject)Instantiate(prfb); temporary.SetActive(true); temporary.GetComponent <Transform>().position = new Vector2(-17.8f + (i + 1) * 35.6f / (trans.e_amt + 1), 5f); cc = temporary.GetComponent <Card_controller>(); cc.Set_lct(temporary.GetComponent <Transform>().position); cc.Gs_type = 1; cc.Gs_id = trans.ci.card_information[trans.Get_enemy(i)].ID; cc.Gs_describe = trans.ci.card_information[trans.Get_enemy(i)].Describe; cc.Gs_level = trans.ci.card_information[trans.Get_enemy(i)].Level; cc.Gs_atk = trans.ci.card_information[trans.Get_enemy(i)].ATK; cc.Gs_hp = trans.ci.card_information[trans.Get_enemy(i)].HP; cc.Gs_order = i; enemy_queue.Add(temporary); } //Locate(player_queue,-5f); //Locate(enemy_queue,5f); }
private int Using_skill(int s, bool camp, GameObject me, int objorder) {//camp表示现在正在施法的单位属于哪个阵营,true为进攻方,false为防守方,me为施法单位,enemy为施法单位此时正在对战的单位 int stage_before = stage; stage = s; Debug.Log("我是" + me.GetComponent <Card_controller>().Gs_ctype.Describe + "目前阶段为" + stage + "开始发动技能"); Card_controller mycontroller = me.GetComponent <Card_controller>(); //Card_controller enemycontroller = enemy.GetComponent<Card_controller>(); Skill sk = trans.ci.card_information[mycontroller.Gs_ctype.ID].skills[stage];//获取施法单位的技能 //Debug.Log("I'm using skill,my description is" + trans.ci.card_information[mycontroller.Gs_ctype.ID].Describe); if (!sk.enable) { Debug.Log("没有可以发动的技能"); return(0); } else { Debug.Log(mycontroller.Gs_ctype.Describe + "发动技能中"); } bool target_flag = true; //技能对象的类型,true为单体,false为队列 Card_controller skill_target = new Card_controller(); //技能的单体对象 List <GameObject> skill_target_queue = new List <GameObject>(); //技能的队列对象 List <GameObject> temp_queue; System.Random rdm = new System.Random();//随机数变量 int temp; Card_controller temp_cd; for (int i = 0; i < sk.type.GetUpperBound(0); i++) { target_flag = true; /*switch (sk.target[i]) * { * case 0: * break; * case 1: * case 2: * case 3: * case 4: * target_flag = true; * break; * case 5: * case 6: * target_flag = false; * break; * default: * //异常 * break; * }*/ switch (sk.target[i]) { case 0: break; case 1: skill_target = me.GetComponent <Card_controller>(); Debug.Log("我是" + me.GetComponent <Card_controller>().Gs_ctype.Describe + ",技能目标为自己"); break; case 2: int k = 0; if (camp) { for (k = 0; k < defensive_queue.Count; k++) { if (defensive_queue[k].GetComponent <Card_controller>().Gs_eternal_order == objorder && !defensive_queue[k].GetComponent <Card_controller>().Getsignal(dead)) { skill_target = defensive_queue[k].GetComponent <Card_controller>(); Debug.Log("我是" + me.GetComponent <Card_controller>().Gs_ctype.Describe + ",技能目标为" + skill_target.GetComponent <Card_controller>().Gs_ctype.Describe); break; } } if (k == defensive_queue.Count || skill_target.Getsignal(dead)) { return(0); } } else { for (k = 0; k < offensive_queue.Count; k++) { if (offensive_queue[k].GetComponent <Card_controller>().Gs_eternal_order == objorder && !offensive_queue[k].GetComponent <Card_controller>().Getsignal(dead)) { skill_target = offensive_queue[k].GetComponent <Card_controller>(); Debug.Log("我是" + me.GetComponent <Card_controller>().Gs_ctype.Describe + ",技能目标为" + skill_target.GetComponent <Card_controller>().Gs_ctype.Describe); break; } } if (k == offensive_queue.Count || skill_target.Getsignal(dead)) { return(0); } } break; case 3: temp_queue = camp ? offensive_queue : defensive_queue; //此时施法单位在攻击方还是防守方? temp = (int)rdm.Next(0, temp_queue.Count); skill_target = temp_queue[temp].GetComponent <Card_controller>(); Debug.Log("我是" + me.GetComponent <Card_controller>().Gs_ctype.Describe + ",技能目标为" + skill_target.GetComponent <Card_controller>().Gs_ctype.Describe); if (skill_target.Getsignal(dead)) { return(0); } break; case 4: temp_queue = camp ? defensive_queue : offensive_queue; //此时施法单位的对手在防守方还是攻击方? temp = (int)rdm.Next(0, temp_queue.Count); skill_target = temp_queue[temp].GetComponent <Card_controller>(); Debug.Log("我是" + me.GetComponent <Card_controller>().Gs_ctype.Describe + ",技能目标为" + skill_target.GetComponent <Card_controller>().Gs_ctype.Describe); if (skill_target.Getsignal(dead)) { return(0); } break; case 5: skill_target_queue = camp ? offensive_queue : defensive_queue; //此时施法单位在攻击方还是防守方? Debug.Log("我是" + me.GetComponent <Card_controller>().Gs_ctype.Describe + ",技能目标为" + skill_target_queue[0].GetComponent <Card_controller>().Gs_ctype.Describe + "所在阵营"); target_flag = false; break; case 6: skill_target_queue = camp ? defensive_queue : offensive_queue; //此时施法单位的对手在攻击方还是防守方? Debug.Log("我是" + me.GetComponent <Card_controller>().Gs_ctype.Describe + ",技能目标为" + skill_target_queue[0].GetComponent <Card_controller>().Gs_ctype.Describe + "所在阵营"); target_flag = false; break; default: //异常 break; } Debug.Log("技能对象为" + sk.target[i]); Debug.Log("技能类型为" + sk.type[i]); Debug.Log("技能数值为" + sk.value[i]); int j = 0; switch (sk.type[i]) { case 1: if (target_flag) { skill_target.Gs_ctype.HP = skill_target.Gs_ctype.HP + sk.value[j]; } else { for (j = 0; j < skill_target_queue.Count; j++) { temp_cd = skill_target_queue[j].GetComponent <Card_controller>(); temp_cd.Gs_ctype.HP = temp_cd.Gs_ctype.HP + sk.value[i]; } } break; case 2: if (target_flag) { skill_target.Gs_ctype.HP = skill_target.Gs_ctype.HP - sk.value[i]; } else { //Debug.Log("施法对象队列为" + skill_target_queue[0].GetComponent<Card_controller>().Gs_ctype.Describe+"所在队列"); for (j = 0; j < skill_target_queue.Count; j++) { temp_cd = skill_target_queue[j].GetComponent <Card_controller>(); temp_cd.Gs_ctype.HP = temp_cd.Gs_ctype.HP - sk.value[i]; } } break; case 3: if (target_flag) { skill_target.Gs_ctype.ATK = skill_target.Gs_ctype.ATK + sk.value[i]; } else { for (j = 0; j < skill_target_queue.Count; j++) { temp_cd = skill_target_queue[j].GetComponent <Card_controller>(); temp_cd.Gs_ctype.ATK = temp_cd.Gs_ctype.ATK + sk.value[i]; } } break; case 4: if (target_flag) { skill_target.Gs_ctype.ATK = skill_target.Gs_ctype.ATK - sk.value[i]; } else { for (j = 0; j < skill_target_queue.Count; j++) { temp_cd = skill_target_queue[j].GetComponent <Card_controller>(); temp_cd.Gs_ctype.ATK = temp_cd.Gs_ctype.ATK - sk.value[i]; } } break; case 5: if (target_flag) { skill_target.Gs_hp_limit = skill_target.Gs_hp_limit + sk.value[i]; } else { for (j = 0; j < skill_target_queue.Count; j++) { temp_cd = skill_target_queue[j].GetComponent <Card_controller>(); temp_cd.Gs_hp_limit = temp_cd.Gs_hp_limit + sk.value[i]; } } break; case 6: if (target_flag) { skill_target.Gs_hp_limit = skill_target.Gs_hp_limit - sk.value[i]; } else { for (j = 0; j < skill_target_queue.Count; j++) { temp_cd = skill_target_queue[j].GetComponent <Card_controller>(); temp_cd.Gs_hp_limit = temp_cd.Gs_hp_limit - sk.value[i]; } } break; case 7: //毁灭 break; default: //异常 break; } } stage = stage_before; Debug.Log("技能发动完毕"); return(Death_decision()); }