public void IsEnableObjects(bool value) { AIplayer.transform.GetComponent <Rigidbody>().useGravity = value; AIplayer.GetComponent <PandaBehaviour>().enabled = value; ball.transform.GetComponent <Rigidbody>().useGravity = value; humanPlayer.transform.GetComponent <Rigidbody>().useGravity = value; }
IEnumerator Wait() { yield return(new WaitForSeconds(2)); GoalUI.SetActive(false); isPauseGame = false; AIplayer.GetComponent <PandaBehaviour>().enabled = true; }
public void GoalEntered() { isPauseGame = true; AIplayer.GetComponent <PandaBehaviour>().enabled = false; GoalUI.SetActive(true); StartCoroutine(Wait()); //wait 1 seconds AI_player.BackToInitPosition(); humanPlayer.BackToInitPosition(); Debug.Log("AI_player init pos= " + humanPlayer.GetPos()); ballController.GoalEntered(); current_time = TURN_TIMER; }
public void AIMovement() { float displacement = (ball.Y - AIplayer.Center.Y); //Prevent movement from being too sudden displacement = MathHelper.Clamp(displacement, -AIspeed, AIspeed); //Keep in screen bounds if ((displacement > 0 && AIplayer.Y + AIplayer.Height >= ScreenHeight) || (displacement < 0 && AIplayer.Y <= 0)) { return; } AIplayer.Translate(0, (int)displacement); }
public void OnTargetFound() { isMarkerDetected = true; isTimerOn = true; scanBarcodeContainer.SetActive(false); timerUiContainer.SetActive(true); scoreUi.SetActive(true); joystick.SetActive(true); menuGameUiContainer.SetActive(true); gameObjectsContainer.SetActive(true); isPauseGame = false; string HumanPlayerAvatar = NetworkClient.users[NetworkClient.clientID].avatar; avatar.DisplayAvatar(humanPlayerAvatar, HumanPlayerAvatar); avatar.DisplayAvatar(aiPlayerAvatar, Avatar.AI_AVATAR); if (level == 1) { AI_player = GameObject.FindObjectOfType <AIPlayerLevel1>(); } else if (level == 2) { AI_player = GameObject.FindObjectOfType <AIPlayerLevel2>(); } GameObject[] g = GameObject.FindGameObjectsWithTag("BlockPlane"); foreach (GameObject obj in g) { MeshRenderer mesh = obj.GetComponent <MeshRenderer>(); mesh.enabled = false; } AIplayer.GetComponent <PandaBehaviour>().enabled = false; ballController = GameObject.FindObjectOfType <BallController>(); if (isTimerFinish && !isGameOver) { IsEnableObjects(true); } }