Ejemplo n.º 1
0
        // player wird angegriffen
        public bool fight_p2p(ref c_npc npc, ref c_LOV player)
        {
            int direction = 0;

                if (npc.Destbox.X < player.Destbox.X)
                {
                    direction = 8;
                }
                else
                {
                    direction = 9;
                }

                if (npc.canAttack)
                {
                    player.properties.livepoints -= npc.properties.staerke;
                    npc.canAttack = false;
                    AUDIO.play_sound(1);
                    if (player.properties.livepoints <= 0) // npc besiegt
                    {
                        player.Color = Color.Blue;

                        AUDIO.play_sound(3);
                    }
                    npc.attackcnt = 1;

                    return true;
                }
                else
                {
                    if(10 * npc.attackcnt <= npc.properties.attackSpeed)
                    {
                        npc.attackcnt++;
                    } else {
                        ac++;
                    }
                       if (ac >= 7)
                        ac = 0;
                    npc.setSprite(direction, ac);

                    npc.caminar = false;

                }

            return false;
        }
Ejemplo n.º 2
0
 public bool checkplayerColl(ref c_npc otherPlayer)
 {
     if (this.Destbox.IntersectsWith(otherPlayer.Destbox) == true)
     {
         otherPlayer.Color = Color.Red;
         if (this.Destbox.Y >= otherPlayer.Destbox.Y)
         {
             this.Zebene = 0.2f;
         }
         else
         {
             this.Zebene = 0.6f;
         }
         return true;
     }
     otherPlayer.Color = Color.White;
     return false;
 }
Ejemplo n.º 3
0
        private bool NPC_check(ref c_npc npc)
        {
            npc.caminar = true;

            if (ENGINE.MATHENGINE.punkt_rect_Collision(ref npc.Destbox, CURSOR.Destbox.Location) == true)
            {
                if (!npc.properties.evil)
                {
                    npc.Color = Color.Green;
                    npc.stop();
                    if (MDOWNR && GUI_TALK.visible == false)
                    {
                        npc.caminar = false;
                        npc.set_interval(false);
                        GUI_TALK.Text = npc.get_random_Message();

                        GUI_TALK.visible = true;
                    }
                    else
                    {
                        if (npc.get_interval() == false && GUI_TALK.visible == false)
                        {
                            npc.set_interval(true);
                        }
                    }
                    if (!npc.caminar)
                        npc.direction = -1;
                }
                else
                {///MÖGLICHER//GENGNER////////////////////////////
                    npc.Color = Color.Red;

                    /////////ANGRIFF///////////////
                    if (MDOWNR && GUI_TALK.visible == false)
                    {
                        ////////PLAYER GREIFT AN////////////////////
                        if (ENGINE.MATHENGINE.PointToPoint(CHARAKTER.Destbox.Location, npc.Destbox.Location) >= CHARAKTER.properties.attackRange)
                        {
                            CHARAKTER.caminar = true;

                            CHARAKTER.AIMF.X = (ENGINE.INPUT.X + (-PositionX));
                            CHARAKTER.AIMF.Y = (ENGINE.INPUT.Y + (-PositionY));

                            CHARAKTER.AIM.X = (int)(CHARAKTER.AIMF.X) / 128;
                            CHARAKTER.AIM.Y = (int)(CHARAKTER.AIMF.Y) / 97;
                        }
                        else
                        {
                            if (ENGINE.fight_p2p(ref npc, ref CHARAKTER, true))
                            {
                                EXPLOSIONS.Add(new c_explosion(ref ENGINE.DEVICE, ref RESOURCES.TEXTURE[1, 1], 500));
                                EXPLOSIONS[EXPLOSIONS.Count - 1].generate_explosion(22, 500, CURSOR.Destbox.X, CURSOR.Destbox.Y, Color.Red.ToArgb(), new Microsoft.DirectX.Vector2(0.15f, 0.15f), 0.5f);
                            }
                        }

                    }

                }
            }
            else
            {
                npc.Color = Color.White;
            }

            if (npc != null)
            {
                if (npc.properties.evil)
                {
                    if (npc != null)
                    {
                        ///////////NPC GREIFT AN////////////////////
                        if (ENGINE.MATHENGINE.PointToPoint(CHARAKTER.Destbox.Location, npc.Destbox.Location) >= npc.properties.attackRange)
                        {
                            npc.caminar = true;
                            ENGINE.get_Path(npc.Destbox.Location, CHARAKTER.box.Location, ref npc.weg);
                            npc.direction = (int)npc.weg[0].Z;

                            if (npc.box.Location == CHARAKTER.box.Location)
                            {
                                //npc.caminar = false;
                            }
                            return false;
                        }
                        else
                        {
                            if (ENGINE.fight_p2p(ref npc, ref CHARAKTER))
                            {
                                Random rnd = new Random();

                                EXPLOSIONS.Add(new c_explosion(ref ENGINE.DEVICE, ref RESOURCES.TEXTURE[1, 1], 500));
                                EXPLOSIONS[EXPLOSIONS.Count - 1].generate_explosion(22, 500, rnd.Next((int)CHARAKTER.Destbox.X, (int)(CHARAKTER.Destbox.X + CHARAKTER.Destbox.Width)), rnd.Next((int)CHARAKTER.Destbox.Y, (int)(CHARAKTER.Destbox.Y + CHARAKTER.Destbox.Height)), Color.Salmon.ToArgb(), new Microsoft.DirectX.Vector2(0.15f, 0.15f), 0.5f);

                                return true;
                            }
                        }
                    }
                }
            }
            return false;
        }
