예제 #1
0
        public static void CreateBullet(Projectile bullet)
        {
            if(projectiles != null && projectiles.Length >0)
            {
                Projectile[] old = projectiles;
                projectiles = new Projectile[old.Length+1];

                for (int i = 0; i != old.Length; i++)
                {
                    projectiles[i] = old[i];
                }

                projectiles[old.Length] = bullet;
            }
            else
            {
                projectiles = new Projectile[1];
                projectiles[0] = bullet;
            }
        }
예제 #2
0
        public static character collided_projectile(character c,int charTag,Projectile p)
        {
            //character output = c;
            if(Vector2.Distance(c.B_baseProps.v_position+new Vector2(0,-100),p.B_base.v_position)<190)
            if (c.attrib.hp_current > 0 || c.currentAnim.f_frame.Length/2 >c.f_currentFrame)
            {

                if(p.owner < world.levels[world.i_currentLvl].char_living.Length)
                if (p.owner != charTag && world.levels[world.i_currentLvl].char_living[p.owner].Type != c.Type)
                {
                    Vector2 pos = p.B_base.v_position;
                    Vector2 velocity = p.B_base.v_velocity;

                    for (int i = 0; i != c.body.Length; i++)
                    {
                        Vector2 v_temp = (c.B_baseProps.v_position - new Vector2(0, c.B_baseProps.f_Position_Z)) + c.body[i].position - (c.body[i].pivot);
                        Vector2 dims = new Vector2(c.body[i].texture[0].Width, c.body[i].texture[0].Height);
                        //float dist = (float)Math.Sqrt((dims.X * dims.X) + (dims.Y * dims.Y));
                        //if (Vector2.Distance(v_temp + c.body[i].position, pos) <= dist/8)
                        {
                            for (int j = 0; j != c.body[i].v_collison_map.Length; j++)
                            {
                                if (Vector2.Distance(v_temp + c.body[i].v_collison_map[j], pos) < gfunc.i_collision_accuracy*4)
                                {
                                    #region ManagesDamageLevels

                                    int damageMult = 1;
                                    if (c.body[i].name == "HEAD")
                                    {
                                        damageMult = 100;
                                        if (world.levels[world.i_currentLvl].char_living[p.owner].controlType == ControlType.player_current &&
                                            c.special_tag != 1337)
                                        {
                                            PlayHeadshot();
                                            c.special_tag = 1337;
                                        }

                                        {
                                            world.levels[world.i_currentLvl].char_living[p.owner].attrib.score += 2000;
                                        }

                                    }

                                    c.body[i].currentHP -= p.damage;
                                    if (c.attrib.hp_current > 0)
                                    {
                                        c.attrib.hp_current -= p.damage * damageMult;
                                    }

                                    if (c.body[i].currentHP < 0)
                                    {

                                        c.body[i].currentHP = 0;
                                        c.action = "dead";
                                        c = dropInventory(c);
                                        if (c.Type == CharType.zombie && c.action != "dead")
                                        {
                                            PlayZombDie();
                                        }
                                    }

                                    int NumDmgLvls = c.body[i].texture.Length;
                                    int oldDmgLvl = c.body[i].damageLevel;
                                    int DmgLvl = gfunc.roundUp((NumDmgLvls - 1) - ((c.body[i].currentHP + 1) / (c.body[i].maxHP / (NumDmgLvls - 1))));
                                    if (oldDmgLvl != DmgLvl)
                                    {
                                        if(gfunc.roundUp(gfunc.RandomNumber(0,4))==1)
                                        createGibs(ref c, ref p);
                                    }
                                    c.body[i].damageLevel = DmgLvl;
                                    #endregion

                                    particle temp;
                                    if (c.attrib.hp_current > 0 || world.levels[world.i_currentLvl].char_living.Length<5)
                                    {
                                        PlayFleshImpact();
                                        if (c.Type == CharType.zombie)
                                        {
                                            PlayZombHit();
                                        }
                                        #region CreateBloodSpray
                                        temp = particles.blood_spray[gfunc.roundUp(gfunc.RandomNumber(0, 4))];
                                        temp.Velocity = (new Vector3(velocity.X / 4, 0, velocity.Y / 4) + new Vector3(gfunc.randomPos(-Vector2.One * 10, Vector2.One * 10), 0)) / 2;
                                        temp.position = new Vector3(pos.X, c.B_baseProps.v_position.Y, pos.Y - c.B_baseProps.v_position.Y);
                                        temp.angular_velo = gfunc.RandomNumber(-.25f, .25f);
                                        PEngine.particle_create(temp);
                                        #endregion
                                        #region CreateBloodSpurt
                                    temp = particles.blood_spurt[gfunc.roundUp(gfunc.RandomNumber(0, 3))];
                                    temp.position = new Vector3(pos.X, c.B_baseProps.v_position.Y, pos.Y - c.B_baseProps.v_position.Y);
                                    PEngine.particle_create(temp);
                                    //temp.
                                    #endregion
                                    }
                                    if (c.attrib.hp_current < 0)
                                    {
                                        if (c.controlType == ControlType.player_current)
                                        { thisPlayerLiving = false; }
                                        world.levels[world.i_currentLvl].char_living[p.owner].attrib.kills++;
                                        //if (world.levels[world.i_currentLvl].char_living[p.owner].controlType == ControlType.player_current)
                                        {
                                            world.levels[world.i_currentLvl].char_living[p.owner].attrib.score += 1000;
                                        }
                                        c.attrib.hp_current = 0;
                                        c = dropInventory(c);
                                        if (c.body[findHead(c)].damageLevel < 4)
                                        {
                                            c = Zombify(c);
                                        }
                                        else
                                        {
                                            c.brain.active = false;
                                        }
                                    }
                                    //output = true;

                                }
                            }
                        }
                    }
                }
            }
            return c;
        }
