Esempio n. 1
0
        public static bool IsCondition(AICondition condition, Prop prop, Power p = null)
        {
            bool      isTrue = true;
            Character ch     = prop as Character;

            switch (condition.type)
            {
            case AIConditionType.Held: isTrue = ch == null || ch.isHeld(); break;

            case AIConditionType.Rooted: isTrue = ch == null || ch.isRooted(); break;

            case AIConditionType.Health: isTrue = prop.GetHealthPct() < condition.threshold; break;

            case AIConditionType.Energy: isTrue = ch == null || ch.GetEnergyPct() < condition.threshold; break;

            case AIConditionType.Random: isTrue = Random.Range(0, 100) < condition.threshold; break;

            case AIConditionType.Shielded: isTrue = p && prop.stats[RPGSettings.GetResistanceStat(p.type)].currentValue > condition.threshold; break;

            case AIConditionType.Boosted: isTrue = p && ch && ch.stats[RPGSettings.GetDamageStat(p.type)].currentValue > condition.threshold; break;

            case AIConditionType.Status: isTrue = prop.GetStacks(condition.status) > 0; break;
            }
            if (condition.reverse)
            {
                isTrue = !isTrue;
            }
            return(isTrue);
        }
Esempio n. 2
0
            public string GetDescription(RPGSettings.DamageType damageType)
            {
                string desc = (modifier > 0 ? "+" : "") + modifier + (RPGSettings.IsMez(stat) ? " " : "% to ");

                if (stat <= RPGSettings.StatName.Def)
                {
                    desc += damageType.ToString() + " ";
                }
                desc += stat.ToString();
                return(desc);
            }
Esempio n. 3
0
 public override void Apply(Prop ch, Character caster = null)
 {
     ch.stats[RPGSettings.GetResistanceStat(RPGSettings.DamageType.Crushing)].addModifier(crushingRes);
     ch.stats[RPGSettings.GetResistanceStat(RPGSettings.DamageType.Piercing)].addModifier(piercingRes);
     ch.stats[RPGSettings.GetResistanceStat(RPGSettings.DamageType.Toxic)].addModifier(toxicRes);
     ch.stats[RPGSettings.GetResistanceStat(RPGSettings.DamageType.Fire)].addModifier(fireRes);
     ch.stats[RPGSettings.GetResistanceStat(RPGSettings.DamageType.Cold)].addModifier(coldRes);
     ch.stats[RPGSettings.GetResistanceStat(RPGSettings.DamageType.Energy)].addModifier(energyRes);
     ch.stats[RPGSettings.GetResistanceStat(RPGSettings.DamageType.Electric)].addModifier(electricRes);
     ch.stats[RPGSettings.GetResistanceStat(RPGSettings.DamageType.Psionic)].addModifier(psionicRes);
     ch.stats[RPGSettings.GetResistanceStat(RPGSettings.DamageType.Magic)].addModifier(magicRes);
     ch.stats[RPGSettings.GetResistanceStat(RPGSettings.DamageType.Negative)].addModifier(negativeRes);
 }
Esempio n. 4
0
        public override void OnInspectorGUI()
        {
            RPGSettings targetSettings = (RPGSettings)target;

            // Show default inspector property editor
            DrawDefaultInspector();

            EditorGUILayout.LabelField("Standard Colours", EditorStyles.boldLabel);
            for (int i = 0; i < (int)RPGSettings.ColorCode.Custom; i++)
            {
                RPGSettings.ColorCode code = (RPGSettings.ColorCode)i;
                targetSettings.colors[i] = EditorGUILayout.ColorField(code.ToString(), targetSettings.colors[i], new GUILayoutOption[0]);
            }
        }
Esempio n. 5
0
 public override bool IsCurrentlyActive(Prop p)
 {
     foreach (Modifier mod in modifiers)
     {
         if (RPGSettings.IsMez(mod.stat))
         {
             if (p.stats.ContainsKey(mod.stat.ToString()))
             {
                 float val = p.stats[mod.stat.ToString()].getCurrentValue();
                 //Debug.Log("ActiveCheck: " + mod.stat.ToString() + " = " + val);
                 if (val <= 0)
                 {
                     return(false);
                 }
             }
         }
     }
     return(true);
 }
