示例#1
0
    //+++++++Task Functions++++++//

    //xFeed
    public void Feed(float amount, CropsAndBuffs.Buff buff_in, Utilities.CropTypes cropType_in)
    {
        if (buff_in.buffType != Utilities.BuffTypes.None)
        {
            currentBuff           = buff_in;
            currentBuff.duration *= Utilities.BUFFSCALE;
            buffCropType          = cropType_in;
            ApplyBuff(currentBuff);
        }

        //eating provides a small boost to all stats depending on how much was recovered
        //recoveryDifference is used to make sure this bonus doesn't encroach into full recovery
        //(ie: eating when already full)
        float recoveryDifference = currentAttributes[Utilities.Attributes.Recovery];

        currentAttributes[Utilities.Attributes.Recovery] = Mathf.Min(currentAttributes[Utilities.Attributes.Recovery] + amount, 10);

        //recoveryDifference now refers to the difference between old and new
        recoveryDifference = currentAttributes[Utilities.Attributes.Recovery] - recoveryDifference;
        string floating = "+" + (Mathf.Round(recoveryDifference * 10) / 10).ToString() + " rec";

        Utilities.FloatText(transform.position + new Vector3(0, 1, 0), floating, Utilities.TextTypes.Positive);

        for (int c = (int)Utilities.Attributes.Strength; c <= (int)Utilities.Attributes.Acumen; c++)
        {
            currentAttributes[(Utilities.Attributes)c] = Mathf.Min(currentAttributes[(Utilities.Attributes)c] + recoveryDifference * Utilities.MEALBONUS, maxAttributes[(Utilities.Attributes)c]);
        }


        //change buff in ui if needed
        if (gameController.selectedCitizen == this.gameObject)
        {
            GameObject.Find("Current_Buff_UI").GetComponent <CurrentBuffUI_Script>().SetBuff();
        }
    }
示例#2
0
 void UpdateMetrics()
 {
     if (isActive && selectedBuff.tag == "Citizen")
     {
         currentBuff = selectedBuff.GetComponent <CitizenBehavior>().currentBuff;
         transform.GetChild(2).GetComponent <TextMesh>().text = Utilities.GenerateBuffText(currentBuff);
     }
 }
 void UpdateMetrics()
 {
     if (isActive && selectedBuff.tag == "Citizen")
     {
         currentBuff = selectedBuff.GetComponent<CitizenBehavior>().currentBuff;
         transform.GetChild(2).GetComponent<TextMesh>().text = Utilities.GenerateBuffText(currentBuff);
     }
 }
示例#4
0
    public void SetBuff()
    {
        if (gameController.selectedCitizen != null)
        {
            selectedBuff = gameController.selectedCitizen;
            currentBuff  = selectedBuff.GetComponent <CitizenBehavior>().currentBuff;

            Utilities.SetCropTexture(transform.GetChild(1).gameObject, selectedBuff.GetComponent <CitizenBehavior>().buffCropType);
            //currentBuff = selectedBuff.GetComponent<CitizenBehavior>().currentBuff;
        }
    }
    public void SetBuff()
    {
        if (gameController.selectedCitizen != null)
        {
            selectedBuff = gameController.selectedCitizen;
            currentBuff = selectedBuff.GetComponent<CitizenBehavior>().currentBuff;

            Utilities.SetCropTexture(transform.GetChild(1).gameObject, selectedBuff.GetComponent< CitizenBehavior>().buffCropType);
            //currentBuff = selectedBuff.GetComponent<CitizenBehavior>().currentBuff;
        }
    }
示例#6
0
    //This will generate the text needed for display depending on buff type
    public static string GenerateBuffText(CropsAndBuffs.Buff buff_in)
    {
        string buffText = "";

        if (buff_in.buffType == BuffTypes.None)
        {
            buffText = "None";
        }
        else if (buff_in.buffType == BuffTypes.Recovery)
        {
            buffText = buff_in.attribute.ToString() + " recovery up. \n";
        }
        else if (buff_in.buffType == BuffTypes.Drain)
        {
            buffText = buff_in.attribute.ToString() + " drain down. \n";
        }
        else if (buff_in.buffType == BuffTypes.AttributeScalar)
        {
            buffText = "Max " + buff_in.attribute.ToString() + " up. \n";
        }
        else if (buff_in.buffType == BuffTypes.AttributeLockPositive)
        {
            buffText = buff_in.attribute.ToString() + " stays above\n";
        }
        else if (buff_in.buffType == BuffTypes.AttributeLockNegative)
        {
            buffText = buff_in.attribute.ToString() + " stays below\n";
        }

        if (buff_in.buffType != BuffTypes.None)
        {
            //adding % sign if needed
            if (buff_in.buffType == BuffTypes.Recovery || buff_in.buffType == BuffTypes.Drain)
            {
                buffText += ("Value = " + Math.Round(buff_in.value, 2) + "%\nDuration = " + Mathf.Ceil(buff_in.duration / TIMESCALE));
            }
            else
            {
                buffText += ("Value = " + Math.Round(buff_in.value, 2) + "\nDuration = " + Mathf.Ceil(buff_in.duration / TIMESCALE));
            }
        }

        return(buffText);
    }
