void Start() { Screen.sleepTimeout = SleepTimeout.NeverSleep; TextAsset cardsData = Resources.Load <TextAsset>("cardsdata"); data = cardsData.text.Split(new char[] { '\n' }); for (int i = 1; i < data.Length - 1; i++) { row = data[i].Split(new char[] { ';' }); if (row[1] != "") { CardsInformations ci = new CardsInformations(); ci.id = row[0]; ci.name = row[1]; ci.damage = row[2]; ci.armor = row[3]; ci.damageElement = row[4]; ci.armorElement = row[5]; cardsInfos.Add(ci); } } foreach (CardsInformations q in cardsInfos) { //Debug.Log(q.name); } }
private void Update() { if (Input.GetKeyDown(KeyCode.A)) { CardsInformations c = new CardsInformations("1.1", "megamassue", "5", "0", "electric", ""); player1.AddEquipment(c); } if (Input.GetKeyDown(KeyCode.Q)) { CardsInformations c = new CardsInformations("1.1", "megamassue", "5", "0", "electric", ""); player2.AddEquipment(c); } if (Input.GetKeyDown(KeyCode.Z)) { CardsInformations c = new CardsInformations("1.2", "megaboubou", "0", "5", "", "electric"); player1.AddEquipment(c); } if (Input.GetKeyDown(KeyCode.S)) { CardsInformations c = new CardsInformations("1.2", "megaboubou", "0", "5", "", "electric"); player2.AddEquipment(c); } if (Input.GetKeyDown(KeyCode.E)) { CardsInformations c = new CardsInformations("1.3", "megaboubou", "8", "8", "ice", "electric"); player1.AddEquipment(c); } if (Input.GetKeyDown(KeyCode.D)) { CardsInformations c = new CardsInformations("1.3", "megaboubou", "8", "8", "ice", "electric"); player2.AddEquipment(c); } if (Input.GetKeyDown(KeyCode.R)) { player1.ScanAdventurer("1"); } if (Input.GetKeyDown(KeyCode.T)) { player1.ScanAdventurer("2"); } if (Input.GetKeyDown(KeyCode.F)) { player2.ScanAdventurer("3"); } }
public void RemoveEquipment(CardsInformations c) { GameObject g; bool b = equipmentDictionnary.TryGetValue(c.id, out g); if (b) { equipmentDictionnary.Remove(c.id); for (int i = 0; i < equipmentGrid.transform.childCount; i++) { if (equipmentGrid.transform.GetChild(i).gameObject == g) { GameObject u = equipmentGrid.transform.GetChild(i).gameObject; u.transform.DOScale(Vector3.zero, 0.5f).SetEase(Ease.OutSine).OnComplete(() => Destroy(u.gameObject)); } } if (c.damageElement != "") { switch (c.damageElement) { case "fire": playerFireATK -= int.Parse(c.damage); break; case "ice": playerIceATK -= int.Parse(c.damage); break; case "electric": playerElectricATK -= int.Parse(c.damage); break; } } if (c.armorElement != "") { switch (c.armorElement) { case "fire": playerFireDEF -= int.Parse(c.armor); break; case "ice": playerIceDEF -= int.Parse(c.armor); break; case "electric": playerElectricDEF -= int.Parse(c.armor); break; } } } UpdateStatsPlayer(); UpdateStatsUIPlayer(); }
public void ReceivePlayer2CardsInfos(OSCMessage message) { Debug.Log("Player Two Scan : " + message.Values[0].StringValue); string id = message.Values[0].StringValue; CardsInformations c = ExcelManager.Instance.GetInfosOfTheCard(id, 2); if (c != null) { if (id == "RDY") { //Met Le joueur pret/non pret SoundManager.instance.ValidationStuff(); playerTwoReady = !playerTwoReady; return; } if (c.name.Contains("Aventurer") == true) { //Recuperer les infos de l'aventurier GameManager.Instance.player2.ScanAdventurer(c.id); print("Adventurer Scanned"); return; } else { //Verifie la position de la carte scanné dans les listes et assigne la fonction correspondante if (ExcelManager.Instance.IsMyCardScannedPlayerTwo(id) == true) { GameManager.Instance.player2.RemoveEquipment(c); Debug.Log("Player Two Scan Remove : " + message.Values[0].StringValue); } else { GameManager.Instance.player2.AddEquipment(c); Debug.Log("Player Two Scan Add : " + message.Values[0].StringValue); } } } }
public CardsInformations GetInfosOfTheCard(string idOfTheScannedCard, int player) { CardsInformations c = new CardsInformations(); bool cardAlreadyFound = false; for (int i = 0; i < cardsInfos.Count; i++) { if (idOfTheScannedCard == cardsInfos[i].id) { c = cardsInfos[i]; cardAlreadyFound = true; if (player == 1) { if (c.name.Contains("Aventurer")) { SoundManager.instance.PositifScan(); return(c); } if (cardsScannedPlayerOne.Count == MaxStuff) { print("ERROR 4 : Too Many Scanned Card For Player 1"); SoundManager.instance.NegatifScan(); return(null); } cardsScannedPlayerOne.Add(c); SoundManager.instance.PositifScan(); SoundManager.instance.AttachedStuffToPlayer(); } else { if (c.name.Contains("Aventurer")) { SoundManager.instance.PositifScan(); return(c); } if (cardsScannedPlayerTwo.Count == MaxStuff) { print("ERROR 5 : Too Many Scanned Card For Player 2"); SoundManager.instance.NegatifScan(); return(null); } SoundManager.instance.PositifScan(); SoundManager.instance.AttachedStuffToPlayer(); cardsScannedPlayerTwo.Add(c); } cardsInfos.RemoveAt(i); break; } } if (cardAlreadyFound == false) { if (player == 1) { for (int i = 0; i < cardsScannedPlayerOne.Count; i++) { if (idOfTheScannedCard == cardsScannedPlayerOne[i].id) { c = cardsScannedPlayerOne[i]; cardsInfos.Add(c); cardsScannedPlayerOne.RemoveAt(i); SoundManager.instance.PositifScan(); SoundManager.instance.DeattachedStuffToPlayer(); } } } else { for (int i = 0; i < cardsScannedPlayerTwo.Count; i++) { if (idOfTheScannedCard == cardsScannedPlayerTwo[i].id) { c = cardsScannedPlayerTwo[i]; cardsInfos.Add(c); cardsScannedPlayerTwo.RemoveAt(i); SoundManager.instance.PositifScan(); SoundManager.instance.DeattachedStuffToPlayer(); } } } } return(c); }
public void AddEquipment(CardsInformations c) { if (GameManager.Instance.state == GameManager.State.STATS) { GameObject equipment; //add the gameobject to the equipment grid if (c.damage != "0" && c.armor != "0") { equipment = Instantiate(GameManager.Instance.cardMixtPrefab, equipmentGrid.transform); equipment.GetComponent <Stuff>().stuffImage.sprite = GameManager.Instance.spriteStuff[int.Parse((c.id).Split('.')[0]) - 1]; equipment.GetComponent <Stuff>().textValueAtk.text = c.damage; equipment.GetComponent <Stuff>().textValueDef.text = c.armor; equipmentDictionnary.Add(c.id, equipment); } else if (c.damage != "0") { equipment = Instantiate(GameManager.Instance.cardAtkPrefab, equipmentGrid.transform); equipment.GetComponent <Stuff>().stuffImage.sprite = GameManager.Instance.spriteStuff[int.Parse((c.id).Split('.')[0]) - 1]; equipment.GetComponent <Stuff>().textValueAtk.text = c.damage; equipmentDictionnary.Add(c.id, equipment); } else if (c.armor != "0") { equipment = Instantiate(GameManager.Instance.cardDefPrefab, equipmentGrid.transform); //equipment.GetComponent<Stuff>().stuffImage.sprite = GameManager.Instance.spriteStuff[int.Parse((c.id).Split('.')[0]) - 1]; equipment.GetComponent <Stuff>().stuffImage.sprite = GameManager.Instance.spriteStuff[20]; equipment.GetComponent <Stuff>().textValueDef.text = c.armor; equipmentDictionnary.Add(c.id, equipment); } if (equipmentDictionnary.TryGetValue(c.id, out equipment)) { equipment.transform.DOScale(Vector3.zero, 0.5f).From().SetEase(Ease.OutBounce); } Stuff stuff = equipment.GetComponent <Stuff>(); //calculate different type of atk and def Color co = new Color(stuff.imageElementAtk.color.r, stuff.imageElementAtk.color.g, stuff.imageElementAtk.color.b, 255); if (c.damageElement.Trim().Replace("\r", "") != "") { switch (c.damageElement.Replace("\r", "")) { case "fire": playerFireATK += int.Parse(c.damage); stuff.imageElementAtk.sprite = GameManager.Instance.fireSprite; stuff.imageElementAtk.color = co; stuff.elementAtk = Element.FIRE; break; case "ice": playerIceATK += int.Parse(c.damage); stuff.imageElementAtk.sprite = GameManager.Instance.iceSprite; stuff.imageElementAtk.color = co; stuff.elementAtk = Element.ICE; break; case "electric": playerElectricATK += int.Parse(c.damage); stuff.imageElementAtk.sprite = GameManager.Instance.electricSprite; stuff.imageElementAtk.color = co; stuff.elementAtk = Element.ELECTRIC; break; } } else { playerATKNoElement += int.Parse(c.damage); } co = new Color(stuff.imageElementDef.color.r, stuff.imageElementDef.color.g, stuff.imageElementDef.color.b, 255); if (c.armorElement.Trim().Replace("\r", "") != "") { switch (c.armorElement.Replace("\r", "")) { case "fire": playerFireDEF += int.Parse(c.armor); stuff.imageElementDef.sprite = GameManager.Instance.fireSprite; stuff.imageElementDef.color = co; stuff.elementDef = Element.FIRE; break; case "ice": playerIceDEF += int.Parse(c.armor); stuff.imageElementDef.sprite = GameManager.Instance.iceSprite; stuff.imageElementDef.color = co; stuff.elementDef = Element.ICE; break; case "electric": playerElectricDEF += int.Parse(c.armor); stuff.imageElementDef.sprite = GameManager.Instance.electricSprite; stuff.imageElementDef.color = co; stuff.elementDef = Element.ELECTRIC; break; default: break; } } else { playerDEFNoElement += int.Parse(c.armor); } //feedback atk or def is double if (stuff.elementAtk == GameManager.Instance.monsterManager.elementDef && stuff.elementAtk != Element.NULL) { stuff.AtkIsDouble(); } if (stuff.elementDef == GameManager.Instance.monsterManager.elementAtk && stuff.elementDef != Element.NULL) { stuff.DefIsDouble(); } UpdateStatsPlayer(); UpdateStatsUIPlayer(); } }