Ejemplo 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);
        }
Ejemplo n.º 2
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);
        }
Ejemplo n.º 3
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;
        }