Exemplo n.º 1
0
        // useable on a single target with no to-hit roll
        public override void OnActivate(Character caster, bool doStatus = true)
        {
            Prop target = GetTarget(caster);

            if (target)
            {
                float     charge  = caster.stats[RPGSettings.StatName.Charge.ToString()].currentValue * 0.01f;
                Character ctarget = target as Character;
                if (ctarget)
                {
                    ctarget.MakeAwareOf(caster);
                }

                // draw the beam to the target
                DrawBeam(caster, target);

                // check for deflection shields on the target
                HitResponse.ReflectionType deflect = target.GetReflection(type);
                if (deflect != HitResponse.ReflectionType.None)
                {
                    // get all targets except the primary one on the other team
                    List <Character> targets = new List <Character>();
                    Character[]      all     = PowerArea.getAll();
                    for (int i = 0; i < all.Length; i++)
                    {
                        // TODO - chaining ally powers
                        if (!all[i].dead && all[i].GetTeam() != ctarget.team)
                        {
                            targets.Add(all[i]);
                        }
                    }

                    Arc(ctarget, targets, charge);
                    return;
                }

                // no deflection, carry on...
                bool hit = Apply(target, charge, caster, doStatus);

                CheckChaining(ctarget, charge);
            }
        }
Exemplo n.º 2
0
        void OnTriggerEnter(Collider col)
        {
            HitResponse.ReflectionType deflect = HitResponse.ReflectionType.None;
            bool finished = true;

            Prop ch = col.gameObject.GetComponent <Prop>();

            if (ch != caster)
            {
                if (ch)
                {
                    // check to see if we deflect it first
                    deflect = ch.GetReflection(parentPower.type);

                    bool apply    = (deflect == HitResponse.ReflectionType.None);
                    bool bounce   = !apply;
                    bool chaining = false;

                    if (chains < (parentPower as PowerProjectile).maxChains)
                    {
                        chains++;
                        bounce   = true;
                        chaining = true;
                        deflect  = HitResponse.ReflectionType.Redirect;
                    }

                    if (apply)
                    {
                        // apply the power normally

                        // bullshit correction because the coordinates are coming out weird here
                        Vector3 pos = ch.transform.position;
                        pos.y = 0;
                        ch.transform.position = pos;

                        // if we miss (based on accuracy), set the flag here so we dont destroy the projectile
                        if (!parentPower.Apply(ch, charge, caster as Character, doStatus))
                        {
                            finished = false;
                        }
                    }

                    if (bounce)
                    {
                        finished = false;
                        // reverse direction for now
                        int       team = -1;
                        Character cha  = (chaining ? caster : ch) as Character;
                        if (cha)
                        {
                            team = cha.team;
                        }
                        float speed = velocity.magnitude;
                        velocity = speed * HitResponse.Reflect(ch, caster.transform.position, deflect, team);

                        startPos = transform.position;
                        if (!chaining)
                        {
                            caster = ch as Character;
                        }
                    }
                }
                if (finished)
                {
                    ObjectFactory.Recycle(gameObject);
                }
            }
        }