public int MakeNewBattleStorage(int OwnerID) { foreach (List <PhotonPlayer> player in Groups.ToArray()) { if (player [0].ID == OwnerID) { List <int> ids = new List <int> (); foreach (PhotonPlayer play in player.ToArray()) { ids.Add(play.ID); } BattleStorage b_stor = new BattleStorage(ids.ToArray()); B_Storages.Add(b_stor); int b_id = B_Storages.IndexOf(b_stor); b_stor.BattleID = b_id; for (int i = 0; i < ids.Count; i++) { userBattle.Add(new int[ids [0], b_id]); } return(b_id); } } return(0); }
public int CheckUsable(Skill Skill, int BattleID, int Position) { BattleStorage b = ServerStorage.Sv_Storage.B_Storages [BattleID]; int row = 0; row = Position - 4; if (Position < 4) { row = Position; } else { row = Position - (4 * (int)(Position / 4)); } int col = Position / 4; int[] tp_targets = Skill.PositionalTarget; TargetList = new List <int> (tp_targets); try{ switch (col) { case 0: TargetList.RemoveRange(0, 12); break; case 1: TargetList.RemoveRange(0, 8); TargetList.RemoveRange(16, 4); break; case 2: TargetList.RemoveRange(0, 4); TargetList.RemoveRange(16, 8); break; case 3: TargetList.RemoveRange(16, 12); break; } }catch { Debug.Log(Skill.Name); } int[] pos = b.Positions; if (Skill.ActivateRow [row] != 0) { for (int i = 0; i < TargetList.Count; i++) { if (pos [i] != 0 && TargetList [i] == 1) { Skill.TargetFields = this.TargetList; return(i); } } } return(0); }
private Character GetTargetWithPosition(BattleStorage b, int Site, int Position) { if (b.Positions [Position + 16 * Site] == 0) { print("error no target found"); } int ID = b.Positions [Position + 16 * Site]; if (ID < 0) { foreach (Character c in b.Enemy.ToArray()) { if (c.ID == ID) { return(c); } } } else { foreach (Character c in b.Players.ToArray()) { if (c.ID == ID) { return(c); } } } return(null); }
public void CreateEnemies(int tp_enemyid, int tp_maxhealth, int tp_armor, float tp_dodge, int tp_position, int tp_mindps, int tp_maxdps, int tp_speed, int tp_fire, int tp_ice, int tp_shock, string tp_skills, int tp_exp, int BattleID) { //Enemy.Add (new Character (true ,0 ,"Enemy", 30, 1, 30, 0.2f, 8, 2, 4, 20,"Warrior",25,25,25,"","","",0)); Character tp_char = new Character(true, tp_enemyid * -1, "Enemy", tp_maxhealth, tp_maxhealth, tp_armor, tp_dodge, tp_position, tp_mindps, tp_maxdps, tp_speed, "Archer", tp_fire, tp_ice, tp_shock, tp_skills, null, null, 0, 0, 0, 0, 0); tp_char.expGain = tp_exp; BattleStorage b = ServerStorage.Sv_Storage.B_Storages [BattleID]; b.Enemy.Add(tp_char); b.enemyloaded++; LoadEnemySkills(tp_enemyid * -1, BattleID); if (b.enemycount <= b.enemyloaded) { string[] simpleChars = new string[b.Enemy.Count]; for (int i = 0; i < simpleChars.Length; i++) { string tp_string = b.Enemy [i].MakeSimpleString(); simpleChars [i] = tp_string; } print("Sending " + simpleChars.Length + " IDs " + b.GroupIds[0]); RaiseEventOptions opt = new RaiseEventOptions(); opt.TargetActors = b.GroupIds; PhotonNetwork.RaiseEvent(51, simpleChars, true, opt); } }
public void MakeEnemies(string tp_string, int tp_customid, int BattleID) { string[] tp_new = tp_string.Split("|" [0]); string[] tp_i = tp_new [0].Split("/" [0]); List <string> tp_array = new List <string> (tp_i); for (int i = 0; i < tp_array.Count; i++) { if (int.Parse(tp_array [i]) == 0) { tp_array.RemoveAt(i); i--; } } tp_i = tp_array.ToArray(); int pos = 0; BattleStorage b = ServerStorage.Sv_Storage.B_Storages [BattleID]; while (true) { int ran = (int)Random.Range(0, tp_i.Length); int u = int.Parse(tp_i [ran]); pos = (u - 1) + 4 * (int)(Random.Range(0, 4)); if (b.Positions [pos + 16] == 0) { b.Positions [pos + 16] = tp_customid * -1; break; } } CreateEnemies(tp_customid, int.Parse(tp_new [1]), int.Parse(tp_new [2]), float.Parse(tp_new[3]), pos, int.Parse(tp_new [4]), int.Parse(tp_new [5]), int.Parse(tp_new [6]), int.Parse(tp_new [7]), int.Parse(tp_new [8]), int.Parse(tp_new [9]), tp_new[10], int.Parse(tp_new[11]), BattleID); }
public void InitializeServerBattle(bool tp_bool, int BattleID) { BattleStorage b = ServerStorage.Sv_Storage.B_Storages [BattleID]; if (tp_bool) { StartCoroutine(b.InitializeBattle(tp_bool)); } }
public void MoveCharacter(int BattleID, int Position, int NewPosition) { BattleStorage b = ServerStorage.Sv_Storage.B_Storages [BattleID]; Debug.Log("moving Id=" + b.Positions [Position] + " to Position=" + NewPosition); if (b.Positions [NewPosition] == 0) { b.Positions [NewPosition] = b.Positions [Position]; b.Positions [Position] = 0; } RaiseEventOptions opt = new RaiseEventOptions(); opt.TargetActors = b.GroupIds; PhotonNetwork.RaiseEvent(61, new int[] { b.Positions [NewPosition], NewPosition }, true, opt); }
public void RollDmg(int BattleID, int TargetMode, float Skill_Mod, bool Dodgeable, int targetPos, int Site, int MinDPS, int MaxDPS) { BattleStorage b = ServerStorage.Sv_Storage.B_Storages [BattleID]; int tp_damage = (int)((MinDPS + MaxDPS * Random.value) * Skill_Mod); Character Target = GetTargetWithPosition(b, Site, targetPos); //Single Target if (TargetMode == 0) { if ((Dodgeable && (Random.value > Target.Dodge)) || !Dodgeable) { //Dmged Target.Health -= tp_damage; RaiseEventOptions opt = new RaiseEventOptions(); opt.TargetActors = b.GroupIds; PhotonNetwork.RaiseEvent(58, new int[] { Target.ID, -tp_damage }, true, opt); } else { //Dodeged GameManager.k_Manager.Target.transform.parent.GetChild(1).GetComponent <CharacterClass> ().MakeText("Dodged", new Color(255, 255, 0)); RaiseEventOptions opt = new RaiseEventOptions(); opt.TargetActors = b.GroupIds; PhotonNetwork.RaiseEvent(59, new int[] { Target.ID, 0 }, true, opt); } } // //AOE // if (TargetMode == 2) { // foreach (Transform trans in k_relatedButton.GetComponent<ButtonClass>().tp_list.ToArray()) { // if (trans.FindChild ("Character(Clone)")!=null) { // if ((Dodgeable && Random.value > trans.FindChild ("Character(Clone)").GetComponent<CharacterClass> ().k_Character.Dodge) || !Dodgeable) { // tp_damage = (int)((b.CharacterOrder [0].MinDPS + b.CharacterOrder [0].MaxDPS * Random.value) * Skill_Mod); // trans.FindChild ("Character(Clone)").GetComponent<CharacterClass> ().k_Character.Health -= tp_damage; // trans.FindChild ("Character(Clone)").GetComponent<CharacterClass> ().MakeText ("- " + tp_damage, new Color (255, 0, 0)); // } else { // trans.FindChild ("Character(Clone)").GetComponent<CharacterClass> ().MakeText ("Dodged", new Color (255, 255, 0)); // } // } // } // } b.EndTurn(); }
private void EstimateEnemies(int BattleID, int[] MinMax, int[] EnemyIDs) { int i = (int)(Random.Range(MinMax[0], MinMax[1] + 1)); BattleStorage b = ServerStorage.Sv_Storage.B_Storages [BattleID]; b.enemycount = i; print("EnemyCount =" + i); for (int j = 0; j < i; j++) { if (j == 0) { LoadEnemies(EnemyIDs [0], j + 1, BattleID); continue; } int o = Random.Range(0, EnemyIDs.Length); LoadEnemies(EnemyIDs[o], j + 1, BattleID); } }
public void DropNewItem(BattleStorage b) { this.TierValue = 0; // GameManager.k_Manager.LootLoaded = false; //Get Level of Lowest Group Member List <Character> tp_char = new List <Character> (); tp_char = b.Players; tp_char = tp_char.OrderBy(go => go.Level).ToList(); PlayerLevel = tp_char [0].Level; print("lowest Player is " + tp_char[0].Name); string Rarity; string Type; int Value = 0; Skill AppliedSkill; string[,] Attributes; float ran = Random.value; RarityTier = 0; if (ran > 0.99999f) { Rarity = "Legendary"; RarityTier = 5; Value += 5000; } else if (ran > 0.95f) { Rarity = "Epic"; RarityTier = 4; Value += 1200; } else if (ran > 0.8f) { Rarity = "Rare"; RarityTier = 3; Value += 1200; } else if (ran > 0.65f) { Rarity = "Magic"; RarityTier = 2; Value += 200; } else if (ran > 0.5f) { Rarity = "Uncommon"; RarityTier = 1; Value += 50; } else { Rarity = "Common"; Value += 10; } int rand = Random.Range(0, 6); switch (rand) { case 0: Type = "Amulet"; break; case 1: Type = "Ring"; break; case 2: Type = "Boots"; break; case 3: Type = "Helm"; break; case 4: Type = "Shoulder"; break; case 5: Type = "Weapon"; break; default: Type = ""; break; } Attributes = GiveNewAttributes(Rarity, Type); Value += (int)(Value * (0.05f * TierValue)); print("New Item :" + Rarity + " - " + Type); print(Attributes.Length); for (int i = 0; i < Attributes.Length / 2; i++) { print(Attributes[i, 0] + " : " + Attributes[i, 1]); } //Problem with getting item ID StartCoroutine(InsertItem(b, Rarity, Type, Attributes, PlayerLevel, Value)); }
IEnumerator InsertItem(BattleStorage b, string tp_rarity, string tp_type, string[,] tp_attributes, int tp_itemlevel, int tp_value) { print(tp_itemlevel + tp_type); float rate = 1.0f; switch (tp_rarity) { case "Common": //common rate = 0.8f; break; case "Uncommon": //base normal rate = 0.9f; break; case "Magic": // Base base normal rate = 1.0f; break; case "Rare": // base base normal special rate = 1.1f; break; case "Epic": // base base normal special rate = 1.25f; break; case "Legendary": rate = 1.4f; break; } int minDps = 0; int maxDps = 0; if (tp_type.Equals("Weapon")) { int avg = (int)Mathf.Round((tp_itemlevel * ((rate - 0.05f) + (Random.value * 0.10f)))); int dif = (int)(Random.value * avg * 0.5f); maxDps = avg + dif; minDps = avg - dif; } string tp_sql = "('New','" + tp_type + "','" + tp_rarity + "','" + tp_value + "','10','" + minDps + "','" + maxDps + "',"; string stats = ""; string[] input = new string[19]; for (int i = 0; i < input.Length; i++) { input [i] = 0 + ""; } for (int i = 0; i < tp_attributes.Length / 2; i++) { //stats = stats + tp_attributes [i] [0] + "|" + tp_attributes [i] [1] + ";"; switch (tp_attributes [i, 0]) { case "Strength": input [0] = tp_attributes [i, 1]; break; case "Constitution": input [1] = tp_attributes [i, 1]; break; case "Dexterity": input [2] = tp_attributes [i, 1]; break; case "Intelligence": input [3] = tp_attributes [i, 1]; break; case "Luck": input [4] = tp_attributes [i, 1]; break; case "Dodge": input [5] = tp_attributes [i, 1]; break; case "Health": input [6] = tp_attributes [i, 1]; break; case "Armor": input [7] = tp_attributes [i, 1]; break; case "Speed": input [8] = tp_attributes [i, 1]; break; case "Crit Chance": input [9] = tp_attributes [i, 1]; break; case "Damage": input [10] = tp_attributes [i, 1]; break; case "Crit Damage": input [11] = tp_attributes [i, 1]; break; case "Magic Damage": input [12] = tp_attributes [i, 1]; break; case "Crit Magic": input [13] = tp_attributes [i, 1]; break; case "Fire Resistance": input [14] = tp_attributes [i, 1]; break; case "Ice Resistance": input [15] = tp_attributes [i, 1]; break; case "Lightning Resistance": input [16] = tp_attributes [i, 1]; break; case "Magic Find": input [17] = tp_attributes [i, 1]; break; case "Gold Find": input [18] = tp_attributes [i, 1]; break; } } for (int i = 0; i < input.Length; i++) { tp_sql = tp_sql + "'" + input[i] + "',"; } int weight = (int)(Random.value * 100); tp_sql = tp_sql + "'" + weight + "','0');"; print(tp_sql); WWWForm form = new WWWForm(); //"' AND type='"+ tp_type + form.AddField("sql_text_post", "INSERT INTO items (item_name, type, rarity, value, item_level,min_dps,max_dps, strength,constitution, dexterity,intelligence,luck ,health,armor,dodge,speed,res_fire,res_ice,res_lightning,damage,crit_damage, magic_damage,crit_magic,crit_chance,magicpercent,goldpercent,weight, skill) VALUES " + tp_sql); WWW itemsdata = new WWW("https://localhost/RPG/InsertData.php", form); yield return(itemsdata); print("Dropped Item is listed at ID: " + itemsdata.text); WWWForm form2 = new WWWForm(); form.AddField("sql_text_post", "SELECT * FROM items WHERE item_id='" + itemsdata.text + "';"); WWW itemsdata2 = new WWW("https://localhost/RPG/GetItem.php", form); yield return(itemsdata2); string tp_string = itemsdata2.text; string[] content = new string[] { tp_string }; RaiseEventOptions opt = new RaiseEventOptions(); opt.TargetActors = b.GroupIds; PhotonNetwork.RaiseEvent(14, content, false, opt); }