void Start() { logText = DataLogger.s; try { scoreBoards = new GameObject[6]; allScores = new int[6, 32]; /*switch (GS.a.myGameRuleType) { * case GameSettings.GameRuleTypes.Health: * for (int i = 0; i < 6; i++) * ScoreBoardManager.s.allScores[i, 0] = GS.a.scoreReach; * break; * }*/ for (int i = 0; i < scoreBoards.Length; i++) { scoreBoards[i] = null; } SetUpPlayerScoreboardPanels(); //SmartScoreboard.s.UpdateScore (0, false); } catch (System.Exception e) { DataLogger.LogError("Scoreboard creation failed error: ", e); } UpdatePanels(); }
public void ReceiveAction(int player, int x, int y, PowerUpManager.ActionType action) { switch (action) { case PowerUpManager.ActionType.Enable: network_scoreboard [player] = (GameObject)Instantiate(scoreboardPrefab, ScoreBoardManager.s.scoreBoards [player].transform); network_scoreboard [player].transform.ResetTransformation(); break; case PowerUpManager.ActionType.Activate: IndividualCard myCard = CardHandler.s.allCards [x, y]; if (myCard.isSelectable) { myCard.SelectCard(); myCard.selectedEffect = (GameObject)Instantiate(selectPrefab, myCard.transform.position, Quaternion.identity); } else { DataHandler.s.NetworkCorrection(myCard); } break; case PowerUpManager.ActionType.Disable: if (network_scoreboard [player] != null) { network_scoreboard [player].GetComponent <DisableAndDestroy> ().Engage(); } network_scoreboard [player] = null; break; default: DataLogger.LogError("Unrecognized power up action PUE"); break; } }
void ReceiveDialogEnd(byte[] data) { int player = 0; char playerChar; playerChar = (char)data[1]; switch (playerChar) { case p_blue: player = 0; break; case p_red: player = 1; break; case p_green: player = 2; break; case p_yellow: player = 3; break; default: DataLogger.LogError("Unknown player char"); break; } GameStarter.s.ReceivePlayerReady(player); }
// Use this for initialization void Awake() { if (s != null && s != this) { Destroy(this.gameObject); return; } else { s = this; } if (!Load()) { mySave = new SaveData(); if (GS.s == null) { GS.s = GetComponent <GS> (); } mySave.levelsCompleted = new bool[GS.s.allModes.Length]; DataLogger.LogError("Loading failed. creating new save"); } else { DataLogger.LogMessage("Loading successful"); } }
void GiveItem(string itemCode) { string[] id = itemCode.Split('-'); int myClass = -1; int myItem = -1; try { myClass = int.Parse(id[0]); myItem = int.Parse(id[1]); } catch { DataLogger.LogError("Can't parse give: " + id[0] + " - " + id[1]); } switch (myClass) { case 0: InventoryMaster.s.Add(InventoryMaster.s.allEquipments[myItem], 1); break; case 1: InventoryMaster.s.Add(InventoryMaster.s.allIngredients[myItem], 1); break; case 2: InventoryMaster.s.Add(InventoryMaster.s.allPotions[myItem], 1); break; default: DataLogger.LogError("Unknown item class " + id[0]); break; } }
public void SetEquipped() { try { if (InventoryMaster.s.activeEquipment != null) { activeItemIcon.sprite = InventoryMaster.s.activeEquipment.item.sprite; activeItemName.text = InventoryMaster.s.activeEquipment.item.name; } else { activeItemIcon.sprite = noEquipmentSprite; activeItemName.text = "Not Equipped"; } /*if (InventoryMaster.s.elementLevel >= 0) { * activePowerIcon.sprite = GS.a.gfxs.cardSprites[InventoryMaster.s.selectedElement + 1 + 7]; * activePowerName.text = "Power"; * } else { * activePowerIcon.sprite = noEquipmentSprite; * activePowerName.text = "Not Equipped"; * }*/ } catch (System.Exception e) { DataLogger.LogError(this.name, e); } craftingPanel.SetActive(false); itemList.SetActive(false); }
//-----------------------------------------------------------------------------------------------Networking public void ReceiveNPCAction(IndividualCard card, NPCManager.ActionType action, int data) { try { switch (action) { case NPCManager.ActionType.Die: Die(data == 1); break; case NPCManager.ActionType.SelectCard: Select(card); break; case NPCManager.ActionType.Activate: Activate(card); break; case NPCManager.ActionType.GoToPos: StartCoroutine(MoveToPosition(card)); break; default: DataLogger.LogError("Unrecognized power up action PUF"); break; } } catch (System.Exception e) { DataLogger.LogError(this.name, e); } }
//example: <triggerChoice=["Kervana napcan Reiz?";0;1,"Yardım Et":2,"Görev Rezi Daha Önemli"]> //data = ["Question Text";<decisionSaveId>;<decisionNumber>,"Decision Button Text":<other Decision>,"etc"] public void ShowDecisionScreen(string data) { isDecisionDone = false; data = data.Substring(1, data.Length - 2); try { string[] parts = data.Split(';'); questionText.text = parts[0].Substring(1, parts[0].Length - 2); decisionSaveId = int.Parse(parts[1]); string[] buttonData = parts[2].Split(':'); for (int i = 0; i < buttonData.Length; i++) { string[] curButtonData = buttonData[i].Split(','); GameObject myBut = Instantiate(decisionButtonPrefab, decisionButtonsParent.transform); myBut.GetComponentInChildren <Button> ().onClick.AddListener(delegate { Choose(float.Parse(curButtonData[0])); }); myBut.GetComponentInChildren <TextMeshProUGUI> ().text = curButtonData[1].Substring(1, curButtonData[1].Length - 2); } } catch (System.Exception e) { DataLogger.LogError("Cant Parse data for Decicion Master: " + data, e); isDecisionDone = true; decisionScreen.SetActive(false); return; } decisionScreen.SetActive(true); }
public static void LevelFinished(bool isWon, GameSettings finishedLevel) { if (isWon) { int levelId = GS.s.GetGameModeId(finishedLevel); try { if (levelId != -1) { if (!(levelId < s.mySave.levelsCompleted.Length)) { bool[] temp = new bool[s.mySave.levelsCompleted.Length]; s.mySave.levelsCompleted.CopyTo(temp, 0); s.mySave.levelsCompleted = new bool[GS.s.allModes.Length]; temp.CopyTo(s.mySave.levelsCompleted, 0); } s.mySave.levelsCompleted[levelId] = true; s.Save(); } else { DataLogger.LogError("Cant complete level: " + levelId.ToString()); } } catch (System.Exception e) { DataLogger.LogError("Cant complete level: " + levelId.ToString(), e); } } }
public static bool isLevelDone(GameSettings levelObject) { if (levelObject == null) { return(true); } int levelId = GS.s.GetGameModeId(levelObject); if (levelId == -1) { DataLogger.LogError("Unregistered level: " + levelObject.name); return(false); } if (levelId < s.mySave.levelsCompleted.Length) { if (s.mySave.levelsCompleted[levelId]) { return(true); } else { return(false); } } else { return(false); } }
public void ReceiveAction(int player, int x, int y, PowerUpManager.ActionType action) { switch (action) { case PowerUpManager.ActionType.Enable: network_scoreboard [player] = (GameObject)Instantiate(scoreboardPrefab, ScoreBoardManager.s.scoreBoards [player].transform); network_scoreboard [player].transform.ResetTransformation(); break; case PowerUpManager.ActionType.Activate: IndividualCard myCard = CardHandler.s.allCards [x, y]; if (myCard.isSelectable) { StartCoroutine(NetworkActivate(player, myCard)); } else { DataHandler.s.NetworkCorrection(myCard); } break; case PowerUpManager.ActionType.Disable: IndividualCard myCard2 = CardHandler.s.allCards [x, y]; StartCoroutine(NetworkDisable(player, myCard2)); break; default: DataLogger.LogError("Unrecognized power up action PUP"); break; } }
public void ReceiveAction(int player, int x, int y, PowerUpManager.ActionType action) { switch (action) { case PowerUpManager.ActionType.Enable: network_scoreboard [player] = (GameObject)Instantiate(sourceScoreBoard, ScoreBoardManager.s.scoreBoards [player].transform); network_scoreboard [player].transform.ResetTransformation(); CoolIceEnabler.s.isEnabled = true; LocalPlayerController.s.canSelect = false; break; case PowerUpManager.ActionType.Disable: if (network_scoreboard [player]) { network_scoreboard [player].GetComponent <DisableAndDestroy> ().Engage(); } network_scoreboard [player] = null; CoolIceEnabler.s.isEnabled = false; LocalPlayerController.s.canSelect = true; break; default: DataLogger.LogError("Unrecognized power up action PUI"); break; } }
void ActivateTheOthers() { try { GameObjectiveMaster.s.StartGame(); if (LevelBeginCall != null) { LevelBeginCall.Invoke(); } LocalPlayerController.isActive = true; /*foreach (MonoBehaviour mono in toCall) { * if (mono != null) { * if (!(mono is LocalPlayerController)) * mono.enabled = true; * } * }*/ if (GS.a.isNPCEnabled) { NPCManager.s.SpawnNPCPeriodic(); } } catch (System.Exception e) { DataLogger.LogError(this.name, e); } }
public void SendRequest(RequestTypes reqType) { char sendChar = v_cardTypeRequest; /*switch (variant) { * case 0: * sendChar = v_tap; * break; * case 1: * sendChar = v_slide; * break; * case -1: * sendChar = v_cardTypeRequest; * break; * default: * sendChar = v_tap; * break; * }*/ try { List <byte> toSend = new List <byte> (); toSend.Add((byte)sendChar); SendData(a_request, toSend.ToArray()); } catch (Exception e) { DataLogger.LogError(this.name, e); } }
public void SendDialogEnd() { try { SendData(a_dialogEnd, new byte[0]); } catch (Exception e) { DataLogger.LogError(this.name, e); } }
public void ChangeGameMode(int id) { a = null; try { ChangeGameMode(allModes[id]); } catch { DataLogger.LogError("Unknown mode id: " + id.ToString()); a = defaultMode.Copy(); } }
public static void HardReset() { PlayerPrefs.DeleteAll(); s.mySave = new SaveData(); s.mySave.activeEquipment = "none"; s.Save(); SceneMaster.s.LoadMenu(); DataLogger.LogError("Progress Hard Reset"); }
public static void ResetProgress() { PlayerPrefs.DeleteAll(); s.mySave = new SaveData(); InventoryMaster.s.Start(); s.Save(); SceneMaster.s.LoadMenu(); //PlayerPrefs.SetInt ("FirstLevelDone", 1); DataLogger.LogError("Progress Reset"); }
public void ActivateInvoke(IndividualCard card) { try{ if (activateHook != null) { activateHook.Invoke(card); } } catch (System.Exception e) { DataLogger.LogError(this.name, e); } }
public void OnRealTimeMessageReceived(bool isReliable, string senderId, byte[] data) { DataLogger.LogMessage("Data received " + ((char)data[0]).ToString()); try { DataHandler.s.ReceiveData(data); //DataLogger.LogMessage("Data processing begun " + ((char)data [0]).ToString()); } catch (Exception e) { //DataLogger.LogMessage ("Data processing failed " + myCommand.ToString (), true); DataLogger.LogError("Data process failed " + ((char)data[0]).ToString(), e); } }
/*IEnumerator activeTimer = null; * IEnumerator DeselectTimer (IndividualCard myCard){ * //print (GS.a.playerSelectionSettings.deselectSpeedPlayer); * if (GS.a.playerSelectionSettings.deselectSpeedPlayer > 0) { * yield return new WaitForSeconds (GS.a.playerSelectionSettings.deselectSpeedPlayer); * * myCard.UnSelectCard (); * DataHandler.s.SendPlayerAction (myCard.x, myCard.y, CardHandler.CardActions.UnSelect); * ReceiveNetworkCorrection (myCard); * } else { * yield return null; * } * }*/ public void DeselectAll() { try { CancelInvoke("CheckCards"); CardChecker.s.UnSelectCards(mem_Cards); CardChecker.s.EmptyArray(mem_Cards); canSelect = true; } catch (System.Exception e) { DataLogger.LogError(this.name, e); } }
public void Choose(float decision) { try { SaveMaster.s.mySave.questDecisions[decisionSaveId] = decision; } catch (System.Exception e) { DataLogger.LogError("Cant save decision", e); } isDecisionDone = true; decisionScreen.SetActive(false); }
public void CheckInvoke() { try{ if (checkHook != null) { checkHook.Invoke(); } } catch (System.Exception e) { DataLogger.LogError(this.name, e); } }
public void SelectInvoke(IndividualCard card) { try{ if (selectHook != null) { selectHook.Invoke(card); } } catch (System.Exception e) { DataLogger.LogError(this.name, e); } }
public void LoadPlayingLevel(int settingsId) { //GoogleAPI.gameMode = 0; //GS.s.ChangeGameMode(id+1); //LoadLevel(singleStartId + id); try { GS.s.ChangeGameMode(settingsId); LoadLevel(playingLevelId); } catch (System.Exception e) { DataLogger.LogError("Cant load level with id: " + settingsId.ToString(), e); } }
const char power_select = 'T'; //PowerUpManager.ActionType.SelectCard; public void SendPowerUpAction(int x, int y, PowerUpManager.PUpTypes type, int id, int power, float amount, PowerUpManager.ActionType action) { List <byte> toSend = new List <byte> (); toSend.AddRange(System.BitConverter.GetBytes((short)x)); toSend.AddRange(System.BitConverter.GetBytes((short)y)); switch (type) { case PowerUpManager.PUpTypes.equipment: toSend.Add((byte)power_equipment); break; case PowerUpManager.PUpTypes.potion: toSend.Add((byte)power_potion); break; default: DataLogger.LogError("Unknown power up type: " + type.ToString() + " can't send multiplayer data"); return; } toSend.AddRange(System.BitConverter.GetBytes((short)id)); toSend.AddRange(System.BitConverter.GetBytes((short)power)); toSend.AddRange(System.BitConverter.GetBytes(amount)); switch (action) { case PowerUpManager.ActionType.Activate: toSend.Add((byte)power_activate); break; case PowerUpManager.ActionType.Disable: toSend.Add((byte)power_disable); break; case PowerUpManager.ActionType.Enable: toSend.Add((byte)power_enable); break; case PowerUpManager.ActionType.SelectCard: toSend.Add((byte)power_select); break; default: DataLogger.LogError("Unknown action type: " + action.ToString() + " can't send multiplayer data"); return; } SendData(a_power, toSend.ToArray()); }
public void EnablePowerUp(PUpTypes type, int id, int power, float amount, Color effectColor) { DataLogger.LogMessage("Activating pup: type:^" + type.ToString() + " - id: " + id.ToString() + " - power: " + power.ToString() + " - amount: " + amount.ToString()); if (canActivatePowerUp == false) { return; } if (type == PUpTypes.equipment) { if (id < equipmentPUps.Length) { if (equipmentPUps[id] != null) { equipmentPUps[id].Enable(power, amount, effectColor); activePUp = equipmentPUps[id]; } else { DataLogger.LogError("Equipment pup with id " + id.ToString() + " is null!"); } } else { DataLogger.LogError("Equipment pup with id " + id.ToString() + " not enough Equipment pups! length:" + equipmentPUps.Length.ToString()); } } else if (type == PUpTypes.potion) { if (id < potionPUps.Length) { if (potionPUps[id] != null) { CharacterStuffController.s.lastActivatedButton = false; potionPUps[id].Enable(power, amount, effectColor); activePUp = potionPUps[id]; } else { DataLogger.LogError("Potion pup with id " + id.ToString() + " is null!"); } } else { DataLogger.LogError("Potion pup with id " + id.ToString() + " not enough potion pups! length:" + potionPUps.Length.ToString()); } } else { DataLogger.LogError("Other pup types arent implemented/does not exist: " + type.ToString()); } }
public void LoadNextLevelInChain() { GameSettings nextLevel = NextLevelInChain(); if (nextLevel != null) { SceneMaster.s.LoadPlayingLevel(nextLevel.id); } else { DataLogger.LogError("Trying to load the next level in chain with empty chain! " + a.name); } }
public void ReceiveAction(int player, int x, int y, PowerUpManager.ActionType action) { switch (action) { case PowerUpManager.ActionType.Enable: StartCoroutine(NetworkNetherRoutine()); break; default: DataLogger.LogError("Unrecognized power up action PUN"); break; } }
public void SendNPCAction(int x, int y, NPCBase source, ActionType action, int data) { int myIndex = ActiveNPCS.IndexOf(source); if (myIndex != -1) { DataHandler.s.SendNPCAction(x, y, myIndex, action, data); } else { DataLogger.LogError("Trying to sent action for unregistered NPC: " + source.gameObject.name); } }