Ejemplo n.º 1
0
        public override void fire(Agent p, PhysicsEngine ph)
        {
            base.fire(p, ph);

            if (curCooldown == cooldown)
            {
                Random  rand  = new Random();
                Vector3 dir   = Vector3.Normalize(p.getDirectionVector());
                Vector3 right = Vector3.Cross(dir, Vector3.Up);
                Vector3 up    = Vector3.Cross(dir, right);
                up                   *= inaccuracy;
                right                *= inaccuracy;
                dir                   = dir + (float)(rand.NextDouble() * 2 - 1) * up + (float)(rand.NextDouble() * 2 - 1) * right;
                inaccuracy            = Math.Min(maxInaccuracy, inaccruacyJump + inaccuracy);
                inaccuracyCurCooldown = 0;

                List <Agent> l = new List <Agent>();
                l.Add(p);
                PhysicsEngine.HitScan      hs  = ph.hitscan(p.getPosition() + new Vector3(0, 75, 0) + p.getDirectionVector() * 10, p.getDirectionVector(), null);
                PhysicsEngine.AgentHitScan ahs = ph.agentHitscan(p.getPosition() + new Vector3(0, 60, 0) + p.getDirectionVector() * 10, dir, l);
                if (hs != null && (ahs == null || hs.Distance() < ahs.Distance()))
                {
                    makeLaser(p, hs.ray, Vector3.Distance(hs.ray.Position, hs.collisionPoint), 5, 5, "Rifle");
                }
                else if (ahs != null)
                {
                    ahs.agent.dealDamage(damage, p);
                    makeLaser(p, ahs.ray, Vector3.Distance(ahs.ray.Position, ahs.collisionPoint), 5, 5, "Rifle");
                }
            }
        }
Ejemplo n.º 2
0
        public override void fire(Agent p, PhysicsEngine ph)
        {
            base.fire(p, ph);

            if (curCooldown == cooldown)
            {
                List <Agent> l = new List <Agent>();
                l.Add(p);
                PhysicsEngine.HitScan      hs  = ph.hitscan(p.getPosition() + new Vector3(0, 75, 0) + p.getDirectionVector() * 10, p.getDirectionVector(), null);
                PhysicsEngine.AgentHitScan ahs = ph.agentHitscan(p.getPosition() + new Vector3(0, 60, 0) + p.getDirectionVector() * 10, p.getDirectionVector(), l);
                if (hs != null && (ahs == null || hs.Distance() < ahs.Distance()))
                {
                    makeLaser(p, hs.ray, Vector3.Distance(hs.ray.Position, hs.collisionPoint), 5, 5, "Pistol");
                }
                else if (ahs != null)
                {
                    ahs.agent.dealDamage(damage, p);
                    makeLaser(p, ahs.ray, Vector3.Distance(ahs.ray.Position, ahs.collisionPoint), 5, 5, "Pistol");
                }
            }
        }
Ejemplo n.º 3
0
        public override void fire(Agent p, PhysicsEngine ph)
        {
            base.fire(p, ph);

            if (curCooldown == cooldown)
            {
                Random     rand = new Random();
                Vector3 [] dirs = new Vector3[5];
                dirs[0] = Vector3.Normalize(p.getDirectionVector());
                Vector3 right = Vector3.Cross(dirs[0], Vector3.Up);
                Vector3 up    = Vector3.Cross(dirs[0], right);
                up     *= 0.15f;
                right  *= 0.15f;
                dirs[1] = dirs[0] + (float)rand.NextDouble() * right + (float)rand.NextDouble() * up;
                dirs[2] = dirs[0] + (float)rand.NextDouble() * right - (float)rand.NextDouble() * up;
                dirs[3] = dirs[0] - (float)rand.NextDouble() * right - (float)rand.NextDouble() * up;
                dirs[4] = dirs[0] - (float)rand.NextDouble() * right + (float)rand.NextDouble() * up;

                foreach (Vector3 dir in dirs)
                {
                    List <Agent> l = new List <Agent>();
                    l.Add(p);
                    PhysicsEngine.HitScan      hs  = ph.hitscan(p.getPosition() + new Vector3(0, 75, 0) + p.getDirectionVector() * 10, dir, null);
                    PhysicsEngine.AgentHitScan ahs = ph.agentHitscan(p.getPosition() + new Vector3(0, 75, 0) + p.getDirectionVector() * 10, dir, l);
                    if (hs != null && (ahs == null || hs.Distance() < ahs.Distance()))
                    {
                        makeLaser(p, hs.ray, Vector3.Distance(hs.ray.Position, hs.collisionPoint), 5, 5, "Shotgun");
                    }
                    else if (ahs != null)
                    {
                        ahs.agent.dealDamage(damage, p);
                        makeLaser(p, ahs.ray, Vector3.Distance(ahs.ray.Position, ahs.collisionPoint), 5, 5, "Shotgun");
                    }
                }
            }
        }