public IEnumerator Plant(Responsible responsible) { var ground = GroundUtil.FindGround(responsible.gameObject.transform.position); if (ground != null) { if (!ground.occupied) { responsible.Target = ground.gameObject; yield return(StartCoroutine(responsible.Walk(ground.gameObject.transform.position))); } else { Debug.Log("Ground is occupied!"); responsible.FinishJob(true); yield return(null); } } responsible.animator.SetTrigger("plant"); yield return(Util.WaitForSeconds(responsible.GetCurrentJob(), 6f)); if (ground != null) { ground.occupied = true; } responsible.animator.ResetTrigger("plant"); responsible.Inventory.Remove(gameObject); var newProduct = Instantiate(_product, new Vector3(ground.gameObject.transform.position.x, _product.transform.position.y, ground.gameObject.transform.position.z), _product.transform.rotation); newProduct.GetComponent <Plant>().SetHarvestable(false); Destroy(gameObject, 1f); responsible.FinishJob(); }
public IEnumerator Sleep(Responsible responsible) { yield return(StartCoroutine(responsible.Walk(interactionPoint.transform.position))); yield return(Util.WaitForSeconds(responsible.GetCurrentJob(), sleepDuration)); responsible.FinishJob(); }
public IEnumerator Walk(Responsible responsible) { yield return(StartCoroutine(responsible.Walk(interactionPoint.transform.position))); responsible.FinishJob(); Debug.Log("Finished walking!"); yield break; }
public virtual IEnumerator Drop(Responsible responsible) { yield return(Util.WaitForSeconds(responsible.GetCurrentJob(), dropDuration)); responsible.Inventory.Remove(gameObject); gameObject.transform.position = responsible.directionPosition.transform.position; SetPicked(false); responsible.FinishJob(); }
public IEnumerator Shower(Responsible responsible) { yield return(StartCoroutine(responsible.Walk(interactionPoint.transform.position))); responsible.GetCurrentJob().SetProgressDuration(10); yield return(new WaitForSeconds(10)); responsible.FinishJob(); }
public virtual IEnumerator Pick(Responsible responsible) { yield return(StartCoroutine(responsible.Walk(interactionPoint.transform.position))); yield return(Util.WaitForSeconds(responsible.GetCurrentJob(), _pickDuration)); responsible.Inventory.Add(this.gameObject); SetPicked(true); responsible.FinishJob(); }
public IEnumerator Eat(Responsible responsible) { yield return(StartCoroutine(responsible.Walk(interactionPoint.transform.position))); yield return(Util.WaitForSeconds(responsible.GetCurrentJob(), eatDuration)); responsible.Heal(20); Destroy(gameObject, 0.5f); responsible.FinishJob(); }
public IEnumerator Chop(Responsible responsible) { yield return(StartCoroutine(responsible.Walk(interactionPoint.transform.position))); yield return(Util.WaitForSeconds(responsible.GetCurrentJob(), SkillManager.GetSkillBonusForDuration(responsible, chopDuration))); GroundUtil.Clear(gameObject.transform.position); responsible.Inventory.Add(CreateProduct()); Destroy(gameObject); responsible.FinishJob(); }
public IEnumerator Mine(Responsible responsible) { yield return(StartCoroutine(responsible.Walk(interactionPoint.transform.position))); yield return(Util.WaitForSeconds(responsible.GetCurrentJob(), mineDuration)); GroundUtil.Clear(gameObject.transform.position); responsible.Inventory.Add(CreateStone()); Destroy(gameObject, 0.5f); responsible.FinishJob(); }
public IEnumerator Harvest(Responsible responsible) { yield return(StartCoroutine(responsible.Walk(interactionPoint.transform.position))); responsible.animator.SetBool("isHarvesting", true); yield return(Util.WaitForSeconds(responsible.GetCurrentJob(), harvestDuration)); responsible.animator.SetBool("isHarvesting", false); GroundUtil.Clear(gameObject.transform.position); responsible.Inventory.Add(CreateProduct()); Destroy(gameObject, 0.5f); responsible.FinishJob(); }
public virtual IEnumerator Unequip(Responsible responsible) { if (equipped) { yield return(Util.WaitForSeconds(responsible.GetCurrentJob(), _unequipDuration)); responsible.Equipment.Unequip(gameObject); UIManager.Instance.SetInventory(responsible); } yield return(null); responsible.FinishJob(); }
public new virtual IEnumerator Drop(Responsible responsible) { yield return(Util.WaitForSeconds(responsible.GetCurrentJob(), dropDuration)); if (equipped) { responsible.Equipment.Unequip(gameObject); } responsible.Inventory.Remove(gameObject); gameObject.transform.position = responsible.gameObject.transform.position; gameObject.GetComponent <Rigidbody>().isKinematic = false; SetPicked(false); SetEquipped(false); responsible.FinishJob(); }
public IEnumerator Eat(Responsible responsible) { if (!picked) { yield return(StartCoroutine(responsible.Walk(interactionPoint.transform.position))); } yield return(Util.WaitForSeconds(responsible.GetCurrentJob(), eatDuration)); if (picked) { responsible.Inventory.Remove(GetGroupName()); } Destroy(this.gameObject, 0.1f); responsible.FinishJob(); }
public virtual IEnumerator Equip(Responsible responsible) { if (picked) { yield return(Util.WaitForSeconds(responsible.GetCurrentJob(), _equipDuration)); } else { yield return(StartCoroutine(responsible.Walk(interactionPoint.transform.position))); responsible.Inventory.Add(this.gameObject); yield return(Util.WaitForSeconds(responsible.GetCurrentJob(), _equipDuration)); } responsible.Equipment.Equip(gameObject); UIManager.Instance.SetInventory(responsible); responsible.FinishJob(); }
public IEnumerator Craft(Responsible responsible) { yield return(StartCoroutine(responsible.Walk(interactionPoint.transform.position))); RecipeManager.Instance.OpenCraftingMenu(recipes, responsible); yield return(new WaitUntil(() => recipeSet)); yield return(currentRecipe.Craft(responsible)); foreach (var quest in responsible.quests) { quest.Progress(ActivityType.Craft, currentRecipe.Name); } var product = RecipeManager.Instance.CreateProduct(currentRecipe, gameObject); product.GetComponent <Pickable>().SetPicked(true); responsible.Inventory.Add(product); responsible.FinishJob(); ResetRecipe(); }
public IEnumerator Eat(Responsible responsible) { if (_harvestable) { yield return(StartCoroutine(responsible.Walk(interactionPoint.transform.position))); } yield return(Util.WaitForSeconds(responsible.GetCurrentJob(), eatDuration)); if (_harvestable) { GroundUtil.Clear(gameObject.transform.position); } else { responsible.Inventory.Remove(gameObject); } responsible.Inventory.Add(CreateSeed()); responsible.Heal(20); Destroy(gameObject, 0.5f); responsible.FinishJob(); }
public IEnumerator Walk(Responsible responsible) { yield return(StartCoroutine(responsible.Walk(interactionPoint.transform.position))); responsible.FinishJob(); }
public IEnumerator Place(Responsible responsible) { if (_placed) { GroundUtil.Clear(transform.position); } Time.timeScale = 0; while (!Input.GetMouseButtonDown(0)) { var ray = Camera.main.ScreenPointToRay(Input.mousePosition); RaycastHit hit; if (Physics.Raycast(ray, out hit)) { float x = hit.point.x % 2; if (x > 1) { x = Mathf.Ceil(hit.point.x); } else { x = Mathf.Floor(hit.point.x); } float z = hit.point.z % 2; if (z > 1) { z = Mathf.Ceil(hit.point.z); } else { z = Mathf.Floor(hit.point.z); } /* * var rand = Random.insideUnitCircle * 5f; * rand.x += responsible.gameObject.transform.position.x; * rand.y += responsible.gameObject.transform.position.z; * * if (x <= rand.x && z <= rand.y) * { * gameObject.transform.position = new Vector3(x, gameObject.transform.localScale.y/2, z); * } */ gameObject.transform.position = new Vector3(x, gameObject.transform.localScale.y / 2, z); var ground_ = GroundUtil.FindGround(transform.position); if (ground_ != null) { if (ground_.occupied) { gameObject.GetComponent <ShaderAdjuster>().SetColor(Color.red); } else { gameObject.GetComponent <ShaderAdjuster>().SetColor(Color.green); } } gameObject.transform.rotation = Quaternion.identity; } yield return(null); } _placed = true; yield return(new WaitUntil(() => _placed)); Time.timeScale = 1; var ground = GroundUtil.FindGround(transform.position); if (!ground.occupied) { GroundUtil.Occupy(gameObject.transform.position); SetPicked(!_placed); responsible.Inventory.Remove(GetGroupName()); } else { transform.position = new Vector3(0, -100f, 0); } responsible.FinishJob(); }