//action to execute if the player press the action button
 void ExecuteAction()
 {
     if (actualShopNpc != null && Vector3.Distance(actualShopNpc.transform.position, transform.position) < actualShopNpc.interactDistance)
     {
         actualShopNpc.Interact();
     }
     else if (actualTownNpc != null && Vector3.Distance(actualTownNpc.transform.position, transform.position) < actualTownNpc.talkDistance)
     {
         actualTownNpc.NPCPushTalk();
     }
     else if (actualEnterBuilding != null && Vector3.Distance(actualEnterBuilding.transform.position, transform.position) < actualEnterBuilding.detectionDistance)
     {
         actualEnterBuilding.Execute();
     }
     else if (actualExitLocation != null && Vector3.Distance(actualExitLocation.transform.position, transform.position) < actualExitLocation.detectionDistance)
     {
         actualExitLocation.Execute();
     }
     else
     {
         actualShopNpc       = null;
         actualTownNpc       = null;
         actualEnterBuilding = null;
         actualExitLocation  = null;
     }
 }
Beispiel #2
0
        public override void Paint(Level level)
        {
            var ice = LevelSave.BiomeGenerated is IceBiome;

            if (ice)
            {
                var clip = Painter.Clip;
                Painter.Clip = null;
                Painter.Rect(level, this, 0, Tile.WallB);
                Painter.Clip = clip;
            }

            var id = GenerateNpc();

            if (id == null)
            {
                return;
            }

            GameSave.Put("npc_appeared", true);

            var d   = Connected.Values.First();
            var npc = ShopNpc.FromId(id);

            level.Area.Add(npc);

            var fl = Tiles.RandomFloorOrSpike();

            if (d.X == Left || d.X == Right)
            {
                var w    = (int)(GetWidth() / 2f + Rnd.Int(-1, 1));
                var door = new Dot(Left + w, Rnd.Int(Top + 2, Bottom - 2));

                Painter.DrawLine(level, new Dot(Left + w, Top), new Dot(Left + w, Bottom), ice ? Tile.WallB : Tile.WallA);
                Painter.Set(level, door, fl);

                npc.Center = new Dot(Left + w + (d.X == Left ? 2 : -2), Rnd.Int(Top + 2, Bottom - 3)) * 16 + new Vector2(8);

                var dr = new CageDoor {
                    Vertical = true
                };

                dr.Center = door * 16 + new Vector2(12, 0);
                level.Area.Add(dr);

                var v = (d.X == Left ? -1 : 1);

                Painter.DrawLine(level, new Dot(Left + w + v, Top + 1), new Dot(Left + w + v, Bottom - 1), Tiles.Pick(Tile.Chasm, Tile.Lava, Tile.SensingSpikeTmp));
                Painter.Set(level, door + new Dot(v, 0), fl);
            }
            else if (true)
            {
                var h    = (int)(GetHeight() / 2f + Rnd.Int(-1, 1));
                var door = new Dot(Rnd.Int(Left + 2, Right - 2), Top + h);

                Painter.DrawLine(level, new Dot(Left, Top + h), new Dot(Right, Top + h), Tile.WallA);
                Painter.Set(level, door, fl);

                npc.Center = new Dot(Rnd.Int(Left + 2, Right - 2), Top + h + (d.Y == Top ? 2 : -2)) * 16 + new Vector2(8);

                var dr = new CageDoor();
                dr.Center = door * 16 + new Vector2(7, 8);
                level.Area.Add(dr);

                var v = (d.Y == Top ? -1 : 1);

                Painter.DrawLine(level, new Dot(Left + 1, Top + h + v), new Dot(Right - 1, Top + h + v), Tiles.Pick(Tile.Chasm, Tile.Lava, Tile.SensingSpikeTmp));
                Painter.Set(level, door + new Dot(0, v), fl);
            }
        }
 public void SetShopNpc(ShopNpc shop)
 {
     actualShopNpc = shop;
 }
Beispiel #4
0
 public KoliShopExchange(WorldClient Client, ShopNpc Npc)
 {
     this.myClient = Client;
     this.Npc      = Npc;
 }
 public ExchangeShopItemListMessage(ShopNpc Npc)
 {
     this.Npc = Npc;
 }