Esempio n. 6
0
        public virtual void ApplyDamage(float damage, RPGSettings.DamageType dt)
        {
            if (dead)
            {
                return;
            }

            // apply damage resistance
            if (dt != RPGSettings.DamageType.Healing)
            {
                damage *= GetFactor(-stats[RPGSettings.GetResistanceStat(dt)].currentValue);
            }
            health -= damage;
            if (health <= 0)
            {
                // die!
                if (explosion)
                {
                    explosion.Explode(GetBodyPart(Character.BodyPart.Chest), null);
                }

                dead = true;

                RPGSettings.instance.RemoveCharacter(this);
                foreach (Character ch in Power.getAll())
                {
                    if (ch.target == this)
                    {
                        ch.target = null;
                    }
                }

                OnDeath();
            }

            int dmg = (int)Mathf.Abs(damage);

            NumberFloat(dmg.ToString(), damage > 0 ? Color.red : Color.green);

            // TODO if we don't have a HUD yet, add a healthbar to props?
            RPGSettings.instance.SetupCharacter(this);
        }
Esempio n. 7
0
        protected void InitProp()
        {
            statusDirty = true;

            for (int i = 0; i < RPGSettings.BasicDamageTypesCount; i++)
            {
                stats[RPGSettings.GetResistanceStat((RPGSettings.DamageType)(1 << i))] = new Stat();
                stats[RPGSettings.GetDefenceStat((RPGSettings.DamageType)(1 << i))]    = new Stat();
            }

            stats[RPGSettings.StatName.Health.ToString()] = new Stat(maxHealth, false);
            healthStat = stats[RPGSettings.StatName.Health.ToString()];

            ThirdPersonCharacter tpc = GetComponent <ThirdPersonCharacter>();

            if (tpc)
            {
                tpc.onGrounded.AddListener(EndKnockback);
            }
        }
Esempio n. 8
0
        // apply this power to a particular target
        // charge varies from 0 to 1
        public bool Apply(Prop target, float charge, Character caster, bool doStatus = true)
        {
            // calculate chance to hit
            if (targetType == TargetType.Enemies)
            {
                float casterAcc   = caster == null ? 0 : caster.stats[RPGSettings.StatName.Accuracy.ToString()].currentValue;
                float chanceToHit = RPGSettings.instance.baseAccuracy * accuracy + casterAcc - target.stats[RPGSettings.GetDefenceStat(type)].currentValue;
                if (Random.Range(0, 100) > chanceToHit)
                {
                    target.NumberFloat("MISS!", Color.white);
                    return(false);
                }
            }

            Character ch = target as Character;

            if (ch && sounds)
            {
                sounds.PlayHit(ch.audioSource);
            }

            // how does the damage get factored in?
            float damage;

            switch (mode)
            {
            case Mode.Charge:
                damage = minDamage + charge * (maxDamage - minDamage);
                break;

            case Mode.Maintain:
                damage = minDamage + (1 - charge) * (maxDamage - minDamage);
                break;

            default:
                damage = Random.Range(minDamage, maxDamage);
                break;
            }
            if (caster)
            {
                damage *= caster.GetFactor(RPGSettings.GetDamageStat(type));
            }

            if (damage != 0)
            {
                target.ApplyDamage(damage, type);
            }
            if (doStatus)
            {
                foreach (Status s in effects)
                {
                    target.ApplyStatus(s, GetDuration(caster), caster, this);
                }
                foreach (Status s in selfEffects)
                {
                    caster.ApplyStatus(s, GetSelfDuration(caster), caster, this);
                }

                // add to a global list of DoT's if not a character?
                if (target as Character == null)
                {
                    if (!Prop.activeProps.Contains(target.gameObject))
                    {
                        Prop.activeProps.Add(target.gameObject);
                    }
                }
            }

            // particles on target
            if (targetFX)
            {
                targetFX.Begin(target.GetBodyPart(targetBodyPart), tint);
            }

            // hit responses on the target
            foreach (HitResponse hr in target.hitResponses)
            {
                if (Random.Range(0, 100) < hr.percentage && (hr.damageType & type) != 0)
                {
                    hr.OnHit(target, damage);
                }
            }

            return(true);
        }
