예제 #1
0
        public static int collidingWithNPC(character input, float dist)
        {
            int output = -1;
            //float output = 0;

            for (int i = 0; i != world.levels[world.i_currentLvl].char_living.Length; i++)
            {
                if (input.name != world.levels[world.i_currentLvl].char_living[i].name)
                {
                    if (Vector2.Distance(input.B_baseProps.v_position + input.B_baseProps.v_velocity,
                                        world.levels[world.i_currentLvl].char_living[i].B_baseProps.v_position + world.levels[world.i_currentLvl].char_living[i].B_baseProps.v_velocity) < dist)
                    {
                        //if (world.levels[world.i_currentLvl].char_living[i].brain.aip_current == input.brain.aip_current)
                        {
                            if (world.levels[world.i_currentLvl].char_living[i].brain.secondary_package_tag != "slowed")
                            {
                                output = i;
                            }
                        }
                    }
                }
            }

            return output;
        }
예제 #2
0
        public static character[] LoadCharacters(ContentManager content)
        {
            CharFunc.shadow = content.Load<Texture2D>("graphics/textures/characters/shadow");
            StreamReader sr;
            sr = new StreamReader(content.RootDirectory + "/world/characters/charList.txt");
            int i_numChar = Convert.ToInt32(sr.ReadLine());

            character[] char_out = new character[i_numChar];
            string name;

            for (int j = 0; j != i_numChar; j++)
            {
                name = sr.ReadLine();

                //for (int i = 0; i != i_numChar; i++)
                //{
                    char_out[j] = LoadCharacter(name,content);
                //}
            }

            return char_out;
        }
예제 #3
0
 private static character RemoveWeapon(character Char,string name)
 {
     int thisWeapon = itemFunc.findInventoryItem(name, Char);
     Char.Inventory.items = itemFunc.killItem_INVEN(Char.Inventory.items, thisWeapon);
     return Char;
 }
예제 #4
0
파일: types.cs 프로젝트: mrpossoms/AnimoNex
        public static character setTo(character c)
        {
            character ouput = new character();

            ouput.accuracy = c.accuracy;
            ouput.angle = c.angle;
            ouput.armor = c.armor;
            ouput.B_baseProps = c.B_baseProps;
            ouput.body = new block[0];
            ouput.body = new block[c.body.Length];
            for (int i = 0; i != c.body.Length; i++)
            {
                ouput.body[i] = c.body[i];
            }
            ouput.controlType = c.controlType;
            ouput.current_weap = c.current_weap;
            ouput.currentAnim = c.currentAnim;
            ouput.f_currentFrame = c.f_currentFrame;
            ouput.attrib = c.attrib;
            ouput.name = c.name;
            ouput.pointingRight = c.pointingRight;
            ouput.Primary_weap = c.Primary_weap;
            ouput.Secondary_weap = c.Secondary_weap;
            ouput.SideArm_weap = c.SideArm_weap;
            ouput.Type = c.Type;
            ouput.action = c.action;

            return ouput;
        }
예제 #5
0
 public static character packageAttackKill(character input)
 {
     input.action = "idle";
     input.angle = 0;
     input.brain.aip_current = aiPackage.idle;
     input.brain.current_package_tag = "";
     input.brain.secondary_package_tag = "";
     return input;
 }
예제 #6
0
 private static character packageTurnIntoZomb(character input)
 {
     if (input.attrib.hp_current <= 0)
     {
         if (input.brain.aip_current == aiPackage.turnIntoZomb)
         {
             if (timeWaited(input.brain, 750))
             {
                 input.brain.aip_current = aiPackage.none;
                 input.attrib.hp_max = 1000;
                 input.attrib.hp_current = 1000;
                 input = CharFunc.setAnimation(input, "zomb_idle");
                 input.action = "idle";
                 input.Type = CharType.zombie;
             }
         }
     }
     return input;
 }
예제 #7
0
 private static character packageKeepDistance(character input)
 {
     if (input.brain.aip_current == aiPackage.keepDistance)
     {
         if(timeWaited(input.brain,100))
         {
             input.brain.aip_current = aiPackage.none;
             input.brain.current_package_tag = "-1";
         }
         float angle = gfunc.PointAt(input.B_baseProps.v_position, world.levels[world.i_currentLvl].char_living[Convert.ToInt32(input.brain.current_package_tag)].B_baseProps.v_position);
         input.B_baseProps.v_velocity = gfunc.TranslateOnAng(4,angle + (float)Math.PI );
     }
     return input;
 }
예제 #8
0
        private static character packageFollow(character input)
        {
            if (input.brain.aip_current != aiPackage.follow)// || timeWaited(input.brain, (int)gfunc.RandomNumber(200, 500)))
            {
                input.brain.tick_last = Game1.time_ticks;
                for (int i = 0; i != world.levels[world.i_currentLvl].char_living.Length; i++)
                {
                    if (world.levels[world.i_currentLvl].char_living[i].Type == input.Type)
                    {
                        if (world.levels[world.i_currentLvl].char_living[i].attrib.kills > input.attrib.kills)
                        {
                            if (Vector2.Distance(world.levels[world.i_currentLvl].char_living[i].B_baseProps.v_position, input.B_baseProps.v_position)
                                <= input.brain.ais_senses.radius_sight)
                            {
                                    input.brain.current_package_tag = i.ToString();
                                    input.brain.aip_current = aiPackage.follow;

                            }
                        }
                    }
                }
            }
            else
            {
                    int tag = Convert.ToInt32(input.brain.current_package_tag);
                    if (tag > world.levels[world.i_currentLvl].char_living.Length && tag < world.levels[world.i_currentLvl].char_living.Length)
                    {
                        float distance = Vector2.Distance(input.B_baseProps.v_position, world.levels[world.i_currentLvl].char_living[tag].B_baseProps.v_position);

                        if (distance > 180)
                        {
                            float angle = gfunc.PointAt(input.B_baseProps.v_position, world.levels[world.i_currentLvl].char_living[tag].B_baseProps.v_position);
                            float velocity = distance * .03f;
                            input.B_baseProps.v_velocity += gfunc.TranslateOnAng(velocity, angle);
                        }
                        else
                        {
                            input.brain.current_package_tag = "";
                            input.brain.aip_current = aiPackage.idle;
                        }
                    }
                    else
                    {
                        input.brain.aip_current = aiPackage.idle;
                    }
            }
            return input;
        }
