private void gameTimer_Tick(object sender, EventArgs e) { #region updating object recs objectRecs.Clear(); objectRecs.Add(new Rectangle(objects[0].x + 265, objects[0].y + 290, 120, 20)); objectRecs.Add(new Rectangle(objects[1].x + 85, objects[1].y + 290, 110, 20)); //appartments objectRecs.Add(new Rectangle(objects[2].x + 50, objects[2].y + 290, 100, 20)); objectRecs.Add(new Rectangle(objects[2].x + 650, objects[2].y + 290, 100, 20)); objectRecs.Add(new Rectangle(objects[2].x + 850, objects[2].y + 290, 100, 20)); objectRecs.Add(new Rectangle(objects[2].x + 1450, objects[2].y + 290, 100, 20)); //characters objectRecs.Add(new Rectangle(objects[3].x, objects[3].y, objects[3].width, objects[3].height)); objectRecs.Add(new Rectangle(objects[4].x, objects[4].y, objects[4].width, objects[4].height)); objectRecs.Add(new Rectangle(objects[5].x, objects[5].y, objects[5].width, objects[5].height)); #endregion #region update nori/object movement //setting the rectangles to the updated x,y noriRec = new Rectangle(nori.x + 40, nori.y + 130, 70, 20); if (wDown == true && sDown == false && nori.y >= 160) { nori.MoveUpDown(-HEROSPEED); animationCounterH++; if (animationCounterH == 4) { if (frameCounter == 1) { noriSprite = noriAnimation[1]; animationCounterH = 0; frameCounter = 2; } else if (frameCounter == 2) { noriSprite = noriAnimation[0]; animationCounterH = 0; frameCounter = 3; } else if (frameCounter == 3) { noriSprite = noriAnimation[2]; animationCounterH = 0; frameCounter = 4; } else if (frameCounter == 4) { noriSprite = noriAnimation[0]; animationCounterH = 0; frameCounter = 1; } } } if (sDown == true && wDown == false && nori.y <= this.Height) { nori.MoveUpDown(HEROSPEED); animationCounterH++; if (animationCounterH == 4) { if (frameCounter == 1) { noriSprite = noriAnimation[4]; animationCounterH = 0; frameCounter = 2; } else if (frameCounter == 2) { noriSprite = noriAnimation[3]; animationCounterH = 0; frameCounter = 3; } else if (frameCounter == 3) { noriSprite = noriAnimation[5]; animationCounterH = 0; frameCounter = 4; } else if (frameCounter == 4) { noriSprite = noriAnimation[3]; animationCounterH = 0; frameCounter = 1; } } } if (dDown == true && aDown == false) { foreach (Object o in objects) { o.MoveLeftRight(-HEROSPEED); } animationCounterH++; if (animationCounterH == 4) { if (frameCounter == 1) { noriSprite = noriAnimation[7]; animationCounterH = 0; frameCounter = 2; } else if (frameCounter == 2) { noriSprite = noriAnimation[6]; animationCounterH = 0; frameCounter = 3; } else if (frameCounter == 3) { noriSprite = noriAnimation[8]; animationCounterH = 0; frameCounter = 4; } else if (frameCounter == 4) { noriSprite = noriAnimation[6]; animationCounterH = 0; frameCounter = 1; } } } if (aDown == true && dDown == false) { foreach (Object o in objects) { o.MoveLeftRight(HEROSPEED); } animationCounterH++; if (animationCounterH == 4) { if (frameCounter == 1) { noriSprite = noriAnimation[10]; animationCounterH = 0; frameCounter = 2; } else if (frameCounter == 2) { noriSprite = noriAnimation[9]; animationCounterH = 0; frameCounter = 3; } else if (frameCounter == 3) { noriSprite = noriAnimation[11]; animationCounterH = 0; frameCounter = 4; } else if (frameCounter == 4) { noriSprite = noriAnimation[9]; animationCounterH = 0; frameCounter = 1; } } } #endregion #region collision checks #region screen changing collisions //library door if (noriRec.IntersectsWith(objectRecs[0]) && spaceDown == true) { LibraryScreen ls = new LibraryScreen(); this.Controls.Add(ls); ls.Focus(); } //arlo's door if (noriRec.IntersectsWith(objectRecs[1]) && spaceDown == true) { ShopScreen ss = new ShopScreen(); this.Controls.Add(ss); ss.Focus(); } #endregion #region text displaying collisions if (displayText == false) { for (int i = 2; i < objectRecs.Count(); i++) { if (noriRec.IntersectsWith(objectRecs[i]) && spaceDown == true) { textNum = i; displayText = true; Thread.Sleep(200); } } } else { DisplayTextCollisions(); } #endregion #region starting fight collisions #endregion #endregion Refresh(); }
private void gameTimer_Tick(object sender, EventArgs e) { #region updating object recs objectRecs.Clear(); //library objectRecs.Add(new Rectangle(objects[0].x + (this.Width / 32) * 9, objects[0].y + buildingHeight, 140, 20)); //arlos objectRecs.Add(new Rectangle(objects[1].x + 85, objects[1].y + buildingHeight, 110, 20)); //appartments(2-5) objectRecs.Add(new Rectangle(objects[2].x + (this.Width / 32) * 2, objects[2].y + buildingHeight, 100, 20)); objectRecs.Add(new Rectangle(objects[2].x + (this.Width / 8) * 5, objects[2].y + buildingHeight, 100, 20)); objectRecs.Add(new Rectangle(objects[2].x + (this.Width / 16) * 13, objects[2].y + buildingHeight, 100, 20)); objectRecs.Add(new Rectangle(objects[2].x + (this.Width / 16) * 22, objects[2].y + buildingHeight, 100, 20)); //characters (6-8) objectRecs.Add(new Rectangle(objects[4].x, objects[4].y, objects[4].width, objects[4].height)); objectRecs.Add(new Rectangle(objects[5].x, objects[5].y, objects[5].width, objects[5].height)); objectRecs.Add(new Rectangle(objects[6].x, objects[6].y, objects[6].width, objects[6].height)); #endregion #region update nori/object movement //setting the rectangles to the updated x,y noriRec = new Rectangle(nori.x + (nori.size / 4), nori.y + (nori.size / 8) * 7, (nori.size / 2), nori.size / 8); if (wDown == true && sDown == false && nori.y >= buildingHeight - (this.Height / 64) * 9) { nori.MoveUpDown(-HEROSPEED); animationCounterH++; spriteNumber = 0; NoriAnimation(); } if (sDown == true && wDown == false && nori.y <= this.Height - (nori.size / 8) * 11) { nori.MoveUpDown(HEROSPEED); animationCounterH++; spriteNumber = 3; NoriAnimation(); } if (dDown == true && aDown == false) { #region stops you if you're at the end of the map if (nori.x >= this.Width / 2 - 100 && LeftSide == true) { ObjectMovement(-HEROSPEED); } else if (nori.x < this.Width / 2 - 100 && LeftSide == true) { nori.MoveLeftRight(HEROSPEED); } if (roadList[3].x + roadList[3].width >= this.Width && LeftSide == false) { ObjectMovement(-HEROSPEED); } else if (nori.x <= this.Width - nori.size && LeftSide == false) { nori.MoveLeftRight(HEROSPEED); } #endregion animationCounterH++; spriteNumber = 6; NoriAnimation(); } if (aDown == true && dDown == false) { #region stops you if you get to the end of the map if (roadList[0].x <= -10 && LeftSide == true) { ObjectMovement(HEROSPEED); } else if (nori.x >= -30 && LeftSide == true) { nori.MoveLeftRight(-HEROSPEED); } if (nori.x <= this.Width / 2 - 100 && LeftSide == false) { ObjectMovement(HEROSPEED); } else if (nori.x > this.Width / 2 - 100 && LeftSide == false) { nori.MoveLeftRight(-HEROSPEED); } #endregion animationCounterH++; spriteNumber = 9; NoriAnimation(); } #endregion #region tells if you're on the left or right side of the map if (objects[0].x + objects[0].width > this.Width / 2) { LeftSide = true; } else { LeftSide = false; } #endregion #region collision checks #region screen changing collisions //library door if (noriRec.IntersectsWith(objectRecs[0]) && spaceDown == true) { //play interaction sound interactionSound.Play(); spaceDown = false; gameTimer.Enabled = false; LibraryScreen ls = new LibraryScreen(); Form form = this.FindForm(); form.Controls.Add(ls); ls.Location = new Point((this.Width - ls.Width) / 2, (this.Height - ls.Height) / 2); ls.Focus(); ls.BringToFront(); } //arlo's door if (noriRec.IntersectsWith(objectRecs[1]) && spaceDown == true) { //play interaction sound interactionSound.Play(); spaceDown = false; gameTimer.Enabled = false; ShopScreen ss = new ShopScreen(); Form form = this.FindForm(); form.Controls.Add(ss); ss.Location = new Point((this.Width - ss.Width) / 2, (this.Height - ss.Height) / 2); ss.Focus(); ss.BringToFront(); } //Calum if (noriRec.IntersectsWith(objectRecs[7]) && spaceDown == true && cOutcome == "blank") { //play interaction sound interactionSound.Play(); enemyName = "Calum"; gameTimer.Enabled = false; BattleScreen bs = new BattleScreen(); Form form = this.FindForm(); form.Controls.Add(bs); bs.Location = new Point((this.Width - bs.Width) / 2, (this.Height - bs.Height) / 2); bs.Focus(); bs.BringToFront(); } //Franky if (noriRec.IntersectsWith(objectRecs[8]) && spaceDown == true && cOutcome == "spared") { //play interaction sound interactionSound.Play(); enemyName = "Franky"; gameTimer.Enabled = false; BattleScreen bs = new BattleScreen(); Form form = this.FindForm(); form.Controls.Add(bs); bs.Location = new Point((this.Width - bs.Width) / 2, (this.Height - bs.Height) / 2); bs.Focus(); bs.BringToFront(); } #endregion #region text displaying collisions if (displayText == false) { #region appartement doors for (int i = 2; i < 6; i++) { if (noriRec.IntersectsWith(objectRecs[i]) && spaceDown == true) { if (i == 3) { dogBark.Play(); } else { interactionSound.Play(); } textNum = i - 2; displayText = true; Thread.Sleep(200); } } #endregion #region Sharol if (noriRec.IntersectsWith(objectRecs[6]) && spaceDown == true) { //play interaction sound interactionSound.Play(); switch (talkingS) { case 0: textNum = 4; displayText = true; spaceDown = false; talkingS++; break; case 1: textNum = 5; displayText = true; spaceDown = false; talkingS++; break; case 2: textNum = 6; displayText = true; spaceDown = false; break; } } #endregion #region Franky if (noriRec.IntersectsWith(objectRecs[8]) && spaceDown == true) { //play interaction sound interactionSound.Play(); if (cOutcome == "blank") { switch (talkingF) { case 0: textNum = 10; displayText = true; spaceDown = false; talkingF++; break; case 1: textNum = 11; displayText = true; spaceDown = false; break; } } //if you killed callum if (cOutcome == "killed") { textNum = 12; displayText = true; spaceDown = false; talkingF++; return; } } #endregion } else { DisplayTextCollisions(); } #endregion #endregion if (escapeDown == true) { Pausing(); } Refresh(); }