示例#7
0
    public void ApplyBuff(CropsAndBuffs.Buff buff_in)
    {
        //to remove any old buff effects
        Unbuff();

        currentBuff = buff_in;

        //creating some floating text
        //uses the buff text from the ui box, but only the first line
        string presplit = Utilities.GenerateBuffText(buff_in);

        string[] split = presplit.Split('\n');
        Utilities.FloatText(transform.position + new Vector3(0, 1, 1), split[0], Utilities.TextTypes.Positive);

        if (currentBuff.buffType != Utilities.BuffTypes.None)
        {
            buffIndicator.SetActive(true);
            //currentBuff.duration = currentBuff.maxDuration;

            //increase max attribute
            if (currentBuff.buffType == Utilities.BuffTypes.AttributeScalar)
            {
                maxAttributes[currentBuff.attribute]     += (int)Mathf.Floor(currentBuff.value);
                currentAttributes[currentBuff.attribute] += (int)Mathf.Floor(currentBuff.value);
            }

            if (currentBuff.buffType == Utilities.BuffTypes.AttributeLockNegative)
            {
                buffParticles.startColor = Color.red;
            }
            else
            {
                buffParticles.startColor = Color.green;
            }

            //print (currentBuff.name + " duration: " + currentBuff.duration + " value: " + currentBuff.value);
        }
        else
        {
            //print ("NO BUFF");
        }
    }
示例#8
0
    /* xSetItem
     * called by cropbehavior when slotting a new item,
     * code varies by type of station and type of crop
     * also sets buff values*/
    public override void SetItem(Utilities.CropTypes crop_in, Utilities.ItemTypes itemType_in, float restQuality_in, CropsAndBuffs.Buff buff_in)
    {
        itemType       = itemType_in;
        cropType       = crop_in;
        restoreQuality = restQuality_in;
        CropsAndBuffs.Crop newCrop = CropsAndBuffs.cropList[cropType];

        if (itemType == Utilities.ItemTypes.Meal)
        {
            currentBuff = buff_in;
        }
        else
        {
            currentBuff.buffType = Utilities.BuffTypes.None;
        }

        recoveryRestore   = newCrop.baseRecovery + newCrop.baseRecovery * restoreQuality;
        maxProductionTime = Utilities.EATTIME / Utilities.TIMESCALE;

        base.SetItem(crop_in, itemType_in, restQuality_in, buff_in);
    }
示例#9
0
    public void CreateCrop(Utilities.CropTypes crop_in, Utilities.ItemTypes type_in, GameObject creator_in, float restQuality_in, float buffQuality_in)
    {
        cropType = crop_in;
        itemType = type_in;
        creator  = creator_in;

        restoreQuality = restQuality_in;
        buffQuality    = buffQuality_in;

        if (itemType == Utilities.ItemTypes.Meal)
        {
            currentBuff              = CropsAndBuffs.buffList[cropType];
            currentBuff.maxDuration += currentBuff.maxDuration * restoreQuality;
            currentBuff.value       += currentBuff.value * buffQuality_in;
            currentBuff.duration     = currentBuff.maxDuration;
        }

        Utilities.SetCropTexture(this.gameObject, crop_in);

        if (itemType != Utilities.ItemTypes.Seed)
        {
            CreateIndicator();
        }
    }
示例#10
0
    /* xSetItem
     * called by cropbehavior when slotting a new item,
     * code varies by type of station and type of crop
     * also sets buff values*/
    public override void SetItem(Utilities.CropTypes crop_in, Utilities.ItemTypes itemType_in, float restQuality_in, CropsAndBuffs.Buff buff_in)
    {
        pestScript.RotateCrop();
        itemType       = itemType_in;
        cropType       = crop_in;
        restoreQuality = restQuality_in;

        CropsAndBuffs.Crop newCrop = CropsAndBuffs.cropList[cropType];

        primaryEff        = newCrop.primaryEff;
        secondaryEff      = newCrop.secondaryEff;
        primaryQual       = newCrop.primaryQual;
        secondaryQual     = newCrop.secondaryQual;
        fatigueRate       = newCrop.fatigueRate;
        maxProductionTime = newCrop.timeToProduce / Utilities.TIMESCALE;

        base.SetItem(crop_in, itemType_in, restQuality_in, buff_in);
    }
