void InitiatUnit() { for (int i = 0; i < 10; i++) { int factionRnd = UnityEngine.Random.Range(1, 3);//random for both factions betteween 1 and 2 int rndX = UnityEngine.Random.Range(0, 20); int rndY = UnityEngine.Random.Range(0, 20); if (factionRnd == 1) { int typeRnd = UnityEngine.Random.Range(1, 3); //random for class type if (typeRnd == 1) { int classRnd = UnityEngine.Random.Range(1, 3); if (classRnd == 1) { units[i] = new RangeUnit(10, 10, 1, 2, 2, rndX, rndY, faction: "Hero", unitType: "Sniper", symbol: 'R'); units[i].MaxHp = 10; } else { units[i] = new RangeUnit(10, 10, 1, 2, 2, rndX, rndY, faction: "Hero", unitType: "Archer", symbol: 'R'); units[i].MaxHp = 10; } } else { int classRnd = UnityEngine.Random.Range(1, 3); if (classRnd == 1) { units[i] = new MeeleUnit(20, 20, 2, 1, 1, rndX, rndY, faction: "Hero", unitType: "Tank", symbol: 'M'); units[i].MaxHp = 20; } else { units[i] = new MeeleUnit(20, 20, 2, 1, 1, rndX, rndY, faction: "Hero", unitType: "Slayer", symbol: 'M'); units[i].MaxHp = 20; } } } else { int typeRnd = UnityEngine.Random.Range(1, 3); //random for class type if (typeRnd == 1) { int classRnd = UnityEngine.Random.Range(1, 3); if (classRnd == 1) { units[i] = new RangeUnit(10, 10, 1, 2, 2, rndX, rndY, faction: "Enemy", unitType: "Sniper", symbol: 'T'); units[i].MaxHp = 10; } else { units[i] = new RangeUnit(10, 10, 1, 2, 2, rndX, rndY, faction: "Enemy", unitType: "Archer", symbol: 'T'); units[i].MaxHp = 10; } } else { int classRnd = UnityEngine.Random.Range(1, 3); if (classRnd == 1) { units[i] = new MeeleUnit(20, 20, 2, 1, 1, rndX, rndY, faction: "Enemy", unitType: "Tank", symbol: 'W'); units[i].MaxHp = 20; } else { units[i] = new MeeleUnit(20, 20, 2, 1, 1, rndX, rndY, faction: "Enemy", unitType: "Slayer", symbol: 'W'); units[i].MaxHp = 20; } } } } int xRnd = UnityEngine.Random.Range(0, 19); int yRnd = UnityEngine.Random.Range(0, 19); buildings[0] = new ResourceBuilding(40, xRnd, yRnd, "Hero", 'Y'); buildings[0].YPos = yRnd; buildings[0].MaxHp = 40; xRnd = UnityEngine.Random.Range(0, 20); yRnd = UnityEngine.Random.Range(0, 20); buildings[1] = new ResourceBuilding(40, xRnd, yRnd, "Enemy", 'A'); buildings[1].YPos = yRnd; buildings[1].MaxHp = 40; xRnd = UnityEngine.Random.Range(0, 20); yRnd = UnityEngine.Random.Range(0, 20); buildings[2] = new FactoryBuilding(40, xRnd, yRnd, "Hero", 'X'); buildings[2].YPos = yRnd; buildings[2].MaxHp = 40; int rndSpn = UnityEngine.Random.Range(1, 3); // if (rndSpn == 1) // { // fBuildings[0].UnitSpn = "Meele"; // fBuildings[0].SpnTic = 5; // fBuildings[0].SpnPtCalc(); // } // else // { // fBuildings[0].UnitSpn = "Range"; // fBuildings[0].SpnTic = 5; // fBuildings[0].SpnPtCalc(); // } xRnd = UnityEngine.Random.Range(0, 20); yRnd = UnityEngine.Random.Range(0, 20); buildings[3] = new FactoryBuilding(40, xRnd, yRnd, "Enemy", 'B'); buildings[3].YPos = yRnd; buildings[3].MaxHp = 40; rndSpn = UnityEngine.Random.Range(1, 3); // if (rndSpn == 1) // { // fBuildings[1].UnitSpn = "Meele"; // fBuildings[1].SpnTic = 5; // fBuildings[1].SpnPtCalc(); // } // else // { // fBuildings[1].UnitSpn = "Range"; // fBuildings[1].SpnTic = 5; // fBuildings[1].SpnPtCalc(); // } }
public Map() //fills map and array { for (int i = 0; i < 20; ++i) { for (int j = 0; j < 20; ++j) { mapArr[i, j] = ','; } } for (int i = 0; i < 10; i++) { int factionRnd = r.Next(1, 3); //random for both factions betteween 1 and 2 int rndX = r.Next(0, 19); int rndY = r.Next(0, 19); if (factionRnd == 1) { int typeRnd = r.Next(1, 3); //random for class type if (typeRnd == 1) { int classRnd = r.Next(1, 3); if (classRnd == 1) { units[i] = new RangeUnit(10, 10, 1, 2, 2, rndX, rndY, faction: "Hero", unitType: "Sniper", symbol: 'R'); units[i].MaxHp = 10; units[i].XPos = rndX; units[i].YPos = rndY; } else { units[i] = new RangeUnit(10, 10, 1, 2, 2, rndX, rndY, faction: "Hero", unitType: "Archer", symbol: 'R'); units[i].MaxHp = 10; units[i].XPos = rndX; units[i].YPos = rndY; } } else { int classRnd = r.Next(1, 3); if (classRnd == 1) { units[i] = new MeeleUnit(20, 20, 2, 1, 1, rndX, rndY, faction: "Hero", unitType: "Tank", symbol: 'M'); units[i].MaxHp = 20; units[i].XPos = rndX; units[i].YPos = rndY; } else { units[i] = new MeeleUnit(20, 20, 2, 1, 1, rndX, rndY, faction: "Hero", unitType: "Slayer", symbol: 'M'); units[i].MaxHp = 20; units[i].XPos = rndX; units[i].YPos = rndY; } } } else { int typeRnd = r.Next(1, 3); //random for class type if (typeRnd == 1) { int classRnd = r.Next(1, 3); if (classRnd == 1) { units[i] = new RangeUnit(10, 10, 1, 2, 2, rndX, rndY, faction: "Enemy", unitType: "Sniper", symbol: 'T'); units[i].MaxHp = 10; units[i].XPos = rndX; units[i].YPos = rndY; } else { units[i] = new RangeUnit(10, 10, 1, 2, 2, rndX, rndY, faction: "Enemy", unitType: "Archer", symbol: 'T'); units[i].MaxHp = 10; units[i].XPos = rndX; units[i].YPos = rndY; } } else { int classRnd = r.Next(1, 3); if (classRnd == 1) { units[i] = new MeeleUnit(20, 20, 2, 1, 1, rndX, rndY, faction: "Enemy", unitType: "Tank", symbol: 'W'); units[i].MaxHp = 20; units[i].XPos = rndX; units[i].YPos = rndY; } else { units[i] = new MeeleUnit(20, 20, 2, 1, 1, rndX, rndY, faction: "Enemy", unitType: "Slayer", symbol: 'W'); units[i].MaxHp = 20; units[i].XPos = rndX; units[i].YPos = rndY; } } } } int xRnd = r.Next(0, 19); int yRnd = r.Next(0, 19); rBuildings[0] = new ResourceBuilding(40, xRnd, yRnd, "Hero", 'Y'); rBuildings[0].YPos = yRnd; rBuildings[0].ResourcePerTic = 1; rBuildings[0].ResType = "Wood"; rBuildings[0].ResourceRemaining = 20; xRnd = r.Next(0, 20); yRnd = r.Next(0, 20); rBuildings[1] = new ResourceBuilding(40, xRnd, yRnd, "Enemy", 'A'); rBuildings[1].YPos = yRnd; rBuildings[1].ResourcePerTic = 1; rBuildings[1].ResType = "Wood"; rBuildings[1].ResourceRemaining = 20; xRnd = r.Next(0, 20); yRnd = r.Next(0, 20); fBuildings[0] = new FactoryBuilding(40, xRnd, yRnd, "Hero", 'X'); fBuildings[0].YPos = yRnd; int rndSpn = r.Next(1, 3); if (rndSpn == 1) { fBuildings[0].UnitSpn = "Meele"; fBuildings[0].SpnTic = 5; fBuildings[0].SpnPtCalc(); } else { fBuildings[0].UnitSpn = "Range"; fBuildings[0].SpnTic = 5; fBuildings[0].SpnPtCalc(); } xRnd = r.Next(0, 20); yRnd = r.Next(0, 20); fBuildings[1] = new FactoryBuilding(40, xRnd, yRnd, "Enemy", 'B'); fBuildings[0].YPos = yRnd; rndSpn = r.Next(1, 3); if (rndSpn == 1) { fBuildings[1].UnitSpn = "Meele"; fBuildings[1].SpnTic = 5; fBuildings[1].SpnPtCalc(); } else { fBuildings[1].UnitSpn = "Range"; fBuildings[1].SpnTic = 5; fBuildings[1].SpnPtCalc(); } }