public IEnumerator CheckForGameOver() { yield return(new WaitForSeconds(0.3f)); Component[] players; players = FindObjectsOfType <PlayerMovement> (); int count = 0; foreach (PlayerMovement player in players) { count++; } Debug.LogError("SHISHIR" + count); if (count == 1 && !screenShown) { foreach (PlayerMovement player in players) { player.alreadyDead = true; } //win WinScreen.SetActive(true); WinScreen.transform.GetChild(2).gameObject.GetComponent <Text> ().text = "Player " + (((PlayerMovement)players[0]).playerId) + " Won."; Debug.Log("Adding to " + DataSaver.scores[((PlayerMovement)players[0]).playerId - 1]); DataSaver.scores[((PlayerMovement)players[0]).playerId - 1] += 1; screenShown = true; } if (count == 0 && !screenShown) { //draw WinScreen.SetActive(false); DrawScreen.SetActive(true); screenShown = true; } }
static bool CheckValidity(string userName, string userPass) { //locate file and split each line with '|' //username on left and password on right try { string[] lines = File.ReadAllLines("login.txt"); foreach (string set in lines) { //if password and username input match those in file return true string[] splits = set.Split('|'); if (splits[0] == userName && splits[1] == userPass) { return(true); } } Console.Clear(); DrawScreen draw = new DrawScreen(); draw.TopScreen(); //if no correct combination return false Console.WriteLine("Incorrect credentials! Please try again!!"); draw.UnderTitleLine(); return(false); } //file not found exception catch (FileNotFoundException) { Console.WriteLine("file not found"); Console.ReadKey(); return(false); } }
//make changes to file with new values public int EditFile(string fName, string lName, string address, string phone, string email, long ttlAmount, long depAmount, long accountNum, string[] allDetails) { DrawScreen draw = new DrawScreen(); StreamWriter file = new StreamWriter(accountNum + ".txt"); Console.WriteLine("Account number: " + accountNum); //save all details to file and change total amount where requires for (int x = 0; x < allDetails.Length; x++) { //if there is amount then change the total if (allDetails[x].Contains("Amount")) { file.WriteLine("Amount: " + ttlAmount); } else { file.WriteLine(allDetails[x]); } } //add transactions with deposits to bpttom of the file naming it appropriately file.Write("Transaction No. {0}: ", (allDetails.Length - 6)); file.WriteLine($"{depAmount}"); file.Flush(); file.Close(); draw.TopScreen(); Console.WriteLine(" Congratulations, You have ${0} ", ttlAmount); draw.UnderTitleLine(); return(0); }
// Use this for initialization void Start() { menu = GetComponent <Menu> (); menuGO = gameObject.transform.Find("Menu").gameObject; menuEnabled = true; dscreen = menu.DrawScreen.GetComponent <DrawScreen> (); }
void OnTriggerExit2D(Collider2D c) { if (c.gameObject.name == "Mouse") { mainCamera.deleteDrawingOfScreen(drawBubble); drawBubble = null; target.GetComponent <playerController>().set_speed(o_speed); } }
void OnTriggerExit2D(Collider2D c) { if (c.gameObject.name == "Mouse") { mainCamera.deleteDrawingOfScreen(drawBubble); drawBubble = null; target.GetComponent<playerController>().set_speed(o_speed); } }
static void Main(string[] args) { rect r = new rect() { x = 10, y = 20 }; Console.WriteLine("Area={0}", r.Area()); DrawScreen.draw(r); }
// Use this for initialization void Start() { speed = GameObject.Find ("Mouse").GetComponent<playerController> ().get_speed (); player = GetComponent<Transform>(); playerScript = GetComponent<playerController>(); moveToSpawn = true; levelStart = true; //Disable later - Enabled for testing deathTimer = 0.0f; timerOn = false; keyDraw = null; }
// Use this for initialization void Start() { speed = GameObject.Find("Mouse").GetComponent <playerController> ().get_speed(); player = GetComponent <Transform>(); playerScript = GetComponent <playerController>(); moveToSpawn = true; levelStart = true; //Disable later - Enabled for testing deathTimer = 0.0f; timerOn = false; keyDraw = null; }
private void drawTexture_left(DrawScreen newObject, int gapItems, int sizeItem) { newObject.setWidthTexture(sizeItem); numberItem_Left++; int posX = sumWidth_Left + gapItems + gapItems * (numberItem_Left - 1); sumWidth_Left += newObject.getWidthTexture(); int posY = Screen.height - gapItems - sizeItem; GUI.DrawTexture(new Rect(posX, posY, newObject.getWidthTexture(), sizeItem), newObject.getMyTexture(), ScaleMode.ScaleToFit, true); }
public void AccountDelete() { DrawScreen draw = new DrawScreen(); draw.TopScreen(); Console.WriteLine(" Delete Account "); draw.UnderTitleLine(); long accountNum = 0; bool accountValid; Console.Write("Enter account number: "); //get input 6-8 digits account number do { accountNum = Convert.ToInt64(Console.ReadLine()); accountValid = SearchAccount.CheckInputValidity(accountNum); } while (!accountValid); //check if account exists with number provided bool existingAccount = SearchAccount.CheckAccountExists(accountNum); //if exists prompt account deletion if (existingAccount) { string path = $"{accountNum}.txt"; string[] detail = System.IO.File.ReadAllLines(path); //display account details foreach (string set in detail) { Console.WriteLine(set); } //get user confirmation to delete //if confirmed delete file from path and return to menu if (ConfirmDelete()) { File.Delete(path); Screens.mainMenu(); } //ask if user wants to search again or return to menu if they dont delete previous file else { CheckAnother(); } } else { Console.WriteLine("Account does not exist "); Screens.mainMenu(); } }
public void AccountSearch() { DrawScreen draw = new DrawScreen(); draw.TopScreen(); Console.WriteLine(" Search Account "); draw.UnderTitleLine(); //do until user exits to main menu do { Console.Write("Enter Account Number: "); bool accountValid; //get a VALID account number 6-8 digits do { accountNum = Convert.ToInt64(Console.ReadLine()); accountValid = CheckInputValidity(accountNum); } while (!accountValid); //if account exists if (CheckAccountExists(accountNum)) { string path = $"{accountNum}.txt"; string[] detail = File.ReadAllLines(path); ClearLineAbove(); Console.ForegroundColor = ConsoleColor.Yellow; Console.WriteLine("Account details for {0}: ", accountNum); draw.OtherLine(); Console.ForegroundColor = ConsoleColor.Cyan; //display account details foreach (string set in detail) { Console.WriteLine(set); } // return detail; } //if account doesnt exist display error message else { Console.ForegroundColor = ConsoleColor.Yellow; Console.WriteLine("there is no file at this account number"); Console.ForegroundColor = ConsoleColor.Cyan; } } while (Confirmation()); // return null; }
void drawKey() { if (playerScript.getKeyState() && keyDraw == null) { keyDraw = new DrawScreen("key1", textureKey, 30, false); cameraScript.addDrawingToScreen(keyDraw); } else if (!playerScript.getKeyState() && keyDraw != null) { cameraScript.deleteDrawingOfScreen(keyDraw); keyDraw = null; } }
public void ShowDrawScreen() { DrawScreen.SetActive(true); Component[] players; players = FindObjectsOfType <PlayerMovement> (); int count = 0; foreach (PlayerMovement player in players) { player.alreadyDead = true; } }
//The main Update loop. Basically just updates Manager which handles //all Game updates. #endregion public void Update() { while (Running) { manager.Update(); //Cause screen to redraw. DrawScreen.Invalidate(); //Basic Thread Slowing. Thread.Sleep(12); } }
void OnTriggerEnter2D(Collider2D c) { if (c.gameObject.name == "Mouse") { audio = GetComponent<AudioSource>(); if (!audio.isPlaying) { audio.Play(); } target = c.gameObject; sticking = true; o_speed = target.GetComponent<playerController>().get_speed(); target.GetComponent<playerController>().set_speed(1.2f); drawBubble = new DrawScreen("", bubbleTexture, 30, true); mainCamera.addDrawingToScreen(drawBubble); } }
//This is the method that will be called over and over by the thread public void GameUpdate() { //This method is running on a seperate thread, thus wont create //any lag for the windowwhen using while(true) while (Running) { //TODO: add game update code manager.Update(); //NOTE: the screen should always be drawn to after update has finished DrawScreen.Redraw(); //This slows the thread. //Idealy in a proper game engine you want thread Stabiliziation :P Thread.Sleep(12); } }
void OnTriggerEnter2D(Collider2D c) { if (c.gameObject.name == "Mouse") { audio = GetComponent <AudioSource>(); if (!audio.isPlaying) { audio.Play(); } target = c.gameObject; sticking = true; o_speed = target.GetComponent <playerController>().get_speed(); target.GetComponent <playerController>().set_speed(1.2f); drawBubble = new DrawScreen("", bubbleTexture, 30, true); mainCamera.addDrawingToScreen(drawBubble); } }
public void Draw(GameTime gameTime) { try { GuiSpriteBatch.Begin(); ForEachScreen(screen => { screen.Draw(GuiSpriteBatch, gameTime); DrawScreen?.Invoke(this, new GuiDrawScreenEventArgs(screen, gameTime)); // DebugHelper.DrawScreen(screen); }); } finally { GuiSpriteBatch.End(); } }
public SfmlRenderer(Config config, RenderWindow window, CommonResource resource) { try { Console.Write("Initialize renderer: "); this.config = config; config.video_gamescreensize = Math.Clamp(config.video_gamescreensize, 0, this.MaxWindowSize); config.video_gammacorrection = Math.Clamp(config.video_gammacorrection, 0, this.MaxGammaCorrectionLevel); this.sfmlWindow = window; this.palette = resource.Palette; this.sfmlWindowWidth = (int)window.Size.X; this.sfmlWindowHeight = (int)window.Size.Y; if (config.video_highresolution) { this.screen = new DrawScreen(640, 400); this.sfmlTextureWidth = 512; this.sfmlTextureHeight = 1024; } else { this.screen = new DrawScreen(320, 200); this.sfmlTextureWidth = 256; this.sfmlTextureHeight = 512; } this.sfmlTextureData = new byte[4 * this.screen.Width * this.screen.Height]; this.sfmlTexture = new Texture((uint)this.sfmlTextureWidth, (uint)this.sfmlTextureHeight); this.sfmlSprite = new Sprite(this.sfmlTexture); this.sfmlSprite.Position = new Vector2f(0, 0); this.sfmlSprite.Rotation = 90; var scaleX = (float)this.sfmlWindowWidth / this.screen.Width; var scaleY = (float)this.sfmlWindowHeight / this.screen.Height; this.sfmlSprite.Scale = new Vector2f(scaleY, -scaleX); this.sfmlStates = new RenderStates(BlendMode.None); this.menu = new MenuRenderer(this.screen); this.threeD = new ThreeDRenderer(resource, this.screen, config.video_gamescreensize); this.statusBar = new StatusBarRenderer(this.screen); this.intermission = new IntermissionRenderer(this.screen); this.openingSequence = new OpeningSequenceRenderer(this.screen, this); this.autoMap = new AutoMapRenderer(this.screen); this.finale = new FinaleRenderer(resource, this.screen); this.pause = Patch.FromWad("M_PAUSE"); var scale = this.screen.Width / 320; this.wipeBandWidth = 2 * scale; this.wipeBandCount = this.screen.Width / this.wipeBandWidth + 1; this.wipeHeight = this.screen.Height / scale; this.wipeBuffer = new byte[this.screen.Data.Length]; this.palette.ResetColors(SfmlRenderer.gammaCorrectionParameters[config.video_gammacorrection]); Console.WriteLine("OK"); } catch (Exception e) { Console.WriteLine("Failed"); this.Dispose(); ExceptionDispatchInfo.Throw(e); } }
public CPU() { Decoder = new Dictionary <int, Action>() { // 0x0*** opcodes. { 0x0, () => { // 0x00E0 -- Clear the screen. if ((IR & 0x00FF) == 0x00E0) { for (int y = 0; y < _g_mem.GetLength(0); y++) { for (int x = 0; x < _g_mem.GetLength(1); x++) { _g_mem[y, x] = false; } } DrawScreen(this, null); } // 0x00EE -- Return from a subroutine. else if ((IR & 0x00FF) == 0x00EE) { PC = stack[SP]; SP--; } else { // No-op or halt } } }, // 0x1nnn -- Jump to location nnn. { 0x1, () => { PC = NNN; } }, // 0x2nnn -- Call subroutine at nnn. { 0x2, () => { SP++; stack[SP] = PC; PC = NNN; } }, // 0x3xnn -- Skip the next instruction if Vx == nn { 0x3, () => { if (V[X] == NN) { PC += 2; } } }, // 0x4xnn -- Skip the next instruction if Vx != nn { 0x4, () => { if (V[X] != NN) { PC += 2; } } }, // 0x5xy0 -- Skip the next instruction if Vx == Vy { 0x5, () => { if (V[X] == V[Y]) { PC += 2; } } }, // 0x6xkk -- Puts the value kk into register Vx { 0x6, () => { V[X] = (byte)NN; } }, // 0x7xkk -- Adds the value kk to the value of register Vx, then stores the result in Vx { 0x7, () => { V[X] += (byte)NN; } }, // 0x800* opcodes. { 0x8, () => { int c = IR & 0x000F; switch (c) { // 0x8xy0 -- Store the value of register Vy in register Vx case 0: V[X] = V[Y]; break; // 0x8xy1 -- Set Vx = Vx OR Vy case 1: V[X] |= V[Y]; break; // 0x8xy2 -- Set Vx = AND Vy case 2: V[X] &= V[Y]; break; // 0x8xy3 -- Set Vx = Vx XOR Vy case 3: V[X] ^= V[Y]; break; // 0x8xy4 -- Set Vx = Vx + Vy, set VF = carry. case 4: int value = V[X] + V[Y]; V[X] = (byte)(value & 0xFF); if (value > 0xFF) { V[0xF] = 1; } else { V[0xF] = 0; } break; // 0x8xy5 -- Set Vx = Vx - Vy, set VF to NOT borrow. case 5: if (V[X] > V[Y]) { V[0xF] = 1; } else { V[0xF] = 0; } V[X] -= V[Y]; break; // 0x8xy6 -- sets Vx = Vx >> 1 case 6: if ((V[X] & 0x01) > 0) { V[0xF] = 1; } else { V[0xF] = 0; } V[X] >>= 1; break; // 0x8xy7 -- SUBN Vx, Vy case 7: if (V[Y] > V[X]) { V[0xF] = 1; } else { V[0xF] = 0; } V[X] = (byte)(V[Y] - V[X]); break; // 8xyE - SHL Vx {, Vy} case 0xE: if ((0x80 & V[X]) == 0x80) { V[0xF] = 1; } else { V[0xF] = 0; } V[X] <<= 1; break; } } }, // 0x9xy0 -- SNE Vx, Vy { 0x9, () => { if (V[X] != V[Y]) { PC += 2; } } }, // 0xAnnn -- LD I, addr { 0xA, () => { I = IR & NNN; } }, //Bnnn - JP V0, addr Jump to location nnn + V0. { 0xB, () => { PC = NNN + V[0]; } }, // Cxkk - RND Vx, byte Set Vx = random byte AND kk { 0xC, () => { V[X] = (byte)(((new Random(DateTime.Now.Second)).Next(0, 255) & 0xFF) & NN); } }, // Dxyn - DRW Vx, Vy, nibble Display n-byte sprite starting at memory location I at (Vx, Vy), set VF = collision. { 0xD, () => { V[0xF] = 0; for (int i = 0; i < N; i++) { byte b = _mem[I + i]; int yPos = (V[Y] + i) % 32; for (int j = 0; j < 8; j++) { int bMask = 0x80 >> j; int xPos = (V[X] + j) % 64; int b_bit = (b & bMask) << j; if (_g_mem[yPos, xPos] && b_bit > 0) { V[0xF] = 1; } _g_mem[yPos, xPos] ^= (b_bit > 0 ? true : false); } } DrawScreen?.Invoke(this, null); } }, { // 0xE*** opcodes. 0xE, () => { // Ex9E - SKP Vx -- Skip next instruction if key with the value of Vx is pressed. if (NN == 0x9E) { if (Keyboard[V[X]]) { PC += 2; } } // ExA1 - SKNP Vx -- Skip next instruction if key with the value of Vx is not pressed. else if (NN == 0xA1) { if (!Keyboard[V[X]]) { PC += 2; } } } }, // 0xF*** opcodes. { 0xF, () => { int c = IR & 0x00FF; switch (c) { // Fx07 - LD Vx, DT -- Set Vx = delay timer value. case 0x07: V[X] = DT; break; // Fx0A - LD Vx, K -- Wait for a key press, store the value of the key in Vx. case 0x0A: var pressedKeys = Keyboard.Where(k => k.Value); while (pressedKeys.Count() <= 0) { // Poll until a key is pressed. Task.Delay(_CLOCK_SPEED); } V[X] = pressedKeys.FirstOrDefault().Key; break; // Fx15 - LD DT, Vx -- Set delay timer = Vx. case 0x15: DT = V[X]; break; // Fx18 - LD ST, Vx -- Set sound timer = Vx. case 0x18: ST = V[X]; break; // Fx1E - ADD I, Vx -- Set I = I + Vx. case 0x1E: I = I + V[X]; break; // Fx29 - LD F, Vx -- Set I = location of sprite for digit Vx. case 0x29: I = V[X] * 5; break; // Fx33 - LD B, Vx. Stores the BCD representation of V[X] in memory locations I, I+1, I+2 case 0x33: int dec = V[X]; int hundreds = (dec / 100); int tens = (dec / 10) - (hundreds * 10); int ones = dec % 10; _mem[I] = (byte)hundreds; _mem[I + 1] = (byte)tens; _mem[I + 2] = (byte)ones; break; // Fx55 - LD [I], Vx -- Store registers V0 through Vx in memory starting at location I. case 0x55: for (int i = 0; i <= X; i++) { _mem[I + i] = V[i]; } break; // Fx65 - LD Vx, [I] -- Read registers V0 through Vx from memory starting at location I. case 0x65: for (int i = 0; i <= X; i++) { V[i] = _mem[I + i]; } break; } } }, }; }
public DrawingManager(DrawScreen screen) => _screen = screen;
public void LastFiveTransaction() { DrawScreen draw = new DrawScreen(); draw.TopScreen(); Console.WriteLine(" A/C Statement "); draw.UnderTitleLine(); long accountNum = 0; bool accountValid; Console.Write("Enter account number: "); //get input 6-8 digits account number do { accountNum = Convert.ToInt64(Console.ReadLine()); accountValid = SearchAccount.CheckInputValidity(accountNum); } while (!accountValid); //check if account exists with number provided bool existingAccount = SearchAccount.CheckAccountExists(accountNum); //if account exists prompt withdrawal money if (existingAccount) { Console.Clear(); Console.WriteLine("Account Number: " + accountNum); string path = $"{accountNum}.txt"; //all details from file string[] detail = System.IO.File.ReadAllLines(path); //last five transaction details string[] lastFive = new string[5]; int y = 0; draw.OtherLine(); //look at bottom five lines in file where all transactions are saved Console.WriteLine("upto 5 previous transactions shown: "); for (int x = (detail.Length - 5); x < detail.Length; x++) { //only add transaction if it contains "transaction" if (detail[x].Contains("Transaction")) { Console.WriteLine(detail[x]); lastFive[y] = detail[x]; y++; } } //check if user wants statement sent to email //YesNoEmail(); //if user wants email statement then email last five trasnactions to their email draw.OtherLine(); if (YesNoEmail()) { Console.WriteLine("Please enter your email address: "); string email = Console.ReadLine(); EmailStatement(lastFive, email); Screens.mainMenu(); } //if no email then go to menu else { Screens.mainMenu(); } } //if account doesnt exist go to menu after message shown else { Console.WriteLine("Account does not exist "); Console.ReadKey(); Screens.mainMenu(); } }
public void NewUser() { DrawScreen draw = new DrawScreen(); Console.ForegroundColor = ConsoleColor.Cyan; bool phoneValid = false; bool emailValid = false; bool detailsValid = false; //do until user exits do { draw.TopScreen(); Console.WriteLine(" Please Fill Out Your Details Below "); draw.UnderTitleLine(); //request users information Console.Write(" First Name: "); newFirstName = Console.ReadLine(); Console.Write(" Last Name: "); newLastName = Console.ReadLine(); Console.Write(" New Address: "); newAddress = Console.ReadLine(); //enter a VALID phone number //number must contain 10 digits do { try { Console.ForegroundColor = ConsoleColor.Cyan; Console.Write(" New Phone: "); newPhone = Convert.ToInt64(Console.ReadLine()); phoneValid = CheckPhoneValidity(newPhone); }catch (FormatException) { ClearLineAbove(); Console.ForegroundColor = ConsoleColor.Red; Console.WriteLine("incorrect input"); Console.ForegroundColor = ConsoleColor.Cyan; } } while (!phoneValid); //enter a VALID email address //email must contain '@' and either 'gmail.com' or 'outlook.com' or 'uts.edu.au' do { Console.ForegroundColor = ConsoleColor.Cyan; Console.Write(" New Email: "); newEmail = Console.ReadLine(); emailValid = CheckEmailValidity(newEmail); } while (!emailValid); //get user confirmation of details detailsValid = ConfirmDetail(newFirstName, newLastName, newAddress, newPhone, newEmail); } while (!detailsValid); //if all details are confirmed correct then create new account file and send email if (ConfirmDetail(newFirstName, newLastName, newAddress, newPhone, newEmail)) { AccountFileCreate(newFirstName, newLastName, newAddress, newPhone, newEmail); SendEmail(newFirstName, newLastName, newAddress, newPhone, newEmail); //Console.ReadKey(); Screens.mainMenu(); } //else if (ConfirmDetail(newFirstName, newLastName, newAddress, newPhone, newEmail)) { // Console.WriteLine("go to main menu"); //Screens restart = new Screens(); //restart.MainMenu(); } }
private void drawTexture_right(DrawScreen newObject, int gapItems, int sizeItem) { newObject.setWidthTexture(sizeItem); numberItem_Right++; sumWidth_Right += newObject.getWidthTexture(); int posX = Screen.width - sumWidth_Right - gapItems - gapItems*(numberItem_Right - 1); int posY = Screen.height - gapItems - sizeItem; GUI.DrawTexture(new Rect(posX, posY, newObject.getWidthTexture(), sizeItem), newObject.getMyTexture(), ScaleMode.ScaleToFit, true); }
public void addDrawingToScreen(DrawScreen newDraw ) { textureScreen.Add(newDraw); }
public void deleteDrawingOfScreen(DrawScreen deleteDraw) { textureScreen.Remove(deleteDraw); }
public void addDrawingToScreen(DrawScreen newDraw) { textureScreen.Add(newDraw); }
// CreateAccount accountNo = new CreateAccount(); public void WithdrawMoney() { DrawScreen draw = new DrawScreen(); draw.TopScreen(); Console.WriteLine(" Withdrawal "); draw.UnderTitleLine(); long withdrawalAmount; long accountNum = 0; bool accountValid = false; long finalAmount = 0; string firstName = null; string lastName = null; string address = null; string phone = null; string email = null; //get VALID account number Console.Write("Enter account number: "); do { accountNum = Convert.ToInt64(Console.ReadLine()); accountValid = SearchAccount.CheckInputValidity(accountNum); } while (!accountValid); //check if account exists with number provided bool existingAccount = SearchAccount.CheckAccountExists(accountNum); //if account exists prompt withdrawal money if (existingAccount) { Console.Write("Enter withdrawal amount: "); withdrawalAmount = Convert.ToInt64(Console.ReadLine()); string path = $"{accountNum}.txt"; string[] detail = System.IO.File.ReadAllLines(path); bool withdrawn = false; // save all other details //add to final amount if it already exists foreach (string set in detail) { string[] splits = set.Split(':'); if (set.Contains("First Name")) { firstName = splits[1]; } if (set.Contains("Last Name")) { lastName = splits[1]; } if (set.Contains("Address")) { address = splits[1]; } if (set.Contains("Phone Number")) { phone = splits[1]; } if (set.Contains("Email")) { email = splits[1]; } //if there is previous value minus withdraw amount and set withdraw to true if (set.Contains("Amount")) { withdrawn = true; finalAmount = (Convert.ToInt64(splits[1]) - withdrawalAmount); } } //if withdraw amount more then funds in account show error message if (finalAmount < 0 || !withdrawn) { Console.WriteLine("You do not have suffecient funds in your account!!"); Screens.mainMenu(); } //if enough funds edit file else { EditFile(firstName, lastName, address, phone, email, finalAmount, withdrawalAmount, accountNum, detail); Screens.mainMenu(); } } //if no file show error message and go to menu else { Console.WriteLine("Account does not exist "); Screens.mainMenu(); } }
public void App_DrawScreen(PInfo[,] information, int x, int y, IRenderingApplication sender) { DrawScreen?.Invoke(information, x, y, sender); }
public void DepositMoney() { DrawScreen draw = new DrawScreen(); draw.TopScreen(); Console.WriteLine(" Deposit "); draw.UnderTitleLine(); long depositAmount; long accountNum = 0; bool accountValid = false; long finalAmount = 0; string firstName = null; string lastName = null; string address = null; string phone = null; string email = null; Console.Write("Enter account number: "); //get Valid account number 6-8 digits do { accountNum = Convert.ToInt64(Console.ReadLine()); accountValid = SearchAccount.CheckInputValidity(accountNum); } while (!accountValid); //check if account exists with number provided bool existingAccount = SearchAccount.CheckAccountExists(accountNum); //if account exists prompt deposit money if (existingAccount) { Console.Write("Enter deposit amount: "); depositAmount = Convert.ToInt64(Console.ReadLine()); string path = $"{accountNum}.txt"; string[] detail = File.ReadAllLines(path); bool deposited = false; //save all other details //add to final amount if it already exists foreach (string set in detail) { string[] splits = set.Split(':'); if (set.Contains("First Name")) { firstName = splits[1]; } if (set.Contains("Last Name")) { lastName = splits[1]; } if (set.Contains("Address")) { address = splits[1]; } if (set.Contains("Phone Number")) { phone = splits[1]; } if (set.Contains("Email")) { email = splits[1]; } if (set.Contains("Transaction")) { //make no changes if it contains 'transactions' } if (set.Contains("Amount")) { finalAmount = (Convert.ToInt64(splits[1]) + depositAmount); deposited = true; } } //if amount doesnt exists in final then deposit amount = final amount if (!deposited) { finalAmount = depositAmount; } //make appropriate changes to file and exit appropriately EditFile(firstName, lastName, address, phone, email, finalAmount, depositAmount, accountNum, detail); Screens.mainMenu(); } //if account doesnt exist display error message and go to menu else { Console.WriteLine("Account does not exist "); Screens.mainMenu(); } }