示例#11
0
    /* xSetItem
     * called by cropbehavior when slotting a new item,
     * code varies by type of station and type of crop
     * also sets buff values*/
    public override void SetItem(Utilities.CropTypes crop_in, Utilities.ItemTypes itemType_in, float restQuality_in, CropsAndBuffs.Buff buff_in)
    {
        itemType       = itemType_in;
        cropType       = crop_in;
        restoreQuality = restQuality_in;
        CropsAndBuffs.Crop newCrop = CropsAndBuffs.cropList[cropType];
        maxProductionTime = newCrop.timeToProduce * Utilities.TRADETIMERATIO / (Utilities.TIMESCALE);

        base.SetItem(crop_in, itemType_in, restQuality_in, buff_in);
    }
示例#12
0
    /* xSetItem
     * called by cropbehavior when slotting a new item,
     * code varies by type of station and type of crop
     * also sets buff values*/
    public virtual void SetItem(Utilities.CropTypes crop_in, Utilities.ItemTypes itemType_in, float restQuality_in, CropsAndBuffs.Buff buff_in)
    {
        timeToProduce = maxProductionTime;

        if (citizen1 != null)
        {
            citizen1Script.SetTaskAttributes(primaryEff, secondaryEff, primaryQual, secondaryQual, fatigueRate);

            Activate();
        }

        if (citizen2 != null)
        {
            citizen2Script.SetTaskAttributes(primaryEff, secondaryEff, primaryQual, secondaryQual, fatigueRate);

            Activate();
        }

        Utilities.SetCropTexture(this.gameObject.transform.GetChild(1).gameObject, crop_in);

        if (gameController.selectedTask == this.gameObject)
        {
            GameObject.Find("Current_Task_UI").GetComponent <CurrentTaskUI_Script>().SetTask();
        }
    }
示例#13
0
    public void ApplyBuff(CropsAndBuffs.Buff buff_in)
    {
        //to remove any old buff effects
        Unbuff();

        currentBuff = buff_in;

        //creating some floating text
        //uses the buff text from the ui box, but only the first line
        string presplit = Utilities.GenerateBuffText(buff_in);
        string[] split = presplit.Split ('\n');
        Utilities.FloatText (transform.position + new Vector3(0,1,1), split[0], Utilities.TextTypes.Positive);

        if (currentBuff.buffType != Utilities.BuffTypes.None)
        {

            buffIndicator.SetActive(true);
            //currentBuff.duration = currentBuff.maxDuration;

            //increase max attribute
            if (currentBuff.buffType == Utilities.BuffTypes.AttributeScalar)
            {
                maxAttributes[currentBuff.attribute] += (int)Mathf.Floor(currentBuff.value);
                currentAttributes[currentBuff.attribute] += (int)Mathf.Floor(currentBuff.value);
            }

            if (currentBuff.buffType == Utilities.BuffTypes.AttributeLockNegative)
            {
                buffParticles.startColor = Color.red;
            }
            else
            {
                buffParticles.startColor = Color.green;
            }

            //print (currentBuff.name + " duration: " + currentBuff.duration + " value: " + currentBuff.value);
        }
        else
        {
            //print ("NO BUFF");
        }
    }
示例#14
0
    //+++++++Task Functions++++++//
    //xFeed
    public void Feed(float amount, CropsAndBuffs.Buff buff_in, Utilities.CropTypes cropType_in)
    {
        if (buff_in.buffType != Utilities.BuffTypes.None)
        {
            currentBuff = buff_in;
            currentBuff.duration *= Utilities.BUFFSCALE;
            buffCropType = cropType_in;
            ApplyBuff(currentBuff);

        }

        //eating provides a small boost to all stats depending on how much was recovered
        //recoveryDifference is used to make sure this bonus doesn't encroach into full recovery
        //(ie: eating when already full)
        float recoveryDifference = currentAttributes[Utilities.Attributes.Recovery];
        currentAttributes[Utilities.Attributes.Recovery] = Mathf.Min (currentAttributes[Utilities.Attributes.Recovery]+amount, 10);

        //recoveryDifference now refers to the difference between old and new
        recoveryDifference = currentAttributes[Utilities.Attributes.Recovery] - recoveryDifference;
        string floating = "+" + (Mathf.Round(recoveryDifference*10)/10).ToString() + " rec";
        Utilities.FloatText (transform.position + new Vector3(0,1,0), floating, Utilities.TextTypes.Positive);

        for (int c = (int)Utilities.Attributes.Strength; c <= (int)Utilities.Attributes.Acumen; c++)
        {
            currentAttributes[(Utilities.Attributes)c] = Mathf.Min(currentAttributes[(Utilities.Attributes)c] + recoveryDifference*Utilities.MEALBONUS, maxAttributes[(Utilities.Attributes)c]);
        }

        //change buff in ui if needed
        if (gameController.selectedCitizen == this.gameObject)
            GameObject.Find("Current_Buff_UI").GetComponent<CurrentBuffUI_Script>().SetBuff();
    }