code
게임 전체 코드이다.
//image_tab.cs
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class image_tab : MonoBehaviour
{
public Image img;
public Sprite tab1;
public Sprite tab2;
public Sprite tab3;
public Sprite tab4;
public void game_tab()
{
img.sprite =tab1;
}
public void graphic_tab()
{
img.sprite =tab2;
}
public void sound_tab()
{
img.sprite =tab3;
}
public void account_tab()
{
img.sprite =tab4;
}
}
//tab.cs
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class tab : MonoBehaviour
{
public InputField id;
public InputField pw;
void Update()
{
if(id.isFocused == true)
{
if(Input.GetKeyUp(KeyCode.Tab))
{
pw.Select();
}
}
}
}
//BackEndmanager.cs
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using BackEnd;
using UnityEngine.UI;
using System.IO;
using System;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using OpenQA.Selenium;
using OpenQA.Selenium.Chrome;
using OpenQA.Selenium.Support.UI;
using System.Threading;
using System.Net;
using System.Runtime.InteropServices;
using UnityEngine.SceneManagement;
using DG.Tweening;
//로그인 & 초기화
public class BackEndmanager : MonoBehaviour
{
//*******************UI*********************************************************************************************************
public InputField idInput;
public InputField paInput;
public GameObject successpanel;
public InputField id;
public InputField pw;
public GameObject panel;
public Text nametext;
public Toggle check;
public GameObject login_panel;
public GameObject loading_panel;
//*******************변수***********************************************************************************************************
//**********************************************************************************************************************************
void Start()
{
DontDestroyOnLoad(this.gameObject);
Initialized();
}
//BackEndCustomSettings에 정의된 값으로 SDK 초기화
public void Initialized()
{
Backend.Initialize(true);
}
//뒤끝서버 로그인 & 회원가입
public void OnClickSignUp()
{
BackendReturnObject bro = Backend.BMember.CustomSignUp(idInput.text, paInput.text);
if (bro.IsSuccess())
{
BackendReturnObject login = Backend.BMember.CustomLogin(idInput.text, paInput.text);
Backend.BMember.CreateNickname(_name.Substring(0, _name.Length - 1));
Debug.Log("회원가입 성공");
Param char_main_data = new Param();
char_main_data.Add("Level", 1);
char_main_data.Add("xp", 0);
char_main_data.Add("money", 1000);
char_main_data.Add("win", 0);
char_main_data.Add("lose", 0);
char_main_data.Add("rating", 500);
Dictionary<int, int> monster = new Dictionary<int, int>
{
{160001, 2},
{160002, 2},
{160003, 2},
{160004, 2},
{160005, 2},
{160006, 2},
{160007, 2},
{150008, 2},
{150009, 2},
{160010, 2},
{160011, 2},
{160012, 2},
{141013, 2},
{141014, 2},
{141015, 2},
{160016, 2},
{160017, 2},
{160018, 2},
{160019, 2},
{160020, 2},
{160021, 2},
{150022, 2},
{160023, 2},
{141024, 2},
{160025, 2},
{160026, 2},
{160027, 2},
{160028, 2},
{160029, 2},
{160030, 2},
{160031, 2},
{160033, 2},
{160034, 2},
{160035, 2},
{160037, 2},
{160039, 2},
{160040, 2},
{160042, 2},
{160043, 2},
{160045, 2},
{160047, 2},
{160048, 2},
{160049, 2},
{160050, 2},
{160051, 2},
{160052, 2},
{160053, 2},
{141054, 2},
{160055, 2},
{150056, 2},
{160057, 2},
{150058, 2},
{140059, 2}
};
Dictionary<int, int> magic = new Dictionary<int, int>
{
{260001,2},
{260002,2},
{260003,2},
{260004,2},
{250005,2},
{250006,2},
{260007,2},
{250008,2},
{260009,2},
{240010,2},
{250011,2},
{250012,2},
{250013,2},
{250014,2},
{250015,2},
{250016,2},
{260017,2},
{260018,2},
{260019,2},
{250020,2},
{250021,2},
{250022,2},
{250023,2},
{240024,2}
};
Dictionary<int, int> equip = new Dictionary<int, int>
{
{360001,2},
{360002,2},
{340003,2},
{330004,2},
{330005,2},
{320006,2},
{320007,2},
{310008,2},
{360009,2},
{340010,2},
{350011,2},
{350012,2},
{340013,2},
{320014,2},
{310015,2},
{360016,2},
{360017,2},
{350018,2},
{350019,2},
{340020,2},
{320021,2},
{310022,2},
{360023,2},
{360024,2}
};
Dictionary<int, int> deck = new Dictionary<int, int>();
char_main_data.Add("deck", deck);
char_main_data.Add("monster", monster);
char_main_data.Add("magic", magic);
char_main_data.Add("equip", equip);
BackendReturnObject card = Backend.GameData.Insert("character", char_main_data);
Debug.Log(card.GetStatusCode());
}
else
{
BackendReturnObject vro = Backend.BMember.CustomLogin(idInput.text, paInput.text);
if (vro.IsSuccess())
{
Debug.Log("로그인 성공");
}
}
}
public string GetThousandCommaText(int data)
{
return string.Format("{0:###,###,###,###}", data);
}
//********************************크롤링 넥슨 홈페이지 로그인************************************************************
bool IsElementPresent(IWebDriver _driver, By _by)
{
try
{
_driver.FindElement(_by);
return true;
}
catch (NoSuchElementException)
{
return false;
}
}
public string _name;
public void login()
{
ChromeOptions options = new ChromeOptions();
options.AddArguments(new List<string>()
{
"--silent-launch",
"--no-startup-window",
"no-sandbox",
"headless"
});
using (IWebDriver driver = new ChromeDriver(@"C:\test_nexon_maplestory_battle_monsters_league\Assets\Packages\Selenium.WebDriver.ChromeDriver.94.0.4606.6100/driver/win32", options))
{
driver.Url = "https://nxlogin.nexon.com/common/login.aspx?redirect=https%3A%2F%2Fmaplestory.nexon.com%2FHome%2FMain";
IWebElement email = driver.FindElement(By.Id("txtNexonID"));
email.SendKeys(id.text);
driver.FindElement(By.Id("txtPWD")).SendKeys(pw.text);
Thread.Sleep(1000);
driver.FindElement(By.XPath("//" + "*[@id=\"nexonLogin\"]/fieldset/div[4]/button")).Click();
Thread.Sleep(1000);
if (check.isOn == true)
{
PlayerPrefs.SetString("nexon_id", id.text);
PlayerPrefs.SetString("nexon_pw", pw.text);
Debug.Log(PlayerPrefs.GetString("nexon_id"));
Debug.Log(PlayerPrefs.GetString("nexon_pw"));
}
if (IsElementPresent(driver, By.ClassName("login_id")))
{
PlayerPrefs.SetString("nexon_id", id.text);
_name = driver.FindElement(By.ClassName("login_id")).FindElement(By.CssSelector("a")).Text.Trim();
Thread.Sleep(1000);
string url = driver.FindElement(By.ClassName("login_char")).FindElement(By.TagName("img")).GetAttribute("src");
string ser_url = driver.FindElement(By.ClassName("login_after_id")).FindElement(By.TagName("img")).GetAttribute("src");
driver.Close();
using (WebClient client = new WebClient())
{
client.DownloadFile(new Uri(url), @"C:\nexon_maplestory_battle_monsters_league_s\Assets\cashe\mychar.png");
}
using (WebClient client = new WebClient())
{
client.DownloadFile(new Uri(ser_url), @"C:\nexon_maplestory_battle_monsters_league_s\Assets\cashe\mychar_server.png");
}
Thread.Sleep(1000);
successpanel.SetActive(true);
nametext.text = _name;
PlayerPrefs.SetString("charname", _name);
PlayerPrefs.SetString("nexon_view_id", id.text);
login_panel.SetActive(false);
}
else
{
StartCoroutine(LoginFail(panel));
driver.Close();
}
}
OnClickSignUp();
}
IEnumerator LoginFail(GameObject panel)
{
panel.SetActive(true);
panel.transform.DOShakePosition(1.0f, 10, 90);
yield return new WaitForSeconds(2.0f);
panel.SetActive(false);
}
//********************************************************씬 변경*************************************************************
public void scene_chage()
{
SceneManager.LoadScene("MAIN_SCENE");
}
}
//BackEndUImanager.cs
using System.Linq;
using System.IO;
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using BackEnd;
using UnityEngine.UI;
using BackEnd.Tcp;
//메인화면 UI 변수 업데이트
public partial class BackEndUImanager : MonoBehaviour
{
public Text txt_level;
public Text txt_xp;
public Text txt_money;
public Text txt_win;
public Text txt_lose;
public Text txt_rating;
public Text txt_total;
public Text txt_level_percent;
public Text txt_nickname;
public Text account;
public Text nickname;
public Text card_money;
public string M_level;
public string M_xp;
public string M_money;
public int M_win;
public int M_defeat;
public int M_total;
// Start is called before the first frame update
void Start()
{
GetMyUserInfo();
UpdateMyUI();
}
public void UpdateMyUI()
{
txt_level.text = M_level;
txt_xp.text =M_xp;
txt_money.text = M_money;
txt_money.text = GetThousandCommaText(int.Parse(M_money));
card_money.text = GetThousandCommaText(int.Parse(M_money));
txt_win.text=M_win.ToString();
txt_lose.text=M_defeat.ToString();
txt_rating.text="-";
txt_total.text = M_total.ToString();
txt_level_percent.text = "("+(int.Parse(M_level)%1000).ToString()+"%)";
txt_nickname.text = Backend.UserNickName;
nickname.text = Backend.UserNickName;
account.text = PlayerPrefs.GetString("nexon_id");
}
public void GetMyUserInfo()
{
var MyInfo = Backend.GameData.GetMyData("character",new Where(), 10);
M_level = MyInfo.Rows()[0]["Level"][0].ToString();
M_xp = MyInfo.Rows()[0]["xp"][0].ToString();
M_money = MyInfo.Rows()[0]["money"][0].ToString();
//친선모드만 구현
GetMyMatchRecord(0);
}
public void GetMyMatchRecord(int index)
{
var result = Backend.Match.GetMatchRecord(MyIndate(), MatchType.Random, MatchModeType.OneOnOne, "2021-07-20T12:58:49.330Z");
M_win = int.Parse(result.Rows()[0]["victory"]["N"].ToString());
M_defeat = int.Parse(result.Rows()[0]["defeat"]["N"].ToString());
M_total = M_win+M_defeat;
}
public string MyIndate()
{
BackendReturnObject bro = Backend.BMember.GetUserInfo();
string indate = bro.GetReturnValuetoJSON()["row"]["inDate"].ToString();
return indate;
}
public string GetThousandCommaText(int data)
{
return string.Format("{0:###,###,###,###}", data);
}
}
//PrettyScroll.cs
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class PrettyScroll : MonoBehaviour
{
public GameObject scrollbar;
float scroll_pos = 0;
float[] pos;
// Update is called once per frame
void Update()
{
pos = new float[transform.childCount];
float distance = 1f / (pos.Length - 1f);
for(int i=0;i<pos.Length;i++)
{
pos[i] = distance *i;
}
if(Input.GetMouseButton(0))
{
scroll_pos = scrollbar.GetComponent<Scrollbar>().value;
}
else
{
for (int i=0;i<pos.Length;i++)
{
if(scroll_pos<pos[i]+(distance/2)&&scroll_pos>pos[i]-(distance/2))
{
scrollbar.GetComponent<Scrollbar>().value = Mathf.Lerp(scrollbar.GetComponent<Scrollbar>().value,pos[i],0.1f);
}
}
}
for(int i=0;i<pos.Length;i++)
{
if(scroll_pos<pos[i]+(distance/2)&&scroll_pos>pos[i]-(distance/2))
{
transform.GetChild(i).localScale = Vector2.Lerp(transform.GetChild(i).localScale, new Vector2(2.5f,2.5f),0.1f);
for(int a = 0;a<pos.Length;a++)
{
if(a!=i)
{
transform.GetChild(a).localScale = Vector2.Lerp(transform.GetChild(a).localScale, new Vector2(2f,2f),0.1f);
}
}
}
}
}
}
//ViewCard.cs
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using BackEnd;
using System.Xml;
using UnityEngine.UI;
using System.Xml.Linq;
using System.Linq;
using UnityEngine.SceneManagement;
public class ViewCard : MonoBehaviour
{
public static ViewCard Inst {get; private set;}
void Awake() => Inst =this;
[SerializeField] GameObject cardPrefeb;
[SerializeField] GameObject Card;
[SerializeField] public GameObject mainDeckContent;
public Sprite[] card_base_mon;
public Sprite[] card_base;
public Sprite[] back;
public List<Item> deckitemBuffer;
public List<Item> myCardItemBuffer;
public List<Item> allBookMon;
public List<Item> allBookMag;
public List<Item> allBookEqp;
[SerializeField] public Dictionary<int,int> saveDeck = new Dictionary<int, int>(50);
[SerializeField] public GameObject myDeckContent;
[SerializeField] public GameObject myCardContent;
//----------------내 덱------------
public GameObject mydeck;
public GameObject mycard;
//-----------------내카드----------
public GameObject monContent;
public GameObject magContent;
public GameObject eqpContent;
//-----------------도감------------
public GameObject allMonContent;
public GameObject allMagContent;
public GameObject allEqpContent;
void Start()
{
AddCardOnMainDeckSetting();
MyCardSetting();
MyDeckSetting();
LoadMyCardTab();
AllBookSetting();
}
public void SaveDeck()
{
if(myDeckContent.transform.childCount !=50)
{
print("카드가 50장이 아닙니다.");
return;
}
Param param = new Param();
Where where = new Where();
param.Remove("deck");
for(int i =0;i<50;i++)
{
if(saveDeck.ContainsKey(int.Parse(myDeckContent.transform.GetChild(i).name)))
{
saveDeck[int.Parse(myDeckContent.transform.GetChild(i).name)]++;
}
else
{
saveDeck.Add(int.Parse(myDeckContent.transform.GetChild(i).name),1);
}
}
param.Add("deck", saveDeck);
Backend.GameData.Update("character", where, param);
Debug.Log("저장되었습니다.");
}
public void LoadAllBook()
{
TextAsset textAsset = (TextAsset)Resources.Load("CARD/xml/monster");
XmlDocument xmlDoc = new XmlDocument();
xmlDoc.LoadXml(textAsset.text);
XmlNodeList nodes = xmlDoc.SelectNodes("rows/row");
foreach (XmlNode node in nodes)
{
Item item = new Item();
item.name = node.SelectSingleNode("NAME").InnerText;
item.grade = int.Parse(node.SelectSingleNode("GRADE").InnerText);
item.cost = Resources.Load<Sprite>("CARD/num/" + node.SelectSingleNode("COST").InnerText);
item.cost_num = int.Parse(node.SelectSingleNode("COST").InnerText);
item.attack = int.Parse(node.SelectSingleNode("ATT").InnerText);
item.health = int.Parse(node.SelectSingleNode("DEF").InnerText);
item.abl = node.SelectSingleNode("ABL").InnerText;
item.code = int.Parse(node.SelectSingleNode("CODE").InnerText);
item.main = Resources.Load<Sprite>("CARD/monster/"+node.SelectSingleNode("CODE").InnerText);
item.background = Resources.Load<Sprite>("CARD/background/"+node.SelectSingleNode("AREA").InnerText);
item.cardbase = card_base_mon[item.grade];
item.ablcode = node.SelectSingleNode("ABLCODE").InnerText;
allBookMon.Add(item);
}
TextAsset textAsset1 = (TextAsset)Resources.Load("CARD/xml/magic");
XmlDocument xmlDoc1 = new XmlDocument();
xmlDoc1.LoadXml(textAsset1.text);
XmlNodeList nodes1 = xmlDoc1.SelectNodes("rows/row");
foreach (XmlNode node in nodes1)
{
Item item = new Item();
if(int.Parse(node.SelectSingleNode("CODE").InnerText.Substring(3,3))<29)
{
item.background = Resources.Load<Sprite>("CARD/background/"+node.SelectSingleNode("NAME").InnerText);
}
else
{
item.main = Resources.Load<Sprite>("CARD/magic/" + node.SelectSingleNode("CODE").InnerText);
item.background = back[int.Parse(node.SelectSingleNode("GRADE").InnerText)];
}
item.name = node.SelectSingleNode("NAME").InnerText;
item.grade = int.Parse(node.SelectSingleNode("GRADE").InnerText);
item.cost = Resources.Load<Sprite>("CARD/num/" + node.SelectSingleNode("COST").InnerText);
item.cost_num = int.Parse(node.SelectSingleNode("COST").InnerText);
item.attack = -1;
item.health = -1;
item.abl = node.SelectSingleNode("ABL").InnerText;
item.code = int.Parse(node.SelectSingleNode("CODE").InnerText);
item.cardbase = card_base[item.grade];
allBookMag.Add(item);
}
TextAsset textAsset2 = (TextAsset)Resources.Load("CARD/xml/equip");
XmlDocument xmlDoc2 = new XmlDocument();
xmlDoc2.LoadXml(textAsset2.text);
XmlNodeList nodes2 = xmlDoc2.SelectNodes("rows/row");
foreach (XmlNode node in nodes2)
{
Item item = new Item();
item.name = node.SelectSingleNode("NAME").InnerText;
item.grade = int.Parse(node.SelectSingleNode("GRADE").InnerText);
item.cost = Resources.Load<Sprite>("CARD/num/" + node.SelectSingleNode("COST").InnerText);
item.cost_num = int.Parse(node.SelectSingleNode("COST").InnerText);
item.attack = int.Parse(node.SelectSingleNode("ATT").InnerText);
item.health = int.Parse(node.SelectSingleNode("DEF").InnerText);
item.abl = node.SelectSingleNode("ABL").InnerText;
item.code = int.Parse(node.SelectSingleNode("CODE").InnerText);
item.main = Resources.Load<Sprite>("CARD/equip/"+node.SelectSingleNode("CODE").InnerText);
item.background = back[item.grade];
item.cardbase = card_base_mon[item.grade];
allBookEqp.Add(item);
}
}
public void LoadMyDeck()
{
deckitemBuffer = new List<Item>(50);
string[] type = new string[3] { "monster.xml", "magic.xml", "equip.xml" };
var bro = Backend.GameData.GetMyData("character", new Where());
var keys = bro.Rows()[0]["deck"][0].Keys;
foreach (var key in keys)
{
if (key.Substring(0, 1) == "1")
{
XDocument document = XDocument.Load(@"C:\nexon_maplestory_battle_monsters_league_s\Assets\Resources\CARD\xml\" + type[0]);
var books = from row in document.Descendants("row")
where (row.Element("CODE").Value == key)
select new
{
name = row.Element("NAME").Value,
grade = row.Element("GRADE").Value,
cost = row.Element("COST").Value,
att = row.Element("ATT").Value,
def = row.Element("DEF").Value,
abl = row.Element("ABL").Value,
code = row.Element("CODE").Value,
area = row.Element("AREA").Value,
ablcode = row.Element("ABLCODE").Value,
link = row.Element("LINK").Value
};
for (int i = 0; i < int.Parse(bro.Rows()[0]["deck"][0][key][0].ToString()); i++)
{
foreach (var row in books)
{
Item item = new Item();
item.name = row.name;
item.grade = int.Parse(row.grade);
item.cost = Resources.Load<Sprite>("CARD/num/" + row.cost);
item.cost_num = int.Parse(row.cost);
item.attack = int.Parse(row.att);
item.health = int.Parse(row.def);
item.abl = row.abl;
item.code = int.Parse(row.code);
item.main = Resources.Load<Sprite>("CARD/monster/" + row.code);
item.background = Resources.Load<Sprite>("CARD/background/" + row.area);
item.cardbase = card_base_mon[item.grade];
item.ablcode = row.ablcode;
item.link = row.link;
deckitemBuffer.Add(item);
}
}
}
if (key.Substring(0, 1) == "2")
{
XDocument document = XDocument.Load(@"C:\nexon_maplestory_battle_monsters_league_s\Assets\Resources\CARD\xml\" + type[1]);
var books = from row in document.Descendants("row")
where (row.Element("CODE").Value == key)
select new
{
name = row.Element("NAME").Value,
grade = row.Element("GRADE").Value,
cost = row.Element("COST").Value,
abl = row.Element("ABL").Value,
code = row.Element("CODE").Value
};
for (int i = 0; i < int.Parse(bro.Rows()[0]["deck"][0][key][0].ToString()); i++)
{
foreach (var row in books)
{
Item item = new Item();
item.name = row.name;
item.grade = int.Parse(row.grade);
item.cost = Resources.Load<Sprite>("CARD/num/" + row.cost);
item.cost_num = int.Parse(row.cost);
item.attack = -1;
item.health = -1;
item.abl = row.abl;
item.code = int.Parse(row.code);
if (int.Parse(row.code.Substring(3, 2)) <= 27)
{
item.background = Resources.Load<Sprite>("CARD/magic/" + row.code);
item.cardbase = card_base[item.grade];
item.main = null;
}
deckitemBuffer.Add(item);
}
}
}
if (key.Substring(0, 1) == "3")
{
XDocument document = XDocument.Load(@"C:\nexon_maplestory_battle_monsters_league_s\Assets\Resources\CARD\xml\" + type[2]);
var books = from row in document.Descendants("row")
where (row.Element("CODE").Value == key)
select new
{
name = row.Element("NAME").Value,
grade = row.Element("GRADE").Value,
cost = row.Element("COST").Value,
att = row.Element("ATT").Value,
def = row.Element("DEF").Value,
abl = row.Element("ABL").Value,
code = row.Element("CODE").Value
};
for (int i = 0; i < int.Parse(bro.Rows()[0]["deck"][0][key][0].ToString()); i++)
{
foreach (var row in books)
{
Item item = new Item();
item.name = row.name;
item.grade = int.Parse(row.grade);
item.cost = Resources.Load<Sprite>("CARD/num/" + row.cost);
item.attack = int.Parse(row.att);
item.health = int.Parse(row.def);
item.abl = row.abl;
item.code = int.Parse(row.code);
item.cardbase = card_base_mon[item.grade];
item.cost_num = int.Parse(row.cost);
item.background = back[item.grade];
item.main = Resources.Load<Sprite>("CARD/equip/" + row.code);
deckitemBuffer.Add(item);
}
}
}
}
}
public void LoadMyCard()
{
string[] type = new string[3] { "monster.xml", "magic.xml", "equip.xml" };
var bro = Backend.GameData.GetMyData("character", new Where());
var keys1 = bro.Rows()[0]["monster"][0].Keys;
foreach (var key in keys1)
{
XDocument document = XDocument.Load(@"C:\nexon_maplestory_battle_monsters_league_s\Assets\Resources\CARD\xml\" + type[0]);
var books = from row in document.Descendants("row")
where (row.Element("CODE").Value == key)
select new
{
name = row.Element("NAME").Value,
grade = row.Element("GRADE").Value,
cost = row.Element("COST").Value,
att = row.Element("ATT").Value,
def = row.Element("DEF").Value,
abl = row.Element("ABL").Value,
code = row.Element("CODE").Value,
area = row.Element("AREA").Value,
ablcode = row.Element("ABLCODE").Value,
link = row.Element("LINK").Value
};
for (int i = 0; i < int.Parse(bro.Rows()[0]["monster"][0][key][0].ToString()); i++)
{
foreach (var row in books)
{
Item item = new Item();
item.name = row.name;
item.grade = int.Parse(row.grade);
item.cost = Resources.Load<Sprite>("CARD/num/" + row.cost);
item.cost_num = int.Parse(row.cost);
item.attack = int.Parse(row.att);
item.health = int.Parse(row.def);
item.abl = row.abl;
item.code = int.Parse(row.code);
item.main = Resources.Load<Sprite>("CARD/monster/" + row.code);
item.background = Resources.Load<Sprite>("CARD/background/" + row.area);
item.cardbase = card_base_mon[item.grade];
item.ablcode = row.ablcode;
item.link = row.link;
myCardItemBuffer.Add(item);
}
}
}
var keys2 = bro.Rows()[0]["magic"][0].Keys;
foreach (var key in keys2)
{
XDocument document = XDocument.Load(@"C:\nexon_maplestory_battle_monsters_league_s\Assets\Resources\CARD\xml\" + type[1]);
var books = from row in document.Descendants("row")
where (row.Element("CODE").Value == key)
select new
{
name = row.Element("NAME").Value,
grade = row.Element("GRADE").Value,
cost = row.Element("COST").Value,
abl = row.Element("ABL").Value,
code = row.Element("CODE").Value
};
for (int i = 0; i < int.Parse(bro.Rows()[0]["magic"][0][key][0].ToString()); i++)
{
foreach (var row in books)
{
Item item = new Item();
item.name = row.name;
item.grade = int.Parse(row.grade);
item.cost = Resources.Load<Sprite>("CARD/num/" + row.cost);
item.cost_num = int.Parse(row.cost);
item.attack = -1;
item.health = -1;
item.abl = row.abl;
item.code = int.Parse(row.code);
if (int.Parse(row.code.Substring(3, 2)) <= 27)
{
item.background = Resources.Load<Sprite>("CARD/magic/" + row.code);
item.cardbase = card_base[item.grade];
item.main = null;
}
myCardItemBuffer.Add(item);
}
}
}
var keys3 = bro.Rows()[0]["equip"][0].Keys;
foreach (var key in keys3)
{
if (key.Substring(0, 1) == "3")
{
XDocument document = XDocument.Load(@"C:\nexon_maplestory_battle_monsters_league_s\Assets\Resources\CARD\xml\" + type[2]);
var books = from row in document.Descendants("row")
where (row.Element("CODE").Value == key)
select new
{
name = row.Element("NAME").Value,
grade = row.Element("GRADE").Value,
cost = row.Element("COST").Value,
att = row.Element("ATT").Value,
def = row.Element("DEF").Value,
abl = row.Element("ABL").Value,
code = row.Element("CODE").Value
};
for (int i = 0; i < int.Parse(bro.Rows()[0]["equip"][0][key][0].ToString()); i++)
{
foreach (var row in books)
{
Item item = new Item();
item.name = row.name;
item.grade = int.Parse(row.grade);
item.cost = Resources.Load<Sprite>("CARD/num/" + row.cost);
item.attack = int.Parse(row.att);
item.health = int.Parse(row.def);
item.abl = row.abl;
item.code = int.Parse(row.code);
item.cardbase = card_base_mon[item.grade];
item.cost_num = int.Parse(row.cost);
item.background = back[item.grade];
item.main = Resources.Load<Sprite>("CARD/equip/" + row.code);
myCardItemBuffer.Add(item);
}
}
}
}
}
public void LoadMyCardTab()
{
foreach (var item in myCardItemBuffer)
{
if (item.code.ToString().Substring(0, 1) == "1")
{
var cardObject = Instantiate(cardPrefeb, Vector2.zero, monContent.transform.rotation);
cardObject.transform.parent = monContent.gameObject.transform;
var card = cardObject.GetComponent<CardMain>();
card.Setup(item, true);
cardObject.GetComponent<BoxCollider2D>().enabled = false;
cardObject.transform.localScale = new Vector3(1.5f, 1.5f, 1.5f);
}
else if(item.code.ToString().Substring(0,1) == "2")
{
var cardObject = Instantiate(cardPrefeb, Vector2.zero, magContent.transform.rotation);
cardObject.transform.parent = magContent.gameObject.transform;
var card = cardObject.GetComponent<CardMain>();
card.Setup(item, true);
cardObject.GetComponent<BoxCollider2D>().enabled = false;
cardObject.transform.localScale = new Vector3(1.5f, 1.5f, 1.5f);
}
else
{
var cardObject = Instantiate(cardPrefeb, Vector2.zero, eqpContent.transform.rotation);
cardObject.transform.parent = eqpContent.gameObject.transform;
var card = cardObject.GetComponent<CardMain>();
card.Setup(item, true);
cardObject.GetComponent<BoxCollider2D>().enabled = false;
cardObject.transform.localScale = new Vector3(1.5f, 1.5f, 1.5f);
}
}
}
public void AddCardOnMainDeckSetting()
{
for(int i=0;i<mainDeckContent.transform.childCount;i++)
{
Destroy(mainDeckContent.transform.GetChild(i).gameObject);
}
LoadMyDeck();
foreach (var item in deckitemBuffer)
{
var cardObject = Instantiate(cardPrefeb,Vector2.zero,mainDeckContent.transform.rotation);
cardObject.transform.parent = mainDeckContent.gameObject.transform;
cardObject.transform.Translate(new Vector2(mainDeckContent.gameObject.transform.position.x+25,mainDeckContent.gameObject.transform.position.y));
var card = cardObject.GetComponent<CardMain>();
card.Setup(item,true);
cardObject.GetComponent<BoxCollider2D>().enabled = false;
}
}
public void MyDeckSetting()
{
foreach (var item in deckitemBuffer)
{
myCardContent.transform.Find(item.code.ToString()).parent = myDeckContent.gameObject.transform;
}
}
public void MyCardSetting()
{
LoadMyCard();
int i =0;
foreach (var item in myCardItemBuffer)
{
var cardObject = Instantiate(cardPrefeb, Vector2.zero, myCardContent.transform.rotation);
cardObject.transform.parent = myCardContent.gameObject.transform;
cardObject.name = item.code.ToString();
cardObject.transform.localScale = new Vector3(1.5f, 1.5f, 1.5f);
var card = cardObject.GetComponent<CardMain>();
card.Setup(item, true);
i += 1;
}
}
public void AllBookSetting()
{
LoadAllBook();
foreach (var item in allBookMon)
{
var cardObject = Instantiate(cardPrefeb, Vector2.zero, allMonContent.transform.rotation);
cardObject.transform.parent = allMonContent.gameObject.transform;
cardObject.transform.localScale = new Vector3(1.5f, 1.5f, 1.5f);
var card = cardObject.GetComponent<CardMain>();
card.Setup(item, true);
cardObject.GetComponent<BoxCollider2D>().enabled = false;
}
foreach (var item in allBookMag)
{
var cardObject = Instantiate(cardPrefeb, Vector2.zero, allMagContent.transform.rotation);
cardObject.transform.parent = allMagContent.gameObject.transform;
cardObject.transform.localScale = new Vector3(1.5f, 1.5f, 1.5f);
var card = cardObject.GetComponent<CardMain>();
card.Setup(item, true);
cardObject.GetComponent<BoxCollider2D>().enabled = false;
}
foreach (var item in allBookEqp)
{
var cardObject = Instantiate(cardPrefeb, Vector2.zero, allEqpContent.transform.rotation);
cardObject.transform.parent = allEqpContent.gameObject.transform;
cardObject.transform.localScale = new Vector3(1.5f, 1.5f, 1.5f);
var card = cardObject.GetComponent<CardMain>();
card.Setup(item, true);
cardObject.GetComponent<BoxCollider2D>().enabled = false;
}
}
public void DragCard(GameObject gameObject)
{
if(gameObject.transform.parent.transform.parent.transform.parent.gameObject == mycard)
{
Debug.Log("card");
mycard.GetComponent<ScrollRect>().vertical = false;
}
else if(gameObject.transform.parent.transform.parent.transform.parent.gameObject == mydeck)
{
Debug.Log("deck");
mydeck.GetComponent<ScrollRect>().vertical = false;
}
gameObject.transform.parent = Card.transform.transform;
Vector3 mousePosition = new Vector3(Input.mousePosition.x,
Input.mousePosition.y, 10);
Vector3 objPosition = Camera.main.ScreenToWorldPoint(mousePosition);
gameObject.transform.position = objPosition;
}
public void MouseUp()
{
mycard.GetComponent<ScrollRect>().vertical = true;
mydeck.GetComponent<ScrollRect>().vertical = true;
}
//113.8 , 552.5 812.7 , 552.5
//113.8 , 70.0 812.7 , 70.0
//831.0 , 552.5 982.3 , 552.5
//831.0 , 70.0 982.3 , 70.0
public void Move(GameObject card)
{
if(Input.mousePosition.x>=113.8 && Input.mousePosition.x<=812.7f &&Input.mousePosition.y<=552.5 && Input.mousePosition.y >=70.0)
{
if(myDeckContent.transform.childCount>=50)
{
print("카드가 이미 50장입니다.");
card.transform.parent = myCardContent.transform;
card.transform.SetSiblingIndex(0);
return;
}
card.transform.parent = myDeckContent.transform;
card.transform.SetSiblingIndex(0);
}
else
{
card.transform.parent = myCardContent.transform;
card.transform.SetSiblingIndex(0);
}
}
public void SceneChager(string scene)
{
SceneManager.LoadScene(scene);
}
}
//CardMain.cs
using System.Net.Mime;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using TMPro;
using DG.Tweening;
using UnityEngine.UI;
public class CardMain : MonoBehaviour
{
[SerializeField] Image Img_main;
[SerializeField] Image card;
[SerializeField] Image Img_cardbase;
[SerializeField] Image Img_background;
[SerializeField] Text TMP_name;
[SerializeField] Text TMP_ATT;
[SerializeField] Text TMP_DEF;
[SerializeField] Text TMP_ABL;
[SerializeField] Image Img_cost;
[SerializeField] Sprite cardBack;
[SerializeField] Sprite img_null;
[SerializeField] string ablcode;
public Item item;
bool isFront;
public void Setup(Item item, bool isFront)
{
this.item =item;
this.isFront = isFront;
if(this.isFront)
{
card.sprite = null;
if(item.code.ToString().Substring(0,1)=="2" && int.Parse(item.code.ToString().Substring(3,3))<29)
{
Img_main.sprite = img_null;
}
else
{
Img_main.sprite = this.item.main;
}
TMP_name.text =this.item.name;
if(item.code.ToString().Substring(0,1) == "2")
{
TMP_ATT.text ="";
TMP_DEF.text="";
}
else
{
TMP_ATT.text = this.item.attack.ToString();
TMP_DEF.text = this.item.health.ToString();
}
TMP_ABL.text = this.item.abl;
Img_cost.sprite = this.item.cost;
Img_cardbase.sprite=this.item.cardbase;
Img_background.sprite=this.item.background;
ablcode = this.item.ablcode;
}
}
public void MoveTransform(PRS prs, bool useDotween, float dotweenTime =0)
{
if(useDotween)
{
transform.DOMove(prs.pos,dotweenTime);
transform.DORotateQuaternion(prs.rot,dotweenTime);
transform.DOScale(prs.scale,dotweenTime);
}
else
{
transform.position=prs.pos;
transform.rotation=prs.rot;
transform.localScale =prs.scale;
}
}
void OnMouseUp()
{
ViewCard.Inst.MouseUp();
ViewCard.Inst.Move(this.gameObject);
}
void OnMouseDrag()
{
ViewCard.Inst.DragCard(this.gameObject);
}
}
//BackEndMatch.cs
using System.ComponentModel;
using System.Reflection;
using System.Net.Mime;
using System.Text.RegularExpressions;
using System.Threading;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using BackEnd;
using BackEnd.Tcp;
using System.Linq;
using System;
using UnityEngine.UI;
using System.Drawing;
public partial class BackEndMatch : MonoBehaviour
{
//***************************인게임 오브젝트*******************************************
//************************************************************************************
//***************************인게임 변수***********************************************
//************************************************************************************
private string inGameRoomToken = string.Empty;
public bool isConnectMatchServer { get; private set; } = false;
public class MatchInfo
{
public string title;
public string inDate;
public MatchType matchType;
public MatchModeType matchModeType;
}
public Texture2D myPlayer;
public Texture2D myServer;
public class UserInfo
{
public byte[] itemList;
public Texture2D Player;
}
public class MatchMembers
{
public string nickname;
public SessionId sessionId;
}
public int flag =0;
public int finish_flag =0;
public static MatchMembers myinfo = new MatchMembers();
public static MatchMembers otherinfo = new MatchMembers();
public List<MatchInfo> matchInfos { get; private set; } = new List<MatchInfo>();
void Start()
{
GetMatchList();
JoinMatchMakingServer();
MatchMakingHandler();
GameHandler();
}
private void Update()
{
Backend.Match.Poll();
}
private void Awake()
{
DontDestroyOnLoad(this.gameObject);
}
public void SendMyInfo()
{
byte[] playerimage = myPlayer.EncodeToPNG();
byte[] send =new byte[] {Convert.ToByte(101)};
byte[] bytedata = new byte[playerimage.Length+send.Length];
Array.Copy(send,0,bytedata,0,send.Length);
Array.Copy(playerimage,0 ,bytedata,send.Length,playerimage.Length);
Backend.Match.SendDataToInGameRoom(bytedata);
byte[] serverimage = myServer.EncodeToPNG();
byte[] send1 =new byte[] {Convert.ToByte(102)};
byte[] bytedata1 = new byte[serverimage.Length+send1.Length];
Array.Copy(send1,0,bytedata1,0,send1.Length);
Array.Copy(serverimage,0 ,bytedata1,send1.Length,serverimage.Length);
Backend.Match.SendDataToInGameRoom(bytedata1);
byte[] item1 = CardManager.Inst.aitembuffer;
byte[] send2 =new byte[] {Convert.ToByte(103)};
byte[] bytedata2 = new byte[item1.Length+send2.Length];
Array.Copy(send2,0,bytedata2,0,send2.Length);
Array.Copy(item1,0 ,bytedata2,send2.Length,item1.Length);
Backend.Match.SendDataToInGameRoom(bytedata2);
byte[] item2 = CardManager.Inst.bitembuffer;
byte[] send3 =new byte[] {Convert.ToByte(104)};
byte[] bytedata3 = new byte[item2.Length+send3.Length];
Array.Copy(send3,0,bytedata3,0,send3.Length);
Array.Copy(item2,0 ,bytedata3,send3.Length,item2.Length);
Backend.Match.SendDataToInGameRoom(bytedata3);
byte[] item3 = CardManager.Inst.citembuffer;
byte[] send4 =new byte[] {Convert.ToByte(105)};
byte[] bytedata4 = new byte[item3.Length+send4.Length];
Array.Copy(send4,0,bytedata4,0,send4.Length);
Array.Copy(item3,0 ,bytedata4,send4.Length,item3.Length);
Backend.Match.SendDataToInGameRoom(bytedata4);
}
public static void SendMessage(byte[] array)
{
Backend.Match.SendDataToInGameRoom(array);
}
public static byte[] ConvertByte(int code)
{
byte[] send = new byte[3];
send[0] = Convert.ToByte(code.ToString().Substring(0,2));
send[1] = Convert.ToByte(code.ToString().Substring(2,2));
send[2] = Convert.ToByte(code.ToString().Substring(4,2));
return send;
}
public static int ConvertInt(byte one, byte two, byte three)
{
int code =0;
code += Convert.ToInt32(one)*10000;
code += Convert.ToInt32(two)*100;
code += Convert.ToInt32(three);
return code;
}
public static void SendSpawn(int code)
{
byte[] send = new byte[4];
send[0] = Convert.ToByte(108);
for(int i =1;i<4;i++)
{
send[i] = Convert.ToByte(int.Parse(code.ToString().Substring(2*(i-1),2)));
}
Backend.Match.SendDataToInGameRoom(send);
}
private bool game =false;
IEnumerator start()
{
yield return new WaitForSeconds(6.0f);
GameManager.Inst.Notification("게임 시작!");
CardManager.Inst.otherItemBuffer = LoadOtherdeck();
GameManager.Inst.StartGame();
func();
}
private void GameHandler()
{
Backend.Match.OnSessionJoinInServer += (args) =>
{
Debug.Log("OnSessionJoinInServer : " + args.ErrInfo);
AccessInGameRoom(inGameRoomToken);
ViewCard.Inst.SceneChager("GAME_SCENE");
};
Backend.Match.OnMatchInGameAccess += (args) =>
{
Debug.Log("OnMatchInGameAccess : " + args.ErrInfo);
};
Backend.Match.OnMatchInGameStart += () =>
{
Debug.Log("OnMatchInGameStart : ");
if (!game)
{
SendMyInfo();
game = true;
}
StartCoroutine(start());
};
Backend.Match.OnMatchResult += (args) => {
Debug.Log(args.Reason);
};
Backend.Match.OnMatchRelay += (args) => {
if (Backend.UserNickName != args.From.NickName)
{
if (args.BinaryUserData[0] == Convert.ToByte(101))
{
MyId(Backend.Match.GetMySessionId());
OtherId(args.From.SessionId);
byte2image1(args.BinaryUserData, args.From.NickName);
}
else if (args.BinaryUserData[0] == Convert.ToByte(102))
{
byte2image2(args.BinaryUserData);
}
else
{
DataProcess(args.BinaryUserData);
}
}
};
}
public void MyId(SessionId id)
{
myinfo.sessionId = id;
myinfo.nickname = Backend.Match.GetNickNameBySessionId(myinfo.sessionId);
Debug.Log("my : " + myinfo.sessionId);
}
public void OtherId(SessionId id)
{
otherinfo.sessionId = id;
otherinfo.nickname = Backend.Match.GetNickNameBySessionId(otherinfo.sessionId);
Debug.Log("other : " + otherinfo.sessionId);
}
private void MatchMakingHandler()
{
Backend.Match.OnJoinMatchMakingServer += (args) =>
{
Debug.Log("OnJoinMatchMakingServer : " + args.ErrInfo);
};
Backend.Match.OnMatchMakingRoomCreate += (args) =>
{
Debug.Log("OnMatchMakingRoomCreate : " + args.ErrInfo + " : " + args.Reason);
//매칭방 접속 이벤트
};
Backend.Match.OnMatchMakingResponse += (args) =>
{
Debug.Log("OnMatchMakingResponse : " + args.ErrInfo + " : " + args.Reason);
ProcessMatchMakingResponse(args);
//매칭 요청 이벤트
};
Backend.Match.OnLeaveMatchMakingServer += (args) =>
{
Debug.Log("OnLeaveMatchMakingServer : " + args.ErrInfo.Category);
//매칭서버 종료 이벤트
};
Backend.Match.OnMatchMakingRoomLeave += (args) => {
Debug.Log("OnMatchMakingRoomLeave : " + args.UserInfo);
};
Backend.Match.OnMatchMakingRoomDestory += (args) => {
Debug.Log("OnMatchMakingRoomDestory : " + args.ErrInfo);
};
}
//매칭서버 접속 1
public void JoinMatchMakingServer()
{
ErrorInfo errorinfo;
Backend.Match.JoinMatchMakingServer(out errorinfo);
}
//매칭 서버 퇴장
public void LeaveMatchMakingSetver()
{
Backend.Match.LeaveMatchMakingServer();
}
//매칭룸 생성 2
public void CreateMatchRoom()
{
Backend.Match.CreateMatchRoom();
}
public void LeaveMatchRoom()
{
Backend.Match.LeaveMatchRoom();
}
//매칭 시작 3
public void RequestMatchMaking(int index)
{
Backend.Match.RequestMatchMaking(matchInfos[index].matchType,matchInfos[index].matchModeType,matchInfos[index].inDate);
Debug.Log(matchInfos[index].matchType.ToString());
}
public void matchcount()
{
for(int i=0;i<matchInfos.Count;i++)
{
Debug.Log(matchInfos[i].title);
}
}
//매치리스트 가져오기
public void GetMatchList()
{
matchInfos.Clear();
var bro = Backend.Match.GetMatchList();
foreach(LitJson.JsonData row in bro.Rows())
{
MatchInfo matchInfo = new MatchInfo();
matchInfo.title = row["matchTitle"]["S"].ToString();
matchInfo.inDate = row["inDate"]["S"].ToString();
foreach (MatchType type in Enum.GetValues(typeof(MatchType)))
{
if (type.ToString().ToLower().Equals(row["matchType"]["S"].ToString().ToLower()))
{
matchInfo.matchType = type;
}
}
foreach (MatchModeType type in Enum.GetValues(typeof(MatchModeType)))
{
if (type.ToString().ToLower().Equals(row["matchModeType"]["S"].ToString().ToLower()))
{
matchInfo.matchModeType = type;
}
}
matchInfos.Add(matchInfo);
}
}
//매칭 중 매칭 취소
public void CancelMatchMaking()
{
Backend.Match.CancelMatchMaking();
}
//매칭 시도 중 응답
private void ProcessMatchMakingResponse(MatchMakingResponseEventArgs args)
{
string debugLog = string.Empty;
switch (args.ErrInfo)
{
case ErrorCode.Success:
// 매칭 성공했을 때
debugLog = string.Format("SUCCESS_MATCHMAKE", args.Reason);
ProcessMatchSuccess(args);
break;
case ErrorCode.Match_InProgress:
// 매칭 신청 성공했을 때 or 매칭 중일 때 매칭 신청을 시도했을 때
// 매칭 신청 성공했을 때
if (args.Reason == string.Empty)
{
debugLog = "SUCCESS_REGIST_MATCHMAKE";
}
break;
case ErrorCode.Match_MatchMakingCanceled:
// 매칭 신청이 취소되었을 때
debugLog = string.Format("CANCEL_MATCHMAKE", args.Reason);
break;
case ErrorCode.Match_InvalidMatchType:
// 매치 타입을 잘못 전송했을 때
debugLog = string.Format("FAIL_REGIST_MATCHMAKE", "INVAILD_MATCHTYPE");
break;
case ErrorCode.Match_InvalidModeType:
// 매치 모드를 잘못 전송했을 때
debugLog = string.Format("FAIL_REGIST_MATCHMAKE", "INVALID_MODETYPE");
break;
case ErrorCode.InvalidOperation:
// 잘못된 요청을 전송했을 때
debugLog = string.Format("INVALID_OPERATION", args.Reason);
break;
case ErrorCode.Match_Making_InvalidRoom:
// 잘못된 요청을 전송했을 때
debugLog = string.Format("INVALID_OPERATION", args.Reason);
break;
case ErrorCode.Exception:
// 매칭 되고, 서버에서 방 생성할 때 에러 발생 시 exception이 리턴됨
// 이 경우 다시 매칭 신청해야 됨
debugLog = string.Format("EXCEPTION_OCCUR", args.Reason);
break;
}
}
//인게임 서버로 입장
private void ProcessMatchSuccess(MatchMakingResponseEventArgs args)
{
ErrorInfo errorInfo;
if (!Backend.Match.JoinGameServer(args.RoomInfo.m_inGameServerEndPoint.m_address, args.RoomInfo.m_inGameServerEndPoint.m_port, false, out errorInfo))
{
var debugLog = string.Format("FAIL_ACCESS_INGAME", errorInfo.ToString(), string.Empty);
Debug.Log(debugLog);
}
inGameRoomToken = args.RoomInfo.m_inGameRoomToken;
}
//인게임룸으로 입장
private void AccessInGameRoom(string roomToken)
{
Backend.Match.JoinGameRoom(roomToken);
}
public static void EndMatch(bool isMine)
{
MatchGameResult nowGameResult = new MatchGameResult();
nowGameResult.m_winners = new List<SessionId>();
nowGameResult.m_losers = new List<SessionId>();
if(isMine)
{
Debug.Log("win : " +myinfo.sessionId +"lose : " +otherinfo.sessionId);
nowGameResult.m_winners.Add(myinfo.sessionId);
nowGameResult.m_losers.Add(otherinfo.sessionId);
}
else
{
Debug.Log("win : " +otherinfo.sessionId +"lose : " +myinfo.sessionId);
nowGameResult.m_winners.Add(otherinfo.sessionId);
nowGameResult.m_losers.Add(myinfo.sessionId);
}
Backend.Match.MatchEnd(nowGameResult);
}
}
//BackEndData.cs
using System.ComponentModel;
using System.Reflection;
using System.Net.Mime;
using System.Text.RegularExpressions;
using System.Threading;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using BackEnd;
using BackEnd.Tcp;
using System;
using UnityEngine.UI;
using System.Drawing;
using TMPro;
using System.Xml.Linq;
using System.Linq;
using DG.Tweening;
public partial class BackEndMatch : MonoBehaviour
{
//받은 데이터 가공
public void byte2image1(byte[] array,string name)
{
byte[] calc = new byte[array.Length-1];
Array.Copy(array,1,calc,0,calc.Length);
Texture2D tex = new Texture2D(2,2);
tex.LoadImage(calc);
Rect rect = new Rect(0,0,tex.width,tex.height);
GameObject.Find("OtherArea").transform.GetChild(0).gameObject.transform.GetChild(0).GetComponent<SpriteRenderer>().sprite = Sprite.Create(tex,rect,new Vector2(0.5f,0.5f));
GameObject.Find("OtherArea").transform.GetChild(0).gameObject.transform.GetChild(2).GetComponent<TextMeshPro>().text = name;
}
public void byte2image2(byte[] array)
{
byte[] calc = new byte[array.Length-1];
Array.Copy(array,1,calc,0,calc.Length);
Texture2D tex = new Texture2D(2,2);
tex.LoadImage(calc);
Rect rect = new Rect(0,0,tex.width,tex.height);
GameObject.Find("OtherArea").transform.GetChild(0).gameObject.transform.GetChild(1).GetComponent<SpriteRenderer>().sprite = Sprite.Create(tex,rect,new Vector2(0.5f,0.5f));
}
public void DataProcess(byte[] array)
{
byte[] calc = new byte[array.Length-1];
Array.Copy(array,1,calc,0,calc.Length);
switch(Convert.ToInt32(array[0]))
{
case 103:
SetOtherItem(calc,Convert.ToInt32(array[0]));
break;
case 104:
SetOtherItem(calc,Convert.ToInt32(array[0]));
break;
case 105:
SetOtherItem(calc,Convert.ToInt32(array[0]));
break;
case 106:
TurnManger.Inst.EndTurn();
break;
case 107:
CardManager.Inst.AddCard(false);
break;
case 108:
SummonCard(calc);
break;
case 0:
BackAttack(calc);
break;
case 1:
StartCoroutine(ability1(calc));
break;
case 2:
StartCoroutine(ability2(calc));
break;
case 8:
StartCoroutine(ability8(calc));
break;
case 9:
StartCoroutine(ability9(calc));
break;
case 11:
StartCoroutine(ability11(calc));
break;
case 13:
StartCoroutine(ability13(calc));
break;
case 14:
StartCoroutine(ability14());
break;
case 15:
StartCoroutine(ability15(calc));
break;
case 16:
StartCoroutine(ability16(calc));
break;
case 17:
StartCoroutine(ability17(calc));
break;
case 19:
StartCoroutine(ability19(calc));
break;
case 20:
StartCoroutine(ability20(calc));
break;
case 22:
StartCoroutine(ability22(calc));
break;
case 23:
StartCoroutine(ability23(calc));
break;
case 24:
StartCoroutine(ability24(calc));
break;
case 25:
StartCoroutine(ability25(calc));
break;
case 26:
StartCoroutine(ability26(calc));
break;
case 27:
StartCoroutine(ability27(calc));
break;
case 28:
StartCoroutine(ability28(calc));
break;
case 30:
StartCoroutine(ability30(calc));
break;
case 31:
StartCoroutine(ability31(calc));
break;
case 33:
StartCoroutine(ability33(calc));
break;
case 34:
StartCoroutine(ability34(calc));
break;
case 35:
StartCoroutine(ability35(calc));
break;
case 36:
StartCoroutine(ability36(calc));
break;
case 37:
StartCoroutine(ability37(calc));
break;
case 39:
StartCoroutine(ability39(calc));
break;
case 40:
StartCoroutine(ability40(calc));
break;
case 41:
StartCoroutine(ability41(calc));
break;
case 42:
CardManager.Inst.AddCard(false);
CardManager.Inst.AddCard(false);
break;
case 46:
StartCoroutine(ability46(calc));
break;
case 47:
StartCoroutine(ability47(calc));
break;
case 38:
StartCoroutine(ability38(calc));
break;
case 4:
StartCoroutine(ability4(calc));
break;
case 32:
StartCoroutine(ability32(calc));
break;
case 44:
StartCoroutine(ability44(calc));
break;
case 45:
StartCoroutine(ability45(calc));
break;
case 200:
renounce();
break;
}
}
public void renounce()
{
Sequence sequence = DOTween.Sequence()
.AppendCallback(() =>
{
EntityManeger.Inst.otherBossEntity.Damaged(100);
EntityManeger.Inst.SpawnDamage(100, EntityManeger.Inst.otherBossEntity.transform);
});
StartCoroutine(GameManager.Inst.GameOver(true));
}
//사령
IEnumerator ability45(byte[] array)
{
yield return null;
Entity defender = ByteToEntity(array[0], false);
int index = Convert.ToInt32(array[1]);
AbilityManager.Inst.SpawnEntity(AbilityManager.Inst.SetEntity(int.Parse(defender.link[index])));
}
//공격 무효화
IEnumerator ability44(byte[] array)
{
yield return null;
Entity attacker = ByteToEntity(array[0], false);
Entity defender = ByteToEntity(array[1], true);
attacker.attackable = false;
Sequence sequence = DOTween.Sequence()
.Append(attacker.transform.DOMove(defender.transform.position, 0.4f)).SetEase(Ease.InSine)
.AppendCallback(() =>
{
attacker.Damaged(defender.attack);
EntityManeger.Inst.SpawnDamage(defender.attack, attacker.transform);
EntityManeger.Inst.SpawnDamage(-attacker.attack, defender.transform);
})
.Append(attacker.transform.DOMove(attacker.transform.position, 0.4f)).SetEase(Ease.OutSine)
.OnComplete(() => EntityManeger.Inst.AttackCallback(attacker, defender));
}
//거울
IEnumerator ability32(byte[] array)
{
yield return null;
Entity attacker = ByteToEntity(array[0],false);
Entity defender = ByteToEntity(array[1],true);
AbilityManager.Inst.AbilityAttack(defender.gameObject,EntityManeger.Inst.otherBossEntity,attacker.attack);
}
//회피
IEnumerator ability4(byte[] array)
{
yield return null;
Entity attacker = ByteToEntity(array[0], false);
Entity defender = ByteToEntity(array[1], true);
attacker.attackable = false;
Sequence sequence = DOTween.Sequence()
.Append(attacker.transform.DOMove(defender.transform.position, 0.4f)).SetEase(Ease.InSine)
.AppendCallback(() =>
{
})
.Append(attacker.transform.DOMove(attacker.transform.position, 0.4f)).SetEase(Ease.OutSine)
.OnComplete(() => EntityManeger.Inst.AttackCallback(attacker, defender));
}
//장난
IEnumerator ability38(byte[] array)
{
yield return null;
Entity attacker = ByteToEntity(array[0], false);
Entity defender = ByteToEntity(array[1], true);
attacker.attackable = false;
Sequence sequence = DOTween.Sequence()
.Append(attacker.transform.DOMove(defender.transform.position, 0.4f)).SetEase(Ease.InSine)
.AppendCallback(() =>
{
defender.Damaged(-attacker.attack);
StartCoroutine(AbilityManager.Inst.UpdateATTDEF(defender, true));
attacker.Damaged(defender.attack);
EntityManeger.Inst.SpawnDamage(defender.attack, attacker.transform);
EntityManeger.Inst.SpawnDamage(-attacker.attack, defender.transform);
})
.Append(attacker.transform.DOMove(attacker.transform.position, 0.4f)).SetEase(Ease.OutSine)
.OnComplete(() => EntityManeger.Inst.AttackCallback(attacker, defender));
}
//군단
IEnumerator ability47(byte[] array)
{
yield return null;
if(array[1] == 0x00)
{
AbilityManager.Inst.SpawnEntity(AbilityManager.Inst.SetItem112414(AbilityManager.Inst.entity112414_0,Convert.ToInt32(array[2]),Convert.ToInt32(array[3]) ));
}
else
{
Entity entity = ByteToEntity(array[0],false);
entity.attack = Convert.ToInt32(array[2]);
entity.health = Convert.ToInt32(array[3]);
entity.gameObject.transform.Find("TMP_ATT").transform.GetComponent<TextMeshPro>().text = entity.attack.ToString();
entity.gameObject.transform.Find("TMP_ATT").transform.DOShakeScale(1.0f, 2, 10, 90, true);
entity.gameObject.transform.Find("TMP_ATT").transform.GetComponent<TextMeshPro>().fontMaterial = AbilityManager.Inst.redColor;
entity.gameObject.transform.Find("TMP_DEF").transform.GetComponent<TextMeshPro>().text = entity.health.ToString();
entity.gameObject.transform.Find("TMP_DEF").transform.DOShakeScale(1.0f, 2, 10, 90, true);
entity.gameObject.transform.Find("TMP_DEF").transform.GetComponent<TextMeshPro>().fontMaterial = AbilityManager.Inst.redColor;
}
}
//폭주
IEnumerator ability46(byte[] array)
{
yield return null;
Entity entity = ByteToEntity(array[0], false);
AbilityManager.Inst.SpawnEntity(AbilityManager.Inst.SetEntity(int.Parse(entity.link[0])));
EntityManeger.Inst.myEntities.Remove(entity);
Sequence sequence = DOTween.Sequence()
.Append(entity.transform.DOShakePosition(1.0f))
.Append(entity.transform.DOScale(Vector3.zero, 0.3f)).SetEase(Ease.OutCirc)
.OnComplete(() =>
{
EntityManeger.Inst.EntityAlignment(entity.isMine);
Destroy(entity.gameObject);
});
}
//봉인
public int swap;
IEnumerator ability41(byte[] array)
{
Entity target = ByteToEntity(array[1],true);
yield return null;
if(array[2] == 0x01)
{
ParticleSystem seal = Instantiate(AbilityManager.Inst.sealParticle, target.transform.position, target.transform.rotation);
seal.gameObject.name = "seal";
swap =target.ablcode1;
target.ablcode1 = 0;
}
else if(array[2] ==0x00)
{
target.ablcode1 = swap;
Destroy(gameObject.transform.Find("seal"));
}
else if(array[2] ==0x02)
{
Destroy(gameObject.transform.Find("seal"));
}
}
//핑크빈의 친구
IEnumerator ability40(byte[] array)
{
Entity entity1 = ByteToEntity(array[0],false);
Entity entity2 = ByteToEntity(array[1],false);
entity1.attack +=3;
entity1.health +=3;
entity2.attack +=3;
entity2.health +=3;
yield return StartCoroutine(AbilityManager.Inst.UpdateATTDEF(entity1,true));
yield return StartCoroutine(AbilityManager.Inst.UpdateATTDEF(entity2,true));
}
//아머
IEnumerator ability39(byte[] array)
{
Entity entity = ByteToEntity(array[0],false);
entity.attack = Convert.ToInt32(array[1]);
entity.health = Convert.ToInt32(array[2]);
yield return StartCoroutine(AbilityManager.Inst.UpdateATTDEF(entity,true));
}
//이면
IEnumerator ability37(byte[] array)
{
yield return null;
Entity entity = ByteToEntity(array[0],false);
if(array[1] == 0x01)
{
int swap = entity.attack;
entity.attack = entity.health;
entity.health = swap;
entity.gameObject.transform.Find("TMP_ATT").transform.GetComponent<TextMeshPro>().text = entity.attack.ToString();
entity.gameObject.transform.Find("TMP_ATT").transform.DOShakeScale(1.0f, 2, 10, 90, true);
entity.gameObject.transform.Find("TMP_ATT").transform.GetComponent<TextMeshPro>().fontMaterial = AbilityManager.Inst.redColor;
entity.gameObject.transform.Find("TMP_DEF").transform.GetComponent<TextMeshPro>().text = entity.health.ToString();
entity.gameObject.transform.Find("TMP_DEF").transform.DOShakeScale(1.0f, 2, 10, 90, true);
entity.gameObject.transform.Find("TMP_DEF").transform.GetComponent<TextMeshPro>().fontMaterial = AbilityManager.Inst.redColor;
}
else
{
int temp = entity.attack;
entity.attack = entity.health;
entity.health = temp;
entity.gameObject.transform.Find("TMP_ATT").transform.GetComponent<TextMeshPro>().text = entity.attack.ToString();
entity.gameObject.transform.Find("TMP_ATT").transform.DOShakeScale(1.0f, 2, 10, 90, true);
entity.gameObject.transform.Find("TMP_ATT").transform.GetComponent<TextMeshPro>().fontMaterial = AbilityManager.Inst.blueColor;
entity.gameObject.transform.Find("TMP_DEF").transform.GetComponent<TextMeshPro>().text = entity.health.ToString();
entity.gameObject.transform.Find("TMP_DEF").transform.DOShakeScale(1.0f, 2, 10, 90, true);
entity.gameObject.transform.Find("TMP_DEF").transform.GetComponent<TextMeshPro>().fontMaterial = AbilityManager.Inst.blueColor;
}
}
//분신
IEnumerator ability36(byte[] array)
{
Entity entity = ByteToEntity(array[0], false);
entity.ablcode1 = 0;
Entity dual = Instantiate(entity, entity.transform.position, entity.transform.rotation);
dual.ablcode1 = 0;
dual.gameObject.name = EntityManeger.Inst.SetEntityNum(false);
EntityManeger.Inst.EntityAlignment(false);
yield return null;
}
//태초
IEnumerator ability35(byte[] array)
{
yield return null;
List<GameObject> chains = new List<GameObject>();
foreach(var target in EntityManeger.Inst.otherEntities)
{
var chain = Instantiate(AbilityManager.Inst.chainPrefeb,target.transform.position,target.transform.rotation);
chains.Add(chain);
target.Damaged(target.health);
}
foreach(var target in EntityManeger.Inst.myEntities)
{
var chain = Instantiate(AbilityManager.Inst.chainPrefeb,target.transform.position,target.transform.rotation);
chains.Add(chain);
target.Damaged(target.health);
}
var fire2 = Instantiate(AbilityManager.Inst.chainPrefeb,EntityManeger.Inst.otherBossEntity.transform.position,EntityManeger.Inst.otherBossEntity.transform.rotation);
chains.Add(fire2);
EntityManeger.Inst.otherBossEntity.Damaged(15);
var fire3 = Instantiate(AbilityManager.Inst.chainPrefeb,EntityManeger.Inst.myBossEntity.transform.position,EntityManeger.Inst.myBossEntity.transform.rotation);
chains.Add(fire3);
EntityManeger.Inst.myBossEntity.Damaged(15);
yield return new WaitForSeconds(1.5f);
foreach(var chain in chains)
{
Destroy(chain.gameObject);
}
EntityManeger.Inst.SpawnDamage(15, EntityManeger.Inst.otherBossEntity.transform);
EntityManeger.Inst.SpawnDamage(15, EntityManeger.Inst.myBossEntity.transform);
yield return new WaitForSeconds(1.5f);
foreach(var row in EntityManeger.Inst.otherEntities)
{
Sequence sequence = DOTween.Sequence()
.Append(row.transform.DOShakePosition(1.0f))
.Append(row.transform.DOScale(Vector3.zero, 0.3f)).SetEase(Ease.OutCirc)
.OnComplete(() =>
{
Destroy(row.gameObject);
});
}
EntityManeger.Inst.otherEntities.RemoveRange(0,EntityManeger.Inst.otherEntities.Count);
foreach(var row in EntityManeger.Inst.myEntities)
{
Sequence sequence = DOTween.Sequence()
.Append(row.transform.DOShakePosition(1.0f))
.Append(row.transform.DOScale(Vector3.zero, 0.3f)).SetEase(Ease.OutCirc)
.OnComplete(() =>
{
Destroy(row.gameObject);
});
}
EntityManeger.Inst.myEntities.RemoveRange(0,EntityManeger.Inst.myEntities.Count);
yield return StartCoroutine(EntityManeger.Inst.CheckBossDie());
}
//오버시어의 힘
IEnumerator ability34(byte[] array)
{
yield return null;
Entity target = ByteToEntity(array[0], false);
if (array[1] == 0x01)
{
target.canBeAttacked = false;
target.attackable = false;
}
else
{
target.canBeAttacked = true;
target.attackable = true;
target.ablcode1 = 35;
}
}
//암흑
IEnumerator ability33(byte[] array)
{
yield return null;
Entity cast = ByteToEntity(array[0],false);
Entity target = ByteToEntity(array[1],false);
if(array[2] == 0x01)
{
target.gameObject.GetComponent<BoxCollider2D>().enabled = false;
}
else
{
target.gameObject.GetComponent<BoxCollider2D>().enabled = true;
}
}
//어둠의 집행
IEnumerator ability31(byte[] array)
{
yield return null;
Entity cast = ByteToEntity(array[0],false);
Entity target = ByteToEntity(array[1],true);
AbilityManager.Inst.Attack(cast,target);
target.attack = 1;
yield return StartCoroutine(AbilityManager.Inst.UpdateATTDEF(target,false));
}
//빛의 집행
IEnumerator ability30(byte[] array)
{
yield return null;
Entity cast = ByteToEntity(array[0],false);
Entity target = ByteToEntity(array[1],true);
AbilityManager.Inst.Attack(cast,target);
target.health = 1;
yield return StartCoroutine(AbilityManager.Inst.UpdateATTDEF(target,false));
}
//변이
public int att28;
public Sprite temp;
IEnumerator ability28(byte[] array)
{
yield return null;
Entity cast = ByteToEntity(array[0],false);
Entity target =ByteToEntity(array[1],true);
if(array[2] ==0x01)
{
att28 = target.attack;
target.attack = 0;
yield return StartCoroutine(AbilityManager.Inst.UpdateATTDEF(target,false));
temp = target.transform.GetChild(0).GetComponent<SpriteRenderer>().sprite;
target.transform.GetChild(0).GetComponent<SpriteRenderer>().sprite = AbilityManager.Inst.pig;
}
else
{
target.attack = att28;
yield return StartCoroutine(AbilityManager.Inst.UpdateATTDEF(target, true));
target.transform.GetChild(0).GetComponent<SpriteRenderer>().sprite = temp;
}
}
//혼란
public int targetcode1;
public int targetcode2;
IEnumerator ability27(byte[] array)
{
Entity cast = ByteToEntity(array[0],false);
Entity target = ByteToEntity(array[1],false);
yield return null;
if(array[2] == 0x01)
{
targetcode1 = target.ablcode1;
targetcode2 = target.ablcode2;
target.ablcode1 = 0;
target.ablcode2 = 0;
ParticleSystem confusion = Instantiate(AbilityManager.Inst.confusionParticle, target.transform.position, target.transform.rotation);
while (true)
{
yield return null;
target.attackable = false;
if (TurnManger.Inst.myTurn)
{
break;
}
}
while (true)
{
yield return null;
target.attackable = false;
if (!TurnManger.Inst.myTurn)
{
break;
}
}
}
else
{
Destroy(GameObject.FindGameObjectWithTag("Confusion"));
target.ablcode1 = targetcode1;
target.ablcode2 = targetcode2;
target.attackable = true;
}
}
//흡수
IEnumerator ability26(byte[] array)
{
Entity cast = ByteToEntity(array[0],false);
Entity target = ByteToEntity(array[1],false);
cast.health = cast.health + target.health;
cast.gameObject.transform.Find("TMP_DEF").transform.GetComponent<TextMeshPro>().text = cast.health.ToString();
cast.gameObject.transform.Find("TMP_DEF").transform.DOShakeScale(1.0f, 2, 10, 90, true);
cast.gameObject.transform.Find("TMP_DEF").transform.GetComponent<TextMeshPro>().fontMaterial = AbilityManager.Inst.redColor;
yield return new WaitForSeconds(0.5f);
EntityManeger.Inst.otherEntities.Remove(target);
target.transform.DOShakeScale(1.0f);
yield return new WaitForSeconds(1.0f);
Destroy(target.gameObject);
EntityManeger.Inst.EntityAlignment(true);
}
//불기둥
IEnumerator ability25(byte[] array)
{
List<GameObject> fires = new List<GameObject>();
List<Entity> dieEntity = new List<Entity>();
yield return null;
foreach(var target in EntityManeger.Inst.myEntities)
{
var fire = Instantiate(AbilityManager.Inst.firePrefab,target.transform.position,target.transform.rotation);
fires.Add(fire);
target.Damaged(1);
if(target.health <=0)
{
dieEntity.Add(target);
}
}
var fire2 = Instantiate(AbilityManager.Inst.firePrefab,EntityManeger.Inst.myBossEntity.transform.position,EntityManeger.Inst.myBossEntity.transform.rotation);
fires.Add(fire2);
EntityManeger.Inst.myBossEntity.Damaged(1);
yield return new WaitForSeconds(1.0f);
foreach(var fire in fires)
{
Destroy(fire.gameObject);
}
foreach(var target in EntityManeger.Inst.myEntities)
{
EntityManeger.Inst.SpawnDamage(1,target.transform);
}
EntityManeger.Inst.SpawnDamage(1,EntityManeger.Inst.myBossEntity.transform);
foreach(var row in dieEntity)
{
EntityManeger.Inst.AttackCallback(row);
}
yield return StartCoroutine(EntityManeger.Inst.CheckBossDie());
}
//구체
IEnumerator ability24(byte[] array)
{
Entity cast = ByteToEntity(array[0],false);
Entity target = ByteToEntity(array[1], true);
GameObject sword = Instantiate(AbilityManager.Inst.suuCircle, cast.transform.position, cast.transform.rotation);
Vector3 dir = target.transform.position - sword.transform.position;
float angle = Mathf.Atan2(dir.y, dir.x) * Mathf.Rad2Deg;
sword.transform.rotation = Quaternion.AngleAxis(-angle, Vector3.forward);
yield return new WaitForSeconds(1.0f);
AbilityManager.Inst.AbilityAttack(sword, target, AbilityManager.Inst.ABL24DAMAGE);
yield return new WaitForSeconds(1.0f);
Destroy(sword);
}
//낙인
IEnumerator ability23(byte[] array)
{
Entity cast = ByteToEntity(array[0],false);
Entity target = ByteToEntity(array[1], true);
GameObject sword = Instantiate(AbilityManager.Inst.demianSword, cast.transform.position, cast.transform.rotation);
Vector3 dir = target.transform.position - sword.transform.position;
float angle = Mathf.Atan2(dir.y, dir.x) * Mathf.Rad2Deg;
sword.transform.rotation = Quaternion.AngleAxis(-angle, Vector3.forward);
yield return new WaitForSeconds(1.0f);
AbilityManager.Inst.AbilityAttack(sword, target, AbilityManager.Inst.ABL23DAMAGE);
yield return new WaitForSeconds(1.0f);
Destroy(sword);
}
//쇠약
IEnumerator ability22(byte[] array)
{
yield return null;
if(array[1] == 0x01)
{
TurnManger.Inst.myGaugeCnt -= 1;
TurnManger.Inst.myNowGaugeCnt -= 1;
TurnManger.Inst.ConsumeCost(true, 0);
}
else
{
TurnManger.Inst.myGaugeCnt += 1;
TurnManger.Inst.myNowGaugeCnt += 1;
TurnManger.Inst.ConsumeCost(true, 0);
}
}
//절망
IEnumerator ability20(byte[] array)
{
Entity target = ByteToEntity(array[1],true);
yield return null;
target.attack = 0;
target.gameObject.transform.Find("TMP_ATT").transform.GetComponent<TextMeshPro>().text = target.attack.ToString();
target.gameObject.transform.Find("TMP_ATT").transform.DOShakeScale(1.0f, 2, 10, 90, true);
target.gameObject.transform.Find("TMP_ATT").transform.GetComponent<TextMeshPro>().fontMaterial = AbilityManager.Inst.blueColor;
}
//폭발
IEnumerator ability19(byte[] array)
{
foreach(var row in EntityManeger.Inst.myEntities)
{
row.health -=1;
yield return StartCoroutine(AbilityManager.Inst.UpdateATTDEF(row,false));
}
}
//자폭
IEnumerator ability17(byte[] array)
{
yield return null;
Entity attacker = ByteToEntity(array[0],false);
Entity defender = ByteToEntity(array[1],true);
Sequence sequence = DOTween.Sequence()
.Append(attacker.transform.DOMove(defender.transform.position, 0.4f)).SetEase(Ease.InSine)
.AppendCallback(() =>
{
defender.Damaged(defender.health);
attacker.Damaged(attacker.health);
EntityManeger.Inst.SpawnDamage(attacker.health, attacker.transform);
EntityManeger.Inst.SpawnDamage(defender.health, defender.transform);
})
.Append(attacker.transform.DOMove(attacker.transform.position, 0.4f)).SetEase(Ease.OutSine)
.OnComplete(() => EntityManeger.Inst.AttackCallback(attacker,defender));
}
//세트
IEnumerator ability16(byte[] array)
{
yield return null;
Entity target = ByteToEntity(array[0],false);
int change = Convert.ToInt32(array[1]);
target.attack += change;
target.health += change;
yield return StartCoroutine(AbilityManager.Inst.UpdateATTDEF(target,true));
}
//소멸
IEnumerator ability15(byte[] array)
{
yield return null;
Entity cast = ByteToEntity(array[0],false);
Entity casted = ByteToEntity(array[1], true);
EntityManeger.Inst.myEntities.Remove(casted);
casted.gameObject.transform.DOShakeScale(1.0f);
yield return new WaitForSeconds(1.2f);
Destroy(casted.gameObject);
EntityManeger.Inst.EntityAlignment(false);
}
//침묵
IEnumerator ability14()
{
yield return new WaitForSeconds(2.0f);
TurnManger.Inst.EndTurn();
}
//부활
IEnumerator ability13(byte[] array)
{
yield return null;
int code = ConvertInt(array[0],array[1],array[2]);
int index = Convert.ToInt32(array[3]);
Item _new = AbilityManager.Inst.SetEntity(code);
if(code == 122254)
_new.attack -=2*index;
else
_new.health +=index;
AbilityManager.Inst.SpawnEntity(_new);
}
//치유
IEnumerator ability11(byte[] array)
{
foreach(var row in EntityManeger.Inst.otherEntities)
{
row.health+=1;
yield return StartCoroutine(AbilityManager.Inst.UpdateATTDEF(row,true));
}
}
public Entity ByteToEntity(byte byt,bool isMine)
{
Entity entity = new Entity();
List<Entity> entities = isMine? EntityManeger.Inst.myEntities : EntityManeger.Inst.otherEntities;
foreach(var row in entities)
{
if(row.gameObject.name == byt.ToString())
{
entity = row;
}
}
if(entity == null)
return EntityManeger.Inst.myBossEntity;
else
return entity;
}
//감염
IEnumerator ability9(byte[] array)
{
yield return null;
Entity cast = ByteToEntity(array[0],false);
Entity casted = ByteToEntity(array[1],true);
casted.attack--;
casted.gameObject.transform.Find("TMP_ATT").transform.GetComponent<TextMeshPro>().text = casted.attack.ToString();
casted.gameObject.transform.Find("TMP_ATT").transform.DOShakeScale(1.0f, 2, 10, 90, true);
casted.gameObject.transform.Find("TMP_ATT").transform.GetComponent<TextMeshPro>().fontMaterial = AbilityManager.Inst.blueColor;
}
//오염
IEnumerator ability8(byte[] array)
{
foreach (var row in EntityManeger.Inst.myEntities)
{
row.attack -= 1;
yield return StartCoroutine(AbilityManager.Inst.UpdateATTDEF(row, false));
}
}
//소환
IEnumerator ability2(byte[] array)
{
yield return null;
EntityManeger.Inst.SpawnEntity(false,AbilityManager.Inst.SetEntity(ConvertInt(array[0],array[1],array[2])),CardManager.Inst.otherCardSpawnPoint.position);
}
//도발
IEnumerator ability1(byte[] array)
{
yield return null;
Entity target = new Entity();
if(array[0] == 0x00)
{
target =EntityManeger.Inst.otherBossEntity;
}
else
{
foreach (var row in EntityManeger.Inst.otherEntities)
{
if (row.gameObject.name == array[0].ToString())
{
target = row;
}
}
}
if(array[1] == 0x01)
{
target.canBeAttacked = true;
}
else
{
target.canBeAttacked = false;
}
}
public void BackAttack(byte[] array)
{
string attname = array[0].ToString();
string defname = array[1].ToString();
Entity attacker = new Entity();
Entity defender = new Entity();
foreach(var row in EntityManeger.Inst.otherEntities)
{
if(row.name == attname)
{
attacker = row;
}
}
if(defname == "0")
{
defender = EntityManeger.Inst.myBossEntity;
}
else
{
foreach (var row in EntityManeger.Inst.myEntities)
{
if (row.name == defname)
{
defender = row;
}
}
}
EntityManeger.Inst.Attack(attacker,defender);
}
public void SummonCard(byte[] array)
{
int code=0;
code += Convert.ToInt32(array[0])*10000;
code += Convert.ToInt32(array[1])*100;
code += Convert.ToInt32(array[2]);
CardManager.Inst.TryPutCard(false,code);
}
public int[] otherItem = new int[50];
public void SetOtherItem(byte[] array,int index)
{
if(index == 103)
{
for(int i = 0;i<otherItem.Length;i++)
{
otherItem[i]+=Convert.ToInt32(array[i])*10000;
}
}
else if(index == 104)
{
for(int i = 0;i<otherItem.Length;i++)
{
otherItem[i]+=Convert.ToInt32(array[i])*100;
}
}
else if(index == 105)
{
for(int i = 0;i<otherItem.Length;i++)
{
otherItem[i]+=Convert.ToInt32(array[i]);
}
}
}
public void func()
{
for(int i =0;i<50;i++)
{
Debug.Log(otherItem[i]);
}
}
//************************************************************************************************
public List<Item> LoadOtherdeck()
{
List<Item> otherItemBuffer = new List<Item>(50);
string[] type = new string[3] {"monster.xml","magic.xml","equip.xml"};
foreach(var key in otherItem)
{
if(key.ToString().Substring(0,1)== "1")
{
XDocument document = XDocument.Load(@"C:\nexon_maplestory_battle_monsters_league_s\Assets\Resources\CARD\xml\" + type[0]);
var books = from row in document.Descendants("row")
where(row.Element("CODE").Value == key.ToString())
select new
{
name = row.Element("NAME").Value,
grade = row.Element("GRADE").Value,
cost = row.Element("COST").Value,
att = row.Element("ATT").Value,
def = row.Element("DEF").Value,
abl = row.Element("ABL").Value,
code = row.Element("CODE").Value,
area = row.Element("AREA").Value,
ablcode = row.Element("ABLCODE").Value,
link = row.Element("LINK").Value
};
foreach(var row in books)
{
Item item = new Item();
item.name = row.name;
item.grade = int.Parse(row.grade);
item.cost = Resources.Load<Sprite>("CARD/num/"+row.cost);
item.cost_num = int.Parse(row.cost);
item.attack = int.Parse(row.att);
item.health=int.Parse(row.def);
item.abl = row.abl;
item.code = int.Parse(row.code);
item.main = Resources.Load<Sprite>("CARD/monster/"+row.code);
item.background = Resources.Load<Sprite>("CARD/background/"+row.area);
item.cardbase = CardManager.Inst.card_base_mon[item.grade];
item.ablcode = row.ablcode;
item.link = row.link;
otherItemBuffer.Add(item);
}
}
if(key.ToString().Substring(0,1)== "2")
{
XDocument document = XDocument.Load(@"C:\nexon_maplestory_battle_monsters_league_s\Assets\Resources\CARD\xml\" + type[1]);
var books = from row in document.Descendants("row")
where(row.Element("CODE").Value == key.ToString())
select new
{
name = row.Element("NAME").Value,
grade = row.Element("GRADE").Value,
cost = row.Element("COST").Value,
abl = row.Element("ABL").Value,
code = row.Element("CODE").Value
};
foreach (var row in books)
{
Item item = new Item();
item.name = row.name;
item.grade = int.Parse(row.grade);
item.cost = Resources.Load<Sprite>("CARD/num/" + row.cost);
item.cost_num = int.Parse(row.cost);
item.attack = -1;
item.health = -1;
item.abl = row.abl;
item.code = int.Parse(row.code);
if (int.Parse(row.code.Substring(3, 2)) <= 27)
{
item.background = Resources.Load<Sprite>("CARD/magic/" + row.code);
item.cardbase = CardManager.Inst.card_base[item.grade];
item.main = null;
}
otherItemBuffer.Add(item);
}
}
if(key.ToString().Substring(0,1)== "3")
{
XDocument document = XDocument.Load(@"C:\nexon_maplestory_battle_monsters_league_s\Assets\Resources\CARD\xml\" + type[2]);
var books = from row in document.Descendants("row")
where(row.Element("CODE").Value == key.ToString())
select new
{
name = row.Element("NAME").Value,
grade = row.Element("GRADE").Value,
cost = row.Element("COST").Value,
att = row.Element("ATT").Value,
def = row.Element("DEF").Value,
abl = row.Element("ABL").Value,
code = row.Element("CODE").Value
};
foreach (var row in books)
{
Item item = new Item();
item.name = row.name;
item.grade = int.Parse(row.grade);
item.cost = Resources.Load<Sprite>("CARD/num/" + row.cost);
item.attack = int.Parse(row.att);
item.health = int.Parse(row.def);
item.abl = row.abl;
item.code = int.Parse(row.code);
item.cardbase = CardManager.Inst.card_base_mon[item.grade];
item.cost_num = int.Parse(row.cost);
item.background = CardManager.Inst.back[item.grade];
item.main = Resources.Load<Sprite>("CARD/equip/" + row.code);
otherItemBuffer.Add(item);
}
}
}
return otherItemBuffer;
}
}
//cursor.cs
using UnityEngine;
using System.Collections;
using UnityEngine.SceneManagement;
public class cursor : MonoBehaviour
{
public Texture2D CT_normal;
public Texture2D[] CT_focus;
public Texture2D CT_attack;
public Texture2D CT_view;
public Texture2D CT_btn;
public Texture2D CT_btnclick;
public Texture2D CT_cardon;
public Texture2D CT_catch;
public static cursor Inst { get; private set; }
void Awake() => Inst = this;
public void Start()
{
StartCoroutine(Normal());
}
public IEnumerator Normal()
{
yield return null;
Cursor.SetCursor(CT_normal, Vector2.zero, CursorMode.Auto);
}
public void Normal1()
{
Cursor.SetCursor(CT_normal, Vector2.zero, CursorMode.Auto);
}
public IEnumerator Focus()
{
for (int i = 0; i < 7; i++)
{
Cursor.SetCursor(cursor.Inst.CT_focus[i], Vector2.zero, CursorMode.Auto);
yield return new WaitForSeconds(0.2f);
}
}
public IEnumerator View()
{
yield return null;
Cursor.SetCursor(CT_view,Vector2.zero,CursorMode.Auto);
}
public IEnumerator Attack()
{
yield return null;
Cursor.SetCursor(CT_attack,Vector2.zero,CursorMode.Auto);
}
public void OnBtn()
{
Cursor.SetCursor(CT_btn,Vector2.zero,CursorMode.Auto);
}
public void ClickBtn()
{
Cursor.SetCursor(CT_btnclick,Vector2.zero,CursorMode.Auto);
}
public IEnumerator OnCard()
{
yield return null;
Cursor.SetCursor(CT_cardon,Vector2.zero,CursorMode.Auto);
}
public IEnumerator CatchCard()
{
yield return null;
Cursor.SetCursor(CT_catch,Vector2.zero,CursorMode.Auto);
}
public void SceneChanger(string scene)
{
SceneManager.LoadScene(scene);
}
}
//EndTurnBtn.cs
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class EndTurnBtn : MonoBehaviour
{
[SerializeField] Sprite active;
[SerializeField] Sprite inactive;
[SerializeField] Text btnText;
void Start()
{
Setup(false);
TurnManger.OnTurnStarted +=Setup;
}
void OnDestroy()
{
TurnManger.OnTurnStarted -=Setup;
}
public void Setup(bool isActive)
{
GetComponent<Image>().sprite = isActive ? active : inactive;
GetComponent<Button>().interactable = isActive;
btnText.color = isActive ? new Color32(255,195,90,255) : new Color32(55,55,55,255);
}
}
//Notification.cs
using System.Numerics;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using TMPro;
using DG.Tweening;
public class Notification : MonoBehaviour
{
[SerializeField] TMP_Text notificationTMP;
public void Show(string message)
{
notificationTMP.text=message;
Sequence sequence = DOTween.Sequence()
.Append(transform.DOScale(UnityEngine.Vector3.one,0.3f).SetEase(Ease.InOutQuad))
.AppendInterval(0.9f)
.Append(transform.DOScale(UnityEngine.Vector3.zero,0.3f).SetEase(Ease.InOutQuad));
}
void Start() => ScaleZero();
[ContextMenu("ScaleOne")]
void ScaleOne() => transform.localScale = UnityEngine.Vector3.one;
[ContextMenu("ScaleZero")]
public void ScaleZero() => transform.localScale = UnityEngine.Vector3.zero;
}
//ResultPanel.cs
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using TMPro;
using DG.Tweening;
using UnityEngine.SceneManagement;
public class ResultPanel : MonoBehaviour
{
[SerializeField] TMP_Text resultTMP;
public void Show(string message)
{
resultTMP.text=message;
transform.DOScale(Vector3.one,0.5f).SetEase(Ease.InOutQuad);
}
public void Comeback()
{
SceneManager.LoadScene(1);
}
void start() =>ScaleZero();
[ContextMenu("ScaleOne")]
void ScaleOne() =>transform.localScale =Vector3.one;
[ContextMenu("ScaleZero")]
public void ScaleZero() => transform.localScale =Vector3.zero;
}
using System.Threading;
using System;
using System.Numerics;
using System.Data;
using System.Xml;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using BackEnd;
using System.Xml.Linq;
using System.Linq;
using Vector3 = UnityEngine.Vector3;
using DG.Tweening;
public class CardManager : MonoBehaviour
{
public GameObject CardList;
public Sprite[] card_base_mon;
public Sprite[] card_base;
public Sprite[] back;
public static CardManager Inst{get; private set;}
void Awake() =>Inst = this;
[SerializeField] ItemSO itemSO;
[SerializeField] GameObject cardPrefab;
[SerializeField] public List<Card> myCards;
[SerializeField] public List<Card> otherCards;
[SerializeField] Transform cardSpwanPoint;
[SerializeField] public Transform otherCardSpawnPoint;
[SerializeField] Transform myCardLeft;
[SerializeField] Transform myCardRight;
[SerializeField] Transform otherCardLeft;
[SerializeField] Transform otherCardRight;
[SerializeField] ECardState eCardState;
[SerializeField] GameObject myDeck;
enum ECardState {Nothing,CanMouseOver,CanMouseDrag}
public List<Item> itemBuffer;
public List<Item> otherItemBuffer;
public byte[] myitem;
Card selectCard;
bool isMyCardDrag;
bool onMyCardArea;
int myPutCount;
public byte[] aitembuffer = new byte[50];
public byte[] bitembuffer = new byte[50];
public byte[] citembuffer = new byte[50];
void ShuffleItemBuffer()
{
for(int i=0;i<itemBuffer.Count;i++)
{
int rand = UnityEngine.Random.Range(i,itemBuffer.Count);
Item temp = itemBuffer[i];
itemBuffer[i]=itemBuffer[rand];
itemBuffer[rand]=temp;
}
}
public void SetItemBuffer()
{
int i = 0;
foreach(var row in itemBuffer)
{
aitembuffer[i] = Convert.ToByte(int.Parse(row.code.ToString().Substring(0,2)));
bitembuffer[i] = Convert.ToByte(int.Parse(row.code.ToString().Substring(2,2)));
citembuffer[i] = Convert.ToByte(int.Parse(row.code.ToString().Substring(4,2)));
i++;
}
}
public Item PopItem(bool isMine)
{
List<Item> items = isMine ? itemBuffer : otherItemBuffer;
if(items.Count ==0)
{
Debug.Log("끝");
return null;
}
Item item = items[0];
items.RemoveAt(0);
return item;
}
public Item PopItemToCode(int code)
{
int index =0;
foreach(var item in itemBuffer)
{
if(item.code == code)
{
itemBuffer.RemoveAt(index);
return item;
}
index++;
}
return null;
}
void Start()
{
LoadMydeck();
ShuffleItemBuffer();
SetItemBuffer();
TurnManger.OnAddCard +=AddCard;
TurnManger.OnTurnStarted +=OnTurnStarted;
}
void OnDestroy()
{
TurnManger.OnAddCard -=AddCard;
TurnManger.OnTurnStarted -=OnTurnStarted;
}
void OnTurnStarted(bool myTurn)
{
if(myTurn)
myPutCount =0;
}
void Update()
{
if(isMyCardDrag)
CardDrag();
DetectCardArea();
SetECardState();
}
public void AddCard(bool isMine)
{
if(isMine)
{
var cardObject = Instantiate(cardPrefab,cardSpwanPoint.position,Utils.QI);
var card =cardObject.GetComponent<Card>();
card.Setup(PopItem(isMine), isMine);
myCards.Add(card);
cardObject.transform.parent = CardList.transform;
SetOriginOrder(isMine);
CardAlignment(isMine);
byte[] send = new byte[1] {Convert.ToByte(107)};
Backend.Match.SendDataToInGameRoom(send);
}
else
{
var cardObject = Instantiate(cardPrefab,otherCardSpawnPoint.position,Utils.QI);
var card =cardObject.GetComponent<Card>();
card.Setup(PopItem(isMine), isMine);
otherCards.Add(card);
SetOriginOrder(isMine);
CardAlignment(isMine);
}
}
void SetOriginOrder(bool isMine)
{
int count = isMine ? myCards.Count : otherCards.Count;
for(int i=0;i<count;i++)
{
var targetCard = isMine ? myCards[i] : otherCards[i];
targetCard?.GetComponent<Order>().SetOriginOrder(i);
}
}
public void CardAlignment(bool isMine)
{
List<PRS> originCardPRSs = new List<PRS>();
if(isMine)
{
originCardPRSs =RoundAlignment(myCardLeft,myCardRight,myCards.Count,0.5f,UnityEngine.Vector3.one*0.8f);
}
else
{
originCardPRSs =RoundAlignment(otherCardLeft,otherCardRight,otherCards.Count,-0.5f,UnityEngine.Vector3.one*0.8f);
}
var targetCards = isMine ? myCards : otherCards;
for(int i =0;i<targetCards.Count;i++)
{
var targetCard =targetCards[i];
targetCard.originPRS = originCardPRSs[i];
targetCard.MoveTransform(targetCard.originPRS,true,0.7f);
}
}
List<PRS> RoundAlignment(Transform leftTr, Transform rightTr, int objCount, float height,UnityEngine.Vector3 scale)
{
float[] objLerps =new float[objCount];
List<PRS> results =new List<PRS>(objCount);
switch(objCount)
{
case 1: objLerps =new float[] {0.5f}; break;
case 2: objLerps =new float[] {0.27f, 0.73f}; break;
case 3: objLerps =new float[] {0.1f,0.5f,0.9f};break;
default:
float interval = 1f / (objCount-1);
for (int i=0;i<objCount;i++)
objLerps[i]=interval*i;
break;
}
for(int i=0;i<objCount;i++)
{
var targetPos = UnityEngine.Vector3.Lerp(leftTr.position,rightTr.position,objLerps[i]);
var targetRot = Utils.QI;
if(objCount>=4)
{
float curve = Mathf.Sqrt(Mathf.Pow(height,2)- Mathf.Pow(objLerps[i]-0.5f,2));
curve = height >= 0 ? curve : -curve;
targetPos.y +=curve;
targetRot =UnityEngine.Quaternion.Slerp(leftTr.rotation,rightTr.rotation,objLerps[i]);
}
results.Add(new PRS(targetPos,targetRot,scale));
}
return results;
}
public bool TryPutCard(bool isMine, int code)
{
if (isMine)
{
Card card = selectCard;
var spawnPos = Utils.MousePos;
var targetCards = myCards;
if (card.item.cost_num <= TurnManger.Inst.myNowGaugeCnt)
{
if (EntityManeger.Inst.SpawnEntity(isMine, card.item, spawnPos))
{
targetCards.Remove(card);
card.transform.DOKill();
DestroyImmediate(card.gameObject);
if (isMine)
{
selectCard = null;
myPutCount++;
TurnManger.Inst.ConsumeCost(isMine, card.item.cost_num);
}
CardAlignment(isMine);
AbilityManager.Inst.eTurnState = AbilityManager.ETurnState.summonsMon;
AbilityManager.Inst.stateTrigger = true;
BackEndMatch.SendSpawn(card.item.code);
return true;
}
else
{
targetCards.ForEach(x => x.GetComponent<Order>().SetMostFrontOrder(false));
CardAlignment(isMine);
return false;
}
}
else
{
return false;
}
}
else
{
Card card = new Card();
for(int i =0;i<otherCards.Count;i++)
{
if(otherCards[i].item.code==code)
{
card = otherCards[i];
}
}
var spawnPos = otherCardSpawnPoint.position;
var targetCards = otherCards;
if (EntityManeger.Inst.SpawnEntity(isMine, card.item, spawnPos))
{
targetCards.Remove(card);
card.transform.DOKill();
DestroyImmediate(card.gameObject);
if (isMine)
{
selectCard = null;
myPutCount++;
TurnManger.Inst.ConsumeCost(isMine, card.item.cost_num);
}
CardAlignment(isMine);
return true;
}
else
{
targetCards.ForEach(x => x.GetComponent<Order>().SetMostFrontOrder(false));
CardAlignment(isMine);
return false;
}
}
}
#region MyCard
public void CardMouseOver(Card card)
{
if(eCardState==ECardState.Nothing)
return;
selectCard = card;
EnlargeCard(true,card);
}
public void CardMouseExit(Card card)
{
EnlargeCard(false,card);
}
public void CardMouseDown()
{
if(eCardState !=ECardState.CanMouseDrag)
return;
isMyCardDrag =true;
}
public void CardMouseUp()
{
isMyCardDrag =false;
if(eCardState !=ECardState.CanMouseDrag)
return;
if(onMyCardArea)
EntityManeger.Inst.RemoveMyEmptyEntity();
else
TryPutCard(true,selectCard.item.code);
}
void CardDrag()
{
if(eCardState !=ECardState.CanMouseDrag)
return;
if(!onMyCardArea)
{
selectCard.MoveTransform(new PRS(Utils.MousePos,Utils.QI,selectCard.originPRS.scale*0.8f),false);
EntityManeger.Inst.InsertMyEmptyEntity(Utils.MousePos.x);
}
}
void DetectCardArea()
{
RaycastHit2D[] hits =Physics2D.RaycastAll(Utils.MousePos,Vector3.forward);
int layer =LayerMask.NameToLayer("MyCardArea");
onMyCardArea =Array.Exists(hits, x=>x.collider.gameObject.layer ==layer);
}
void EnlargeCard(bool isEnlarge, Card card)
{
if(isEnlarge)
{
UnityEngine.Vector3 enlargePos = new UnityEngine.Vector3(card.originPRS.pos.x,-10f,-10f);
card.MoveTransform(new PRS(enlargePos,Utils.QI,Vector3.one*1.0f),false);
}
else
card.MoveTransform(card.originPRS,false);
card.GetComponent<Order>().SetMostFrontOrder(isEnlarge);
}
void SetECardState()
{
if(TurnManger.Inst.isLoading)
eCardState = ECardState.Nothing;
else if(!TurnManger.Inst.myTurn || TurnManger.Inst.myNowGaugeCnt <=0)
eCardState =ECardState.CanMouseOver;
else if(TurnManger.Inst.myTurn)
eCardState = ECardState.CanMouseDrag;
}
#endregion
//*******************************덱 불러오기******************************************
public void LoadMydeck()
{
itemBuffer = new List<Item>(50);
string[] type = new string[3] {"monster.xml","magic.xml","equip.xml"};
var bro = Backend.GameData.GetMyData("character",new Where());
var keys = bro.Rows()[0]["deck"][0].Keys;
foreach(var key in keys)
{
if(key.Substring(0,1)== "1")
{
XDocument document = XDocument.Load(@"C:\nexon_maplestory_battle_monsters_league_s\Assets\Resources\CARD\xml\" + type[0]);
var books = from row in document.Descendants("row")
where(row.Element("CODE").Value == key)
select new
{
name = row.Element("NAME").Value,
grade = row.Element("GRADE").Value,
cost = row.Element("COST").Value,
att = row.Element("ATT").Value,
def = row.Element("DEF").Value,
abl = row.Element("ABL").Value,
code = row.Element("CODE").Value,
area = row.Element("AREA").Value,
ablcode = row.Element("ABLCODE").Value,
link = row.Element("LINK").Value
};
for(int i=0;i<int.Parse(bro.Rows()[0]["deck"][0][key][0].ToString());i++)
{
foreach(var row in books)
{
Item item = new Item();
item.name = row.name;
item.grade = int.Parse(row.grade);
item.cost = Resources.Load<Sprite>("CARD/num/"+row.cost);
item.cost_num = int.Parse(row.cost);
item.attack = int.Parse(row.att);
item.health=int.Parse(row.def);
item.abl = row.abl;
item.code = int.Parse(row.code);
item.main = Resources.Load<Sprite>("CARD/monster/"+row.code);
item.background = Resources.Load<Sprite>("CARD/background/"+row.area);
item.cardbase = card_base_mon[item.grade];
item.ablcode = row.ablcode;
item.link = row.link;
itemBuffer.Add(item);
}
}
}
if(key.Substring(0,1)== "2")
{
XDocument document = XDocument.Load(@"C:\nexon_maplestory_battle_monsters_league_s\Assets\Resources\CARD\xml\" + type[1]);
var books = from row in document.Descendants("row")
where(row.Element("CODE").Value == key)
select new
{
name = row.Element("NAME").Value,
grade = row.Element("GRADE").Value,
cost = row.Element("COST").Value,
abl = row.Element("ABL").Value,
code = row.Element("CODE").Value
};
for(int i=0;i<int.Parse(bro.Rows()[0]["deck"][0][key][0].ToString());i++)
{
foreach(var row in books)
{
Item item = new Item();
item.name = row.name;
item.grade = int.Parse(row.grade);
item.cost = Resources.Load<Sprite>("CARD/num/"+row.cost);
item.cost_num = int.Parse(row.cost);
item.attack = -1;
item.health=-1;
item.abl = row.abl;
item.code = int.Parse(row.code);
if(int.Parse(row.code.Substring(3,2))<=27)
{
item.background = Resources.Load<Sprite>("CARD/magic/"+row.code);
item.cardbase =card_base[item.grade];
item.main = null;
}
itemBuffer.Add(item);
}
}
}
if(key.Substring(0,1)== "3")
{
XDocument document = XDocument.Load(@"C:\nexon_maplestory_battle_monsters_league_s\Assets\Resources\CARD\xml\" + type[2]);
var books = from row in document.Descendants("row")
where(row.Element("CODE").Value == key)
select new
{
name = row.Element("NAME").Value,
grade = row.Element("GRADE").Value,
cost = row.Element("COST").Value,
att = row.Element("ATT").Value,
def = row.Element("DEF").Value,
abl = row.Element("ABL").Value,
code =row.Element("CODE").Value
};
for(int i=0;i<int.Parse(bro.Rows()[0]["deck"][0][key][0].ToString());i++)
{
foreach(var row in books)
{
Item item = new Item();
item.name = row.name;
item.grade = int.Parse(row.grade);
item.cost = Resources.Load<Sprite>("CARD/num/"+row.cost);
item.attack = int.Parse(row.att);
item.health=int.Parse(row.def);
item.abl = row.abl;
item.code = int.Parse(row.code);
item.cardbase = card_base_mon[item.grade];
item.cost_num = int.Parse(row.cost);
item.background = back[item.grade];
item.main = Resources.Load<Sprite>("CARD/equip/"+row.code);
itemBuffer.Add(item);
}
}
}
}
}
}
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using TMPro;
using DG.Tweening;
public class Card : MonoBehaviour
{
[SerializeField] SpriteRenderer Img_main;
[SerializeField] SpriteRenderer card;
[SerializeField] SpriteRenderer Img_cardbase;
[SerializeField] SpriteRenderer Img_background;
[SerializeField] TMP_Text TMP_name;
[SerializeField] TMP_Text TMP_ATT;
[SerializeField] TMP_Text TMP_DEF;
[SerializeField] TMP_Text TMP_ABL;
[SerializeField] SpriteRenderer Img_cost;
[SerializeField] Sprite cardBack;
[SerializeField] string ablcode;
public Item item;
bool isFront;
public PRS originPRS;
public void Setup(Item item, bool isFront)
{
this.item =item;
this.isFront = isFront;
if(this.isFront)
{
card.sprite = null;
Img_main.sprite = this.item.main;
TMP_name.text =this.item.name;
TMP_ATT.text =this.item.attack.ToString();
TMP_DEF.text=this.item.health.ToString();
TMP_ABL.text =this.item.abl;
Img_cost.sprite = this.item.cost;
Img_cardbase.sprite=this.item.cardbase;
Img_background.sprite=this.item.background;
ablcode = this.item.ablcode;
}
else
{
card.sprite =cardBack;
Img_cost.enabled = false;
Img_main.enabled = false;
}
}
public void MoveTransform(PRS prs, bool useDotween, float dotweenTime =0)
{
if(useDotween)
{
transform.DOMove(prs.pos,dotweenTime);
transform.DORotateQuaternion(prs.rot,dotweenTime);
transform.DOScale(prs.scale,dotweenTime);
}
else
{
transform.position=prs.pos;
transform.rotation=prs.rot;
transform.localScale =prs.scale;
}
}
void OnMouseOver()
{
if(isFront)
{
CardManager.Inst.CardMouseOver(this);
}
}
void OnMouseExit()
{
if(isFront)
{
StartCoroutine(cursor.Inst.Normal());
CardManager.Inst.CardMouseExit(this);
}
}
void OnMouseEnter()
{
if(isFront)
StartCoroutine(cursor.Inst.OnCard());
}
void OnMouseDown()
{
if(isFront)
{
CardManager.Inst.CardMouseDown();
StartCoroutine(cursor.Inst.CatchCard());
}
}
void OnMouseUp()
{
if(isFront)
{
CardManager.Inst.CardMouseUp();
}
}
}
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using DG.Tweening;
public class EntityManeger : MonoBehaviour
{
public static EntityManeger Inst { get; private set; }
void Awake() => Inst = this;
[SerializeField] GameObject entityPrefab;
[SerializeField] public List<Entity> myEntities;
[SerializeField] public List<Entity> otherEntities;
[SerializeField] Entity myEmptyEntity;
[SerializeField] public Entity myBossEntity;
[SerializeField] public Entity otherBossEntity;
[SerializeField] GameObject TargetPicker;
[SerializeField] GameObject attackEntityPicker;
[SerializeField] GameObject damagePrefab;
const int MAX_ENTITY_COUNT = 10;
public bool IsFullMyEntities => myEntities.Count >= MAX_ENTITY_COUNT && !ExitMyEmptyEntity;
bool IsFullOtherEntities => otherEntities.Count >= MAX_ENTITY_COUNT;
bool ExitMyEmptyEntity => myEntities.Exists(x => x == myEmptyEntity);
bool ExistTargetPickEntity => targetPickEntity != null;
public int myEmptyEntityIndex => myEntities.FindIndex(x => x == myEmptyEntity);
bool CanMouseInput => TurnManger.Inst.myTurn && !TurnManger.Inst.isLoading;
public Entity selectEntity;
public Entity targetPickEntity;
public Entity targetEntity;
public Entity castEntity;
WaitForSeconds delay1 = new WaitForSeconds(1);
WaitForSeconds delay2 = new WaitForSeconds(2);
public int myEntityNum = 1;
public int otherEntityNum = 1;
public string SetEntityNum(bool isMine)
{
string thisEntityNum = "";
if(isMine)
{
thisEntityNum = myEntityNum.ToString();
myEntityNum++;
}
else
{
thisEntityNum = otherEntityNum.ToString();
otherEntityNum++;
}
return thisEntityNum;
}
void Start()
{
TurnManger.OnTurnStarted += OnTurnStarted;
}
void OnDestroy()
{
TurnManger.OnTurnStarted -= OnTurnStarted;
}
void OnTurnStarted(bool myTurn)
{
AttackableReset(myTurn);
}
void Update()
{
ShowTargetPicker(ExistTargetPickEntity);
}
public IEnumerator CheckBossDie()
{
yield return delay2;
if (myBossEntity.isDie)
StartCoroutine(GameManager.Inst.GameOver(false));
if (otherBossEntity.isDie)
StartCoroutine(GameManager.Inst.GameOver(true));
}
void ShowTargetPicker(bool isShow)
{
TargetPicker.SetActive(isShow);
if (ExistTargetPickEntity)
TargetPicker.transform.position = targetPickEntity.transform.position;
}
public void EntityAlignment(bool isMine)
{
float targetY = isMine ? -6.0f : 6.0f;
var targetEntities = isMine ? myEntities : otherEntities;
for (int i = 0; i < targetEntities.Count; i++)
{
float targetX = (targetEntities.Count - 1) * -2.5f + i * 5.0f;
var targetEntity = targetEntities[i];
targetEntity.originPos = new Vector3(targetX, targetY, 0);
targetEntity.MoveTransform(targetEntity.originPos, true, 0.5f);
targetEntity.GetComponent<Order>()?.SetOriginOrder(i);
}
}
public void InsertMyEmptyEntity(float xPos)
{
if (IsFullMyEntities)
return;
if (!ExitMyEmptyEntity)
myEntities.Add(myEmptyEntity);
Vector3 EmptyEntityPos = myEmptyEntity.transform.position;
EmptyEntityPos.x = xPos;
myEmptyEntity.transform.position = EmptyEntityPos;
int _emptyEntityIndex = myEmptyEntityIndex;
myEntities.Sort((entity1, entity2) => entity1.transform.position.x.CompareTo(entity2.transform.position.x));
if (myEmptyEntityIndex != _emptyEntityIndex)
EntityAlignment(true);
}
public void RemoveMyEmptyEntity()
{
if (!ExitMyEmptyEntity)
return;
myEntities.RemoveAt(myEmptyEntityIndex);
EntityAlignment(true);
}
public bool SpawnEntity(bool isMine, Item item, Vector3 spawnPos)
{
if (isMine)
{
if (IsFullMyEntities || !ExitMyEmptyEntity)
return false;
}
else
{
if (IsFullOtherEntities)
return false;
}
var entityObject = Instantiate(entityPrefab, spawnPos, Utils.QI);
var entity = entityObject.GetComponent<Entity>();
if (isMine)
{
myEntities[myEmptyEntityIndex] = entity;
entity.name = SetEntityNum(isMine);
}
else
{
otherEntities.Insert(UnityEngine.Random.Range(0, otherEntities.Count), entity);
entity.name = SetEntityNum(isMine);
}
entity.isMine = isMine;
entity.Setup(item);
EntityAlignment(isMine);
return true;
}
public void EntityMouseDown(Entity entity)
{
if (!CanMouseInput)
return;
selectEntity = entity;
AbilityManager.Inst.eTurnState = AbilityManager.ETurnState.drag;
AbilityManager.Inst.stateTrigger = true;
}
public void EntityMouseUp()
{
if (!CanMouseInput)
return;
if (selectEntity && targetPickEntity && selectEntity.attackable)
Attack(selectEntity, targetPickEntity);
selectEntity = null;
targetPickEntity = null;
}
public void EntityMouseDrag()
{
if (!CanMouseInput || selectEntity == null)
return;
bool existTarget = false;
foreach (var hit in Physics2D.RaycastAll(Utils.MousePos, Vector3.forward))
{
Entity entity = hit.collider?.GetComponent<Entity>();
if (entity != null && !entity.isMine && selectEntity.attackable)
{
targetPickEntity = entity;
targetEntity = entity;
existTarget = true;
break;
}
}
if (!existTarget)
targetPickEntity = null;
}
public void AttackableReset(bool isMine)
{
var targetEntities = isMine ? myEntities : otherEntities;
targetEntities.ForEach(x => x.attackable = true);
}
public Entity castedEntitiy;
public void Attack(Entity attacker, Entity defender)
{
if (defender.canBeAttacked == false && attacker.ablcode1 !=21)
{
return;
}
attacker.attackable = false;
attacker.GetComponent<Order>().SetMostFrontOrder(true);
if (attacker.isMine)
{
if (defender.isBossOrEmpty)
{
byte[] send = new byte[3] { 0x00, Convert.ToByte(attacker.gameObject.name), Convert.ToByte("0") };
BackEndMatch.SendMessage(send);
}
else
{
byte[] send = new byte[3] { 0x00, Convert.ToByte(attacker.gameObject.name), Convert.ToByte(defender.gameObject.name) };
BackEndMatch.SendMessage(send);
}
AbilityManager.Inst.eTurnState = AbilityManager.ETurnState.attacking;
AbilityManager.Inst.stateTrigger = true;
if (AbilityManager.Inst.abilityNum[attacker.ablcode1].state == (int)AbilityManager.ETurnState.attacking || AbilityManager.Inst.abilityNum[defender.ablcode1].state == (int)AbilityManager.ETurnState.beAttacked)
{
castEntity = attacker;
return;
}
}
Sequence sequence = DOTween.Sequence()
.Append(attacker.transform.DOMove(defender.transform.position, 0.4f)).SetEase(Ease.InSine)
.AppendCallback(() =>
{
attacker.Damaged(defender.attack);
defender.Damaged(attacker.attack);
SpawnDamage(defender.attack, attacker.transform);
SpawnDamage(attacker.attack, defender.transform);
})
.Append(attacker.transform.DOMove(attacker.originPos, 0.4f)).SetEase(Ease.OutSine)
.OnComplete(() => AttackCallback(attacker, defender));
StartCoroutine(cursor.Inst.Attack());
}
public void AttackCallback(params Entity[] entities)
{
entities[0].GetComponent<Order>().SetMostFrontOrder(false);
foreach (var entity in entities)
{
if (!entity.isDie || entity.isBossOrEmpty)
continue;
if (entity.isMine)
{
AbilityManager.Inst.eTurnState = AbilityManager.ETurnState.myMonDie;
AbilityManager.Inst.stateTrigger = true;
if(AbilityManager.Inst.abilityNum[entity.ablcode1].state == (int)AbilityManager.ETurnState.myMonDie)
{
castEntity = entity;
}
myEntities.Remove(entity);
}
else
otherEntities.Remove(entity);
Sequence sequence = DOTween.Sequence()
.Append(entity.transform.DOShakePosition(1.0f))
.Append(entity.transform.DOScale(Vector3.zero, 0.3f)).SetEase(Ease.OutCirc)
.OnComplete(() =>
{
EntityAlignment(entity.isMine);
Destroy(entity.gameObject);
});
}
StartCoroutine(CheckBossDie());
}
public void SpawnDamage(int damage, Transform tr)
{
if (damage <= 0)
return;
var damageComponent = Instantiate(damagePrefab).GetComponent<Damage>();
damageComponent.SetupTransform(tr);
damageComponent.Damaged(damage);
}
}
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using TMPro;
using DG.Tweening;
public class Entity : MonoBehaviour
{
[SerializeField] Item item;
[SerializeField] SpriteRenderer entity;
[SerializeField] SpriteRenderer character;
[SerializeField] TMP_Text nameTMP;
[SerializeField] TMP_Text attackTMP;
[SerializeField] TMP_Text healthTMP;
[SerializeField] GameObject sleepParticle;
public int code;
public int attack;
public int ablcode1, ablcode2;
public int health;
public bool attackable;
public bool isMine;
public bool isBossOrEmpty;
public bool canBeAttacked;
public int grade;
public Vector3 originPos;
public int livecnt;
public bool isDie;
public List<string> link;
public bool dual;
private void Start() {
TurnManger.OnTurnStarted +=OnTurnStarted;
}
private void OnDestroy() {
TurnManger.OnTurnStarted -=OnTurnStarted;
}
void OnTurnStarted(bool myTurn)
{
if(isBossOrEmpty)
return;
if(isMine==myTurn)
livecnt++;
sleepParticle.SetActive(livecnt<1);
}
public void Setup(Item item)
{
dual = false;
code = item.code;
grade = item.grade;
canBeAttacked =true;
attack =item.attack;
health =item.health;
this.item =item;
character.sprite =this.item.main;
nameTMP.text=this.item.name;
attackTMP.text=this.item.attack.ToString();
healthTMP.text=this.item.health.ToString();
ablcode1 = int.Parse(this.item.ablcode.Substring(0,2));
ablcode2 = int.Parse(this.item.ablcode.Substring(2,2));
if(item.link.Length>1)
{
string[] splitTxt =item.link.Split(',');
for(int i=0;i<splitTxt.Length;i++)
{
link.Add(splitTxt[i]);
}
}
}
public void MoveTransform(Vector3 pos, bool useDotween, float dotweenTime=0)
{
if(useDotween)
transform.DOMove(pos,dotweenTime);
else
transform.position = pos;
}
public bool Damaged(int damage)
{
health -=damage;
healthTMP.text =health.ToString();
if(health<=0)
{
isDie =true;
return true;
}
return false;
}
void OnMouseDown()
{
// ToolTipManager.Inst.ToolOut();
if(isMine)
EntityManeger.Inst.EntityMouseDown(this);
}
void OnMouseUp()
{
if(isMine)
EntityManeger.Inst.EntityMouseUp();
}
void OnMouseDrag()
{
if(isMine)
EntityManeger.Inst.EntityMouseDrag();
}
void OnMouseOver()
{
if(EntityManeger.Inst.selectEntity == null)
ToolTipManager.Inst.Tool(this);
}
void OnMouseEnter()
{
if(Input.GetMouseButton(0))
StartCoroutine(cursor.Inst.Focus());
else
{
if (this.isMine)
{
StartCoroutine(cursor.Inst.Normal());
}
else
{
StartCoroutine(cursor.Inst.View());
}
}
}
void OnMouseExit()
{
ToolTipManager.Inst.ToolOut();
StartCoroutine(cursor.Inst.Normal());
}
}
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class GameManager : MonoBehaviour
{
[SerializeField] Notification notification;
[SerializeField] ResultPanel resultPanel;
[SerializeField] GameObject endTurnBtn;
[SerializeField] CameraEffect cameraEffect;
public static GameManager Inst{ get;private set;}
WaitForSeconds delay2 = new WaitForSeconds(2);
WaitForSeconds delay1 = new WaitForSeconds(1);
void Awake() =>Inst =this;
void Start()
{
//StartGame();
cameraEffect.SetGrayScale(false);
}
void Update()
{
#if UNITY_EDITOR
InputCheatKey();
#endif
}
void InputCheatKey()
{
if(Input.GetKeyDown(KeyCode.Keypad1))
{
TurnManger.OnAddCard?.Invoke(true);
}
if(Input.GetKeyDown(KeyCode.Keypad2))
{
TurnManger.Inst.EndTurn();
}
}
public void StartGame()
{
StartCoroutine(TurnManger.Inst.StartGameCo());
}
public void Notification(string message)
{
notification.Show(message);
}
public IEnumerator GameOver(bool isMyWin)
{
TurnManger.Inst.isLoading =true;
endTurnBtn.SetActive(false);
yield return delay1;
resultPanel.Show(isMyWin ? "승리!!" : "패배...");
cameraEffect.SetGrayScale(true);
BackEndMatch.EndMatch(isMyWin);
}
}
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using BackEnd.Tcp;
using BackEnd;
public class TurnManger : MonoBehaviour
{
public GameObject myGauge;
public GameObject otherGauge;
public static TurnManger Inst {get; private set;}
void Awake() => Inst =this;
[Header("Develop")]
[SerializeField] [Tooltip("시작 턴 모드를 정합니다")] ETurnMode eturnMode;
[SerializeField] [Tooltip("시작 카드 개수를 정합니다")] int startCardCount;
[Header("Properties")]
public bool myTurn;
public bool isLoading;
public int myGaugeCnt;
public int myNowGaugeCnt;
public int otherNowGaugeCnt;
public int otherGaugeCnt;
enum ETurnMode {Random,My,Other}
WaitForSeconds delay05 = new WaitForSeconds(0.5f);
WaitForSeconds delay07 = new WaitForSeconds(0.7f);
public static Action<bool> OnAddCard;
public static event Action<bool> OnTurnStarted;
void Gamesetup()
{
myGaugeCnt =2;
otherGaugeCnt=2;
myTurn = FirstTurn();
}
public bool FirstTurn()
{
for(int i =0;i<50;i++)
{
if(CardManager.Inst.itemBuffer[i].code>CardManager.Inst.otherItemBuffer[i].code)
{
return true;
}
else if(CardManager.Inst.itemBuffer[i].code<CardManager.Inst.otherItemBuffer[i].code)
{
return false;
}
}
return true;
}
public IEnumerator StartGameCo()
{
Gamesetup();
isLoading =true;
for(int i=0;i<startCardCount;i++)
{
yield return delay05;
OnAddCard?.Invoke(true);
}
StartCoroutine(StartTurnCo());
}
IEnumerator StartTurnCo()
{
isLoading =true;
SetGauge(myTurn);
if(myTurn)
{
GameManager.Inst.Notification("나의 턴!");
AbilityManager.Inst.eTurnState=AbilityManager.ETurnState.turnStart;
AbilityManager.Inst.stateTrigger =true;
}
yield return delay07;
if(myTurn)
OnAddCard?.Invoke(myTurn);
yield return delay07;
isLoading =false;
OnTurnStarted?.Invoke(myTurn);
}
public void EndTurn()
{
if(myTurn)
{
otherGaugeCnt++;
AbilityManager.Inst.eTurnState=AbilityManager.ETurnState.turnEnd;
AbilityManager.Inst.stateTrigger =true;
byte[] send = new byte[1] {Convert.ToByte(106)};
Backend.Match.SendDataToInGameRoom(send);
}
else
{
myGaugeCnt++;
}
myTurn = !myTurn;
Debug.Log("End Turn");
StartCoroutine(StartTurnCo());
}
public void SetGauge(bool myTurn)
{
if(myTurn)
{
for(int i=0;i<myGaugeCnt;i++)
{
myGauge.transform.GetChild(i).gameObject.SetActive(true);
}
myNowGaugeCnt=myGaugeCnt;
}
else
{
for(int i=0;i<otherGaugeCnt;i++)
{
otherGauge.transform.GetChild(i).gameObject.SetActive(true);
}
otherNowGaugeCnt = otherGaugeCnt;
}
}
public void ConsumeCost(bool isMine, int cost)
{
int cnt = isMine ? myNowGaugeCnt : otherNowGaugeCnt;
GameObject Gauge = isMine ? myGauge : otherGauge;
cnt = cnt -cost;
if(isMine)
myNowGaugeCnt -=cost;
else
otherNowGaugeCnt -=cost;
for(int i=0; i<22;i++)
{
Gauge.transform.GetChild(i).gameObject.SetActive(false);
}
for(int i=0;i<cnt;i++)
{
Gauge.transform.GetChild(i).gameObject.SetActive(true);
}
}
}
using System.Dynamic;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using TMPro;
using System.Xml.Linq;
using System.Linq;
using System.Xml;
public class ToolTipManager : MonoBehaviour
{
public static ToolTipManager Inst { get; private set; }
void Awake() => Inst = this;
[SerializeField] TextMeshProUGUI text;
[SerializeField] GameObject tooltip;
public void Tool(Entity entity)
{
if (entity.ablcode1 != 0)
{
tooltip.SetActive(true);
tooltip.transform.position = Input.mousePosition;
text.text = XMLToText(entity.ablcode1,entity);
}
}
public string XMLToText(int index,Entity entity)
{
string contents = "";
if (entity.ablcode1 == 2)
{
contents += "소환 : 몬스터 소환 시 ";
foreach (var row in entity.link)
{
XDocument document = XDocument.Load(@"C:\nexon_maplestory_battle_monsters_league_s\Assets\Resources\CARD\xml\monster.xml");
var books = from item in document.Descendants("row")
where (item.Element("CODE").Value == row.ToString())
select new
{
name = item.Element("NAME").Value
};
foreach (var eow in books)
{
contents += eow.name + ", ";
}
}
contents = contents.Substring(0,contents.Length-2);
contents += "을(를) 소환한다.";
return contents;
}
else if(entity.ablcode1 == 3)
{
contents += "소환 : 이 몬스터가 죽을 시 ";
foreach (var row in entity.link)
{
XDocument document = XDocument.Load(@"C:\nexon_maplestory_battle_monsters_league_s\Assets\Resources\CARD\xml\monster.xml");
var books = from item in document.Descendants("row")
where (item.Element("CODE").Value == row.ToString())
select new
{
name = item.Element("NAME").Value
};
foreach (var eow in books)
{
contents += eow.name + ", ";
}
}
contents = contents.Substring(0,contents.Length-2);
contents += "을(를) 소환한다.";
return contents;
}
else if(entity.ablcode1 == 13)
{
if(entity.code == 122254)
{
contents = "부활 : 이 몬스터가 사망 시 공격력이 2 감소한 상태로 부활한다.";
}
else
{
contents = "부활 : 이 몬스터가 사망 시 방어력이 1 증가한 상태로 부활한다.(최대 5번)";
}
return contents;
}
else if(entity.ablcode1 ==16)
{
if(entity.code<=140283)
{
contents = "몬스터 소환 시 세트 효과를 가진 몬스터가 필드 위에 있을 경우 공격력, 방어력 1 증가";
}
else
{
contents = "몬스터 소환 시 세트 효과를 가진 몬스터가 필드 위에 있을 경우 공격력, 방어력 2 증가";
}
return contents;
}
else
{
TextAsset textAsset = (TextAsset)Resources.Load("CARD/xml/monabl");
XmlDocument xmlDoc = new XmlDocument();
xmlDoc.LoadXml(textAsset.text);
XmlNodeList nodes = xmlDoc.SelectNodes("root/row");
foreach (XmlNode node in nodes)
{
if (node.SelectSingleNode("NUM").InnerText == index.ToString())
{
contents = node.SelectSingleNode("NAME").InnerText + " : " + node.SelectSingleNode("CONTENT").InnerText;
break;
}
}
return contents;
}
}
public void ToolOut()
{
tooltip.SetActive(false);
}
}
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Order : MonoBehaviour
{
[SerializeField] Renderer[] backRenderers;
[SerializeField] Renderer[] middleRenderers;
[SerializeField] Renderer[] frontRenderers;
[SerializeField] string sortingLayerName;
int originOrder;
public void SetOriginOrder(int originOrder)
{
this.originOrder=originOrder;
SetOrder(originOrder,sortingLayerName);
}
public void SetMostFrontOrder(bool isMostFront)
{
SetOrder(isMostFront ? 100 : originOrder,sortingLayerName);
}
public void SetOrder(int order,string sortingLayerName)
{
int mulOrder = order * 10;
foreach(var renderer in backRenderers)
{
renderer.sortingLayerName = sortingLayerName;
renderer.sortingOrder = mulOrder;
}
foreach(var renderer in middleRenderers)
{
renderer.sortingLayerName = sortingLayerName;
renderer.sortingOrder = mulOrder+1;
}
foreach(var renderer in frontRenderers)
{
renderer.sortingLayerName = sortingLayerName;
renderer.sortingOrder = mulOrder+2;
}
}
}
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class CameraEffect : MonoBehaviour
{
[SerializeField] Material effectMat;
void OnRenderImage(RenderTexture _src, RenderTexture _dest)
{
if(effectMat ==null)
return;
Graphics.Blit(_src,_dest,effectMat);
}
void Ondestroy()
{
SetGrayScale(false);
}
public void SetGrayScale(bool isGrayscale)
{
effectMat.SetFloat("_GrayscaleAmount",isGrayscale ? 1 : 0);
effectMat.SetFloat("_DarkAmount",isGrayscale ? 0.12f : 0);
}
}
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using TMPro;
using DG.Tweening;
public class Damage : MonoBehaviour
{
[SerializeField] TMP_Text damageTMP;
Transform tr;
public void SetupTransform(Transform tr)
{
this.tr =tr;
}
void Update()
{
if(tr !=null)
transform.position =tr.position;
}
public void Damaged(int damage)
{
if(damage <=0)
return;
GetComponent<Order>().SetOrder(1000,"Entity");
damageTMP.text =$"-{damage}";
Sequence sequence =DOTween.Sequence()
.Append(transform.DOScale(Vector3.one * 4.0f,0.5f).SetEase(Ease.InOutBack))
.AppendInterval(1.0f)
.Append(transform.DOScale(Vector3.zero, 0.5f).SetEase(Ease.InOutBack))
.OnComplete(() => Destroy(gameObject));
}
}
using System.Globalization;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using System.Xml.Linq;
using System.Linq;
public partial class AbilityManager : MonoBehaviour
{
public static AbilityManager Inst {get; private set;}
void Awake() => Inst = this;
[SerializeField] public ETurnState eTurnState;
[SerializeField] public List<Entity> myEntities;
[SerializeField] public List<Entity> otherEntities;
[SerializeField] public bool stateTrigger = false;
public AbilityNum[] abilityNum = new AbilityNum[48];
public enum ETurnState
{ turnStart = 0,
summonsMon,
attacking,
drag,
useEnchanceMagic,
turnEnd,
beAttacked,
myMonDie,
normal
}
//********************************************const******************************************
//********************************************const******************************************
public struct AbilityNum
{
public string name;
public int state;
}
void Start()
{
Setup();
}
public ETurnState triggerState = ETurnState.turnEnd;
void Update()
{
GetEntities();
if(stateTrigger)
{
stateTrigger = false;
Debug.Log(eTurnState.ToString());
UseAbility();
eTurnState = ETurnState.normal;
}
}
public void Setup()
{
for(int i=1;i<abilityNum.Length+1;i++)
{
XDocument document = XDocument.Load(@"C:\nexon_maplestory_battle_monsters_league_s\Assets\Resources\CARD\xml\monabl.xml");
var books = from row in document.Descendants("row")
where(row.Element("NUM").Value == i.ToString())
select new
{
name = row.Element("NAME").Value,
code = row.Element("CODE").Value
};
foreach(var row in books)
{
abilityNum[i].name = row.name;
abilityNum[i].state = int.Parse(row.code);
}
}
}
public void GetEntities()
{
myEntities = EntityManeger.Inst.myEntities;
otherEntities = EntityManeger.Inst.otherEntities;
}
public void UseAbility()
{
List<Entity> isThereEntities;
Entity entity = new Entity();
switch(eTurnState)
{
case ETurnState.turnStart:
isThereEntities = CheckAbl(true,eTurnState);
if(isThereEntities != null)
{
StartCoroutine(DoAbility0(myEntities,otherEntities,isThereEntities));
}
isThereEntities = null;
break;
case ETurnState.summonsMon:
entity = CheckAblEntity1(true,eTurnState);
if(entity != null)
{
StartCoroutine(DoAbility1(myEntities,otherEntities,entity));
}
entity = null;
break;
case ETurnState.attacking:
entity = EntityManeger.Inst.castEntity;
if(entity != null)
{
if(abilityNum[entity.ablcode1].state == (int)ETurnState.attacking)
{
StartCoroutine(DoAbility2(myEntities,otherEntities,entity,EntityManeger.Inst.targetEntity));
}
if(abilityNum[EntityManeger.Inst.targetEntity.ablcode1].state == (int)ETurnState.beAttacked)
{
StartCoroutine(DoAbility7(myEntities,otherEntities,entity,EntityManeger.Inst.targetEntity));
}
}
entity = null;
break;
case ETurnState.drag:
entity = CheckAblEntity3(true,eTurnState);
if(entity != null)
{
StartCoroutine(DoAbility3(myEntities,otherEntities,entity));
}
entity = null;
break;
/*case ETurnState.useEnchanceMagic: //미구현
isThereEntities = CheckAbl(true,eTurnState);
if(isThereEntities != null)
{
}
isThereEntities = null;
break;*/
case ETurnState.turnEnd:
isThereEntities = CheckAbl(true,eTurnState);
if(isThereEntities != null)
{
StartCoroutine(DoAbility5(myEntities,otherEntities,isThereEntities));
}
isThereEntities = null;
break;
case ETurnState.myMonDie:
entity = CheckAblEntity7(true,ETurnState.beAttacked);
if(entity != null)
{
Debug.Log(entity);
StartCoroutine(DoAbility9(myEntities,otherEntities,entity));
}
isThereEntities = null;
break;
}
}
public List<Entity> CheckAbl(bool isMine,ETurnState state)
{
List<Entity> entities = isMine ? myEntities : otherEntities;
if(entities == null)
{
return null;
}
List<Entity> returnEntities = new List<Entity>();
for(int i =0;i<entities.Count;i++)
{
if(entities[i].ablcode1 !=0)
{
if(abilityNum[entities[i].ablcode1].state == (int) state || abilityNum[entities[i].ablcode2].state == (int) state)
{
returnEntities.Add(entities[i]);
}
}
}
return returnEntities;
}
public Entity CheckAblEntity1(bool isMine, ETurnState state)
{
Entity entity = myEntities[myEntities.Count-1];
if(entity.ablcode1 ==0)
{
return null;
}
else
{
if(abilityNum[entity.ablcode1].state == (int) state)
{
return entity;
}
return null;
}
}
public Entity CheckAblEntity2(bool isMine, ETurnState state)
{
if (EntityManeger.Inst.castEntity !=null)
{
Entity entity = EntityManeger.Inst.castEntity;
EntityManeger.Inst.castEntity = null;
if (entity.ablcode1 == 0)
{
return null;
}
else
{
if (abilityNum[entity.ablcode1].state == (int)state)
{
return entity;
}
return null;
}
}
return null;
}
public Entity CheckAblEntity3(bool isMine, ETurnState state)
{
return EntityManeger.Inst.selectEntity;
}
public Entity CheckAblEntity7(bool isMine, ETurnState state)
{
return EntityManeger.Inst.castEntity;
}
}
using System;
using System.Reflection;
using System.Dynamic;
using System.Net.Mime;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using TMPro;
using DG.Tweening;
using System.Xml.Linq;
using System.Linq;
using Random = UnityEngine.Random;
public partial class AbilityManager
{
public int ABL23DAMAGE = 5;
public int ABL24DAMAGE = 4;
[SerializeField] public GameObject targetPrefeb;
[SerializeField] public GameObject demianSword;
[SerializeField] public GameObject suuCircle;
[SerializeField] public GameObject entityPrefab;
[SerializeField] public GameObject firePrefab;
[SerializeField] public GameObject chainPrefeb;
[SerializeField] public Material redColor;
[SerializeField] public Material blueColor;
[SerializeField] public ParticleSystem confusionParticle;
[SerializeField] public ParticleSystem sealParticle;
[SerializeField] Entity myBoss;
[SerializeField] Entity otherBoss;
[SerializeField] public Item entity112414_0;
[SerializeField] public Sprite pig;
//----------------------------------------------------------------턴 시작 시 발동---------------------------------------------------------------
IEnumerator DoAbility0(List<Entity> myEntities, List<Entity> otherEntities, List<Entity> ablEntities)
{
int[] abilityNum = { 9, 15, 20, 23, 24, 26, 27, 34, 37, 47 , 5};
int entityCnt = ablEntities.Count;
foreach (Entity entity in ablEntities)
{
switch (entity.ablcode1)
{
case 9:
//감염
yield return StartCoroutine(Ability9(myEntities, otherEntities, entity));
yield return new WaitForSeconds(6.0f);
break;
case 15:
//소멸
yield return StartCoroutine(Ability15(myEntities, otherEntities, entity));
yield return new WaitForSeconds(6.0f);
break;
case 20:
//절망
yield return StartCoroutine(Ability20(myEntities, otherEntities, entity));
yield return new WaitForSeconds(6.0f);
break;
case 23:
//낙인(특수)
yield return StartCoroutine(Ability23(myEntities, otherEntities, entity));
yield return new WaitForSeconds(6.0f);
break;
case 24:
//구체(특수)
yield return StartCoroutine(Ability24(myEntities, otherEntities, entity));
yield return new WaitForSeconds(6.0f);
break;
case 26:
//흡수(특수)
yield return StartCoroutine(Ability26(myEntities, otherEntities, entity));
yield return new WaitForSeconds(50.0f);
break;
case 27:
//혼란(특수)
yield return StartCoroutine(Ability27(otherEntities, entity));
yield return new WaitForSeconds(6.0f);
break;
case 37:
//이면
yield return StartCoroutine(Ability37(entity));
yield return new WaitForSeconds(6.0f);
break;
case 34:
//오버시어의 힘
yield return StartCoroutine(Ability34(entity));
break;
case 47:
//군단
yield return StartCoroutine(Ability47(myEntities, entity));
break;
case 5:
//무작위 공격
yield return StartCoroutine(Ability5(otherEntities, entity));
break;
}
}
}
//감염
IEnumerator Ability9(List<Entity> myEntities, List<Entity> otherEntities, Entity entity)
{
yield return new WaitForSeconds(3.0f);
List<Entity> targetList = new List<Entity>();
foreach (Entity target in otherEntities)
{
if (target.attack > 0)
targetList.Add(target);
}
if (targetList != null)
{
entity.GetComponent<Order>().SetOrder(0, "Ability");
GameManager.Inst.Notification("감염 발동!");
yield return new WaitForSeconds(2.0f);
entity.transform.DOScale(1.5f, 0.5f);
yield return new WaitForSeconds(1.0f);
int index = Random.Range(0, targetList.Count);
byte[] send = new byte[3] {0x09, Convert.ToByte(entity.gameObject.name),Convert.ToByte(targetList[index].gameObject.name)};
BackEndMatch.SendMessage(send);
targetList[index].attack--;
targetList[index].gameObject.transform.Find("TMP_ATT").transform.GetComponent<TextMeshPro>().text = targetList[index].attack.ToString();
targetList[index].gameObject.transform.Find("TMP_ATT").transform.DOShakeScale(1.0f, 2, 10, 90, true);
targetList[index].gameObject.transform.Find("TMP_ATT").transform.GetComponent<TextMeshPro>().fontMaterial = blueColor;
entity.transform.DOScale(0.8f, 0.5f);
entity.GetComponent<Order>().SetOriginOrder(0);
}
}
//소멸
IEnumerator Ability15(List<Entity> myEntities, List<Entity> otherEntities, Entity entity)
{
//발동 몬스터 확대
yield return new WaitForSeconds(3.0f);
if (otherEntities != null)
{
List<Entity> list = new List<Entity>();
for (int i = 0; i < otherEntities.Count; i++)
{
if (otherEntities[i].grade > 3)
list.Add(otherEntities[i]);
}
if (list.Count != 0)
{
entity.GetComponent<Order>().SetOrder(0, "Ability");
GameManager.Inst.Notification("소멸 발동!");
yield return new WaitForSeconds(2.0f);
entity.transform.DOScale(1.5f, 0.5f);
yield return new WaitForSeconds(1.0f);
int index = Random.Range(0, list.Count);
byte[] send = new byte[3] {0x0F,Convert.ToByte(entity.gameObject.name),Convert.ToByte(list[index].gameObject.name)};
BackEndMatch.SendMessage(send);
otherEntities.Remove(list[index]);
list[index].gameObject.transform.DOShakeScale(1.0f);
yield return new WaitForSeconds(1.2f);
Destroy(list[index].gameObject);
EntityManeger.Inst.EntityAlignment(false);
entity.transform.DOScale(0.8f, 0.5f);
entity.GetComponent<Order>().SetOriginOrder(0);
}
}
}
//절망
IEnumerator Ability20(List<Entity> myEntities, List<Entity> otherEntities, Entity entity)
{
yield return new WaitForSeconds(3.0f);
List<Entity> targetList = new List<Entity>();
foreach (Entity target in otherEntities)
{
if (target.attack > 0 && target.grade > 3)
targetList.Add(target);
}
if (targetList != null)
{
entity.GetComponent<Order>().SetOrder(0, "Ability");
GameManager.Inst.Notification("절망 발동!");
yield return new WaitForSeconds(2.0f);
entity.transform.DOScale(1.5f, 0.5f);
yield return new WaitForSeconds(1.0f);
int index = Random.Range(0, targetList.Count);
byte[] send = new byte[3] {Convert.ToByte(20),Convert.ToByte(entity.gameObject.name),Convert.ToByte(targetList[index].gameObject.name)};
BackEndMatch.SendMessage(send);
targetList[index].attack = 0;
targetList[index].gameObject.transform.Find("TMP_ATT").transform.GetComponent<TextMeshPro>().text = targetList[index].attack.ToString();
targetList[index].gameObject.transform.Find("TMP_ATT").transform.DOShakeScale(1.0f, 2, 10, 90, true);
targetList[index].gameObject.transform.Find("TMP_ATT").transform.GetComponent<TextMeshPro>().fontMaterial = blueColor;
entity.transform.DOScale(0.8f, 0.5f);
entity.GetComponent<Order>().SetOriginOrder(0);
}
}
//낙인
IEnumerator Ability23(List<Entity> myEntities, List<Entity> otherEntities, Entity entity)
{
yield return new WaitForSeconds(3.0f);
if (Random.Range(0, 2) == 0)
{
entity.GetComponent<Order>().SetOrder(0, "Ability");
GameManager.Inst.Notification(abilityNum[23].name + " 발동!");
yield return new WaitForSeconds(2.0f);
entity.transform.DOScale(1.5f, 0.5f);
yield return new WaitForSeconds(1.0f);
int index = Random.Range(0, otherEntities.Count);
byte[] send = new byte[3] {Convert.ToByte(23),Convert.ToByte(entity.gameObject.name),Convert.ToByte(otherEntities[index].gameObject.name)};
BackEndMatch.SendMessage(send);
GameObject sword = Instantiate(demianSword, entity.transform.position, entity.transform.rotation);
Vector3 dir = otherEntities[index].transform.position - sword.transform.position;
float angle = Mathf.Atan2(dir.y, dir.x) * Mathf.Rad2Deg;
sword.transform.rotation = Quaternion.AngleAxis(-angle, Vector3.forward);
yield return new WaitForSeconds(1.0f);
AbilityAttack(sword, otherEntities[index], ABL23DAMAGE);
yield return new WaitForSeconds(1.0f);
Destroy(sword);
entity.transform.DOScale(0.8f, 0.5f);
entity.GetComponent<Order>().SetOriginOrder(0);
}
}
//구체
IEnumerator Ability24(List<Entity> myEntities, List<Entity> otherEntities, Entity entity)
{
yield return new WaitForSeconds(3.0f);
if (Random.Range(0, 2) == 0)
{
entity.GetComponent<Order>().SetOrder(0, "Ability");
GameManager.Inst.Notification(abilityNum[24].name + " 발동!");
yield return new WaitForSeconds(2.0f);
entity.transform.DOScale(1.5f, 0.5f);
yield return new WaitForSeconds(1.0f);
int index = Random.Range(0, otherEntities.Count);
byte[] send = new byte[3] {Convert.ToByte(24),Convert.ToByte(entity.gameObject.name),Convert.ToByte(otherEntities[index].gameObject.name)};
BackEndMatch.SendMessage(send);
GameObject sword = Instantiate(suuCircle, entity.transform.position, entity.transform.rotation);
Vector3 dir = otherEntities[index].transform.position - sword.transform.position;
float angle = Mathf.Atan2(dir.y, dir.x) * Mathf.Rad2Deg;
sword.transform.rotation = Quaternion.AngleAxis(-angle, Vector3.forward);
yield return new WaitForSeconds(1.0f);
AbilityAttack(sword, otherEntities[index], ABL24DAMAGE);
yield return new WaitForSeconds(1.0f);
Destroy(sword);
entity.transform.DOScale(0.8f, 0.5f);
entity.GetComponent<Order>().SetOriginOrder(0);
}
}
//기권
public void Renounce()
{
byte[] send = new byte[1] {Convert.ToByte(200)};
BackEndMatch.SendMessage(send);
Sequence sequence = DOTween.Sequence()
.AppendCallback(() =>
{
myBoss.Damaged(100);
EntityManeger.Inst.SpawnDamage(100, myBoss.transform);
});
StartCoroutine(GameManager.Inst.GameOver(false));
}
//ABL을 통해 공격
public void AbilityAttack(GameObject attacker, Entity defender, int damage)
{
Sequence sequence = DOTween.Sequence()
.Append(attacker.transform.DOMove(defender.transform.position, 0.4f)).SetEase(Ease.InSine)
.AppendCallback(() =>
{
defender.Damaged(damage);
EntityManeger.Inst.SpawnDamage(damage, defender.transform);
})
.Append(attacker.transform.DOMove(attacker.transform.position, 0.4f)).SetEase(Ease.OutSine)
.OnComplete(() => EntityManeger.Inst.AttackCallback(defender));
}
//흡수
public Entity targetObject26;
IEnumerator Ability26(List<Entity> myEntities, List<Entity> otherEntities, Entity entity)
{
yield return new WaitForSeconds(3.0f);
if (myEntities.Count > 1)
{
GameManager.Inst.Notification("내 몬스터를 선택");
yield return new WaitForSeconds(2.0f);
foreach (Entity targetEntity in myEntities)
{
if (targetEntity == entity)
continue;
else
{
Instantiate(targetPrefeb, targetEntity.transform.position, targetEntity.transform.rotation);
}
}
while (true)
{
yield return null;
if (Input.GetMouseButtonDown(0))
targetObject26 = EntityManeger.Inst.selectEntity;
if (targetObject26 != null)
break;
}
yield return new WaitForSeconds(0.5f);
GameObject[] objects = GameObject.FindGameObjectsWithTag("Target");
for (int i = 0; i < objects.Length; i++)
Destroy(objects[i]);
yield return new WaitForSeconds(1.5f);
byte[] send =new byte[3] {Convert.ToByte(26),Convert.ToByte(entity.gameObject.name),Convert.ToByte(targetObject26.gameObject.name)};
BackEndMatch.SendMessage(send);
entity.health = entity.health + targetObject26.health;
entity.gameObject.transform.Find("TMP_DEF").transform.GetComponent<TextMeshPro>().text = entity.health.ToString();
entity.gameObject.transform.Find("TMP_DEF").transform.DOShakeScale(1.0f, 2, 10, 90, true);
entity.gameObject.transform.Find("TMP_DEF").transform.GetComponent<TextMeshPro>().fontMaterial = redColor;
yield return new WaitForSeconds(0.5f);
myEntities.Remove(targetObject26);
targetObject26.transform.DOShakeScale(1.0f);
yield return new WaitForSeconds(1.0f);
Destroy(targetObject26.gameObject);
EntityManeger.Inst.EntityAlignment(true);
}
}
//혼란
public Entity targetObject27;
public int tempAbl1, tempAbl2;
IEnumerator Ability27(List<Entity> otherEntities, Entity entity)
{
yield return new WaitForSeconds(3.0f);
if (otherEntities.Count > 0)
{
List<Entity> targetList = new List<Entity>();
foreach (Entity target in otherEntities)
{
if (target.attack > 0)
targetList.Add(target);
}
if (targetList != null)
{
entity.GetComponent<Order>().SetOrder(0, "Ability");
GameManager.Inst.Notification("혼란 발동!");
yield return new WaitForSeconds(2.0f);
entity.transform.DOScale(1.5f, 0.5f);
yield return new WaitForSeconds(1.0f);
int index = Random.Range(0, targetList.Count);
byte[] send = new byte[4] {Convert.ToByte(27),Convert.ToByte(entity.gameObject.name),Convert.ToByte(targetList[index].gameObject.name),0x01};
BackEndMatch.SendMessage(send);
targetObject27 = targetList[index];
tempAbl1 = targetList[index].ablcode1;
tempAbl2 = targetList[index].ablcode2;
targetList[index].ablcode1 = 0;
targetList[index].ablcode2 = 0;
ParticleSystem confusion = Instantiate(confusionParticle, targetList[index].transform.position, targetList[index].transform.rotation);
entity.transform.DOScale(0.8f, 0.5f);
entity.GetComponent<Order>().SetOriginOrder(0);
}
}
while (true)
{
yield return null;
targetObject27.attackable = false;
if (TurnManger.Inst.myTurn == false)
{
break;
}
}
while (true)
{
yield return null;
targetObject27.attackable = false;
if (TurnManger.Inst.myTurn)
{
break;
}
}
if (otherEntities.Count > 0)
{
Destroy(GameObject.FindGameObjectWithTag("Confusion"));
targetObject27.ablcode1 = tempAbl1;
targetObject27.ablcode2 = tempAbl2;
targetObject27.attackable = true;
byte[] send = new byte[4] {Convert.ToByte(27),Convert.ToByte(entity.gameObject.name),Convert.ToByte(targetObject27.gameObject.name),0x00};
BackEndMatch.SendMessage(send);
}
}
//이면
IEnumerator Ability37(Entity entity)
{
yield return new WaitForSeconds(3.0f);
entity.GetComponent<Order>().SetOrder(0, "Ability");
GameManager.Inst.Notification("이면 발동!");
yield return new WaitForSeconds(2.0f);
entity.transform.DOScale(1.5f, 0.5f);
yield return new WaitForSeconds(1.0f);
int swap = entity.attack;
entity.attack = entity.health;
entity.health = swap;
entity.gameObject.transform.Find("TMP_ATT").transform.GetComponent<TextMeshPro>().text = entity.attack.ToString();
entity.gameObject.transform.Find("TMP_ATT").transform.DOShakeScale(1.0f, 2, 10, 90, true);
entity.gameObject.transform.Find("TMP_ATT").transform.GetComponent<TextMeshPro>().fontMaterial = redColor;
entity.gameObject.transform.Find("TMP_DEF").transform.GetComponent<TextMeshPro>().text = entity.health.ToString();
entity.gameObject.transform.Find("TMP_DEF").transform.DOShakeScale(1.0f, 2, 10, 90, true);
entity.gameObject.transform.Find("TMP_DEF").transform.GetComponent<TextMeshPro>().fontMaterial = redColor;
byte[] send =new byte[3] {Convert.ToByte(37),Convert.ToByte(entity.gameObject.name),0x01};
BackEndMatch.SendMessage(send);
yield return new WaitForSeconds(1.0f);
entity.transform.DOScale(0.8f, 0.5f);
entity.GetComponent<Order>().SetOriginOrder(0);
while (true)
{
yield return null;
if (TurnManger.Inst.myTurn == false)
{
int temp = entity.attack;
entity.attack = entity.health;
entity.health = temp;
entity.gameObject.transform.Find("TMP_ATT").transform.GetComponent<TextMeshPro>().text = entity.attack.ToString();
entity.gameObject.transform.Find("TMP_ATT").transform.DOShakeScale(1.0f, 2, 10, 90, true);
entity.gameObject.transform.Find("TMP_ATT").transform.GetComponent<TextMeshPro>().fontMaterial = blueColor;
entity.gameObject.transform.Find("TMP_DEF").transform.GetComponent<TextMeshPro>().text = entity.health.ToString();
entity.gameObject.transform.Find("TMP_DEF").transform.DOShakeScale(1.0f, 2, 10, 90, true);
entity.gameObject.transform.Find("TMP_DEF").transform.GetComponent<TextMeshPro>().fontMaterial = blueColor;
byte[] send1 = new byte[3] { Convert.ToByte(37), Convert.ToByte(entity.gameObject.name), 0x00 };
BackEndMatch.SendMessage(send1);
break;
}
}
}
//오버시어의 힘
IEnumerator Ability34(Entity entity)
{
int cnt = 0;
byte[] send =new byte[3] {Convert.ToByte(34),Convert.ToByte(entity.gameObject.name),0x01};
BackEndMatch.SendMessage(send);
while (true)
{
entity.canBeAttacked = false;
entity.attackable = false;
yield return null;
if (TurnManger.Inst.myTurn)
{
cnt++;
if (cnt == 4)
{
entity.canBeAttacked = true;
entity.attackable = true;
entity.ablcode1 = 35;
byte[] send1 =new byte[3] {Convert.ToByte(34),Convert.ToByte(entity.gameObject.name),0x00};
BackEndMatch.SendMessage(send1);
break;
}
}
}
}
//군단
IEnumerator Ability47(List<Entity> myEntities, Entity entity)
{
yield return new WaitForSeconds(3.0f);
entity.GetComponent<Order>().SetOrder(0, "Ability");
GameManager.Inst.Notification("군단 발동!");
yield return new WaitForSeconds(2.0f);
entity.transform.DOScale(1.5f, 0.5f);
yield return new WaitForSeconds(1.0f);
entity.transform.DOScale(0.8f, 0.5f);
entity.GetComponent<Order>().SetOriginOrder(0);
//몬스터를 소환할 수 있어 용사 소환
if (myEntities.Count < 10)
{
int att = Random.Range(0,4);
int def = Random.Range(0,4);
SpawnEntity(SetItem112414(entity112414_0, att, def));
byte[] send = new byte[5] {Convert.ToByte(47),Convert.ToByte(entity.gameObject.name),0x00,Convert.ToByte(att),Convert.ToByte(def)};
BackEndMatch.SendMessage(send);
}
//몬스터를 소환할 수 없어 공/방 증가
else
{
entity.attack = entity.attack + Random.Range(0, 4);
entity.health = entity.health + Random.Range(0, 4);
entity.gameObject.transform.Find("TMP_ATT").transform.GetComponent<TextMeshPro>().text = entity.attack.ToString();
entity.gameObject.transform.Find("TMP_ATT").transform.DOShakeScale(1.0f, 2, 10, 90, true);
entity.gameObject.transform.Find("TMP_ATT").transform.GetComponent<TextMeshPro>().fontMaterial = redColor;
entity.gameObject.transform.Find("TMP_DEF").transform.GetComponent<TextMeshPro>().text = entity.health.ToString();
entity.gameObject.transform.Find("TMP_DEF").transform.DOShakeScale(1.0f, 2, 10, 90, true);
entity.gameObject.transform.Find("TMP_DEF").transform.GetComponent<TextMeshPro>().fontMaterial = redColor;
byte[] send = new byte[5] {Convert.ToByte(47),Convert.ToByte(entity.gameObject.name),0x01,Convert.ToByte(entity.attack),Convert.ToByte(entity.health)};
BackEndMatch.SendMessage(send);
}
}
//타락한 용사 생성
public Item SetItem112414(Item link, int attack, int health)
{
link.abl = null;
link.code = 11241401;
link.ablcode = "0000";
link.attack = attack;
link.health = health;
link.grade = 6;
link.main = Resources.Load<Sprite>("CARD/monster/" + link.code.ToString());
link.name = "타락한 용사";
return link;
}
//ABL을 통해 소환
public void SpawnEntity(Item item)
{
var entityObject = Instantiate(entityPrefab, Utils.MousePos, Utils.QI);
var entity = entityObject.GetComponent<Entity>();
myEntities.Add(entity);
entity.Setup(item);
entity.isMine = true;
entity.name = EntityManeger.Inst.SetEntityNum(true);
EntityManeger.Inst.EntityAlignment(true);
}
//무작위 공격
IEnumerator Ability5(List<Entity> otherEntities,Entity entity)
{
yield return new WaitForSeconds(2.0f);
Entity target = new Entity();
if(otherEntities.Count>0)
{
int index = Random.Range(0,otherEntities.Count+1);
if(index != otherEntities.Count)
{
target = otherEntities[index];
}
else
{
target = otherBoss;
}
}
else
{
target = otherBoss;
}
Debug.Log(target);
Attack(entity,target);
byte[] send = new byte[3] {0x00,Convert.ToByte(entity.gameObject.name),Convert.ToByte(target.gameObject.name)};
BackEndMatch.SendMessage(send);
}
//-----------------------------------------------------------------------------------------------------------------------------------------------
//----------------------------------------------------------------몬스터 소환 시 발동-------------------------------------------------------------
IEnumerator DoAbility1(List<Entity> myEntities, List<Entity> otherEntities, Entity entity)
{
switch (entity.ablcode1)
{
case 1:
//도발
yield return StartCoroutine(Ability1(myEntities, otherEntities, entity));
break;
case 2:
//소환
yield return StartCoroutine(Ability2(myEntities, entity));
break;
case 16:
//세트
yield return StartCoroutine(Ability16(myEntities, entity));
break;
case 36:
//분신
yield return StartCoroutine(Ability36(myEntities, entity));
break;
case 40:
//핑크빈의 친구
yield return StartCoroutine(Ability40(myEntities, entity));
break;
case 41:
//봉인
yield return StartCoroutine(Ability41(otherEntities,entity));
break;
case 18:
//즉시 공격
yield return StartCoroutine(Ability18(entity));
break;
}
}
//도발
public int tauntCnt = 0;
IEnumerator Ability1(List<Entity> myEntities, List<Entity> otherEntities, Entity entity)
{
tauntCnt++;
for (int i = 0; i < myEntities.Count; i++)
{
if (myEntities[i].ablcode1 == 1)
{
myEntities[i].canBeAttacked = true;
byte[] send = new byte[3] {0x01 , Convert.ToByte(myEntities[i].gameObject.name),0x01};
BackEndMatch.SendMessage(send);
}
else
{
myEntities[i].canBeAttacked = false;
byte[] send = new byte[3] {0x01 , Convert.ToByte(myEntities[i].gameObject.name),0x00};
BackEndMatch.SendMessage(send);
}
}
myBoss.canBeAttacked = false;
byte[] sendp = new byte[3] {0x01 , 0x00,0x00};
BackEndMatch.SendMessage(sendp);
while (true)
{
yield return null;
foreach(var row in myEntities)
{
if(row.ablcode1 !=1 && row.canBeAttacked)
{
row.canBeAttacked = false;
byte[] send = new byte[3] { 0x01, Convert.ToByte(row.gameObject.name), 0x00 };
BackEndMatch.SendMessage(send);
}
}
if (entity.isDie)
{
tauntCnt--;
if (tauntCnt == 0)
{
for (int i = 0; i < myEntities.Count; i++)
{
myEntities[i].canBeAttacked = true;
byte[] send = new byte[3] {0x01 , Convert.ToByte(myEntities[i].gameObject.name),0x01};
BackEndMatch.SendMessage(send);
}
myBoss.canBeAttacked = true;
byte[] send1 = new byte[3] { 0x01, 0x00, 0x01 };
BackEndMatch.SendMessage(send1);
break;
}
}
}
}
//소환
IEnumerator Ability2(List<Entity> myEntities, Entity entity)
{
yield return new WaitForSeconds(3.0f);
int code = int.Parse(entity.link[Random.Range(0, entity.link.Count)]);
SpawnEntity(SetEntity(code));
entity.ablcode1 = 0;
byte[] send = new byte[4]{0x02,BackEndMatch.ConvertByte(code)[0],BackEndMatch.ConvertByte(code)[1],BackEndMatch.ConvertByte(code)[2]};
BackEndMatch.SendMessage(send);
}
//item 정보 불러오기
public Item SetEntity(int code)
{
Item item = new Item();
XDocument document = XDocument.Load(@"C:\nexon_maplestory_battle_monsters_league_s\Assets\Resources\CARD\xml\monster.xml");
var books = from row in document.Descendants("row")
where (row.Element("CODE").Value == code.ToString())
select new
{
name = row.Element("NAME").Value,
grade = row.Element("GRADE").Value,
att = row.Element("ATT").Value,
def = row.Element("DEF").Value,
abl = row.Element("ABL").Value,
code = row.Element("CODE").Value,
ablcode = row.Element("ABLCODE").Value,
link = row.Element("LINK").Value
};
foreach (var row in books)
{
item.name = row.name;
item.grade = int.Parse(row.grade);
item.attack = int.Parse(row.att);
item.health = int.Parse(row.def);
item.abl = row.abl;
item.code = int.Parse(row.code);
item.main = Resources.Load<Sprite>("CARD/monster/" + row.code);
item.ablcode = row.ablcode;
item.link = row.link;
}
return item;
}
//세트
public int set1 = 0;
public int set2 = 0;
IEnumerator Ability16(List<Entity> myEntities, Entity entity)
{
List<int> linkList = new List<int>();
foreach (var code in entity.link)
{
if (code != entity.code.ToString())
linkList.Add(int.Parse(code));
}
int index = linkList.Count;
foreach (var code in linkList)
{
Entity target = FindEntityByCodeInMyEntities(code);
if (target != null)
{
target.attack += 1;
target.health += 1;
yield return StartCoroutine(UpdateATTDEF(target, true));
byte[] send = new byte[3] {Convert.ToByte(16),Convert.ToByte(target.gameObject.name),Convert.ToByte(1)};
BackEndMatch.SendMessage(send);
}
}
if (entity.link[0] == "140279")
{
set1 += 1;
if (set1 != 1)
{
entity.attack += set1 - 1;
entity.health += set1 - 1;
yield return new WaitForSeconds(0.5f);
yield return StartCoroutine(UpdateATTDEF(entity, true));
byte[] send = new byte[3] {Convert.ToByte(16),Convert.ToByte(entity.gameObject.name),Convert.ToByte(set1-1)};
BackEndMatch.SendMessage(send);
}
}
else
{
set2 += 1;
if (set2 != 1)
{
entity.attack += (set2 - 1) * 2;
entity.health += (set2 - 1) * 2;
yield return new WaitForSeconds(0.5f);
yield return StartCoroutine(UpdateATTDEF(entity, true));
byte[] send = new byte[3] {Convert.ToByte(16),Convert.ToByte(entity.gameObject.name),Convert.ToByte((set2 - 1) * 2)};
BackEndMatch.SendMessage(send);
}
}
while (true)
{
yield return null;
if (entity.isDie)
{
foreach (var code in linkList)
{
Entity target = FindEntityByCodeInMyEntities(code);
if (target != null)
{
target.attack -= 1;
target.health -= 1;
yield return StartCoroutine(UpdateATTDEF(target, true));
byte[] send = new byte[3] {Convert.ToByte(16),Convert.ToByte(entity.gameObject.name),Convert.ToByte(-1)};
BackEndMatch.SendMessage(send);
}
}
if (entity.link[0] == "140279")
set1 -= 1;
else
set2 -= 1;
break;
}
}
}
//entity code로 entity 찾기
public Entity FindEntityByCodeInMyEntities(int code)
{
foreach (var entity in myEntities)
{
if (entity.code == code)
return entity;
}
return null;
}
//공격력 방어력 업데이트
public IEnumerator UpdateATTDEF(Entity entity, bool upOrdown)
{
if (upOrdown)
{
entity.gameObject.transform.Find("TMP_ATT").transform.GetComponent<TextMeshPro>().text = entity.attack.ToString();
entity.gameObject.transform.Find("TMP_ATT").transform.DOShakeScale(1.0f, 2, 10, 90, true);
entity.gameObject.transform.Find("TMP_ATT").transform.GetComponent<TextMeshPro>().fontMaterial = redColor;
entity.gameObject.transform.Find("TMP_DEF").transform.GetComponent<TextMeshPro>().text = entity.health.ToString();
entity.gameObject.transform.Find("TMP_DEF").transform.DOShakeScale(1.0f, 2, 10, 90, true);
entity.gameObject.transform.Find("TMP_DEF").transform.GetComponent<TextMeshPro>().fontMaterial = redColor;
}
else
{
entity.gameObject.transform.Find("TMP_ATT").transform.GetComponent<TextMeshPro>().text = entity.attack.ToString();
entity.gameObject.transform.Find("TMP_ATT").transform.DOShakeScale(1.0f, 2, 10, 90, true);
entity.gameObject.transform.Find("TMP_ATT").transform.GetComponent<TextMeshPro>().fontMaterial = blueColor;
entity.gameObject.transform.Find("TMP_DEF").transform.GetComponent<TextMeshPro>().text = entity.health.ToString();
entity.gameObject.transform.Find("TMP_DEF").transform.DOShakeScale(1.0f, 2, 10, 90, true);
entity.gameObject.transform.Find("TMP_DEF").transform.GetComponent<TextMeshPro>().fontMaterial = blueColor;
}
yield return new WaitForSeconds(1.1f);
}
//분신
IEnumerator Ability36(List<Entity> myEntities, Entity entity)
{
yield return null;
if(myEntities.Count<10)
{
entity.ablcode1 = 0;
Entity dual = Instantiate(entity,entity.transform.position,entity.transform.rotation);
dual.ablcode1 = 0;
dual.gameObject.name = EntityManeger.Inst.SetEntityNum(true);
EntityManeger.Inst.EntityAlignment(true);
byte[] send = new byte[2] {Convert.ToByte(36),Convert.ToByte(entity.gameObject.name)};
BackEndMatch.SendMessage(send);
}
}
//핑크빈의 친구
IEnumerator Ability40(List<Entity> myentities, Entity entity)
{
foreach (var pinkentity in myentities)
{
if (pinkentity.code == 122271)
{
pinkentity.attack += 3;
pinkentity.health += 3;
entity.attack += 3;
entity.health += 3;
yield return StartCoroutine(UpdateATTDEF(pinkentity, true));
yield return StartCoroutine(UpdateATTDEF(entity, true));
byte[] send = new byte[3] {Convert.ToByte(40),Convert.ToByte(entity.gameObject.name),Convert.ToByte(pinkentity.gameObject.name)};
BackEndMatch.SendMessage(send);
}
}
}
//봉인
IEnumerator Ability41(List<Entity> otherEntities, Entity entity)
{
yield return null;
List<Entity> target = new List<Entity>();
foreach (var targetEntity in otherEntities)
{
if (targetEntity.grade >= 3 && targetEntity.ablcode1 != 0)
{
target.Add(targetEntity);
}
}
if (target.Count != 0)
{
Entity sealEntity = target[Random.Range(0, target.Count)];
ParticleSystem seal = Instantiate(sealParticle, sealEntity.transform.position, sealEntity.transform.rotation);
int swap = sealEntity.ablcode1;
sealEntity.ablcode1 = 0;
byte[] send = new byte[4] { Convert.ToByte(41), Convert.ToByte(entity.gameObject.name), Convert.ToByte(sealEntity.gameObject.name), 0x01 };
BackEndMatch.SendMessage(send);
while (true)
{
yield return null;
if (entity.isDie)
{
sealEntity.ablcode1 = swap;
Destroy(seal.gameObject);
byte[] send1 = new byte[4] { Convert.ToByte(41), Convert.ToByte(entity.gameObject.name), Convert.ToByte(sealEntity.gameObject.name), 0x00 };
BackEndMatch.SendMessage(send1);
break;
}
if (sealEntity.isDie)
{
Destroy(seal.gameObject);
byte[] send2 = new byte[4] { Convert.ToByte(41), Convert.ToByte(entity.gameObject.name), Convert.ToByte(sealEntity.gameObject.name), 0x02 };
BackEndMatch.SendMessage(send2);
break;
}
}
}
}
//즉시 공격
IEnumerator Ability18(Entity entity)
{
yield return null;
entity.livecnt++;
}
//-----------------------------------------------------------------------------------------------------------------------------------------------
//----------------------------------------------------------------공격 시-------------------------------------------------------------------------
IEnumerator DoAbility2(List<Entity> myEntities, List<Entity> otherEntities, Entity entity,Entity target)
{
switch (entity.ablcode1)
{
case 10:
//추적
yield return StartCoroutine(Ability10(otherEntities,entity));
break;
case 12:
//연타
yield return StartCoroutine(Ability12(entity,target));
break;
case 17:
//자폭
yield return StartCoroutine(Ability17(entity,target));
break;
case 25:
//불기둥
yield return StartCoroutine(Ability25(otherEntities,entity));
break;
case 30:
//빛의 집행
yield return StartCoroutine(Ability30(entity,target));
break;
case 31:
//어둠의 집행
yield return StartCoroutine(Ability31(entity,target));
break;
case 39:
//아머
yield return StartCoroutine(Ability39(entity));
break;
case 35:
//태초
yield return StartCoroutine(Ability35(entity));
break;
}
}
//추적
IEnumerator Ability10(List<Entity> otherEntities, Entity entity)
{
Entity target = new Entity();
int minimum = 50;
foreach(var otherEntity in otherEntities)
{
if(otherEntity.health<minimum)
{
minimum = otherEntity.health;
target = otherEntity;
}
}
yield return new WaitForSeconds(0.5f);
Attack(entity,target);
byte[] send = new byte[3] {0x00, Convert.ToByte(entity.gameObject.name),Convert.ToByte(target.gameObject.name)};
BackEndMatch.SendMessage(send);
yield return new WaitForSeconds(0.5f);
}
//연타
IEnumerator Ability12(Entity thisEntity,Entity targetEntity)
{
if (thisEntity.dual == false)
{
thisEntity.dual = true;
Attack(thisEntity, targetEntity);
byte[] send = new byte[3] {0x00, Convert.ToByte(thisEntity.gameObject.name),Convert.ToByte(targetEntity.gameObject.name)};
BackEndMatch.SendMessage(send);
EntityManeger.Inst.targetEntity = null;
thisEntity.attackable = true;
yield return null;
}
else
{
Attack(thisEntity,targetEntity);
byte[] send = new byte[3] {0x00, Convert.ToByte(thisEntity.gameObject.name),Convert.ToByte(targetEntity.gameObject.name)};
BackEndMatch.SendMessage(send);
}
}
//기본공격
public void Attack(Entity attacker, Entity defender)
{
attacker.attackable = false;
Sequence sequence = DOTween.Sequence()
.Append(attacker.transform.DOMove(defender.transform.position, 0.4f)).SetEase(Ease.InSine)
.AppendCallback(() =>
{
defender.Damaged(attacker.attack);
attacker.Damaged(defender.attack);
EntityManeger.Inst.SpawnDamage(defender.attack, attacker.transform);
EntityManeger.Inst.SpawnDamage(attacker.attack, defender.transform);
})
.Append(attacker.transform.DOMove(attacker.transform.position, 0.4f)).SetEase(Ease.OutSine)
.OnComplete(() => EntityManeger.Inst.AttackCallback(attacker,defender));
}
//자폭
IEnumerator Ability17(Entity attacker,Entity defender)
{
yield return null;
if(defender != null && defender.grade >= 3)
{
byte[] send = new byte[3] {Convert.ToByte(17),Convert.ToByte(attacker.gameObject.name),Convert.ToByte(defender.gameObject.name)};
BackEndMatch.SendMessage(send);
attacker.attackable = false;
Sequence sequence = DOTween.Sequence()
.Append(attacker.transform.DOMove(defender.transform.position, 0.4f)).SetEase(Ease.InSine)
.AppendCallback(() =>
{
defender.Damaged(defender.health);
attacker.Damaged(attacker.health);
EntityManeger.Inst.SpawnDamage(attacker.health, attacker.transform);
EntityManeger.Inst.SpawnDamage(defender.health, defender.transform);
})
.Append(attacker.transform.DOMove(attacker.transform.position, 0.4f)).SetEase(Ease.OutSine)
.OnComplete(() => EntityManeger.Inst.AttackCallback(attacker,defender));
}
}
//불기둥
IEnumerator Ability25(List<Entity> otherEntities, Entity entity)
{
List<GameObject> fires = new List<GameObject>();
List<Entity> dieEntity = new List<Entity>();
yield return null;
byte[] send =new byte[2] {Convert.ToByte(25),Convert.ToByte(entity.gameObject.name)};
BackEndMatch.SendMessage(send);
foreach(var target in otherEntities)
{
var fire = Instantiate(firePrefab,target.transform.position,target.transform.rotation);
fires.Add(fire);
target.Damaged(1);
if(target.health <=0)
{
dieEntity.Add(target);
}
}
var fire2 = Instantiate(firePrefab,otherBoss.transform.position,otherBoss.transform.rotation);
fires.Add(fire2);
otherBoss.Damaged(1);
yield return new WaitForSeconds(1.0f);
foreach(var fire in fires)
{
Destroy(fire.gameObject);
}
foreach(var target in otherEntities)
{
EntityManeger.Inst.SpawnDamage(1,target.transform);
}
EntityManeger.Inst.SpawnDamage(1,otherBoss.transform);
foreach(var row in dieEntity)
{
EntityManeger.Inst.AttackCallback(row);
}
yield return StartCoroutine(EntityManeger.Inst.CheckBossDie());
}
//빛의 집행
IEnumerator Ability30(Entity attacker, Entity defender)
{
yield return null;
Attack(attacker,defender);
yield return new WaitForSeconds(1.0f);
if(attacker != null && defender != null &&defender.health > 1&&defender.grade>=3)
{
defender.health = 1;
StartCoroutine(UpdateATTDEF(defender,false));
byte[] send = new byte[3] {Convert.ToByte(30),Convert.ToByte(attacker.gameObject.name),Convert.ToByte(defender.gameObject.name)};
BackEndMatch.SendMessage(send);
}
}
//어둠의 집행
IEnumerator Ability31(Entity attacker, Entity defender)
{
yield return null;
Attack(attacker,defender);
yield return new WaitForSeconds(1.0f);
if(attacker != null && defender != null &&defender.attack > 1 && defender.grade>=3)
{
defender.attack = 1;
StartCoroutine(UpdateATTDEF(defender,false));
byte[] send = new byte[3] {Convert.ToByte(31),Convert.ToByte(attacker.gameObject.name),Convert.ToByte(defender.gameObject.name)};
BackEndMatch.SendMessage(send);
}
}
//아머
IEnumerator Ability39(Entity entity)
{
yield return new WaitForSeconds(1.5f);
entity.attack-=2;
entity.health += 5;
yield return StartCoroutine(UpdateATTDEF(entity, true));
byte[] send = new byte[4] { Convert.ToByte(39),Convert.ToByte(entity.gameObject.name) ,Convert.ToByte(entity.attack),Convert.ToByte(entity.health)};
BackEndMatch.SendMessage(send);
while(true)
{
yield return null;
if(entity.attackable == true)
{
entity.attack +=2;
if(entity.health>5)
{
entity.health -=5;
}
else
{
entity.health =1;
}
yield return StartCoroutine(UpdateATTDEF(entity,true));
byte[] send1 = new byte[4] { Convert.ToByte(39),Convert.ToByte(entity.gameObject.name), Convert.ToByte(entity.attack),Convert.ToByte(entity.health)};
BackEndMatch.SendMessage(send1);
break;
}
}
}
//태초
IEnumerator Ability35(Entity entity)
{
List<GameObject> chains = new List<GameObject>();
yield return null;
byte[] send = new byte[2] {Convert.ToByte(35),Convert.ToByte(entity.gameObject.name)};
BackEndMatch.SendMessage(send);
foreach(var target in otherEntities)
{
var chain = Instantiate(chainPrefeb,target.transform.position,target.transform.rotation);
chains.Add(chain);
target.Damaged(target.health);
}
foreach(var target in myEntities)
{
var chain = Instantiate(chainPrefeb,target.transform.position,target.transform.rotation);
chains.Add(chain);
target.Damaged(target.health);
}
var fire2 = Instantiate(chainPrefeb,otherBoss.transform.position,otherBoss.transform.rotation);
chains.Add(fire2);
otherBoss.Damaged(15);
var fire3 = Instantiate(chainPrefeb,myBoss.transform.position,myBoss.transform.rotation);
chains.Add(fire3);
myBoss.Damaged(15);
yield return new WaitForSeconds(1.5f);
foreach(var chain in chains)
{
Destroy(chain.gameObject);
}
EntityManeger.Inst.SpawnDamage(15, otherBoss.transform);
EntityManeger.Inst.SpawnDamage(15, myBoss.transform);
yield return new WaitForSeconds(1.5f);
foreach(var row in otherEntities)
{
Sequence sequence = DOTween.Sequence()
.Append(row.transform.DOShakePosition(1.0f))
.Append(row.transform.DOScale(Vector3.zero, 0.3f)).SetEase(Ease.OutCirc)
.OnComplete(() =>
{
Destroy(row.gameObject);
});
}
otherEntities.RemoveRange(0,otherEntities.Count);
foreach(var row in myEntities)
{
Sequence sequence = DOTween.Sequence()
.Append(row.transform.DOShakePosition(1.0f))
.Append(row.transform.DOScale(Vector3.zero, 0.3f)).SetEase(Ease.OutCirc)
.OnComplete(() =>
{
Destroy(row.gameObject);
});
}
myEntities.RemoveRange(0,myEntities.Count);
yield return StartCoroutine(EntityManeger.Inst.CheckBossDie());
}
//-----------------------------------------------------------------------------------------------------------------------------------------------
//-------------------------------------------------------------턴 종료 시-------------------------------------------------------------------------
IEnumerator DoAbility5(List<Entity> myEntities, List<Entity> otherEntities, List<Entity> ablEntities)
{
int[] abilityNum = { 11,22,28,14,46,33};
int entityCnt = ablEntities.Count;
foreach (Entity entity in ablEntities)
{
switch (entity.ablcode1)
{
case 11:
//치유
yield return StartCoroutine(Ability11(myEntities, entity));
yield return new WaitForSeconds(6.0f);
break;
case 22:
//쇠약
yield return StartCoroutine(Ability22(entity));
yield return new WaitForSeconds(6.0f);
break;
case 28:
//변이
yield return StartCoroutine(Ability28(otherEntities, entity));
yield return new WaitForSeconds(6.0f);
break;
case 14:
//침묵
yield return StartCoroutine(Ability14());
yield return new WaitForSeconds(6.0f);
break;
case 46:
//폭주
yield return StartCoroutine(Ability46(entity));
yield return new WaitForSeconds(6.0f);
break;
case 33:
//암흑
yield return StartCoroutine(Ability33(myEntities,entity));
yield return new WaitForSeconds(6.0f);
break;
}
}
}
//치유
IEnumerator Ability11(List<Entity> myEntities, Entity entitiy)
{
foreach(var row in myEntities)
{
row.health+=1;
yield return UpdateATTDEF(row,true);
}
byte[] send = new byte[2] {0x0B, Convert.ToByte(entitiy.gameObject.name)};
BackEndMatch.SendMessage(send);
}
//쇠약
IEnumerator Ability22(Entity entity)
{
TurnManger.Inst.otherGaugeCnt -=1;
TurnManger.Inst.otherNowGaugeCnt-=1;
TurnManger.Inst.ConsumeCost(false,0);
byte[] send = new byte[3] {Convert.ToByte(22),Convert.ToByte(entity.gameObject.name),0x01};
BackEndMatch.SendMessage(send);
entity.ablcode1 = 0;
while(true)
{
yield return null;
if(entity.isDie)
{
entity.ablcode1 = 22;
TurnManger.Inst.otherGaugeCnt +=1;
TurnManger.Inst.otherNowGaugeCnt+=1;
TurnManger.Inst.ConsumeCost(false,0);
byte[] send1 = new byte[3] {Convert.ToByte(22),Convert.ToByte(entity.gameObject.name),0x00};
BackEndMatch.SendMessage(send1);
break;
}
}
}
//변이
IEnumerator Ability28(List<Entity> otherEntities, Entity entity)
{
if(otherEntities.Count>0)
{
Entity target = otherEntities[Random.Range(0,otherEntities.Count)];
int att;
att = target.attack;
target.attack = 0;
yield return StartCoroutine(UpdateATTDEF(target,false));
Sprite temp = target.transform.GetChild(0).GetComponent<SpriteRenderer>().sprite;
target.transform.GetChild(0).GetComponent<SpriteRenderer>().sprite = pig;
byte[] send =new byte[4] {Convert.ToByte(28),Convert.ToByte(entity.gameObject.name),Convert.ToByte(target.gameObject.name),0x01};
BackEndMatch.SendMessage(send);
while(true)
{
yield return null;
if(entity.isDie || TurnManger.Inst.myTurn)
{
target.attack = att;
yield return StartCoroutine(UpdateATTDEF(target,true));
target.transform.GetChild(0).GetComponent<SpriteRenderer>().sprite = temp;
byte[] send1 =new byte[4] {Convert.ToByte(28),Convert.ToByte(entity.gameObject.name),Convert.ToByte(target.gameObject.name),0x00};
BackEndMatch.SendMessage(send1);
break;
}
}
}
}
//침묵
IEnumerator Ability14()
{
if(Random.Range(0,10)<3)
{
yield return new WaitForSeconds(3.0f);
GameManager.Inst.Notification("침묵!");
byte[] send = new byte[1] {0x0E};
BackEndMatch.SendMessage(send);
}
}
//암흑
IEnumerator Ability33(List<Entity> myEntities, Entity entity)
{
yield return null;
int index = Random.Range(0,myEntities.Count);
Debug.Log(myEntities[index]);
myEntities[index].gameObject.GetComponent<BoxCollider2D>().enabled = false;
byte[] send = new byte[4] {Convert.ToByte(33),Convert.ToByte(entity.gameObject.name),Convert.ToByte(myEntities[index].gameObject.name),0x01};
BackEndMatch.SendMessage(send);
while(true)
{
yield return null;
if(TurnManger.Inst.myTurn)
{
myEntities[index].gameObject.GetComponent<BoxCollider2D>().enabled = true;
byte[] send1 = new byte[4] {Convert.ToByte(33),Convert.ToByte(entity.gameObject.name),Convert.ToByte(myEntities[index].gameObject.name),0x00};
BackEndMatch.SendMessage(send1);
break;
}
}
}
//폭주
IEnumerator Ability46(Entity entity)
{
while(true)
{
yield return null;
if(entity.isDie)
break;
if(TurnManger.Inst.myTurn)
{
SpawnEntity(SetEntity(int.Parse(entity.link[0])));
myEntities.Remove(entity);
Sequence sequence = DOTween.Sequence()
.Append(entity.transform.DOShakePosition(1.0f))
.Append(entity.transform.DOScale(Vector3.zero, 0.3f)).SetEase(Ease.OutCirc)
.OnComplete(() =>
{
EntityManeger.Inst.EntityAlignment(entity.isMine);
Destroy(entity.gameObject);
});
byte[] send =new byte[2] {Convert.ToByte(46),Convert.ToByte(entity.gameObject.name)};
BackEndMatch.SendMessage(send);
break;
}
}
}
//----------------------------------------------------------------------------------------------------------------------------------------------
//-------------------------------------------------------------드래그 시-------------------------------------------------------------------------
IEnumerator DoAbility3(List<Entity> myEntities,List<Entity> otherEntities, Entity entity)
{
switch (entity.ablcode1)
{
case 29:
//저주
yield return StartCoroutine(Ability29(entity));
break;
case 21:
//직접 공격
yield return null;
break;
}
}
//저주
IEnumerator Ability29(Entity entity)
{
otherBoss.canBeAttacked = false;
while(true)
{
yield return null;
if(entity != EntityManeger.Inst.selectEntity)
{
otherBoss.canBeAttacked = true;
break;
}
}
}
//직접 공격
IEnumerator Ability21(List<Entity> otherEntities, Entity entity)
{
yield return null;
}
//----------------------------------------------------------------------------------------------------------------------------------------------
//-------------------------------------------------------------공격상대 능력 발동 시--------------------------------------------------------------------
IEnumerator DoAbility7(List<Entity> myEntities,List<Entity> otherEntities, Entity attacker,Entity defender)
{
switch (defender.ablcode1)
{
case 38:
//장난
yield return StartCoroutine(Ability38(attacker,defender));
break;
case 4:
//회피
yield return StartCoroutine(Ability4(attacker,defender));
break;
case 32:
//거울
yield return StartCoroutine(Ability32(attacker,defender));
break;
case 44:
//공격 무효화
yield return StartCoroutine(Ability44(attacker,defender));
break;
case 45:
//사령
yield return StartCoroutine(Ability45(myEntities,attacker,defender));
break;
case 35:
//태초
yield return StartCoroutine(Ability35(attacker));
break;
}
}
//장난
IEnumerator Ability38(Entity attacker,Entity defender) // 공격자 : 나
{
yield return null;
if(Random.Range(0,2) ==0)
{
byte[] send = new byte[] {Convert.ToByte(38),Convert.ToByte(attacker.gameObject.name),Convert.ToByte(defender.gameObject.name)};
BackEndMatch.SendMessage(send);
attacker.attackable = false;
Sequence sequence = DOTween.Sequence()
.Append(attacker.transform.DOMove(defender.transform.position, 0.4f)).SetEase(Ease.InSine)
.AppendCallback(() =>
{
defender.Damaged(-attacker.attack);
StartCoroutine(UpdateATTDEF(defender,true));
attacker.Damaged(defender.attack);
EntityManeger.Inst.SpawnDamage(defender.attack, attacker.transform);
EntityManeger.Inst.SpawnDamage(-attacker.attack, defender.transform);
})
.Append(attacker.transform.DOMove(attacker.transform.position, 0.4f)).SetEase(Ease.OutSine)
.OnComplete(() => EntityManeger.Inst.AttackCallback(attacker, defender));
}
else
{
if(abilityNum[attacker.ablcode1].state != (int)ETurnState.attacking)
{
byte[] send = new byte[3] { 0x00, Convert.ToByte(attacker.gameObject.name), Convert.ToByte(defender.gameObject.name) };
BackEndMatch.SendMessage(send);
Attack(attacker,defender);
}
}
}
//회피
IEnumerator Ability4(Entity attacker,Entity defender)
{
yield return null;
if(Random.Range(0,2) ==0)
{
byte[] send = new byte[3] {Convert.ToByte(4),Convert.ToByte(attacker.gameObject.name),Convert.ToByte(defender.gameObject.name)};
BackEndMatch.SendMessage(send);
attacker.attackable = false;
Sequence sequence = DOTween.Sequence()
.Append(attacker.transform.DOMove(defender.transform.position, 0.4f)).SetEase(Ease.InSine)
.AppendCallback(() =>
{
})
.Append(attacker.transform.DOMove(attacker.transform.position, 0.4f)).SetEase(Ease.OutSine)
.OnComplete(() => EntityManeger.Inst.AttackCallback(attacker, defender));
}
else
{
if(abilityNum[attacker.ablcode1].state != (int)ETurnState.attacking)
{
byte[] send = new byte[3] { 0x00, Convert.ToByte(attacker.gameObject.name), Convert.ToByte(defender.gameObject.name) };
BackEndMatch.SendMessage(send);
Attack(attacker,defender);
}
}
}
//거울
IEnumerator Ability32(Entity attacker,Entity defender)
{
yield return null;
if (abilityNum[attacker.ablcode1].state != (int)ETurnState.attacking)
{
byte[] send = new byte[3] { 0x00, Convert.ToByte(attacker.gameObject.name), Convert.ToByte(defender.gameObject.name) };
BackEndMatch.SendMessage(send);
Attack(attacker, defender);
}
yield return new WaitForSeconds(1.5f);
if(!defender.isDie)
{
byte[] send =new byte[3] {Convert.ToByte(32),Convert.ToByte(attacker.gameObject.name),Convert.ToByte(defender.gameObject.name)};
BackEndMatch.SendMessage(send);
AbilityAttack(defender.gameObject,myBoss,attacker.attack);
}
}
//공격 무효화
IEnumerator Ability44(Entity attacker,Entity defender)
{
yield return null;
if(Random.Range(0,2) ==0)
{
byte[] send = new byte[3] { Convert.ToByte(44), Convert.ToByte(attacker.gameObject.name), Convert.ToByte(defender.gameObject.name) };
BackEndMatch.SendMessage(send);
attacker.attackable = false;
Sequence sequence = DOTween.Sequence()
.Append(attacker.transform.DOMove(defender.transform.position, 0.4f)).SetEase(Ease.InSine)
.AppendCallback(() =>
{
attacker.Damaged(defender.attack);
EntityManeger.Inst.SpawnDamage(defender.attack, attacker.transform);
EntityManeger.Inst.SpawnDamage(-attacker.attack, defender.transform);
})
.Append(attacker.transform.DOMove(attacker.transform.position, 0.4f)).SetEase(Ease.OutSine)
.OnComplete(() => EntityManeger.Inst.AttackCallback(attacker, defender));
}
else
{
if (abilityNum[attacker.ablcode1].state != (int)ETurnState.attacking)
{
byte[] send = new byte[3] { 0x00, Convert.ToByte(attacker.gameObject.name), Convert.ToByte(defender.gameObject.name) };
BackEndMatch.SendMessage(send);
Attack(attacker, defender);
}
}
}
//사령
IEnumerator Ability45(List<Entity> myentities, Entity attacker, Entity defender)
{
yield return null;
if (abilityNum[attacker.ablcode1].state != (int)ETurnState.attacking)
{
byte[] send = new byte[3] { 0x00, Convert.ToByte(attacker.gameObject.name), Convert.ToByte(defender.gameObject.name) };
BackEndMatch.SendMessage(send);
Attack(attacker, defender);
}
yield return new WaitForSeconds(1.5f);
if (!defender.isDie && defender.health <= 5 && myentities.Count<10)
{
int index = Random.Range(0,defender.link.Count);
byte[] send = new byte[3] { Convert.ToByte(45), Convert.ToByte(defender.gameObject.name), Convert.ToByte(index) };
BackEndMatch.SendMessage(send);
SpawnEntity(SetEntity(int.Parse(defender.link[index])));
}
}
//----------------------------------------------------------------------------------------------------------------------------------------------
//-------------------------------------------------------------몬스터 소멸 시--------------------------------------------------------------------
IEnumerator DoAbility9(List<Entity> myEntities,List<Entity> otherEntities, Entity entity)
{
switch (entity.ablcode1)
{
case 3:
//제물
yield return StartCoroutine(Ability3(entity));
break;
case 8:
//오염
yield return StartCoroutine(Ability8(entity,otherEntities));
break;
case 13:
//부활
yield return StartCoroutine(Ability13(entity));
break;
case 19:
//폭발
yield return StartCoroutine(Ability19(entity,otherEntities));
break;
case 42:
//카드 뽑기
yield return StartCoroutine(Ability42(entity));
break;
}
}
//제물
IEnumerator Ability3(Entity entity)
{
yield return null;
if(myEntities.Count<10)
{
int index = Random.Range(0,entity.link.Count);
yield return new WaitForSeconds(1.0f);
SpawnEntity(SetEntity(int.Parse(entity.link[index])));
byte[] send = new byte[4]{0x02,BackEndMatch.ConvertByte(index)[0],BackEndMatch.ConvertByte(index)[1],BackEndMatch.ConvertByte(index)[2]};
BackEndMatch.SendMessage(send);
}
}
//오염
IEnumerator Ability8(Entity entity,List<Entity> otherEntities)
{
if(otherEntities.Count>0)
{
foreach(var row in otherEntities)
{
row.attack-=1;
yield return StartCoroutine(UpdateATTDEF(row,false));
}
byte[] send = new byte[2] {0x08, Convert.ToByte(entity.gameObject.name)};
BackEndMatch.SendMessage(send);
}
}
public int cnt122254 = 0;
public int cnt120422 = 0;
//부활
IEnumerator Ability13(Entity entity)
{
yield return new WaitForSeconds(1.0f);
if(entity.code == 122254) //혼테일 3회
{
if(cnt122254 != 3)
{
Debug.Log("122254");
cnt122254+=1;
Item _new = SetEntity(entity.code);
_new.attack -=2*cnt122254;
SpawnEntity(_new);
byte[] send = new byte[5] {0x0D, BackEndMatch.ConvertByte(122254)[0],BackEndMatch.ConvertByte(122254)[1],BackEndMatch.ConvertByte(122254)[2],Convert.ToByte(cnt122254)};
BackEndMatch.SendMessage(send);
}
else
{
cnt122254 = 0;
}
}
else if (entity.code == 120422)//블랙 크레센도 슬라임 5회
{
if (Random.Range(0, 10) > 2)
{
cnt120422 +=1;
Item _new = SetEntity(entity.code);
_new.health +=1*cnt120422;
SpawnEntity(_new);
byte[] send = new byte[5] {0x0D, BackEndMatch.ConvertByte(120422)[0],BackEndMatch.ConvertByte(120422)[1],BackEndMatch.ConvertByte(120422)[2],Convert.ToByte(cnt120422)};
BackEndMatch.SendMessage(send);
}
else
{
cnt120422 = 0;
}
}
else
{
if(Random.Range(0,1) == 0)
{
SpawnEntity(SetEntity(entity.code));
}
}
}
//폭발
IEnumerator Ability19(Entity entity,List<Entity> otherEntities)
{
if(otherEntities.Count>0)
{
byte[] send = new byte[2] {Convert.ToByte(19),Convert.ToByte(entity.gameObject.name)};
BackEndMatch.SendMessage(send);
foreach(var row in otherEntities)
{
row.health -=1;
yield return StartCoroutine(UpdateATTDEF(row,false));
}
}
}
//카드 뽑기
IEnumerator Ability42(Entity entity)
{
yield return new WaitForSeconds(0.5f);
CardManager.Inst.AddCard(true);
yield return new WaitForSeconds(0.5f);
CardManager.Inst.AddCard(true);
}
//----------------------------------------------------------------------------------------------------------------------------------------------
}