예제 #9
0
 public static int findCharacter(character c)
 {
     int o = -1;
     for (int i = 0; i != world.levels[world.i_currentLvl].char_living.Length; i++)
     {
         if (world.levels[world.i_currentLvl].char_living[i].attrib.hp_current > 0)
         {
             if (world.levels[world.i_currentLvl].char_living[i].name == c.name)
             {
                 o = i;
             }
         }
     }
     return o;
 }
예제 #10
0
 public static void drawItemName(SpriteBatch sb, character input)
 {
     int targTag = pickup_targetItem(input);
     if (targTag != -1)
     {
         string name = world.levels[world.i_currentLvl].items[targTag].name;
         sb.DrawString(UI.pump_font, name, world.levels[world.i_currentLvl].items[targTag].B_base.v_position - camera.v_pos - new Vector2(20,60), Color.Red);
     }
 }
예제 #11
0
        public static character draw(SpriteBatch sb, character Character, bool pointingRight)
        {
            character reordered = Character;

            if(!Character.reordered)
               reordered = ReorderSprites(Character);

            sb.Draw(shadow,
                (reordered.B_baseProps.v_position+ new Vector2(0,20) - camera.v_pos),
                null,
                Color.White,
                0,//+(float)Math.PI,
                new Vector2(shadow.Width,shadow.Height)/2,//new Vector2(reordered.body[i].texture[DmgLvl].Width,reordered.body[i].texture[DmgLvl].Height) - reordered.body[i].pivot,
                camera.scale*2,
                SpriteEffects.FlipVertically,
                0);

                for (int i = 0; i != reordered.body.Length; i++)
                {
                    Color blockCol = Color.White;
                    switch (Character.Type)
                    {
                        case CharType.survivor:
                            blockCol = Color.GhostWhite;
                            if (Character.controlType == ControlType.player_current)
                                blockCol = Color.White;
                            break;
                        case CharType.zombie:
                            blockCol = Color.Gray;
                            break;

                    }

                    if (!pointingRight)
                    {

                        int DmgLvl = reordered.body[i].damageLevel;
                        Vector2 tempPivot = reordered.body[i].pivot;
                        Vector2 tempPos = reordered.body[i].position;
                        tempPivot.X = reordered.body[i].texture[DmgLvl].Width- tempPivot.X;
                        tempPos.X = -tempPos.X;

                        if (reordered.body[i].name == "HAND_L" && reordered.current_weap.bolt_back != null)
                        {
                            Character.current_weap.angle = weapFunc.drawWeapon(sb, reordered, i, false);
                        }
                        if(Character.special_tag!=-1)
                        DrawItemInHand(sb, ref Character, ref reordered, i, ref blockCol);

                        sb.Draw(reordered.body[i].texture[DmgLvl],
                                            (reordered.B_baseProps.v_position - new Vector2(0, Character.B_baseProps.f_Position_Z) - camera.v_pos) + tempPos,
                                            null,
                                            blockCol,
                                            -reordered.body[i].angle,//+(float)Math.PI,
                                            tempPivot,//new Vector2(reordered.body[i].texture[DmgLvl].Width,reordered.body[i].texture[DmgLvl].Height) - reordered.body[i].pivot,
                                            camera.scale,
                                            SpriteEffects.FlipHorizontally,
                                            0);
                    }
                    else
                    {
                        int DmgLvl = reordered.body[i].damageLevel;

                        if (reordered.body[i].name == "HAND_L" && reordered.current_weap.bolt_back!=null)
                        {
                            Character.current_weap.angle = weapFunc.drawWeapon(sb, reordered, i, true);
                        }

                        if (Character.special_tag != -1)
                        DrawItemInHand(sb, ref Character, ref reordered, i, ref blockCol);

                        sb.Draw(reordered.body[i].texture[DmgLvl],
                                            (reordered.B_baseProps.v_position - new Vector2(0, Character.B_baseProps.f_Position_Z) - camera.v_pos) + reordered.body[i].position,
                                            null,
                                            blockCol,
                                            reordered.body[i].angle,
                                            reordered.body[i].pivot,
                                            camera.scale,
                                            SpriteEffects.None,
                                            0);
                       // Vector2 v_temp = (reordered.B_baseProps.v_position - new Vector2(0, Character.B_baseProps.f_Position_Z) - camera.v_pos) + reordered.body[i].position-(reordered.body[i].pivot);
                       // for (int j = 0; j != reordered.body[i].v_collison_map.Length; j++)
                       // {
                       //     sb.Draw(Tex_null, v_temp+reordered.body[i].v_collison_map[j], Color.Red);
                       // }
                    }

                }

                return Character;
        }