Esempio n. 9
0
 // Use this for initialization
 void Awake()
 {
     instance = this;
 }
Esempio n. 10
0
        // Use this for initialization
        void Start()
        {
            animator    = GetComponent <Animator>();
            brain       = GetComponent <AIBrain>();
            audioSource = GetComponent <AudioSource>();
            if (audioSource == null)
            {
                audioSource = gameObject.AddComponent <AudioSource>();
            }
            InitProp();

            fadeTime = 10.0f;

            for (int i = 0; i < RPGSettings.BasicDamageTypesCount; i++)
            {
                stats[RPGSettings.GetDamageStat((RPGSettings.DamageType)(1 << i))] = new Stat();
            }
            // healing damage boost does make sense
            stats[RPGSettings.GetDamageStat(RPGSettings.DamageType.Healing)] = new Stat();

            // special starting values and non-buffs go here
            stats[RPGSettings.StatName.Energy.ToString()] = new Stat(maxEnergy, false);
            stats[RPGSettings.StatName.Charge.ToString()] = new Stat(0, false);

            // all others are normal buffable stats
            RPGSettings.StatName numStats = (RPGSettings.StatName)System.Enum.GetNames(typeof(RPGSettings.StatName)).Length;
            for (RPGSettings.StatName i = RPGSettings.StatName.EnergyRegen; i <= numStats; i++)
            {
                if (!stats.ContainsKey(i.ToString()))
                {
                    stats[i.ToString()] = new Stat();
                }
            }

            energyStat = stats[RPGSettings.StatName.Energy.ToString()];

            RPGSettings.instance.SetupCharacter(this);

            tpc = GetComponent <ThirdPersonCharacter>();
            if (tpc)
            {
                baseJumpPower = tpc.m_JumpPower;
            }

            Transform beamChild = transform.Find("Beam");

            if (beamChild == null)
            {
                GameObject go = ObjectFactory.GetObject(RPGSettings.instance.beam);
                beamChild               = go.transform;
                beamChild.parent        = transform;
                beamChild.localPosition = Vector3.zero;
            }
            if (beamChild)
            {
                beam = beamChild.GetComponent <BeamRenderer>();
            }

            ApplyPassives();

            //create a tragetting reticle and disable it
            reticle = ObjectFactory.GetObject(RPGSettings.instance.reticle);
            reticle.transform.parent        = transform;
            reticle.transform.localPosition = Vector3.zero;
            reticle.name = "reticle";
            reticle.SetActive(false);

            bodyParts[BodyPart.Root]         = transform;
            bodyParts[BodyPart.Head]         = head;
            bodyParts[BodyPart.Chest]        = chest;
            bodyParts[BodyPart.LeftHand]     = leftHand;
            bodyParts[BodyPart.RightHand]    = rightHand;
            bodyParts[BodyPart.LeftFoot]     = leftFoot;
            bodyParts[BodyPart.RightFoot]    = rightFoot;
            bodyParts[BodyPart.LeftForeArm]  = leftForeArm;
            bodyParts[BodyPart.RightForeArm] = rightForeArm;
            bodyParts[BodyPart.LeftBicep]    = leftBicep;
            bodyParts[BodyPart.RightBicep]   = rightBicep;
            bodyParts[BodyPart.LeftThigh]    = leftThigh;
            bodyParts[BodyPart.LightThigh]   = rightThigh;
            bodyParts[BodyPart.LeftCalf]     = leftCalf;
            bodyParts[BodyPart.RightCalf]    = rightCalf;
            bodyParts[BodyPart.Waist]        = waist;
            bodyParts[BodyPart.Weapon1]      = weapon1;
            bodyParts[BodyPart.Weapon2]      = weapon2;
        }