void FixedUpdate() { if (HealthBarLogic.alreadyDead) { return; } playerRigid.velocity = Vector3.ClampMagnitude(playerRigid.velocity, 12f); #if UNITY_EDITOR if (Input.GetKey(KeyCode.D)) { OnRightButtonClick(); } else if (Input.GetKey(KeyCode.A)) { OnLeftButtonClick(); } else if (Input.GetKey(KeyCode.S)) { playerAnimControlScript.OnButtonDownClick(); } else { OnStopMovingClick(); } if (Input.GetKeyDown(KeyCode.R)) { PlayerScore.money += 100; } if (Input.GetKey(KeyCode.Space)) { OnJumpButtonClick(); } #endif Moving(horMove); }
void Start() { if (Application.loadedLevelName == "LevelCompleteScene" || Application.loadedLevelName == "MainMenu" || Application.loadedLevelName == "DeathMenu" || Application.loadedLevelName == "InformationScene" || Application.loadedLevelName == "GameCompleteScene") { return; } GameObject player = GameObject.Find("Player"); PlayerMovement playerMovementScript = player.GetComponent <PlayerMovement> (); PlayerAnimationControl playerAnimControlScript = player.GetComponent <PlayerAnimationControl> (); textAlert = this.gameObject.GetComponentInChildren <TextAlert> (); HealthBarLogic playerHealthBar = GameObject.Find("HealthBar").GetComponent <HealthBarLogic> (); if (Application.loadedLevelName == "Level5") { StartCoroutine(Level5Intro()); } Button[] buttons = gameObject.GetComponentsInChildren <Button> (); // buttons [0].onClick.AddListener (() => { // //playerMovementScript.OnLeftButtonClick(); // }); buttons [1].onClick.AddListener(() => { playerAnimControlScript.OnButtonDownClick(); }); // buttons [2].onClick.AddListener (() => { // //playerMovementScript.OnRightButtonClick(); // }); buttons [3].onClick.AddListener(() => { playerAnimControlScript.OnUpButtonClick(); }); buttons [4].onClick.AddListener(() => { playerMovementScript.OnStopMovingClick(); }); buttons [5].onClick.AddListener(() => { playerAnimControlScript.OnShootButtonClick(); }); buttons [6].onClick.AddListener(() => { playerMovementScript.OnJumpButtonClick(); }); buttons [7].onClick.AddListener(() => { //ShieldBuy if (HealthBarLogic.alreadyDead) { return; } if (PlayerScore.money >= 15) { if (playerHealthBar.shieldAmount < 100) { playerHealthBar.ShieldPlayer(50, 6); PlayerScore.money -= 15; } else { textAlert.ShowMessage("Нямате нужда от това в момента!"); } } else { textAlert.ShowMessage("Нямате достатъчно пари, за да закупите това!"); } }); buttons [8].onClick.AddListener(() => { //HealthBuy if (HealthBarLogic.alreadyDead) { return; } if (PlayerScore.money >= 20) { if (playerHealthBar.Health == 100) { textAlert.ShowMessage("Вече сте на пълни жизнени точки!"); return; } playerHealthBar.HealPlayer(40); PlayerScore.money -= 20; } else { textAlert.ShowMessage("Нямате достатъчно пари, за да закупите това!"); } }); buttons [9].onClick.AddListener(() => { //TimeSlowerBuy if (HealthBarLogic.alreadyDead) { return; } if (PlayerScore.money >= 10) { if (GameObject.Find("TimeSlowerGO") != null) { textAlert.ShowMessage("Вече сте използвали този ефект!"); } else { GameObject timeSlowerGO = new GameObject("TimeSlowerGO"); timeSlowerGO.AddComponent <CollectablesLogic>(); StartCoroutine(timeSlowerGO.GetComponent <CollectablesLogic>().TimeSlower()); PlayerScore.money -= 10; } } else { textAlert.ShowMessage("Нямате достатъчно пари, за да закупите това!"); } }); buttons [10].onClick.AddListener(() => { //RocketLauncherBuy if (HealthBarLogic.alreadyDead) { return; } if (PlayerScore.money >= 50) { if (playerAnimControlScript.isKneeingButtonClicked) { playerAnimControlScript.OnUpButtonClick(); } if (playerMovementScript.facingRight) { Instantiate(rocketLauncher, player.gameObject.transform.position - new Vector3(0, 0.1f, 0), Quaternion.Euler(0, 180, 0)); } else if (playerMovementScript.facingRight == false) { Instantiate(rocketLauncher, player.gameObject.transform.position - new Vector3(0, 0.1f, 0), Quaternion.Euler(0, 0, 0)); } PlayerScore.money -= 50; } else { textAlert.ShowMessage("Нямате достатъчно пари, за да закупите това!"); } }); }