private bool playerGoesFast(int x, int y) { if (PowerUp.checkIfPlayerHasModification(PowerUpModifierKind.iGoFastModifier, this.guid) > -1) { if (PowerUp.checkIfPlayerHasModification(PowerUpModifierKind.iGoSlowModifier, this.guid) > -1) { return(false); } else { int index = PowerUp.checkIfPlayerHasModification(PowerUpModifierKind.makePlayersBigModifier, this.guid); if (index > -1) { if (Game.Instance.powerUpModificationList[this.guid][index].getCount() > 0) { this._bigPlayerLocation.Add(new KeyValuePair <int[], int[]>(new int[2] { PowerUp.countBigModifiers(this.guid), (int)this._playersteering }, new int[2] { x, y })); } } this._playerbody.Add(new int[2] { x, y }); return(true); } } return(false); }
public void playerMove(bool grow) { // not used List<int[]> checkHead = new List<int[]>(); int x = _playerbody[_playerbody.Count - 1][0]; int y = _playerbody[_playerbody.Count - 1][1]; List <Player> duplicateCount = Game.Instance.PLayerList.FindAll(z => z.guid == this.guid); switch (this._playersteering) { case PlayerSteering.Up: y--; if (PowerUp.checkIfPlayerHasModification(PowerUpModifierKind.iGoDiagonalModifier, this.guid) > -1 || (duplicateCount.Count > 1 && duplicateCount[0].name.Length != this.name.Length)) { x--; } if (playerGoesFast(x, y)) { y--; if (PowerUp.checkIfPlayerHasModification(PowerUpModifierKind.iGoDiagonalModifier, this.guid) > -1 || (duplicateCount.Count > 1 && duplicateCount[0].name.Length != this.name.Length)) { x--; } this._playerbody.RemoveAt(0); } break; case PlayerSteering.Down: y++; if (PowerUp.checkIfPlayerHasModification(PowerUpModifierKind.iGoDiagonalModifier, this.guid) > -1 || (duplicateCount.Count > 1 && duplicateCount[0].name.Length != this.name.Length)) { x++; } if (playerGoesFast(x, y)) { y++; if (PowerUp.checkIfPlayerHasModification(PowerUpModifierKind.iGoDiagonalModifier, this.guid) > -1 || (duplicateCount.Count > 1 && duplicateCount[0].name.Length != this.name.Length)) { x++; } this._playerbody.RemoveAt(0); } break; case PlayerSteering.Left: x--; if (PowerUp.checkIfPlayerHasModification(PowerUpModifierKind.iGoDiagonalModifier, this.guid) > -1 || (duplicateCount.Count > 1 && duplicateCount[0].name.Length != this.name.Length)) { y++; } if (playerGoesFast(x, y)) { x--; if (PowerUp.checkIfPlayerHasModification(PowerUpModifierKind.iGoDiagonalModifier, this.guid) > -1 || (duplicateCount.Count > 1 && duplicateCount[0].name.Length != this.name.Length)) { y++; } this._playerbody.RemoveAt(0); } break; case PlayerSteering.Right: x++; if (PowerUp.checkIfPlayerHasModification(PowerUpModifierKind.iGoDiagonalModifier, this.guid) > -1 || (duplicateCount.Count > 1 && duplicateCount[0].name.Length != this.name.Length)) { y--; } if (playerGoesFast(x, y)) { x++; if (PowerUp.checkIfPlayerHasModification(PowerUpModifierKind.iGoDiagonalModifier, this.guid) > -1 || (duplicateCount.Count > 1 && duplicateCount[0].name.Length != this.name.Length)) { y--; } this._playerbody.RemoveAt(0); } break; } makeSnakeHoles(); int index = PowerUp.checkIfPlayerHasModification(PowerUpModifierKind.makePlayersBigModifier, this.guid); if (index > -1) { if (Game.Instance.powerUpModificationList[this.guid][index].getCount() > 0) { this._bigPlayerLocation.Add(new KeyValuePair <int[], int[]>(new int[2] { PowerUp.countBigModifiers(this.guid), (int)this._playersteering }, new int[2] { x, y })); } } this._playerbody.Add(new int[2] { x, y }); makeSnakeSmallerIfOtherPlayerAteRedApple(); checkIfPlayerShouldGrowThenGivePoint(grow); }