예제 #1
0
 void DrawBeam(Character caster, Prop target)
 {
     if (beamSettings.beamMaterial || beamSettings.beamParticles)
     {
         caster.beam.Activate(caster.GetBodyPart(userBodyPart), target.GetBodyPart(targetBodyPart), beamSettings, tint.GetColor());
     }
 }
예제 #2
0
        public bool CanSee(Prop target)
        {
            Vector3 headPos = transform.position;

            headPos.y = chest.position.y;
            Vector3 targetHeadPos = target.transform.position;

            targetHeadPos.y = target.GetBodyPart(BodyPart.Chest).position.y;

            float dist = (targetHeadPos - headPos).magnitude;
            Ray   ray  = new Ray(headPos, (targetHeadPos - headPos) / dist);

            RaycastHit[] hits         = Physics.RaycastAll(ray, dist + 1.0f);
            GameObject   first        = null;
            float        bestDistance = dist + 2.0f;

            foreach (RaycastHit hit in hits)
            {
                if (hit.collider.gameObject != gameObject && hit.distance < bestDistance)
                {
                    bestDistance = hit.distance;
                    first        = hit.collider.gameObject;
                }
            }
            return(first == target.gameObject);
        }
예제 #3
0
        void UpdateParticles(Prop p, Status newStatus)
        {
            foreach (KeyValuePair <string, GameObject> pair in systems)
            {
                bool turnOff = (character.groupedEffects.ContainsKey(pair.Key) == false);
                if (!turnOff)
                {
                    turnOff = !character.groupedEffects[pair.Key].IsCurrentlyActive(character);
                }
                if (turnOff)
                {
                    // turn on the fader to deactivate it
                    LifeSpanFader fader = pair.Value.GetComponent <LifeSpanFader>();
                    if (!fader)
                    {
                        Debug.Log("Missing fader!");
                    }
                    if (fader && !fader.enabled)
                    {
                        fader.lifespan = 1;
                        fader.enabled  = true;
                    }
                }
            }

            foreach (KeyValuePair <string, Status> pair in character.groupedEffects)
            {
                if (pair.Value.fx && pair.Value.IsCurrentlyActive(character)) // only turn on if valid and we have na FX for it
                {
                    // if we dont have a particle system for this key yet, make one
                    if (systems.ContainsKey(pair.Key) == false)
                    {
                        Status s = pair.Value;
                        if (s.fx)
                        {
                            systems[pair.Key] = s.fx.Begin(character.GetBodyPart(s.bodyPart), s.tint, false, false);
                        }
                    }
                    else
                    {
                        LifeSpanFader fader = systems[pair.Key].GetComponent <LifeSpanFader>();
                        if (!fader)
                        {
                            Debug.Log("Missing fader!");
                        }
                        else
                        {
                            fader.Restart();
                        }
                    }
                }
            }
        }
예제 #4
0
 public override void Apply(Prop ch, Character caster = null)
 {
     if (!delays.ContainsKey(ch) || delays[ch] < Time.time)
     {
         if (!explosion)
         {
             Debug.Log("Explosion " + name + "has no PowerArea");
             return;
         }
         if (explosion.userFX)
         {
             GameObject go = explosion.userFX.Begin(ch.GetBodyPart(explosion.userBodyPart), explosion.tint);
             explosion.userFX.ScaleToRadius(go, explosion.GetRadius(caster));
         }
         explosion.Explode(ch.transform, caster);
         delays[ch] = Time.time + 0.4f;
     }
 }
예제 #5
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);
        }
예제 #6
0
 public void PlayEffect(Prop p)
 {
     responseFX.Begin(p.GetBodyPart(responseBodyPart), tint);
 }