Ejemplo n.º 1
0
        //private int mStackCount;

        public Buff(string id, NebulaObject inOwner, BonusType inBuffType,
                    float inInterval          = -1.0f, float inValue = 1.0f,
                    Func <bool> inCustomCheck = null, int inSourceSkillId = -1,
                    bool requireSkill         = true)
        {
            this.id       = id;
            buffType      = inBuffType;
            value         = inValue;
            interval      = inInterval;
            customCheck   = inCustomCheck;
            mTimer        = inInterval;
            owner         = inOwner;
            sourceSkillId = inSourceSkillId;

            //set valid at moment creation
            valid = true;
            // mStackCount = 1;
            m_RequireSkill = requireSkill;

            //if buff act indefinetly and object and skill not setted this error, impossible make check validity
            //indefinte buffs act only on self
            if (requireSkill)
            {
                if (interval <= 0)
                {
                    if (owner == null || (sourceSkillId == -1))
                    {
                        valid = false;
                        throw new Exception("For unlimited buffs must be setted owner and source skill");
                    }
                }

                if (!(sourceSkillId == -1) && owner != null)
                {
                    cachedSkills = owner.GetComponent <PlayerSkills>();
                    if (cachedSkills == null)
                    {
                        //throw new Exception("Owner of buff must have component PlayerSKills");
                        valid = false;
                        s_Log.ErrorFormat("owner os this buff mus have component PlayerSkills: {0}", owner.ObjectString());
                    }
                }
            }
        }