public void GenerateView() { DataTable dt = new DataTable(); dt.Columns.Add("Symbol"); dt.Columns.Add("ShareName"); dt.Columns.Add("NumShares"); dt.Columns.Add("LastPrice"); dt.Columns.Add("LastValue"); dt.Columns.Add("LastPriceChange"); dt.Columns.Add("LastValChange"); dt.Columns.Add("UnrealizedGain"); dt.Columns.Add("DateTimeLast"); Totals = new TotalData(); foreach(LastShareData last in LastData) { Stake s = null; Portfolio.Shares.TryGetValue(last.Symbol, out s); if (s != null) { float acqval = s.TotShares * s.AvgPrice; float lastval = s.TotShares * last.LastPrice; float lastvalchange = s.TotShares * last.PriceChange; Totals.AckValue += acqval; Totals.LastValue += lastval; Totals.LastChange += lastvalchange; DataRow row = dt.NewRow(); row["Symbol"] = last.Symbol; row["ShareName"] = last.ShareName; row["NumShares"] = s.TotShares; row["LastPrice"] = last.LastPrice.ToString("C2"); row["LastValue"] = lastval.ToString("C2"); row["LastPriceChange"] = FormatUtils.CombiCellStr(last.PriceChange, 100 * last.PriceChange / (last.LastPrice - last.PriceChange)); row["LastValChange"] = FormatUtils.CurrencyStr(lastvalchange); row["UnrealizedGain"] = FormatUtils.CombiCellStr(lastval - acqval, 100 * (lastval - acqval) / acqval); row["DateTimeLast"] = last.RepDT.ToString(); dt.Rows.Add(row); } } //dt.Rows[1].Visible = CurrUser.ShowStockNames; GridView3.DataSource = dt; GridView3.DataBind(); }
public void setTotalMoney(TotalData totalData, Food food) { totalData.AllMoney += food.Price; totalData.paymentMoney += food.Price; }
/// <summary> ///On level complete. /// </summary> public void OnLevelComplete() { if (instantiated) { return; } instantiated = true; KeepDataOnPlayMode.instance.reloadedTimes += 1; if (KeepDataOnPlayMode.instance.reloadedTimes > 5) { KeepDataOnPlayMode.instance.reloadedTimes = 0; } if (KeepDataOnPlayMode.instance.randomAds == KeepDataOnPlayMode.instance.reloadedTimes) { KeepDataOnPlayMode.instance.reloadedTimes = 0; KeepDataOnPlayMode.instance.randomAds = KeepDataOnPlayMode.instance.generateIntAds(); TotalData.LoadTotalFromFile(); if (!TotalData.totalData.noads) { ShowAd(); } } // Debug.Log("on Level Complete"); int timerType = 0; if (timer != null) { // Debug.Log("timer"); timer.Stop(); timerType = 1; CoinsToInt(); } else { // Debug.Log("timer countdown"); CoinsToInt(); timerCountdown.Stop(); timerType = 2; } isRunning = false; // Time.timeScale = 0; try { ///Save the stars level DataManager.WorldData currentWorldData = DataManager.FindWorldDataById(World.selectedWorld.ID, DataManager.filterdWorldsData); DataManager.LevelData currentLevelData = currentWorldData.FindLevelDataById(TableLevel.selectedLevel.ID); TotalData.LoadTotalFromFile(); // Debug.Log ("currentWorldData: " + currentWorldData); // Debug.Log ("currentLevelData: " + currentLevelData.ID); // Debug.Log("timerType: " + timerType); if (timerType == 1) { // Debug.Log("first"); // currentLevelData.leveltime = (int)timer.timeInSeconds; // Debug.Log ("currentLevelData.leveltime " + currentLevelData.leveltime); int currentTime = currentLevelData.leveltime; currentLevelData.leveltime = timer.timeInSeconds; if (currentTime == 0) { // if(currentLevelData.ID == 1){ // TotalData.totalData.laser = 3; // TotalData.totalData.green = 3; // TotalData.totalData.blue = 3; // TotalData.SaveTotalToFile(); // Debug.Log("done"); // } // Debug.Log("zero"); /// currentWorldData.Worldtime += timer.timeInSeconds; } // currentWorldData.Worldtime += currentTime; TotalData.totalData.totalTime += timer.timeInSeconds; // currentWorldData.Worldtime += currentLevelData.leveltime; // currentTotalData.totalTime += currentWorldData.Worldtime; if (currentTime > timer.timeInSeconds) { // Debug.Log("less"); currentLevelData.leveltime = timer.timeInSeconds; currentWorldData.Worldtime += timer.timeInSeconds; TotalData.totalData.totalTime -= (currentTime - timer.timeInSeconds); // currentWorldData.Worldtime -= (currentTime - timer.timeInSeconds); } TotalData.SaveTotalToFile(); // Debug.Log("currentTime: " + currentTime); // Debug.Log ("currentWorldData.Worldtime: " + currentWorldData.Worldtime); currentLevelData.levelScore = coins; // currentWorldData.worldScore += coins; // DataManager.SaveWorldsDataToFile (DataManager.); //TotalData.totalData.totalCoins = coins; // Debug.Log ("totaldata2: " + TotalData.totalData.totalCoins); // Debug.Log("currentTotalData.totalCoins: " + currentTotalData.totalCoins); //TotalData.SaveTotalToFile(); // Debug.Log("gamemanager: " + currentTotalData.totalCoins); // if (currentLevelData.starsLevel < TableLevel.StarsNumber.TWO){ // Debug.Log ("good thing"); // } //Calculate the stars rating if (timer.timeInSeconds >= 0 && timer.timeInSeconds <= threeStarsTimePeriod) { currentLevelData.starsLevel = TableLevel.StarsNumber.THREE; } else if (timer.timeInSeconds > threeStarsTimePeriod && timer.timeInSeconds <= twoStarsTimePeriod) { currentLevelData.starsLevel = TableLevel.StarsNumber.TWO; } else { currentLevelData.starsLevel = TableLevel.StarsNumber.ONE; } } else if (timerType == 2) { // Debug.Log("second"); // Debug.Log ("timerCountdown.timeInSeconds " + timerCountdown.timeInSeconds); // int currentScore = currentLevelData.leveltime; // currentWorldData.Worldtime += currentLevelData.leveltime; // if(currentLevelData.leveltime > timer.timeInSeconds || currentLevelData.leveltime == 0){ // currentLevelData.leveltime = timer.timeInSeconds; // currentWorldData.Worldtime -= timer.timeInSeconds; // } // currentLevelData.levelScore = coins; // if (currentLevelData.starsLevel < TableLevel.StarsNumber.TWO){ // Debug.Log ("good thing"); // } //Calculate the stars rating // Debug.Log ("test"); currentLevelData.levelScore = coins; currentWorldData.worldScore += coins; // TotalData.totalData.totalCoins += coins; // TotalData.SaveTotalToFile(); if (timerCountdown.timeInSeconds >= 0 && timerCountdown.timeInSeconds <= threeStarsTimePeriod) { currentLevelData.starsLevel = TableLevel.StarsNumber.THREE; } else if (timerCountdown.timeInSeconds > threeStarsTimePeriod && timerCountdown.timeInSeconds <= twoStarsTimePeriod) { currentLevelData.starsLevel = TableLevel.StarsNumber.TWO; } else { currentLevelData.starsLevel = TableLevel.StarsNumber.ONE; } } // Debug.Log ("test2"); // Debug.Log ("levelsdata.count " + currentWorldData.levelsData.Count); if (currentLevelData.ID + 1 <= currentWorldData.levelsData.Count) { // ///Unlock the next level // Debug.Log ("Unlock next level"); DataManager.LevelData nextLevelData = currentWorldData.FindLevelDataById(TableLevel.selectedLevel.ID + 1); // Debug.Log ("nextleveldata: " + nextLevelData); nextLevelData.isLocked = false; DataManager.SaveWorldsDataToFile(DataManager.filterdWorldsData); } if (currentLevelData.ID == currentWorldData.levelsData.Count) { // Debug.Log ("Last level: " + currentLevelData .ID); DataManager.WorldData nextWorldData = DataManager.FindWorldDataById(World.selectedWorld.ID + 1, DataManager.filterdWorldsData); nextWorldData.WorldIsLocked = false; // Debug.Log ("world " + nextWorldData.ID + nextWorldData.WorldIsLocked); } // Debug.Log ("test3"); DataManager.SaveWorldsDataToFile(DataManager.filterdWorldsData); TotalData.totalData.totalCoins += coins; // Debug.Log ("currentWorldData.Worldtime: " + currentWorldData.Worldtime); TotalData.SaveTotalToFile(); // for (int ID = 0; ID < 5; ID ++){ // int ID = 2; // Debug.Log("World_GameManger " + World.selectedWorld.ID + World.selectedWorld.WorldIsLocked); // } BlackArea2.Show(); WinDialogObj.gameObject.SetActive(true); winDialog.starsNumber = currentLevelData.starsLevel; winDialog.Show(); } catch (Exception ex) { Debug.Log(ex.Message); } // Debug.Log ("You win..."); Time.timeScale = 0; //AudioSource.PlayClipAtPoint(finishSFX,Vector3.zero); }
// Use this for initialization void Start() { if (TotalData.total.players.Count == 0) { TotalData.Players tempPlayers = null; foreach (Transform obj in transform) { tempPlayers = new TotalData.Players(); tempPlayers.ID = obj.GetComponent <Player> ().ID; tempPlayers.price = obj.GetComponent <Player> ().price; tempPlayers.isLocked = true; if (tempPlayers.ID == 1) { tempPlayers.isLocked = false; tempPlayers.isActive = true; } TotalData.total.players.Add(tempPlayers); } TotalData.SaveTotalToFile(); } if (TotalData.total.players.Count < transform.childCount) { int totalPlayers = TotalData.total.players.Count; int scenePlayers = transform.childCount; TotalData.Players tempPlayers = null; for (int i = totalPlayers; i < scenePlayers; i++) { tempPlayers = new TotalData.Players(); tempPlayers.ID = transform.GetChild(i).GetComponent <Player> ().ID; tempPlayers.price = transform.GetChild(i).GetComponent <Player> ().price; tempPlayers.isLocked = true; TotalData.total.players.Add(tempPlayers); } TotalData.SaveTotalToFile(); } TotalData.LoadTotalFromFile(); foreach (TotalData.Players player in TotalData.total.players) { foreach (Transform obj in transform) { if (obj.GetComponent <Player> ().ID == player.ID) { if (!player.isLocked) { obj.GetComponent <Player> ().isLocked = false; } if (player.isActive) { obj.GetComponent <Player> ().isActive = true; } obj.GetComponent <Player> ().price = player.price; obj.GetComponent <Player> ().setPlayer(); } } } }
void Start() { TotalData.LoadTotalFromFile(); // Debug.Log (TotalData.totalData.totalCoins); totalCoins.text = TotalData.totalData.totalCoins.ToString(); }
/// <summary> /// Settings up the level contents in the table. /// </summary> /// <param name="tableLevel">Table level.</param> /// <param name="ID">ID of the level.</param> private void SettingUpLevel(TableLevel tableLevel, int ID) { if (tableLevel == null) { return; } ///Get World Data of the current World tempWorldData = DataManager.FindWorldDataById(World.selectedWorld.ID, DataManager.filterdWorldsData); // Debug.Log("tempworlddata0 " + World.selectedWorld.ID + ".." + DataManager.filterdWorldsData); // Debug.Log("tempworlddata " + World.selectedWorld.ID + tempWorldData + "..." + DataManager.filterdWorldsData); if (tempWorldData == null) { Debug.Log("Null WorldData"); return; } ///Get Level Data of the wanted (selected) Level tempLevelData = tempWorldData.FindLevelDataById(tableLevel.ID); if (tempLevelData == null) { Debug.Log("Null LevelData"); return; } // Debug.Log("tempLevelData " + tableLevel.ID + "..."+tempLevelData.isLocked + "...."+tempLevelData); /// Debug.Log("time for levels " + tempLevelData.leveltime); //If the level is locked then , skip the next if (tempLevelData.isLocked) { return; } //show summary time TotalData.LoadTotalFromFile(); // Debug.Log ("totaldata: " + TotalData.totalData.totalCoins); // Debug.Log("levelsTable: " + currentTotalData.totalTime) // sumTime = currentTotalData.totalTime; // Debug.Log ("Worldtime: " + TotalData.totalData.totalTime); // Debug.Log ("leveltime: " + tempLevelData.leveltime); // Debug.Log ("levelScore: " + tempLevelData.levelScore); // sumTime = TotalData.totalData.totalTime; // sumTime = tempWorldData.Worldtime; // sumTime += tempLevelData.leveltime; // time.text = ": " + currentTotalData.totalCoins.ToString(); time.text = ": " + TotalData.totalData.totalTime.ToString(); //show summary coins // sumCoins = sumCoins += tempLevelData.levelScore; coins.text = ": " + TotalData.totalData.totalCoins.ToString(); // Debug.Log ("data: " + TotalData.totalData.totalCoins); // Debug.Log ("laser: " + TotalData.totalData.laser); // Debug.Log ("time: " + tempLevelData.leveltime ); //Enable level animator tableLevel.GetComponent <Animator> ().enabled = true; ///Make the button interactable tableLevel.GetComponent <Button> ().interactable = true; ///Show the stars of the level tableLevel.transform.Find("Stars").gameObject.SetActive(true); ///Hide the lock tableLevel.transform.Find("Lock").gameObject.SetActive(false); tableLevel.transform.Find("Background").gameObject.SetActive(true); ///Show the title of the level tableLevel.transform.Find("LevelTitle").gameObject.SetActive(true); ///Setting up the level title tableLevel.transform.Find("LevelTitle").GetComponent <Text> ().text = ID.ToString(); ///Get stars Number from current Level Data tableLevel.starsNumber = tempLevelData.starsLevel; tempTransform = tableLevel.transform.Find("Stars"); ///Apply the current Stars Rating if (tempLevelData.starsLevel == TableLevel.StarsNumber.ONE) //One Star { tempTransform.Find("FirstStar").GetComponent <Image> ().sprite = starOn; tempTransform.Find("SecondStar").GetComponent <Image> ().sprite = starOff; tempTransform.Find("ThirdStar").GetComponent <Image> ().sprite = starOff; } else if (tempLevelData.starsLevel == TableLevel.StarsNumber.TWO) //Two Stars { tempTransform.Find("FirstStar").GetComponent <Image> ().sprite = starOn; tempTransform.Find("SecondStar").GetComponent <Image> ().sprite = starOn; tempTransform.Find("ThirdStar").GetComponent <Image> ().sprite = starOff; } else if (tempLevelData.starsLevel == TableLevel.StarsNumber.THREE) //Three Stars { tempTransform.Find("FirstStar").GetComponent <Image> ().sprite = starOn; tempTransform.Find("SecondStar").GetComponent <Image> ().sprite = starOn; tempTransform.Find("ThirdStar").GetComponent <Image> ().sprite = starOn; } else //Zero Stars { tempTransform.Find("FirstStar").GetComponent <Image> ().sprite = starOff; tempTransform.Find("SecondStar").GetComponent <Image> ().sprite = starOff; tempTransform.Find("ThirdStar").GetComponent <Image> ().sprite = starOff; } }
public override string ToString() { if (TotalData != null) { return(string.Format("Packet[{0}. Data: {1}]", Sender.ToString(), string.Join("", Data.Select(p => (char)p)))); } else { return(string.Format("Packet[{0}. Data: {1}]", Sender.ToString(), string.Join("", TotalData.Select(p => (char)p)))); } }
public string ToString(bool v) { if (TotalData != null) { return(string.Format("Packet[{0}. Data: {1}]", Sender.ToString(), string.Join(",", TotalData.Select(p => p.ToString())))); } else { return(string.Format("Packet[{0}. Data: {1}]", Sender.ToString(), string.Join(",", Data.Select(p => p.ToString())))); } }