void Update() { Eagle.velocity = new Vector2(speed * direction, Eagle.velocity.y);//Eagle movement transform.localScale = new Vector3(-direction, transform.localScale.y, transform.localScale.z); //Saving Eagle position if (Input.GetKeyDown(KeyCode.R)) { SaveLoadScript.Save(this.gameObject, "Eagle"); } //Loading Eagle position if (Input.GetKeyDown(KeyCode.L)) { SaveLoadScript.Load(this.gameObject, "Eagle"); } }
void GenerateMap() { if (!MapProperties.isLoaded) { clearMap = new ClearMapGenerator(MapProperties.height, MapProperties.width, MapProperties.difficulty); clearMap.CreateMap(field); clearMap.CreateObstacles(obstacle); clearMap.CreateStartAndFinish(start, end); } else { SaveLoadScript.Load(); loadedMap = new LoadedMapGenerator(MapProperties.height, MapProperties.width); loadedMap.CreateMap(field); loadedMap.CreateObstacles(obstacle); loadedMap.CreateStartAndFinish(start, end); } }
void Update() { Opossum.velocity = new Vector2(speed * direction, Opossum.velocity.y);// Opossum movement transform.localScale = new Vector3(-direction, Opossum.transform.localScale.y, Opossum.transform.localScale.z); //Saving Opossum position if (Input.GetKeyDown(KeyCode.R)) { SaveLoadScript.Save(this.gameObject, "Opossum"); } //Loading Opossum position if (Input.GetKeyDown(KeyCode.L)) { SaveLoadScript.Load(this.gameObject, "Opossum"); } }
public void LoadData() { SaveData data = SaveLoadScript.LoadData(); player.PlayerHP = data.PlayerHP; player.PlayerCharges = data.PlayerCharges; player.WolfUnlock = data.WolfUnlock; player.FlashUnlock = data.FlashUnlock; player.BatUnlock = data.BatUnlock; player.RaygunUnlock = data.RaygunUnlock; player.BeenScared = data.BeenScared; player.StartGame = data.StartGame; player.TriggerFlash = data.TriggerFlash; player.MoonShineNum = data.MoonShineNum; player.HealthNum = data.HealthNum; item.ItemCollected = data.ItemCollected; location.PowerOn = data.PowerOn; location.DarkRoom = data.DarkRoom; }
void Update() { if (Input.GetMouseButtonDown(2)) { open(); playerDataPath = "D:/" + path + ".db"; elementMaxSize = max(_texture.width, _texture.height) * 80 / 337; setDiagram(); findElement(); //cellSize = max(_texture.width / 12, _texture.height / 12); // playerDataPath = "D:/" + "SchemeFromPhotot" + ".db"; setCornersOnScheme(); setScheme(); setWires(); Save(); SaveLoadScript.playerDataPath = playerDataPath; SaveLoadScript.Load(); //setBorders(); } }
// Use this for initialization public override void Start() { SaveLoadScript.LoadGame(); CharacterStats stats = SaveLoadScript.playerStats; // check if game was saved at least once, otherwise we put the player stats to null if (SaveLoadScript.saved == true) { base.characterStats = stats; GetComponent <PlayerScript> ().level = SaveLoadScript.playerLevel; GetComponent <PlayerScript> ().Exp = SaveLoadScript.playerXP; } canMoveX = true; rigidBody = GetComponent <Rigidbody2D>(); //Call the Parent's class start method base.Start(); groundCheckLayerMask = LayerMask.GetMask("Ground", "UndergroundGround"); //initial set of state variables IsAttacking = false; IsDodging = false; attackCounter = 0; weaponIndex = 0; firstAttack = true; setIsBlocking(false); IsTransforming = false; IsChargingAShot = false; initialGravityScale = ThisRigidBody.gravityScale; InvokeRepeating("staminaRegeneration", 0, 0.1f); InvokeRepeating("hpRegeneration", 0, 0.5f); audioSource1 = gameObject.AddComponent <AudioSource> (); audioSource2 = gameObject.AddComponent <AudioSource> (); audioSource3 = gameObject.AddComponent <AudioSource> (); audioSource3.clip = clips [2]; audioSource2.clip = clips [4]; }
// Use this for initialization void Start() { //Debug.Log ("raj Internet: " + Application.internetReachability); //Debug.Log ("raj Font Size: " + style_label.fontSize); //Debug.Log ("raj Screen.dp: " + (style_label.fontSize * Screen.dpi)/ 320 ); style_label.fontSize = Mathf.FloorToInt((style_label.fontSize * Screen.dpi) / 320); inner_style_box.fontSize = Mathf.FloorToInt((inner_style_box.fontSize * Screen.dpi) / 320); style_popup_label.fontSize = Mathf.FloorToInt((style_popup_label.fontSize * Screen.dpi) / 320); style_popup_button.fontSize = Mathf.FloorToInt((style_popup_button.fontSize * Screen.dpi) / 320); Helper.gameOver = false; best_score = SaveLoadScript.Load(); score_value = getTimeInString(best_score); //background_player = (Texture)TextureScale.Bilinear ((Texture2D)background_player, Screen.width / 2, Screen.width / 2); current_score_value = getTimeInString(current_score); background_heading_x = x_offset; background_heading_y = y_offset; background_heading_w = Screen.width - (x_offset * 2); background_heading_h = Screen.height / 5; //(background_heading.height * background_heading_w) / background_heading.width;// background_heading_chase_x = x_offset; background_heading_chase_y = background_heading_y + background_heading_h; background_heading_chase_w = Screen.width / 2 + Screen.width / 6; background_heading_chase_h = ((background_heading_chase.height * background_heading_chase_w) / background_heading_chase.width) + 30; //Screen.width/8; background_player_x = x_offset; background_player_y = background_heading_chase_y + background_heading_chase_h + (2 * y_offset); //background_enemy_y + (background_enemy_h / 2); background_player_w = Screen.width / 2 - (x_offset * 2); background_player_h = Screen.width / 2 - (x_offset * 2); background_caption_x = Screen.width / 4; background_caption_y = background_heading_chase_y + background_heading_chase_h; background_caption_w = Screen.width / 2; background_caption_h = Screen.width / 8; background_enemy_w = Screen.width / 4; background_enemy_h = Screen.width / 4; background_enemy_x = Screen.width - background_enemy_w - x_offset; background_enemy_y = background_heading_chase_y + (background_heading_chase_h / 2); //background_heading_y + background_heading_h + y_offset; start_button_w = background_player_w * 0.75f; start_button_h = Screen.height / 12; start_button_x = background_player_x + (background_player_w - start_button_w) / 2; start_button_y = background_player_y + background_player_h + (y_offset * 3); score_box_x = Screen.width / 2 + x_offset; score_box_y = background_enemy_y + background_enemy_h + (y_offset * 2); score_box_w = Screen.width / 2 - (x_offset * 2); //score_box_h = style_label.fontSize * 2 + inner_style_box.fontSize * 2 + y_offset*2; bestScore_label_x = score_box_x + x_offset; bestScore_label_y = score_box_y + y_offset; bestScore_label_w = style_label.fontSize * score_label.Length; bestScore_label_h = style_label.fontSize + y_offset; bestScore_box_w = score_box_w * 0.75f; bestScore_box_h = inner_style_box.fontSize + 15; bestScore_box_x = score_box_x + (score_box_w - bestScore_box_w) / 2; bestScore_box_y = bestScore_label_y + bestScore_label_h + y_offset; currentScore_label_x = score_box_x + x_offset; currentScore_label_y = bestScore_box_y + bestScore_box_h + y_offset * 2; currentScore_label_w = style_label.fontSize * current_score_label.Length; currentScore_label_h = style_label.fontSize + y_offset; currentScore_box_w = score_box_w * 0.75f; currentScore_box_h = inner_style_box.fontSize + 15; currentScore_box_x = score_box_x + (score_box_w - currentScore_box_w) / 2; currentScore_box_y = currentScore_label_y + currentScore_label_h + y_offset; score_box_h = bestScore_label_h + bestScore_box_h + currentScore_label_h + currentScore_box_h + (y_offset * 7); challenge_button_x = score_box_x; challenge_button_y = score_box_y + score_box_h + (y_offset * 3); challenge_button_w = score_box_w; challenge_button_h = start_button_h; /*leaderboard_button_x = score_box_x; * leaderboard_button_y = challenge_button_y + challenge_button_h + y_offset; * leaderboard_button_w = score_box_w; * leaderboard_button_h = start_button_h;*/ leaderboard_button_x = x_offset; leaderboard_button_y = start_button_y + start_button_h + y_offset; leaderboard_button_w = background_player_w; leaderboard_button_h = start_button_h; popup_window_x = (Screen.width - Screen.width * 0.75f) / 2; popup_window_y = (Screen.height - Screen.height / 3) / 2; popup_window_w = Screen.width * 0.75f; popup_window_h = Screen.height / 4; popup_button_w = popup_window_w / 2; popup_button_h = style_popup_button.fontSize + y_offset; popup_button_x = (popup_window_w - popup_button_w) / 2; popup_button_y = popup_window_h - popup_button_h - 2 * y_offset; popup_label_x = x_offset; // + (popup_window_w/2); popup_label_y = y_offset * 2; popup_label_w = popup_window_w - (x_offset * 2); popup_label_h = popup_window_h - popup_button_h; /*#if UNITY_ANDROID * * StartAppWrapper.loadAd (); * * StartAppWrapper.addBanner ( * StartAppWrapper.BannerType.AUTOMATIC, * StartAppWrapper.BannerPosition.BOTTOM); * #endif*/ PlayGamesPlatform.Activate(); }
private void FixedUpdate() { // checking grounded parameter and invoking OnLandEvent bool wasGrounded = grounded; grounded = false; Collider2D[] colliders = Physics2D.OverlapCircleAll(GroundCheck.position, GroundRadius, WhatIsGround); for (int i = 0; i < colliders.Length; i++) { if (colliders[i].gameObject != gameObject) { grounded = true; if (!wasGrounded) { OnLandEvent.Invoke(); } } } //movement move = Input.GetAxis("Horizontal"); Hero.velocity = new Vector2(move * speed, Hero.velocity.y); animator.SetFloat("Speed", Mathf.Abs(move)); // Runing animation if ((Input.GetKeyDown(KeyCode.W) || Input.GetKeyDown(KeyCode.UpArrow) || Input.GetKeyDown(KeyCode.Space)) && grounded) { Hero.AddForce(new Vector2(0, jumpForce)); animator.SetBool("IsJumping", true); // Jumping animation Debug.Log(Time.fixedDeltaTime); } if (Input.GetKeyDown(KeyCode.S) || Input.GetKeyDown(KeyCode.DownArrow)) { animator.SetBool("IsCrouching", true); } if (Input.GetKeyUp(KeyCode.S) || Input.GetKeyUp(KeyCode.DownArrow)) { animator.SetBool("IsCrouching", false); } // Flipping sprite left or right if (move < 0 && FacingRight) { Flip(); } else if (move > 0 && !FacingRight) { Flip(); } //Quit from the game when Lives = 0 if (Lives == 0) { Application.Quit(); } // Saving if (Input.GetKeyDown(KeyCode.R)) { SaveLoadScript.Save(this.gameObject, "Hero"); PlayerPrefs.SetInt("Lives", Lives); PlayerPrefs.SetInt("Gems", Gems); } // Loading if (Input.GetKeyDown(KeyCode.L)) { SaveLoadScript.Load(this.gameObject, "Hero"); Gems = PlayerPrefs.GetInt("Gems"); Lives = PlayerPrefs.GetInt("Lives"); } }
void Start() { _camera = GameObject.Find("Main Camera").GetComponent <CameraController>(); Saveload = GameObject.Find("SaveLoadObject").GetComponent <SaveLoadScript>(); Saveload.LoadGame(); }
void saveGame() { SaveLoadScript.SaveGame(player.GetComponent <PlayerControllerScript> ().characterStats, player.GetComponent <PlayerScript>().level, player.GetComponent <PlayerScript>().Exp); }
void Awake() { SaveLoadScript.Load(); }
public void SaveGame() { SaveLoadScript.Save(); BroadcastInfoPopUp("Successfully saved"); }
/// <summary> /// A játék mentése az adott slotra /// </summary> public void SaveGame(int slot) { SaveLoadScript.Save(slot); }
void Start() { #if (UNITY_EDITOR) EditorPlaymodeStop = false; #endif SetScriptSearch(); SODataConfirm(); UGUIOperateScript = GetComponent <jInputUGUIOperationSender>(); if (SetScript != null) { PlayerNum = SetScript.PlayerNum; InputLength = SetScript.DefaultInputArray.Length; UpMoveNumList = SetScript.UpMoveNumList; DownMoveNumList = SetScript.DownMoveNumList; RightMoveNumList = SetScript.RightMoveNumList; LeftMoveNumList = SetScript.LeftMoveNumList; UGUISubmitNumList = SetScript.UGUISubmitNumList; UGUICancelNumList = SetScript.UGUICancelNumList; } else { if (jInputSOData != null) { PlayerNum = jInputSOData.PlayerNum; InputLength = jInputSOData.DefaultInputArray.Count; UpMoveNumList = jInputSOData.UpMoveNumList; DownMoveNumList = jInputSOData.DownMoveNumList; RightMoveNumList = jInputSOData.RightMoveNumList; LeftMoveNumList = jInputSOData.LeftMoveNumList; UGUISubmitNumList = jInputSOData.UGUISubmitNumList; UGUICancelNumList = jInputSOData.UGUICancelNumList; } } if (PlayerNum <= 0 || InputLength <= 0) { ErrorStopEditor(); } #if (UNITY_STANDALONE || UNITY_EDITOR) if (SaveLoad == null) { SaveLoad = gameObject.GetComponent <SaveLoadScript>(); } #endif if (AllJoinInputArray.Length <= 0) { AllJoinInputArray = new string[InputLength * PlayerNum + 1]; } if (InputArray == null) { InputArray = new string[InputLength]; if (SetScript != null) { SetScript.DefaultInputArray.CopyTo(AllJoinInputArray, 0); } else { if (jInputSOData.DefaultInputArray.Count == 0 || jInputSOData.DefaultInputArray[0] == null) { ErrorStopEditor(); } else { jInputSOData.DefaultInputArray.CopyTo(AllJoinInputArray, 0); } } LevelLoadedCheck = true; } if (PlayerNum >= 2) { if (InputArray2p == null) { InputArray2p = new string[InputLength]; if (SetScript != null) { SetScript.DefaultInputArray2p.CopyTo(AllJoinInputArray, InputLength); } else { if (jInputSOData.DefaultInputArray2p.Count == 0 || jInputSOData.DefaultInputArray2p[0] == null || jInputSOData.DefaultInputArray2p.Count != InputLength) { ErrorStopEditor(); } else { jInputSOData.DefaultInputArray2p.CopyTo(AllJoinInputArray, InputLength); } } LevelLoadedCheck = true; } } if (PlayerNum >= 3) { if (InputArray3p == null) { InputArray3p = new string[InputLength]; if (SetScript != null) { SetScript.DefaultInputArray3p.CopyTo(AllJoinInputArray, InputLength * 2); } else { if (jInputSOData.DefaultInputArray3p.Count == 0 || jInputSOData.DefaultInputArray3p[0] == null || jInputSOData.DefaultInputArray3p.Count != InputLength) { ErrorStopEditor(); } else { jInputSOData.DefaultInputArray3p.CopyTo(AllJoinInputArray, InputLength * 2); } } LevelLoadedCheck = true; } } if (PlayerNum >= 4) { if (InputArray4p == null) { InputArray4p = new string[InputLength]; if (SetScript != null) { SetScript.DefaultInputArray4p.CopyTo(AllJoinInputArray, InputLength * 3); } else { if (jInputSOData.DefaultInputArray4p.Count == 0 || jInputSOData.DefaultInputArray4p[0] == null || jInputSOData.DefaultInputArray4p.Count != InputLength) { ErrorStopEditor(); } else { jInputSOData.DefaultInputArray4p.CopyTo(AllJoinInputArray, InputLength * 3); } } LevelLoadedCheck = true; } } if (LevelLoadedCheck != false) { MapperSaveData = string.Join(",", AllJoinInputArray); #if (UNITY_STANDALONE || UNITY_EDITOR) SaveLoad.LoadInputSetting(); #else if (PlayerPrefs.HasKey("PrefsMappingData")) { MapperSaveData = PlayerPrefs.GetString("PrefsMappingData"); } else { PlayerPrefs.SetString("PrefsMappingData", MapperSaveData); } #endif string[] LoadArray = MapperSaveData.Split(','); if (AllJoinInputArray.Length != LoadArray.Length) { Debug.LogWarning("[jInput] SaveData items are different number of current input items."); MapperSaveData = string.Join(",", AllJoinInputArray); #if (UNITY_STANDALONE || UNITY_EDITOR) SaveLoad.DeleteInputSetting(); SaveLoad.SaveInputSetting(); #else PlayerPrefs.DeleteKey("PrefsMappingData"); PlayerPrefs.SetString("PrefsMappingData", MapperSaveData); #endif Debug.LogWarning("[jInput] jInputMapping was created new SaveData with Default Input Mapping."); } else { AllJoinInputArray = MapperSaveData.Split(','); } Array.Copy(AllJoinInputArray, 0, InputArray, 0, InputLength); if (PlayerNum >= 2) { Array.Copy(AllJoinInputArray, InputLength, InputArray2p, 0, InputLength); } if (PlayerNum >= 3) { Array.Copy(AllJoinInputArray, InputLength * 2, InputArray3p, 0, InputLength); } if (PlayerNum >= 4) { Array.Copy(AllJoinInputArray, InputLength * 3, InputArray4p, 0, InputLength); } } LevelLoadedCheck = false; DontDestroyOnLoad(gameObject); for (int i = 0; i < 5; i++) { AllowMoveCheckAry[i] = false; AllowRepeatCheckAry[i] = false; PrevAxisIndexAry[i] = 0; PrevActionTimeAry[i] = 0; RepeatActionTimeAry[i] = 0; ConsecutiveMoveCountAry[i] = 0; } }
// Start is called before the first frame update public void SaveData() { SaveLoadScript.SaveData(this); }
void OnGUI() { if (!Helper.gameOver) { GUI.DrawTexture(new Rect(Screen.width - Screen.width / 10, 10, Screen.width / 10, Screen.width / 10), sound_on_off); if (GUI.Button(new Rect(Screen.width - Screen.width / 10, 10, Screen.width / 10, Screen.width / 10), "", style_Audio_button)) { if (isMusicPlaying()) { sound_on_off = sound_off; sound_option = 0; stopMusic(); SaveLoadScript.Save_sound(sound_option); } else { sound_on_off = sound_on; sound_option = 1; playMusic(); SaveLoadScript.Save_sound(sound_option); } } } if (Helper.gameOver && displaygameOverPopup) { float box_width = Screen.width - 50; float box_height = Screen.height / 2; float button_width = box_width / 6; float button_height = button_width; float label_score_x = 0; float label_score_y = 40; float label_score_w = box_width; float label_score_h = label_score.fontSize; float label_Bscore_x = 0; float label_Bscore_y = label_score_y + label_score_h; float label_Bscore_w = box_width; float label_Bscore_h = label_scoreBest.fontSize; float image_x = 10; float image_y = label_Bscore_y + label_Bscore_h + 10; float image_w = box_width / 3; float image_h; box_height = label_score_y + label_score_h + label_Bscore_h + (2 * button_height) + 80; image_h = box_height / 2; image_w = image_h; image_x = ((box_width / 2) - image_w) / 2; float button_home_y = label_Bscore_y + label_Bscore_h + ((box_height - (label_Bscore_y + label_Bscore_h)) - button_height) / 2; float button_retry_y = button_home_y; float button_home_x = box_width / 2; //(box_width - button_width)/2; float button_retry_x = button_home_x + button_width + button_width / 2; //layout start GUI.Box(new Rect(0, 0, Screen.width, Screen.height), ""); GUI.Box(new Rect(0, 0, Screen.width, Screen.height), ""); GUI.BeginGroup(new Rect((Screen.width - box_width) / 2, (Screen.height - box_height) / 2, box_width, box_height)); //GUI.BeginGroup(new Rect(0, 0, Screen.width, Screen.height)); //the menu background box GUI.Box(new Rect(0, 0, box_width, box_height), "", bg_scoreBox); //GUI.Label(new Rect(0,10,box_width, 40),"Game Over",label_gameover); GUI.Label(new Rect(label_score_x, label_score_y, label_score_w, label_score_h), "Your Score: " + MainMenu.current_score, label_score); GUI.Label(new Rect(label_Bscore_x, label_Bscore_y, label_Bscore_w, label_Bscore_h), "Best Score: " + best_score, label_scoreBest); GUI.DrawTexture(new Rect(image_x, image_y, image_w, image_h), score_image); //GUI.DrawTexture (new Rect (button_width, box_width/2, box_width/6, box_width/6), homeTexture); if (GUI.Button(new Rect(button_home_x, button_home_y, button_width, button_height), "", style_home_button)) { loadMainMenu(); } //GUI.DrawTexture (new Rect (box_width - button_width*2, box_width/2, box_width/6, box_width/6), retryTexture); if (GUI.Button(new Rect(button_retry_x, button_retry_y, button_width, button_height), "", style_retry_button)) { Helper.isRetry = true; restartGame(); } //layout end GUI.EndGroup(); } /*thumbStyle.fixedHeight = Screen.height / 40; * touchSensitivity = GUI.VerticalSlider (new Rect (Screen.width - Screen.width/20, * 15 + Screen.width/10, Screen.width/20, Screen.height/4), * touchSensitivity, 1.0f, 10.0f, sliderStyle, thumbStyle); * Helper.touchsense = touchSensitivity; * //Debug.Log ("touchSensitivity: "+touchSensitivity); */ }
// Use this for initialization void Start() { SaveLoadScript.Save_no_of_game_plays(0); Invoke("loadMainMenu", 3f); }