Ejemplo n.º 4
0
        public void load_detailmap(string Datname)
        {
            StreamReader sr = new StreamReader(this.Pfad + @"\maps\detailmaps\" + Datname);

            int o = -1;

            while (sr.Peek() != -1)
            {
                o++;
                string line = sr.ReadLine();

                if (o == 0)
                {
                    this.detailmapsize = line.Length;
                    detailmap = new detailObjekt[this.detailmapsize, this.detailmapsize];
                    NPC = new c_npc[this.detailmapsize, this.detailmapsize,20];

                }

                for (int i = 0; i < line.Length; i++)
                {

                    switch (line[i]) ////BÄUME UND ÄHNLICHES
                    {
                        case '0':
                            detailmap[o, i].detailmap = -1;

                            break;

                        case '#':

                            NPC[o, i,0] = new c_npc(3, 1, 11, 9, 96,this.Pfad + @"\npc\");
                            NPC[o, i, 0].caminar = true;

                            NPC[o, i, 0].Color = Color.White;
                            NPC[o, i, 0].speed.X = 0.8f;
                            NPC[o, i, 0].speed.Y = 0.8f;

                            //die DrawBox des players///
                            NPC[o, i, 0].box.X = i * 128;
                            NPC[o, i, 0].box.Y = o * 97;
                            NPC[o, i, 0].box.Width = 96;
                            NPC[o, i, 0].box.Height = 96;

                            NPC[o, i, 0].Destbox.X = NPC[o, i, 0].box.X;
                            NPC[o, i, 0].Destbox.Y = NPC[o, i, 0].box.Y;
                            NPC[o, i, 0].Destbox.Width = NPC[o, i, 0].box.Width;
                            NPC[o, i, 0].Destbox.Height = NPC[o, i, 0].box.Height;

                            NPC[o, i, 0].HitBox = new Polygon();
                            NPC[o, i, 0].HitBox.Points.Add(new Vector(30, 50));
                            NPC[o, i, 0].HitBox.Points.Add(new Vector(60, 50));
                            NPC[o, i, 0].HitBox.Points.Add(new Vector(60, 80));
                            NPC[o, i, 0].HitBox.Points.Add(new Vector(30, 80));
                            NPC[o, i, 0].HitBox.BuildEdges();

                            //////////NPC EIGENSCHAFTEN///////////////
                            NPC[o, i, 0].properties.evil = true;
                            NPC[o, i, 0].properties.expirience = 10;
                            NPC[o, i, 0].properties.klasse = "wiking";
                            NPC[o, i, 0].properties.level = 1;
                            NPC[o, i, 0].properties.livepoints = 50;
                            NPC[o, i, 0].properties.mana = 10;
                            NPC[o, i, 0].properties.name = "npc";
                            NPC[o, i, 0].properties.staerke = 1;
                            NPC[o, i, 0].properties.defensivpoints = 0;
                            NPC[o, i, 0].properties.attackSpeed = 20;
                            NPC[o, i, 0].properties.attackRange = 80;
                            //////////////////////////////////////////

                            ////////////////////////////
                            detailmap[o, i].detailmap = -1; //OBJEKTKLASSE

                            break;

                        case '1':
                            detailmap[o, i].detailmap = 1; //OBJEKTKLASSE

                            detailmap[o, i].destinationRect.Width = 135; //ZIELBREITE
                            detailmap[o, i].destinationRect.Height = 150; //ZIELHÖHE

                           ////////////////////////////////////////////////////
                            detailmap[o, i].HitRadius = 10;

                            detailmap[o, i].HitBox = new Polygon();
                            detailmap[o, i].HitBox.Points.Add(new Vector(55, 105));
                            detailmap[o, i].HitBox.Points.Add(new Vector(92, 105));
                            detailmap[o, i].HitBox.Points.Add(new Vector(92, 125));
                            detailmap[o, i].HitBox.Points.Add(new Vector(55, 125));
                            detailmap[o, i].HitBox.BuildEdges();
                           ////////////////////////////////////////////////////
                            detailmap[o, i].rect = new Rectangle(0,0,130,130); //SRC RECTANGLE AUS DATEI

                            break;
                        case '2':

                            detailmap[o, i].detailmap = 1; //OBJEKTKLASSE

                            detailmap[o, i].destinationRect.Width = 135; //ZIELBREITE
                            detailmap[o, i].destinationRect.Height = 150; //ZIELHÖHE

                           ////////////////////////////////////////////////////
                            detailmap[o, i].HitRadius = 10;

                            detailmap[o, i].HitBox = new Polygon();
                            detailmap[o, i].HitBox.Points.Add(new Vector(55, 105));
                            detailmap[o, i].HitBox.Points.Add(new Vector(92, 105));
                            detailmap[o, i].HitBox.Points.Add(new Vector(92, 125));
                            detailmap[o, i].HitBox.Points.Add(new Vector(55, 125));
                            detailmap[o, i].HitBox.BuildEdges();
                           ////////////////////////////////////////////////////
                            detailmap[o, i].rect = new Rectangle(150,0,130,130); //SRC RECTANGLE AUS DATEI

                            break;
                        case '3':

                            detailmap[o, i].detailmap = 1; //OBJEKTKLASSE

                            detailmap[o, i].destinationRect.Width = 350; //ZIELBREITE
                            detailmap[o, i].destinationRect.Height = 335; //ZIELHÖHE

                            ////////////////////////////////////////////////////
                            detailmap[o, i].HitRadius = 10;

                            detailmap[o, i].HitBox = new Polygon();
                            detailmap[o, i].HitBox.Points.Add(new Vector(145, 265));
                            detailmap[o, i].HitBox.Points.Add(new Vector(192, 265));
                            detailmap[o, i].HitBox.Points.Add(new Vector(192, 285));
                            detailmap[o, i].HitBox.Points.Add(new Vector(145, 285));
                            detailmap[o, i].HitBox.BuildEdges();
                            ////////////////////////////////////////////////////
                            detailmap[o, i].rect = new Rectangle(0, 145, 350, 363); //SRC RECTANGLE AUS DATEI

                            break;
                    }

                    switch (line[i]) ////WÄNDE UND ÄHNLICHES
                    {
                        case 'a':

                            detailmap[o, i].detailmap = 2; //OBJEKTKLASSE

                            detailmap[o, i].destinationRect.Width = 128; //ZIELBREITE
                            detailmap[o, i].destinationRect.Height = 97; //ZIELHÖHE

                            ////////////////////////////////////////////////////
                            detailmap[o, i].HitRadius = 10;

                            detailmap[o, i].HitBox = new Polygon();
                            detailmap[o, i].HitBox.Points.Add(new Vector(0, 68));
                            detailmap[o, i].HitBox.Points.Add(new Vector(128, 68));
                            detailmap[o, i].HitBox.Points.Add(new Vector(128, 93));
                            detailmap[o, i].HitBox.Points.Add(new Vector(0, 93));
                            detailmap[o, i].HitBox.BuildEdges();
                            ////////////////////////////////////////////////////
                            detailmap[o, i].rect = new Rectangle(0, 0, 128, 97); //SRC RECTANGLE AUS DATEI

                            break;

                        case 'b':

                            detailmap[o, i].detailmap = 2; //OBJEKTKLASSE

                            detailmap[o, i].destinationRect.Width = 128; //ZIELBREITE
                            detailmap[o, i].destinationRect.Height = 190; //ZIELHÖHE

                            ////////////////////////////////////////////////////
                            detailmap[o, i].HitRadius = 10;

                            detailmap[o, i].HitBox = new Polygon();
                            detailmap[o, i].HitBox.Points.Add(new Vector(0, 68));
                            detailmap[o, i].HitBox.Points.Add(new Vector(128, 165));
                            detailmap[o, i].HitBox.Points.Add(new Vector(128, 192));
                            detailmap[o, i].HitBox.Points.Add(new Vector(0, 94));
                            detailmap[o, i].HitBox.BuildEdges();
                            ////////////////////////////////////////////////////
                            detailmap[o, i].rect = new Rectangle(128, 0, 128, 190); //SRC RECTANGLE AUS DATEI

                            break;
                        case 'c':

                            detailmap[o, i].detailmap = 2; //OBJEKTKLASSE

                            detailmap[o, i].destinationRect.Width = 128; //ZIELBREITE
                            detailmap[o, i].destinationRect.Height = 190; //ZIELHÖHE

                            ////////////////////////////////////////////////////
                            detailmap[o, i].HitRadius = 10;

                            detailmap[o, i].HitBox = new Polygon();
                            detailmap[o, i].HitBox.Points.Add(new Vector(128, 68));
                            detailmap[o, i].HitBox.Points.Add(new Vector(0, 165));
                            detailmap[o, i].HitBox.Points.Add(new Vector(0, 192));
                            detailmap[o, i].HitBox.Points.Add(new Vector(128, 94));
                            detailmap[o, i].HitBox.BuildEdges();
                            ////////////////////////////////////////////////////
                            detailmap[o, i].rect = new Rectangle(256, 0, 128, 190); //SRC RECTANGLE AUS DATEI

                            break;

                        case 'd':

                            detailmap[o, i].detailmap = 2; //OBJEKTKLASSE

                            detailmap[o, i].destinationRect.Width = 30; //ZIELBREITE
                            detailmap[o, i].destinationRect.Height = 150; //ZIELHÖHE

                            ////////////////////////////////////////////////////////
                            detailmap[o, i].HitRadius = 10;

                            detailmap[o, i].HitBox = new Polygon();
                            detailmap[o, i].HitBox.Points.Add(new Vector(0 , 0));
                            detailmap[o, i].HitBox.Points.Add(new Vector(25, 0));
                            detailmap[o, i].HitBox.Points.Add(new Vector(25, 150));
                            detailmap[o, i].HitBox.Points.Add(new Vector(0 , 150));
                            detailmap[o, i].HitBox.BuildEdges();
                            ////////////////////////////////////////////////////
                            detailmap[o, i].rect = new Rectangle(388, 0, 30, 97); //SRC RECTANGLE AUS DATEI

                            break;
                    }

                        detailmap[o, i].color = Color.White;

                }
            }
            sr.Close();
        }
Ejemplo n.º 5
0
        public bool fight_p2p(ref c_npc npc, ref c_LOV player,bool playerAttacks)
        {
            if (playerAttacks) //player greift an
            {
                int direction = 0;
                if (player.Destbox.X < npc.Destbox.X)
                {
                    direction = 8;
                }
                else
                {
                    direction = 9;
                }
                if (player.canAttack)
                {
                    npc.properties.livepoints -= player.properties.staerke;
                    player.canAttack = false;
                    AUDIO.play_sound(1);
                    if (npc.properties.livepoints <= 0) // npc besiegt
                    {
                        npc = null;
                        AUDIO.play_sound(2);
                    }
                    player.attackcnt = 1;
                    player.setSprite(direction, 0);
                    return true;
                }
                else
                {
                    int ac = (int)(player.attackcnt / (player.properties.attackSpeed / ((player.properties.attackSpeed / 100) * 10)));
                    if (ac >= 7) ac = 0;
                        player.setSprite(direction, ac);
                        player.attackcnt++;

                }

            }

            return false;
        }