Esempio n. 1
0
    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();
    }
Esempio n. 2
0
        public IEnumerator Sleep(Responsible responsible)
        {
            yield return(StartCoroutine(responsible.Walk(interactionPoint.transform.position)));

            yield return(Util.WaitForSeconds(responsible.GetCurrentJob(), sleepDuration));

            responsible.FinishJob();
        }
Esempio n. 3
0
    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();
    }
Esempio n. 4
0
    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 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();
    }
Esempio n. 6
0
    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();
    }
Esempio n. 7
0
    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();
    }
Esempio n. 8
0
        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();
        }
Esempio n. 9
0
    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();
    }
Esempio n. 10
0
        public IEnumerator Craft(Responsible responsible)
        {
            yield return(Util.WaitForSeconds(responsible.GetCurrentJob(), Duration));

            foreach (var ingredient in Ingredients)
            {
                if (responsible.Inventory.FindCount(ingredient.Name) >= ingredient.Amount)
                {
                    responsible.Inventory.Remove(ingredient.Name, ingredient.Amount);
                }
            }
        }
Esempio n. 11
0
        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();
        }
Esempio n. 12
0
    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();
    }
Esempio n. 13
0
    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();
    }
Esempio n. 14
0
    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();
    }
Esempio n. 15
0
        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();
        }
Esempio n. 16
0
        public static float GetSkillBonusForDuration(Responsible responsible, float duration)
        {
            SkillAttribute skillAttribute = System.Attribute.GetCustomAttribute(responsible.GetCurrentJob().Method, typeof(SkillAttribute)) as SkillAttribute;

            if (skillAttribute == null)
            {
                return(duration);
            }

            var reducedDuration = duration;

            if (responsible.Skills.ContainsKey(skillAttribute.SkillType))
            {
                reducedDuration *= (float)
                                   (responsible.Skills[skillAttribute.SkillType].MaxLevel -
                                    responsible.Skills[skillAttribute.SkillType].Level + 1) /
                                   responsible.Skills[skillAttribute.SkillType].MaxLevel;
            }

            Debug.Log("Reduced duration: " + reducedDuration);

            return(reducedDuration);
        }