예제 #12
0
        public static character CreateActor(Vector2 pos, float Z, CharType type, ControlType ctype, string name)
        {
            character output = new character();
            int tag = 0;
            if (name == "")
            {
                int CharID =6;
                while(world.characters[CharID].name == "SPECOPS")
                {
                    CharID = (int)gfunc.roundUp(gfunc.RandomNumber(0, world.characters.Length - 1));
                }
                //output = world.characters[CharID];
                output = character.setTo(world.characters[CharID]);

            }
            else
            {
                for (int i = 0; i != world.characters.Length; i++)
                {
                    if (world.characters[i].name == name)
                    {
                        tag = i;
                    }
                }
                //output = world.characters[tag];
                output = character.setTo(world.characters[tag]);
            }

            for (int i = 0; i != output.body.Length; i++)
            {
                if (output.body[i].name == "HEAD")
                {
                    output.body[i].maxHP = output.body[i].currentHP = 250;
                }
                output.body[i].maxHP = output.body[i].currentHP = 250;
            }
            output.attrib.hp_current = output.attrib.hp_max = 1000;

            output = setAnimation(output, "human_idle_stand");
            output.B_baseProps.v_position = pos;
            output.B_baseProps.f_Position_Z = Z;
            output.Type = type;
            output.controlType = ctype;
            if (ctype == ControlType.player_current)
            {
                output.name = Gamer.SignedInGamers[0].Gamertag;
            }
            else
            {
                output.name = gfunc.RandomName(true);
            }
            output.special_tag = -1;
            output.Inventory.maxWeight = 20;

            if (output.controlType == ControlType.NPC)
            {
                output.brain.active = true;
                output.brain.ais_senses = new aiSenses(500, 700, 40, 0, 0, 0);
            }

            return output;
        }
예제 #13
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;
        }
예제 #14
0
        public static character characterFireWeapon(character  c)
        {
            if (c.current_weap.timeWaited >= c.current_weap.ROFdelay &&
                c.currentAnim.name != "human_sprint_twohanded_armed" && !c.B_baseProps.airBorn)
            {
                if (c.current_weap.clipCurrent > 0)
                {
                    skill attrib = c.attrib;
                    float inaccuracy = (c.current_weap.inaccuracy / attrib.str_current);
                    c.current_weap.shooting = true;
                    Vector2 muzzPos = weapFunc.findMuzzlePos(c.B_baseProps.v_position,
                                                             c.B_baseProps.v_position + c.body[7].position,
                                                             c.current_weap.muzzPos,
                                                             c.angle,
                                                             c.pointingRight);
                    Vector2 actPos = weapFunc.findMuzzlePos(c.B_baseProps.v_position,
                                                             c.B_baseProps.v_position + c.body[7].position,
                                                             c.current_weap.actionPos,
                                                             c.angle,
                                                             c.pointingRight);
                    int i = findCharacter(c);

                    PlayGunSounds(i);

                    if (world.levels[world.i_currentLvl].char_living[i].current_weap.Pt == ProjectileType.SG_pellet)
                    {
                        for (int r = 0; r != 3; r++)
                        {
                            float angle = gfunc.RandomNumber(-inaccuracy, inaccuracy);
                            c = weapFunc.FireShot(c, muzzPos,
                            world.levels[world.i_currentLvl].char_living[i].current_weap.angle + angle,
                            world.levels[world.i_currentLvl].char_living[i].current_weap.Pt, i);
                        }
                    }
                    else
                    {
                        c = weapFunc.FireShot(c, muzzPos,
                                          world.levels[world.i_currentLvl].char_living[i].current_weap.angle + gfunc.RandomNumber(-inaccuracy, inaccuracy),
                                          world.levels[world.i_currentLvl].char_living[i].current_weap.Pt, i);
                    }

                    c.current_weap.clipCurrent--;
                    c.current_weap.timeWaited = 0;

                    int force = 5;

                    if (world.levels[world.i_currentLvl].char_living[i].current_weap.Pt != ProjectileType.P357 &&
                    world.levels[world.i_currentLvl].char_living[i].current_weap.Pt != ProjectileType.P38)
                    {
                        #region CreateShell

                        effects.particle p_temp = effects.particles.shell_ar[0];

                        switch (c.current_weap.Pt)
                        {
                            case ProjectileType.AR223:
                            case ProjectileType.AR762:
                            case ProjectileType.SR308:
                            case ProjectileType.SR50:
                                p_temp = effects.particles.shell_ar[0];
                                break;
                            case ProjectileType.CAR22:
                            case ProjectileType.SMG45:
                            case ProjectileType.SMG9:
                                p_temp = effects.particles.shell_pistol[0];
                                break;
                            case ProjectileType.SG_pellet:
                                p_temp = effects.particles.shell_shotgun[0];
                                break;
                        }

                        p_temp.Velocity = new Vector3(gfunc.randomPos(-new Vector2(1, 0) * force, new Vector2(1, 0) * force),
                                                      gfunc.RandomNumber(-force, 1));
                        p_temp.friction = .95f;

                        p_temp.position = new Vector3(actPos.X,
                                                      c.B_baseProps.v_position.Y,
                                                      actPos.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);
                        #endregion
                    }
                    #region CreateSmoke
                    effects.particle p_temp1 = effects.particles.smoke_local[gfunc.roundUp(gfunc.RandomNumber(0, 1))];
                    p_temp1.position = new Vector3(actPos.X,
                                                  c.B_baseProps.v_position.Y,
                                                  actPos.Y - c.B_baseProps.v_position.Y);
                    force = 5;
                    p_temp1.Velocity = new Vector3(gfunc.randomPos(-new Vector2(.25f, .25f) * force, new Vector2(.25f, -.75f) * force), 0);
                    p_temp1.angular_velo = gfunc.RandomNumber(-.1, .1);
                    effects.PEngine.particle_create(p_temp1);

                    force = 3;
                    p_temp1.Velocity = new Vector3(gfunc.randomPos(-new Vector2(.25f, .25f) * force, new Vector2(.25f, -.75f) * force), 0);
                    p_temp1.angular_velo = gfunc.RandomNumber(-.1, .1);
                    p_temp1.position = new Vector3(muzzPos, 0);
                    effects.PEngine.particle_create(p_temp1);
                    #endregion
                    if (c.controlType == ControlType.player_current)
                        Controller.set_rumble(PlayerIndex.One, 0, c.current_weap.ROFdelay, 5); //shake the controller when firing
                }
                else
                {
                    if (c.current_weap.wear != -1)
                    {
                        c.current_weap.wear = -1;
                        weapFunc.PlayDryFire();
                    }
                }
            }
            else
            {
                c.current_weap.shooting = false;
                if (c.current_weap.auto)
                    c.current_weap.timeWaited++;
            }
            return c;
        }