예제 #3
0
        private static void createGibs(ref character c, ref Projectile p)
        {
            int gibTag = gfunc.roundUp(gfunc.RandomNumber(0, particles.gib.Length - 1));
            effects.particle p_temp = effects.particles.gib[gibTag];

            int force = 10;
            p_temp.Velocity = new Vector3(gfunc.randomPos(-new Vector2(1, 1) * force, new Vector2(1, 1) * force),
                                          gfunc.RandomNumber(-force, 1));
            p_temp.friction = .95f;
            p_temp.angular_velo = gfunc.RandomNumber(-.1, .1);
            p_temp.position = new Vector3(p.B_base.v_position.X,
                                          c.B_baseProps.v_position.Y,
                                          p.B_base.v_position.Y - (c.B_baseProps.v_position.Y + (float)gfunc.RandomNumber(-2, 2)));
            p_temp.angular_velo = gfunc.RandomNumber(-.5, .5);
            effects.PEngine.particle_create(p_temp);
        }
예제 #4
0
        public static void KillBullet(int b)
        {
            Projectile[] lower = new Projectile[b];
            Projectile[] upper = new Projectile[projectiles.Length - (b+1)];

            for (int i = 0; i != projectiles.Length; i++)
            {
                if (i < b)
                {
                    lower[i] = projectiles[i];
                }
                if (i > b)
                {
                    upper[i-lower.Length-1] = projectiles[i];
                }
            }
            projectiles = new Projectile[lower.Length + upper.Length];
            for (int i = 0; i != projectiles.Length; i++)
            {
                if (i < lower.Length)
                {
                    projectiles[i] = lower[i];
                }
                else
                {
                    projectiles[i] = upper[i-lower.Length];
                }

            }
        }
예제 #5
0
        public static character FireShot(character c, Vector2 Muzzle_pos, float ang, ProjectileType pt, int charTag)
        {
            Vector2 pos = Muzzle_pos;
            float Z = 10;   //change later
            float velocity = 0;
            int damage = 0;

            //add velocities for each type of ammunition
            SetBulletProperties(pt, ref velocity, ref damage);

            velocity /= 5;

            Vector2 V_velo = gfunc.TranslateOnAng(velocity, ang);

            Projectile bullet = new Projectile(tracer,
                                               new Base(pos, Z, ang, V_velo, 0, 0.01f),
                                               pt, 1000);
            bullet.damage = damage;
            if (c.angle > -.5f)
            {
                c.angle -= 0.002f * damage;//recoil
            }
            else
            {
                c.angle = -.49f;
            }
            bullet.owner = charTag;
            bullet.B_base.airBorn = true;
            CreateBullet(bullet);
            return c;
        }