コード例 #1
0
    /// <summary>
    /// Adjust experience.
    /// </summary>
    public void AdjustExperience(float Value)
    {
        CTierInfo tier = CGame.AssetManager.mUnitRules.GetTier(mStats.mTier);

        if (mStats.mLevel >= tier.mMaxLevel)
        {
            return;
        }

        mStats.mExperience += Value;

        if (mStats.mExperience >= mStats.mRequiredXP)
        {
            mStats.mExperience       = 0;
            mStats.mLevel           += 1;
            mStats.mSalary          += tier.mSalary.mIncrease;
            mStats.mIntelligence    += tier.mIntelligence.mIncrease;
            mStats.mMaxStamina      += tier.mMaxStamina.mIncrease;
            mStats.mMaxSpeed        += tier.mMaxSpeed.mIncrease;
            mStats.mHungerRate      += tier.mHungerRate.mIncrease;
            mStats.mMaxHunger       += tier.mMaxHunger.mIncrease;
            mStats.mPaperCapacity   += tier.mPaperCapacity.mIncrease;
            mStats.mAttackDamage    += tier.mAttackDamage.mIncrease;
            mStats.mDefense         += tier.mDefense.mIncrease;
            mStats.mIdleTime        += tier.mIdleTime.mIncrease;
            mStats.mWorkStaminaRate += tier.mWorkStaminaRate.mIncrease;
            mStats.mRequiredXP      += tier.mRequiredXP.mIncrease;
            mStats.mPromotionDemand += tier.mPromotionDemand.mIncrease;
        }
    }
コード例 #2
0
    /// <summary>
    /// Promote this unit.
    /// </summary>
    public void Promote()
    {
        if (mIntern)
        {
            return;
        }

        CTierInfo tier     = CGame.AssetManager.mUnitRules.GetTier(mStats.mTier);
        CTierInfo nextTier = CGame.AssetManager.mUnitRules.GetTier(mStats.mTier + 1);

        if (nextTier != tier)
        {
            mStats.mTier            = nextTier.mTierIndex;
            mStats.mLevel           = 1;
            mStats.mPromotionDemand = 1;

            if (tier.mSalary.Get(1) > mStats.mSalary)
            {
                mStats.mSalary += tier.mSalary.mIncrease;
            }
            if (tier.mPaperCapacity.Get(1) > mStats.mPaperCapacity)
            {
                mStats.mPaperCapacity += tier.mPaperCapacity.mIncrease;
            }
            if (tier.mAttackDamage.Get(1) > mStats.mAttackDamage)
            {
                mStats.mAttackDamage += tier.mAttackDamage.mIncrease;
            }
            if (tier.mIdleTime.Get(1) > mStats.mIdleTime)
            {
                mStats.mIdleTime += tier.mIdleTime.mIncrease;
            }
            if (tier.mWorkStaminaRate.Get(1) > mStats.mWorkStaminaRate)
            {
                mStats.mWorkStaminaRate += tier.mWorkStaminaRate.mIncrease;
            }
            if (tier.mRequiredXP.Get(1) > mStats.mRequiredXP)
            {
                mStats.mRequiredXP += tier.mRequiredXP.mIncrease;
            }

            mWorld.AddTransientEventFOW(mPosition).SetEffect(mPosition.ToWorldVec3());
        }

        mPromotionCounter = 0;
        mStress           = 0;
        mQuitCounter      = 0;
    }
コード例 #3
0
    public void Generate(CWorld World, int Tier, int Level)
    {
        mOwner = 0;

        CTierInfo tier = CGame.AssetManager.mUnitRules.GetTier(Tier);

        if (tier == null)
        {
            Debug.LogError("Requested tier did not exist in resume generation");
            return;
        }

        if (Tier == 1)
        {
            Level = 1;            // (int)(World.SimRnd.GetNextFloat() * );
        }
        if (tier.mMaxLevel != 0 && Level > tier.mMaxLevel)
        {
            Level = tier.mMaxLevel;
        }

        mStats.mName  = CUtility.GenerateRandomName(World.SimRnd);
        mStats.mTier  = tier.mTierIndex;
        mStats.mLevel = Level;

        mStats.mSalary          = tier.mSalary.Get(Level);
        mStats.mIntelligence    = tier.mIntelligence.Get(Level);
        mStats.mMaxStamina      = tier.mMaxStamina.Get(Level);
        mStats.mMaxSpeed        = tier.mMaxSpeed.Get(Level);
        mStats.mHungerRate      = tier.mHungerRate.Get(Level);
        mStats.mMaxHunger       = tier.mMaxHunger.Get(Level);
        mStats.mPaperCapacity   = tier.mPaperCapacity.Get(Level);
        mStats.mAttackDamage    = tier.mAttackDamage.Get(Level);
        mStats.mDefense         = tier.mDefense.Get(Level);
        mStats.mIdleTime        = tier.mIdleTime.Get(Level);
        mStats.mWorkStaminaRate = tier.mWorkStaminaRate.Get(Level);
        mStats.mRequiredXP      = tier.mRequiredXP.Get(Level);
        mStats.mPromotionDemand = 1;

        mStats.mMaxStress          = 100;
        mStats.mRestDesired        = 40;
        mStats.mRestForced         = 20;
        mStats.mEatDesired         = 50;
        mStats.mEatForced          = 80;
        mStats.mStressRecoveryRate = 1;
        mStats.mEatRate            = 10;
        mStats.mAttackSpeed        = 1;
    }
コード例 #4
0
    public CUnitRules()
    {
        mTiers = new List <CTierInfo>();
        CJSONParser tiers      = new CJSONParser();
        CJSONValue  tiersArray = tiers.Parse(CGame.DataDirectory + "rules.txt");

        if (tiersArray == null)
        {
            Debug.LogError("Can't load rules");
            return;
        }

        for (int i = 0; i < tiersArray.GetCount(); ++i)
        {
            CJSONValue t = tiersArray[i];

            CTierInfo tier = new CTierInfo();
            tier.mTitle     = t.GetString("title", "unknown");
            tier.mTierIndex = i;
            tier.mMaxLevel  = t.GetInt("max_level");
            tier.mSalary.Set(t["salary"]);
            tier.mIntelligence.Set(t["intelligence"]);
            tier.mMaxStamina.Set(t["max_stamina"]);
            tier.mMaxSpeed.Set(t["max_speed"]);
            tier.mHungerRate.Set(t["hunger_rate"]);
            tier.mMaxHunger.Set(t["max_hunger"]);
            tier.mPaperCapacity.Set(t["paper_capacity"]);
            tier.mAttackDamage.Set(t["attack_damage"]);
            tier.mDefense.Set(t["defense"]);
            tier.mIdleTime.Set(t["idle_time"]);
            tier.mWorkStaminaRate.Set(t["work_stamina_rate"]);
            tier.mRequiredXP.Set(t["required_xp"]);
            tier.mPromotionDemand.Set(t["promotion_demand"]);
            mTiers.Add(tier);
        }
    }