예제 #15
0
        private static character updateAttributes(character input)
        {
            if (input.Type != CharType.zombie)
            {
                if (input.attrib.hp_current > 0)
                {
                    input.attrib.score++;
                    #region Hunger
                    if (input.attrib.hun_current < 1)
                    {
                        input.attrib.hun_current += 0.00001f; //hunger
                        input.attrib.hp_current -= (float)Math.Abs(input.attrib.hp_current - (input.attrib.hp_max / (input.attrib.hun_current + 1)));
                        if (input.controlType == ControlType.player_current)
                        {
                            if (input.attrib.hun_current > .9f && input.attrib.hun_current < .901f)
                                UI.addMessage("Hunger is at 90%");
                            if (input.attrib.hun_current > .5f && input.attrib.hun_current < .501f)
                                UI.addMessage("Hunger is at 50%");
                            if (input.attrib.hun_current > .75f && input.attrib.hun_current < .751f)
                                UI.addMessage("Hunger is at 75%");
                        }
                    }
                    else
                    {
                        input.attrib.hp_current -= 0.001f; //if hunger is max then kill player slowly
                    }
                    #endregion

                    #region Stamina
                    if (input.attrib.sta_current < input.attrib.sta_max)
                    {
                        input.attrib.sta_current += (1 / ((input.attrib.hun_current / 2) + 1)) / (250f);
                        input.attrib.sta_prog += 1f / 2500f;
                        if (input.attrib.sta_prog > input.attrib.sta_max)
                        {
                            input.attrib.sta_max++;
                            input.attrib.sta_prog = 0;
                            if (input.controlType == ControlType.player_current)
                                UI.addMessage("Stamina increased to level " + input.attrib.sta_max.ToString());
                        }
                    }
                    #endregion

                    #region StealthAndStrength
                    input.attrib.stl_current = (input.attrib.stl_max /
                ((gfunc.findVelocity(input.B_baseProps.v_velocity) + ((input.attrib.hun_current + 1) * (input.Inventory.CurWeight)) + 1))); //update stealth
                    input.attrib.str_current = input.attrib.str_max / (input.attrib.hun_current + 1);

                    if (gfunc.findVelocity(input.B_baseProps.v_velocity) > 0)
                    {
                        input.attrib.stl_prog += (1f / 2500f) * input.attrib.stl_current;
                        if (input.attrib.stl_prog > input.attrib.stl_max)
                        {
                            input.attrib.stl_max++;
                            input.attrib.stl_prog = 0;
                            if (input.controlType == ControlType.player_current)
                                UI.addMessage("Stealth increased to level " + input.attrib.stl_max.ToString());
                        }
                        input.attrib.str_prog += ((1f / 2500f) * ((input.Inventory.CurWeight)));
                        if (input.attrib.str_prog > input.attrib.str_max)
                        {
                            input.attrib.str_max++;
                            input.attrib.str_prog = 0;
                            if (input.controlType == ControlType.player_current)
                                UI.addMessage("Strength increased to level " + input.attrib.str_max.ToString());
                        }
                    }
                    #endregion

                    input.attrib.med_current = input.attrib.med_max / input.attrib.hun_current; //med update
                    input.attrib.mech_current = input.attrib.mech_max / input.attrib.hun_current; //med update
                }
            }
            return input;
        }
