public void SetBuildPoint(PlantPoint plantPoint) { //Cuadno el plant poin esta vacio para sacar el buildUI currentPlantPoint = plantPoint; buildUI.position = currentPlantPoint.transform.position; buildCanvas.SetActive(true); }
public void SetPlantPoint(PlantPoint plantPoint) { //Si el plantPoint tiene una planta se activa el plantpointUI con la informacion de la planta. currentPlantPoint = plantPoint; plantUI.position = currentPlantPoint.transform.position; plantCanvas.SetActive(true); }
// Start is called before the first frame update void Start() { if (icon_Plant_Behaviour == null) { icon_Plant_Behaviour = gameObject.transform.parent.gameObject.GetComponentInChildren <Icon_Plant_Behaviour>(); } plantPoint = gameObject.transform.parent.gameObject.GetComponent <PlantPoint>(); StartCoroutine(EatPlant()); StartCoroutine(RotateRat()); }
public void SelectBuildPoint(PlantPoint plantPoint) //Metodo que se llamara cada vez que el jugador haga click sobre un plant point. { if (currentPlantPoint == plantPoint) { DeselectBuildPoint(); return; } currentPlantPoint = plantPoint; SetBuildPoint(currentPlantPoint); }
//Metodos para el manejo de los plantpoints y la UI public void SelectPlantPoint(PlantPoint plantPoint) //Metodo que se llamara cada vez que el jugador haga click sobre un plant point. { if (currentPlantPoint == plantPoint) { DeselectPlantPoint(); return; } currentPlantPoint = plantPoint; UIManager.Instance.SetPlantPoint(currentPlantPoint); }
void UpdatePlant(Spawner spawner) { List <PlantPoint> plantPoints = spawner.PatchOfSoil.PlantPoints; for (int i = 0; i < plantPoints.Count; i++) { PlantPoint plantPoint = plantPoints[i]; if (plantPoint.HasCrop) { plantPoint.Plant.GetComponent <Plant_Behaviour>().StartRound = true; } plantPoint.RoundStarted = true; } }
//This method checks if the current plantPoint has a plant on it or not //depending on the value it tell the UIManager wich canvas deactivate private void ClearPlantPoint() { if (CurrentPlantPoint) { if (CurrentPlantPoint.currentPlant) { UIManager.Instance.DeselectPlantPoint(); } else if (!CurrentPlantPoint.currentPlant) { UIManager.Instance.DeselectBuildPoint(); } CurrentPlantPoint = null; } else { return; } }
//This are the built-in methos for detecting trigger collision. //Here is called each time an object enters in collision with the sphereCollider public void OnTriggerEnter(Collider collider) { //If the object that entered collision is tagged as PlantPoint. Here for telling the //script to not check any collision that is not a plantPoint if (collider.CompareTag("PlantPoint")) { Debug.Log("Detecto un plantPoint" + collider.gameObject.GetComponent <PlantPoint>()); CurrentPlantPoint = collider.gameObject.GetComponent <PlantPoint>(); if (CurrentPlantPoint.currentPlant) { UIManager.Instance.SelectPlantPoint(CurrentPlantPoint); } else if (!currentPlantPoint.currentPlant) { UIManager.Instance.SelectBuildPoint(CurrentPlantPoint); } } else { return; } }
private void OnTriggerEnter(Collider collision) { if (collision.gameObject.tag == "AmmoChest") { playerManager.EnableFillingAmmoIcon(); barrelCollidingWithAmmoChest = true; } else if (collision.gameObject.tag == "HarvestChest") { playerManager.EnableFillingHarvestIcon(); barrelCollidingWithHarvestChest = true; } else if (collision.gameObject.GetComponent <PlantModel>() != null) { nastyCollidedGameObject = collision.gameObject; playerManager.EnableHarvestIcon(); barrelCollidingWithPlant = true; } else if (collision.gameObject.GetComponent <PlantPoint>() != null) { nastyCollidedGameObject = collision.gameObject; playerManager.EnablePlantIcon(); barrelCollidingWithPlantPoint = true; PlantPointScript = collision.gameObject.GetComponent <PlantPoint>(); } else if (collision.gameObject.GetComponent <Rat_Movement_Logic>() != null) { nastyCollidedGameObject = collision.gameObject; shotGunBehaviourScript_.BarrelOnRat = true; shotGunBehaviourScript_.RatOnBarrel = nastyCollidedGameObject; } else { DisablePlayerIcons(); } }
private void GetPlayerInput() { Ray ray = new Ray(Harvest_Raycast_SpawnPoint.position, Harvest_Raycast_SpawnPoint.forward); RaycastHit hit; if (Physics.Raycast(ray, out hit, Cam_Ray_Length)) { Debug.DrawLine(ray.origin, hit.point); gameobjectCollided = hit.collider.gameObject; if (gameobjectCollided.GetComponent <PlantModel>() != null) { if (gameobjectCollided.GetComponentInParent <Plant_Behaviour>().CanBeHarvested()) { playerManager.EnableHarvestIcon(); } else { playerManager.DisableHarvestIcon(); } if (Input.GetKeyDown(KeyCode.Q) || Input.GetKeyDown(KeyCode.E)) { Harvest(gameobjectCollided); } } else if (gameobjectCollided.GetComponent <PlantPoint>() != null) { PlantPointScript = gameobjectCollided.GetComponent <PlantPoint>(); if (!PlantPointScript.HasCrop) { playerManager.EnablePlantIcon(); } else { playerManager.DisablePlantIcon(); } if (Input.GetKeyDown(KeyCode.Q) || Input.GetKeyDown(KeyCode.E)) { Plant(gameobjectCollided); } } else if (gameobjectCollided.gameObject.tag == "AmmoChest") { playerManager.EnableFillingAmmoIcon(); if (Input.GetKeyDown(KeyCode.Q) || Input.GetKeyDown(KeyCode.E)) { shotGunBehaviourScript_.FillBulletsPocket(); Debug.Log("Fill ammo now!"); } } else if (gameobjectCollided.gameObject.tag == "HarvestChest") { playerManager.EnableFillingHarvestIcon(); if (Input.GetKeyDown(KeyCode.Q) || Input.GetKeyDown(KeyCode.E)) { playerManager.updateScore(); } } else { DisablePlayerIcons(); } } else { DisablePlayerIcons(); } IfBarrelInsideTheObject(nastyCollidedGameObject); RotateView(); // the jump state needs to read here to make sure it is not missed if (!m_Jump) { m_Jump = CrossPlatformInputManager.GetButtonDown("Jump"); } if (!m_PreviouslyGrounded && m_CharacterController.isGrounded) { StartCoroutine(m_JumpBob.DoBobCycle()); PlayLandingSound(); m_MoveDir.y = 0f; m_Jumping = false; } if (!m_CharacterController.isGrounded && !m_Jumping && m_PreviouslyGrounded) { m_MoveDir.y = 0f; } m_PreviouslyGrounded = m_CharacterController.isGrounded; }
public void DeselectBuildPoint() //Function for deselection the plantpoint { currentPlantPoint = null; HideBuildUI(); }