public void GravityOff() { GameData.gravityTimer = 100; gravityOff = true; for (int y = 0; y < rows; y++) { for (int x = 0; x < cols; x++) { if (resources.GetPropByTag(getTagXY(x, y), "gResponds") == "yes") { SetAttrXY(x, y, false); } } } }
bool TryToMove(Vector2 moveVector) { bool result; result = false; pos.x += moveVector.x; pos.y += moveVector.y; if (pos.x < 0) { pos.x = 0; } if (pos.x > 29) { pos.x = 29; } if (pos.y < 0) { pos.y = 0; } if (pos.y > 19) { pos.y = 19; } int X = (int)Mathf.Round(pos.x); int Y = (int)Mathf.Round(pos.y); string otherTag = boardManager.getTagXY(X, Y); if (resources.GetPropByTag(otherTag, "pushable") == "no" && actionButton) { // don't push unpushable pos = transform.position; otherTag = null; } switch (otherTag) { case "door": { if (boardManager.GetAttrXY(X, Y)) { FinishLevel(); result = true; } else { pos = transform.position; } } break; case "boulder": { int A = X + (int)moveVector.x; int B = Y; //+(int)moveAttempt.y; if (!boardManager.PushAsBoulder(X, Y, A, B)) { pos = transform.position; } else { SFX.PlaySFX("push"); result = true; } } break; case "jellybean": { boardManager.destroyXY(X, Y); EnergyRefill(); result = true; } break; case "forcefield": { pos = transform.position; break; } case "trigger": { pos = transform.position; } break; case "gravity": { boardManager.destroyXY(X, Y); SFX.PlaySFX("gravity"); if (boardManager.gravityOff == false) { boardManager.setGravityImageDirection(180f); } boardManager.GravityOff(); result = true; } break; case "elixir": { SFX.PlaySFX("elixir"); boardManager.destroyXY(X, Y); GameData.lives++; result = true; } break; case "teleport": { SFX.PlaySFX("teleport"); boardManager.destroyXY(X, Y); //destroy current teleport Vector2 newPos = boardManager.GetTeleport(); //get coordinates of new teleport X = (int)newPos.x; Y = (int)newPos.y; boardManager.destroyXY(X, Y); //destroy new teleport pos.x = newPos.x; pos.y = newPos.y; result = true; } break; case "earth": { SFX.PlaySFX("earth"); boardManager.destroyXY(X, Y); result = true; } break; case "wethellsoil": { boardManager.destroyXY(X, Y); result = true; } break; case "diamond": { boardManager.destroyXY(X, Y); SFX.PlaySFX("diamond"); GameData.diamondsCollected++; GameData.score += GameData.pointsPerDiamond; if (GameData.diamondsCollected >= GameData.diamondRequired) { boardManager.DoorActivate(); } result = true; } break; case "wall": { pos = transform.position; } break; case "bubble": { int A = X + (int)moveVector.x; int B = Y + (int)moveVector.y; if (!boardManager.PushAsBubble(X, Y, A, B)) //can we push the bubble from XY to AB ? { pos = transform.position; //if can't - don't move } else { result = true; } } break; case "fire": { boardManager.destroyXY(X, Y); Die(); result = true; } break; } if (actionButton) { pos = transform.position; } transform.position = pos; cameraManager.FollowPlayer(); return(result); }