예제 #16
0
        private static character packageAttack(character input)
        {
            #region ZombieAttack
            if (input.Type == CharType.zombie)
            {
                if (input.brain.aip_current != aiPackage.attack)
                {
                    if (timeWaited(input.brain, 65))
                    {
                        input.brain.tick_last = Game1.time_ticks;
                        for (int i = 0; i != world.levels[world.i_currentLvl].char_living.Length; i++)
                        {
                            if (world.levels[world.i_currentLvl].char_living[i].Type != input.Type)
                            {
                                if (world.levels[world.i_currentLvl].char_living[i].attrib.hp_current > 0)
                                {
                                    if (Vector2.Distance(input.B_baseProps.v_position, world.levels[world.i_currentLvl].char_living[i].B_baseProps.v_position) <
                                       input.brain.ais_senses.radius_hearing)
                                    {
                                        if (world.levels[world.i_currentLvl].char_living[i].attrib.stl_current < gfunc.RandomNumber(.75, .90))
                                        {
                                            //if (collidingWithNPC(input,40) == -1)
                                            //{
                                            CharFunc.PlayZombMoan();
                                            input.brain.current_package_tag = world.levels[world.i_currentLvl].char_living[i].name;
                                            input.brain.aip_current = aiPackage.attack;
                                            //}
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
                else
                {
                    int tag = findNPC(input.brain.current_package_tag);  //tag is target
                    if (tag != -1)
                    {
                        float distance = Vector2.Distance(input.B_baseProps.v_position, world.levels[world.i_currentLvl].char_living[tag].B_baseProps.v_position);
                        if (distance > 100)
                        {
                            float angle = gfunc.PointAt(input.B_baseProps.v_position, world.levels[world.i_currentLvl].char_living[tag].B_baseProps.v_position);
                            float velocity = distance * .03f;
                            tag = collidingWithNPC(input, 40);
                            input.B_baseProps.v_velocity = gfunc.TranslateOnAng(velocity, angle);
                            if (tag == -1)
                            {
                                input.brain.secondary_package_tag = "none";
                            }
                            else
                            {
                                //input.B_baseProps.v_velocity=Vector2.Zero;
                                //input.B_baseProps.v_velocity.Y *= -3;
                                input.B_baseProps.v_velocity /= 3;

                                //input.B_baseProps.v_velocity += gfunc.randomPos(input.B_baseProps.v_velocity, input.B_baseProps.v_velocity * 2);
                                input.brain.secondary_package_tag = "slowed";
                            }
                        }
                        else
                        {
                            input.action = "attack";
                        }
                    }
                    else
                    {
                        input = packageAttackKill(input);
                    }
                }
            }
            #endregion
            if (input.Type != CharType.zombie)
            {
                if (input.brain.aip_current != aiPackage.attack)
                {
                    if (findWeapon(input) != -1)
                    {
                        for (int i = 0; i != world.levels[world.i_currentLvl].char_living.Length; i++)
                        {
                            CharType target = findLargestThreat(input);
                            int tag = findClosestNPC(input, target);
                            if (tag != -1)
                            {
                                input.brain.aip_current = aiPackage.attack;
                                input.brain.current_package_tag = tag.ToString();
                            }
                        }
                    }
                }
                else
                {
                    input.current_weap.shooting = false;
                    if (input.action != "reload")
                    {
                            int tag = Convert.ToInt32(input.brain.current_package_tag);
                            if (tag < world.levels[world.i_currentLvl].char_living.Length)
                            {
                                float targetDist = Vector2.Distance(world.levels[world.i_currentLvl].char_living[tag].B_baseProps.v_position, input.B_baseProps.v_position);
                                if (targetDist < input.brain.ais_senses.radius_sight)
                                {
                                    if (world.levels[world.i_currentLvl].char_living[tag].attrib.hp_current > 0)
                                    {
                                        #region IfUnarmedEquipWeapon
                                        if (input.current_weap.name == "unarmed" || input.current_weap.name == null) //if no weapon is equiped
                                        {
                                            int weapTag = findWeapon(input); //find weapon that has ammo

                                            if (weapTag != -1)
                                            {
                                                input.current_weap = weapFunc.FindWeapon(input.Inventory.items[weapTag].gameTag);
                                                input.action = "reload";
                                            }
                                            else
                                            {
                                                input = packageAttackKill(input);
                                            }
                                        }
                                        #endregion
                                        if (input.current_weap.clipCurrent > 0) //if the clipisnt empty
                                        {

                                            #region Aim
                                            float desiredAngle = gfunc.PointAt(input.B_baseProps.v_position, world.levels[world.i_currentLvl].char_living[tag].B_baseProps.v_position);

                                            if (input.B_baseProps.v_position.X > world.levels[world.i_currentLvl].char_living[tag].B_baseProps.v_position.X)
                                            {
                                                input.pointingRight = false;
                                                input.B_baseProps.v_velocity += gfunc.TranslateOnAng(0.001f, desiredAngle);
                                            }
                                            else
                                            {
                                                input.pointingRight = true;
                                                input.B_baseProps.v_velocity += gfunc.TranslateOnAng(0.001f, desiredAngle);
                                            }

                                            if (!input.pointingRight)
                                            {
                                                desiredAngle = -desiredAngle + (float)Math.PI;
                                            }
                                            input.angle = desiredAngle;

                                            #endregion

                                            #region Shoot
                                            if (Math.Abs(input.angle - desiredAngle) < .25f)
                                            {
                                                input = CharFunc.characterFireWeapon(input);
                                            }
                                            #endregion

                                        }
                                        else
                                        {
                                            int weapTag = findWeaponAndAmmo(input);
                                            if (weapTag != -1)
                                            {
                                                input.current_weap = weapFunc.FindWeapon(input.Inventory.items[weapTag].name);
                                                input.action = "reload";
                                            }
                                        }
                                    }
                                    else
                                    {
                                        input = packageAttackKill(input);
                                    }
                                }
                                else
                                {
                                    float desiredAngle = gfunc.PointAt(input.B_baseProps.v_position, world.levels[world.i_currentLvl].char_living[tag].B_baseProps.v_position);
                                    float velocity = 5;
                                    input.B_baseProps.v_velocity += gfunc.TranslateOnAng(velocity, desiredAngle);

                                    if (!input.pointingRight)
                                    {
                                        desiredAngle = -desiredAngle + (float)Math.PI;
                                    }

                                    input.angle = desiredAngle;
                                }
                            }
                            else
                            {
                                input = packageAttackKill(input);
                            }
                    }

                }
            }
            return input;
        }
예제 #17
0
 private static character packageFlee(character input)
 {
     if (input.brain.aip_current != aiPackage.flee)
     {
         if (input.Type != CharType.zombie)
         {
             for (int i = 0; i != world.levels[world.i_currentLvl].char_living.Length; i++)
             {
                 if (input.Type != world.levels[world.i_currentLvl].char_living[i].Type && world.levels[world.i_currentLvl].char_living[i].attrib.hp_current >0)
                 {
                     if (world.levels[world.i_currentLvl].char_living[i].current_weap.name != "unarmed" &&
                         world.levels[world.i_currentLvl].char_living[i].current_weap.name != null ||
                         world.levels[world.i_currentLvl].char_living[i].Type == CharType.zombie)
                     {
                         if (Vector2.Distance(input.B_baseProps.v_position, world.levels[world.i_currentLvl].char_living[i].B_baseProps.v_position) < input.brain.ais_senses.radius_hearing)
                         {
                             input.brain.aip_current = aiPackage.flee;
                             CharFunc.PlayCharFlee();
                             float ang = gfunc.PointAt(input.B_baseProps.v_position, world.levels[world.i_currentLvl].char_living[i].B_baseProps.v_position);
                             float velocity = 10;
                             input.brain.destination = gfunc.TranslateOnAng(velocity, ang + (float)Math.PI);
                             input.brain.current_package_tag = i.ToString();
                             input.brain.tick_last = Game1.time_ticks;
                         }
                     }
                 }
             }
         }
     }
     else
     {
         //int tag = Convert.ToInt32(input.brain.current_package_tag);
         float dist = Vector2.Distance(input.B_baseProps.v_position, input.brain.destination);
         if (!timeWaited(input.brain, 50))
         {
             //float angle = gfunc.PointAt(input.B_baseProps.v_position, world.levels[world.i_currentLvl].char_living[tag].B_baseProps.v_position);
             input.B_baseProps.v_velocity += input.brain.destination;//gfunc.TranslateOnAng(velocity, angle + (float)Math.PI);
         }
         else
         {
             input.brain.aip_current = aiPackage.idle;
             input.brain.current_package_tag = "";
         }
     }
     return input;
 }
예제 #18
0
 public static int findHead(character c)
 {
     int output = -1;
     for (int i = 0; i != c.body.Length; i++)
     {
         if (c.body[i].name == "HEAD")
         {
             output = i;
         }
     }
     return output;
 }
예제 #19
0
        private static character packageIdle(character input)
        {
            if (input.brain.aip_current != aiPackage.idle || timeWaited(input.brain, (int)gfunc.RandomNumber(200, 500)))
            {
                input.brain.tick_last = Game1.time_ticks;

                input.B_baseProps.v_velocity.X = gfunc.RandomNumber(-0.1, 0.1);
            }
            return input;
        }
예제 #20
0
        public static character updateNode(character input)
        {
            if (input.brain.aip_current != aiPackage.turnIntoZomb)
            {
                //input = pakageIdle(input);
                if (input.brain.aip_current != aiPackage.attack &&
                   input.brain.aip_current != aiPackage.pickupItem &&
                    input.brain.aip_current != aiPackage.flee)
                {
                    if(input.brain.aip_current!=aiPackage.follow)
                    input = packageWander(input);
                }
                if (input.brain.aip_current != aiPackage.attack &&
                    input.brain.aip_current != aiPackage.flee &&
                    input.brain.aip_current != aiPackage.follow)
                {
                    input = packagePickUpItem(input);
                }
                if (input.brain.aip_current != aiPackage.pickupItem &&
                   input.brain.aip_current != aiPackage.attack &&
                    input.brain.aip_current != aiPackage.follow)
                {
                    input = packageFlee(input);
                }
                if (input.brain.aip_current != aiPackage.attack)
                {
                    //input = packageFollow(input);
                }

                //if ()
                {
                    input = packageAttack(input);
                }
            }
            else
            {
                input = packageTurnIntoZomb(input);
            }
            //input = packageKeepDistance(input);
            return input;
        }
예제 #21
0
        private static character packagePickUpItem(character input)
        {
            if (input.Type != CharType.zombie)
            {
                if (world.levels[world.i_currentLvl].items != null && world.levels[world.i_currentLvl].items.Length != 0)
                {
                    if (input.brain.aip_current != aiPackage.pickupItem)
                    {
                        //int tag = findClosestItem(input);

                        int tag = -1;
                        int tempammo = findClosestAmmo(input);
                        if (findWeapon(input) == -1)
                        {
                            tag = findClosestGun(input);
                        }
                        else if ((tempammo != -1))
                        {
                            tag = tempammo;
                        }
                        if (tag != -1)
                        {
                            tag = findClosestItem(input);
                        }

                        if (tag != -1 && world.levels[world.i_currentLvl].items.Length != 0 &&
                            world.levels[world.i_currentLvl].items[tag].weight < (input.Inventory.maxWeight - input.Inventory.CurWeight))
                        {
                            if (world.levels[world.i_currentLvl].items[tag].type != itemType.junk)
                            {
                                input.brain.aip_current = aiPackage.pickupItem;
                                input.brain.current_package_tag = tag.ToString();
                                input.brain.destination = world.levels[world.i_currentLvl].items[tag].B_base.v_position;
                            }
                        }

                    }
                    else
                    {
                        float distance = Vector2.Distance(input.B_baseProps.v_position, input.brain.destination);
                        if (distance > 5)
                        {
                            //int tag = Convert.ToInt32(input.brain.current_package_tag);
                            float angle = gfunc.PointAt(input.B_baseProps.v_position, input.brain.destination);
                            float velocity = 5f;
                            input.B_baseProps.v_velocity += gfunc.TranslateOnAng(velocity, angle);
                        }
                        else
                        {
                            input.action = "pickup";
                        }
                    }

                }
            }
            return input;
        }
예제 #22
0
 private static int findClosestItem(character input)
 {
     int tag = -1;
     float currentLowest = 9999f;
     for (int i = 0; i != world.levels[world.i_currentLvl].items.Length; i++)
     {
         float dist = Vector2.Distance(input.B_baseProps.v_position, world.levels[world.i_currentLvl].items[i].B_base.v_position);
         if (dist < input.brain.ais_senses.radius_sight)
         {
             if (dist < currentLowest)
             {
                 tag = i;
                 currentLowest = dist;
             }
         }
     }
     return tag;
 }
예제 #23
0
        private static character packageWander(character input)
        {
            if (input.brain.aip_current == aiPackage.idle || Vector2.Distance(input.B_baseProps.v_position, input.brain.destination) <= 10 ||
                timeWaited(input.brain,200))
            {
                input.brain.tick_last = Game1.time_ticks;
                input.brain.aip_current = aiPackage.wander;
                input.brain.destination = LvlFunc.randomPositon();//gfunc.randomPos(new Vector2(175, 400), new Vector2(1000, 750));
                input.current_weap = input.Primary_weap;
                input.f_currentFrame = 0;
                if (input.Type == CharType.zombie)
                    CharFunc.PlayZombMoan();
            }
            else
            {
                float angle = gfunc.PointAt(input.B_baseProps.v_position, input.brain.destination);

                    input.B_baseProps.v_velocity += gfunc.TranslateOnAng(5,angle);
            }
            return input;
        }
예제 #24
0
 private static int findClosestNPC(character input, CharType type)
 {
     int tag = -1;
     float currentLowest = 9999f;
     for (int i = 0; i != world.levels[world.i_currentLvl].char_living.Length; i++)
     {
         if (world.levels[world.i_currentLvl].char_living[i].Type == type && world.levels[world.i_currentLvl].char_living[i].attrib.hp_current > 0)
         {
             float dist = Vector2.Distance(input.B_baseProps.v_position, world.levels[world.i_currentLvl].char_living[i].B_baseProps.v_position);
             if (dist < input.brain.ais_senses.radius_sight)
             {
                 if (dist < currentLowest)
                 {
                     tag = i;
                     currentLowest = dist;
                 }
             }
         }
     }
     return tag;
 }
예제 #25
0
        public static character packagePickupKill(character input)
        {
            input.brain.destination = Vector2.Zero;
            input.brain.current_package_tag = "";
            input.brain.aip_current = aiPackage.idle;

            return input;
        }
예제 #26
0
        private static CharType findSmallestThreat(character input)
        {
            CharType output = CharType.zombie;
            int zombies = 0, bandits = 0, soldiers = 0, survivors = 0;

            for (int i = 0; i != world.levels[world.i_currentLvl].char_living.Length; i++)
            {
                if (world.levels[world.i_currentLvl].char_living[i].attrib.hp_current > 0)
                {
                    if (findWeaponAndAmmo(world.levels[world.i_currentLvl].char_living[i]) != -1 || world.levels[world.i_currentLvl].char_living[i].Type == CharType.zombie)
                        if (world.levels[world.i_currentLvl].char_living[i].Type != input.Type)
                        {
                            if (world.levels[world.i_currentLvl].char_living[i].Type == CharType.zombie)
                                zombies++;
                            if (world.levels[world.i_currentLvl].char_living[i].Type == CharType.survivor)
                                survivors++;
                            if (world.levels[world.i_currentLvl].char_living[i].Type == CharType.soldier)
                                soldiers++;
                            if (world.levels[world.i_currentLvl].char_living[i].Type == CharType.bandit)
                                bandits++;
                        }
                }
            }
            int smallest = 1000;

            #region FindMost
            if (zombies < smallest)
            {
                smallest = zombies;
                output = CharType.zombie;
            }
            if (bandits < smallest)
            {
                smallest = bandits;
                output = CharType.bandit;
            }
            if (soldiers < smallest)
            {
                smallest = soldiers;
                output = CharType.soldier;
            }
            if (survivors > smallest)
            {
                smallest = survivors;
                output = CharType.survivor;
            }
            #endregion

            return output;
        }
예제 #27
0
        private static character LoadCharacter(string name,ContentManager content)
        {
            character c_temp = new character(name,Vector2.Zero,ControlType.player_current,CharType.survivor);
            c_temp.B_baseProps.v_position = new Vector2(0, 0);
            StreamReader sr = new StreamReader(content.RootDirectory + "/world/characters/" + name + ".guy");
            //sr.ReadLine(); //attributes start;
            #region LoadAttributes
            c_temp.accuracy = Convert.ToSingle(sr.ReadLine());
            c_temp.angle = Convert.ToSingle(sr.ReadLine());
            c_temp.armor = Convert.ToInt32(sr.ReadLine());
            c_temp.attrib.hp_max = Convert.ToInt32(sr.ReadLine());
            c_temp.attrib.mech_max = Convert.ToInt32(sr.ReadLine());
            c_temp.attrib.med_max = Convert.ToInt32(sr.ReadLine());
            int fake = Convert.ToInt32(sr.ReadLine());
            c_temp.attrib.sta_max = Convert.ToInt32(sr.ReadLine());
            c_temp.attrib.stl_max = Convert.ToInt32(sr.ReadLine());
            c_temp.attrib.str_max = Convert.ToInt32(sr.ReadLine());
            #endregion
            //sr.ReadLine(); //blocks start
            c_temp.body = new block[Convert.ToInt32(sr.ReadLine())];
            for (int i = 0; i != c_temp.body.Length; i++)
            {
                //sr.ReadLine();//block starts
                #region getChildren
                c_temp.body[i].children = new int[Convert.ToInt32(sr.ReadLine())];
                for (int j = 0; j != c_temp.body[i].children.Length; j++)
                {
                    c_temp.body[i].children[j] = Convert.ToInt32(sr.ReadLine());
                }
                #endregion
                #region getParents
                string temp = sr.ReadLine();

                c_temp.body[i].parents = new int[Convert.ToInt32(temp)];
                for (int j = 0; j != c_temp.body[i].parents.Length; j++)
                {
                    c_temp.body[i].parents[j] = Convert.ToInt32(sr.ReadLine());
                }

                #endregion
                int numTex = Convert.ToInt32(sr.ReadLine());
                c_temp.body[i].texture = new Texture2D[6];
                c_temp.body[i].TexturePath = new string[6];
                c_temp.body[i].TexturePath[0] = sr.ReadLine();
                for (int j = 0; j != 6; j++)
                {
                    c_temp.body[i].texture[j] = content.Load<Texture2D>(("graphics/textures/characters/" + c_temp.body[i].TexturePath[0] + j.ToString()));
                }
                c_temp.body[i].v_collison_map = gfunc.collision.MakeCollisionMap(Vector2.Zero, c_temp.body[i].texture[0], gfunc.i_collision_accuracy);

                c_temp.body[i].angle = Convert.ToSingle(sr.ReadLine());
                c_temp.body[i].height = Convert.ToInt32(sr.ReadLine());
                c_temp.body[i].width = Convert.ToInt32(sr.ReadLine());
                c_temp.body[i].name = sr.ReadLine();
                c_temp.body[i].zorder = Convert.ToInt32(sr.ReadLine());
                Vector2 pivot = Vector2.Zero, pos = Vector2.Zero;
                pivot.X = Convert.ToSingle(sr.ReadLine());
                pivot.Y = Convert.ToSingle(sr.ReadLine());
                c_temp.body[i].pivot = pivot;
                pos.X = Convert.ToSingle(sr.ReadLine());
                pos.Y = Convert.ToSingle(sr.ReadLine());
                c_temp.body[i].position = (pos + c_temp.B_baseProps.v_position);

                if (c_temp.body[i].v_collison_mapOR == null)
                {
                    c_temp.body[i].v_collison_mapOR = gfunc.collision.MakeCollisionMap(Vector2.Zero, c_temp.body[i].texture[0], gfunc.i_collision_accuracy);
                }
                else
                {
                    c_temp.body[i].v_collison_map = new Vector2[c_temp.body[i].v_collison_mapOR.Length];
                    for (int j = 0; j != c_temp.body[i].v_collison_mapOR.Length; j++)
                    {
                        c_temp.body[i].v_collison_map[j] = c_temp.body[i].v_collison_mapOR[j];
                    }
                }

            }
            return c_temp;
        }
예제 #28
0
        private static int findWeaponAndAmmo(character input)
        {
            int output = -1;
            if (input.Inventory.items != null && input.Inventory.items.Length != 0)
            {
                int weap_tag = -1;
                float weap_quality = 0;
                #region FindWeaponWithAmmo
                for (int i = 0; i != input.Inventory.items.Length; i++)
                {
                    if (input.Inventory.items[i].type == itemType.weapon)
                    {
                        if (input.Inventory.items[i].quality > weap_quality)
                        {
                            weapon weap_possible = weapFunc.FindWeapon(input.Inventory.items[i].name);
                            int ammoTag = weapFunc.FindAmmoType(input, weap_possible);
                            if (ammoTag != -1)
                            {
                                weap_tag = i;
                                weap_quality = input.Inventory.items[i].quality;
                            }
                        }
                    }
                }
                #endregion

                output = weap_tag;
            }
            return output;
        }
예제 #29
0
 public static int findInventoryItem(string name, character c)
 {
     int output = -1;
     for (int i = 0; i != c.Inventory.items.Length; i++)
     {
         if (c.Inventory.items[i].name == name)
         {
             output = i;
         }
     }
     return output;
 }
예제 #30
0
        private static int pickup_targetItem(character c)
        {
            int tag = -1;
            if(world.levels[world.i_currentLvl].items != null)
            for (int j = 0; j != world.levels[world.i_currentLvl].items.Length; j++)
            {
                Vector2 offset = Vector2.Zero;

                if (c.pointingRight)
                {
                    offset = new Vector2(100, 0);
                }
                else
                {
                    offset = new Vector2(-100, 0);
                }

                if (Vector2.Distance(world.levels[world.i_currentLvl].items[j].B_base.v_position,
                                    c.B_baseProps.v_position + offset) < 40 && world.levels[world.i_currentLvl].items[j].usable)
                {
                    tag = j;

                    j = world.levels[world.i_currentLvl].items.Length - 1;
                }
            }
            return tag;
        }