public void Show(int vicID) { vicFactionID = vicID; if (GameControlTB.playerFactionExisted) { if (GameControlTB.IsHotSeatMode()) { if (GameControlTB.IsPlayerFaction(vicFactionID)) { outcomeTxt = "Victory!!"; } else { outcomeTxt = "Defeated..."; } } //single player mode else { if (GameControlTB.IsPlayerFaction(vicFactionID)) { outcomeTxt = "Victory!!"; } else { outcomeTxt = "Defeated"; } } } else { outcomeTxt = "Faction " + vicFactionID + " Won!!"; } if (!GameControlTB.IsHotSeatMode() && GameControlTB.playerFactionExisted && GameControlTB.LoadMode() == _LoadMode.UsePersistantData) { int pointGain = GameControlTB.instance.pointGain; int pointReward = GameControlTB.instance.winPointReward; if (!GameControlTB.IsPlayerFaction(vicFactionID)) { pointReward = 0; } int killBonus = pointGain - pointReward; int total = GlobalStatsTB.GetPlayerPoint(); int initial = total - pointGain; statsTxt = killBonus + "\n" + pointReward + "\n" + initial; pointTxt = total.ToString(); } }
int GetPlayerPoint() { //~ if(UINGUISetup.IsSetupScene()){ //~ return UINGUISetup.playerPoint; //~ } //~ else{ if (!PerkManagerTB.UsePersistentData()) { return(PerkManagerTB.GetPoint()); } else { return(GlobalStatsTB.GetPlayerPoint()); } //~ } }
// Use this for initialization void Start() { if (loadMode == _LoadMode.UsePersistantData) { if (!GlobalStatsTB.loaded) { GlobalStatsTB.Init(); } playerPoint = GlobalStatsTB.GetPlayerPoint(); UISetupUnit.selectedUnits = GlobalStatsTB.GetPlayerUnitList(); } else { playerPoint = startingPlayerPoint; } }
public int IsAvailable() { if (!PerkManagerTB.UsePersistentData()) { if (PerkManagerTB.GetPoint() < cost) { return(1); //return "insufficient point to unlock perk"; //return false; } } else { if (GlobalStatsTB.GetPlayerPoint() < cost) { return(1); //return "insufficient player point to unlock perk"; //return false; } } if (PerkManagerTB.GetPerkPoint() < pointReq) { return(2); //return "insufficient perk point to unlock perk"; //return false; } for (int i = 0; i < prereq.Count; i++) { if (!PerkManagerTB.GetPerk(prereq[i]).unlocked) { return(3); //return "pre-req perk needed to unlock perk"; //return false; } } //return true; //return ""; return(0); }
void OnStartBattle(string sceneToLoad) { if (UISetupUnit.selectedUnits.Count == 0) { //DisplayMessage("No unit is selected!"); return; } //if(usePersistantData){ if (loadMode == _LoadMode.UsePersistantData) { GlobalStatsTB.SetPlayerPoint(playerPoint); GlobalStatsTB.SetPlayerUnitList(UISetupUnit.selectedUnits); } else if (loadMode == _LoadMode.UseTemporaryData) { GlobalStatsTB.SetTempPlayerUnitList(UISetupUnit.selectedUnits); } Application.LoadLevel(sceneToLoad); }
//battle ended public static void BattleEnded(int vicFactionID) { battleEnded = true; if (instance.playerFactionID.Contains(vicFactionID)) { //if(vicFactionID==GetPlayerFactionID()){ GainPoint(instance.winPointReward); //if using persistent data, save the point gain in this level if (instance.loadMode == _LoadMode.UsePersistantData) { //instance.pointGain+=instance.winPointReward; GlobalStatsTB.GainPlayerPoint(instance.pointGain); } } if (onBattleEndE != null) { onBattleEndE(vicFactionID); } }
void OnGUI() { if (UI.buttonStyle == null) { UI.InitButtonStyle(); } if (GUI.Button(new Rect(Screen.width - 35, 5, 30, 30), "R", UI.buttonStyle)) { GlobalStatsTB.ResetAll(); Application.LoadLevel(Application.loadedLevelName); } GUIStyle style = new GUIStyle(); style.fontSize = 20; style.fontStyle = FontStyle.Bold; style.normal.textColor = Color.black; style.alignment = TextAnchor.UpperRight; GUI.Label(new Rect(0 + 2, 5 + 2, Screen.width - 45, 50), "Point: " + playerPoint, style); style.normal.textColor = UI.colorH; GUI.Label(new Rect(0, 5, Screen.width - 45, 50), "Point: " + playerPoint, style); if (GUI.Button(new Rect(Screen.width - 65, Screen.height - 65, 60, 60), "Start\nBattle", UI.buttonStyle)) { LoadNextScene(); } if (GUI.Button(new Rect(5, Screen.height - 65, 60, 60), "Main\nMenu", UI.buttonStyle)) { if (mainMenu != "") { Application.LoadLevel(mainMenu); } else { Debug.Log("Menu scene name not specified"); } } if (tab == _Tab.Unit) { if (GUI.Button(new Rect(Screen.width / 2 - 45 - 3, Screen.height - 35 - 3, 86, 36), "Unit", UI.buttonStyle)) { tab = _Tab.Unit; } if (GUI.Button(new Rect(Screen.width / 2 + 45, Screen.height - 35, 80, 30), "Perk", UI.buttonStyle)) { tab = _Tab.Perk; } uiUnit.DrawUnitMenu(); } else { if (GUI.Button(new Rect(Screen.width / 2 - 45, Screen.height - 35, 80, 30), "Unit", UI.buttonStyle)) { tab = _Tab.Unit; } if (GUI.Button(new Rect(Screen.width / 2 + 45 - 3, Screen.height - 35 - 3, 86, 36), "Perk", UI.buttonStyle)) { tab = _Tab.Perk; } uiPerk.DrawPerkMenu(true); } }
public static bool UnlockPerk(PerkTB perk, bool flag) { if (perk.unlocked) { Debug.Log("attemp to unlock unlocked perk"); return(false); } perk.unlocked = true; perkPoint += 1; if (flag) { if (!instance.usePersistentData) { instance.point -= perk.cost; } else { GlobalStatsTB.GainPlayerPoint(-perk.cost); } } if (perk.applyToAllUnit) { for (int i = 0; i < perk.effects.Count; i++) { PerkEffectTB effect = perk.effects[i]; int effectID = (int)effect.type; if (effect.isModifier) { globalUnitStats.stats[effectID].mod += effect.value; } else { globalUnitStats.stats[effectID].value += effect.value; } } } else { for (int i = 0; i < unitStats.Count; i++) { if (perk.unitPrefab.Contains(unitStats[i].unit)) { perk.unitPrefabID.Add(unitStats[i].unit.prefabID); for (int j = 0; j < perk.effects.Count; j++) { PerkEffectTB effect = perk.effects[j]; int effectID = (int)effect.type; if (effect.isModifier) { unitStats[i].stats[effectID].mod += effect.value; } else { unitStats[i].stats[effectID].value += effect.value; } } break; } } } if (onPerkUnlockE != null) { onPerkUnlockE(perk); } return(true); }
public void DrawPerkMenu(bool preBattle) { //GUI.depth = 0; GUIStyle style = new GUIStyle(); style.fontSize = 20; style.fontStyle = FontStyle.Bold; style.normal.textColor = UI.colorH; style.alignment = TextAnchor.UpperCenter; List <PerkTB> perkList = PerkManagerTB.GetAllPerks(); PerkTB perk = null; int winWidth = 595; int winHeight = 470; int startX = Screen.width / 2 - winWidth / 2; int startY = Screen.height / 2 - winHeight / 2; int rowLimit = 8; int row = 0; int column = 0; for (int i = 0; i < 3; i++) { GUI.Box(new Rect(startX, startY, winWidth, winHeight), ""); } GUI.Label(new Rect(startX, startY + 10, winWidth, winHeight), "Perk Menu", style); int point = 0; if (!PerkManagerTB.UsePersistentData()) { point = PerkManagerTB.GetPoint(); } else { point = GlobalStatsTB.GetPlayerPoint(); } style.fontSize = 14; style.fontStyle = FontStyle.Bold; style.normal.textColor = UI.colorH; style.alignment = TextAnchor.UpperLeft; if (!preBattle) { GUI.Label(new Rect(startX + 10, startY + 5, 150, 25), "Point: " + point, style); } GUI.Label(new Rect(startX + 10, startY + 20, 150, 25), "PerkPoint: " + PerkManagerTB.perkPoint, style); if (!preBattle) { if (GUI.Button(new Rect(startX + winWidth - 35, startY + 5, 30, 30), "X", UI.buttonStyle)) { OnPerkmenu(); } } startX += 10; startY += 40; int scrollLength = (int)(Mathf.Ceil(perkList.Count / 8 + 1) * 70); if (perkList.Count % rowLimit == 0) { scrollLength -= 70; } Rect viewRect = new Rect(startX, startY, winWidth - 20, 280); Rect scrollRect = new Rect(startX, startY, winWidth - 50, scrollLength); GUI.Box(viewRect, ""); scrollPosition = GUI.BeginScrollView(viewRect, scrollPosition, scrollRect); startX += 5; startY += 5; for (int ID = 0; ID < perkList.Count; ID++) { perk = perkList[ID]; Texture icon = null; if (perk.unlocked) { icon = perk.iconUnlocked; } else { if (perk.IsAvailable() == 0) { icon = perk.icon; } else { icon = perk.iconUnavailable; } } if (selectedID == ID) { if (GUI.Button(new Rect(startX + column * 70 - 3, startY + row * 70 - 3, 66, 66), icon)) { selectedID = ID; } } else { if (GUI.Button(new Rect(startX + column * 70, startY + row * 70, 60, 60), icon)) { selectedID = ID; } } column += 1; if (column == 8) { row += 1; column = 0; } } GUI.EndScrollView(); startY += 285; GUI.Box(new Rect(startX - 5, startY, winWidth - 20, 130), ""); perk = perkList[selectedID]; int perkAvai = perk.IsAvailable(); string status = ""; if (perk.unlocked) { status = " (Unlocked)"; } else if (perkAvai != 0) { status = " (Unavailable)"; } style.fontSize = 17; style.alignment = TextAnchor.UpperLeft; style.normal.textColor = UI.colorH; GUI.Label(new Rect(startX, startY += 5, winWidth - 30, 30), perk.name + status, style); style.fontSize = 17; style.alignment = TextAnchor.UpperRight; style.normal.textColor = UI.colorH; GUI.Label(new Rect(startX, startY += 5, winWidth - 30, 30), "Cost: " + perk.cost, style); style.alignment = TextAnchor.UpperLeft; style.normal.textColor = UI.colorN; style.wordWrap = true; GUI.Label(new Rect(startX, startY += 25, winWidth - 30, 30), perk.desp, style); string requireTxt = ""; //inssufficient points if (perkAvai == 1) { requireTxt = "Require " + perk.cost + "point"; } //min perk point not reach else if (perkAvai == 2) { requireTxt = "Require " + perk.pointReq + " perk points"; } //pre-req perk not unlocked else if (perkAvai == 3) { string text = "Require: "; List <int> list = perk.prereq; int i = 0; foreach (int ID in list) { if (i > 0) { text += ", "; } text += PerkManagerTB.GetAllPerks()[ID].name; i += 1; } requireTxt = text; } style.fontSize = 14; style.alignment = TextAnchor.UpperLeft; style.normal.textColor = Color.red; style.wordWrap = false; GUI.Label(new Rect(startX, startY + 75, winWidth - 30, 30), requireTxt, style); if (!perk.unlocked && perkAvai == 0) { if (GUI.Button(new Rect(startX + winWidth - 30 - 120, startY += 60, 120, 30), "Unlock", UI.buttonStyle)) { OnUnlockPerkButton(perk); } } }