Inheritance: AbstractTest
示例#1
0
        public void CheckTile(Game game, AbstractWorld world)
        {
            //reflektion

            IWorldObject ObjectInTile = null;

            ObjectInTile = world.WorldObjects.Find(wo =>
                                                   wo.Position.X == Position.X && wo.Position.Y == Position.Y);
            string NameOfObjectInTile = ObjectInTile.GetType().Name;

            if (NameOfObjectInTile != "Player")
            {
                switch (NameOfObjectInTile)
                {
                case "Sword":
                    Weapon = ObjectInTile as IWeapon;
                    ObjectInTile.Position = null;
                    world.WorldObjects.Remove(ObjectInTile);
                    break;

                case "Bow":
                    Weapon = ObjectInTile as IWeapon;
                    ObjectInTile.Position = null;
                    world.WorldObjects.Remove(ObjectInTile);
                    break;

                case "Monster":
                    game.CombatOponent = ObjectInTile as ICharacter;
                    game.GameState     = GameState.Combat;
                    break;
                }
                Console.WriteLine(NameOfObjectInTile);
                Console.ReadKey();
            }
        }
示例#2
0
        public override void DeleteNestedObjects()
        {
            Background.DeleteNestedObjects();
            Background = null;

            GUI.DeleteNestedObjects();
            GUI = null;

            World.DeleteNestedObjects();
            World = null;
        }
示例#3
0
 public void C_Execute(Executer exe, ArgsController args)
 {
     //выбор мира
     if (args.SubCmds.IsSubcmd(0, "wselect"))
     {
         string wrldName = args.StrArgs[0];
         if (WrldSelected != null && wrldName == WrldSelected.WorldName)
         {
             Interactor.Logger.Error($"Мир {wrldName} уже выбран!");
             return;
         }
         if (Interactor.WorldController.Any((a) => a.WorldName == wrldName))
         {
             WrldSelected = Interactor.WorldController.First((a) => a.WorldName == wrldName);
             Interactor.Logger.Success($"Мир {WrldSelected.WorldName} выбран! | {WrldSelected.BehaviourID}");
         }
         else
         {
             Interactor.Logger.Error($"Мир {wrldName} не найден!");
         }
     }
     else if (args.SubCmds.IsSubcmd(0, "obj"))
     {
         if (WrldSelected is null)
         {
             Interactor.Logger.Error("Мир не выбран!");
             return;
         }
         if (args.SubCmds.IsSubcmd(1, "add"))
         {
             string whatIs = args.StrArgs[0];
             if (ObjsToCreate.Any(a => a.ObjectName == whatIs))
             {
                 WrldSelected.AddObject(ObjsToCreate.Find(a => a.ObjectName == whatIs));
                 Interactor.Logger.Success($"Объект {whatIs} добавлен в мир!");
             }
             else
             {
                 Interactor.Logger.Error($"Объект {whatIs} не найден!");
             }
         }
         else if (args.SubCmds.IsSubcmd(1, "list"))
         {
             Interactor.Logger.Info($"Объекты в мире ({WrldSelected.ObjectsInTheWorld.Count}): ");
             foreach (var obj in WrldSelected.ObjectsInTheWorld)
             {
                 Interactor.Logger.Info($"{obj.ObjectName} | {obj.BehaviourID}");
             }
         }
     }
 }
示例#4
0
        public virtual void Move(Game game, AbstractWorld world, char direction)
        {
            switch (direction)
            {
            case 'w':
                if (world.Tiles.Find(ti => ti.Position.X == Position.X && ti.Position.Y == Position.Y - 1).Passable)
                {
                    Position = new Position(Position.X, Position.Y - 1);

                    CheckTile(game, world);
                }
                else
                {
                    //log not accessible
                }
                break;

            case 'a':
                if (world.Tiles.Find(ti => ti.Position.X == Position.X - 1 && ti.Position.Y == Position.Y).Passable)
                {
                    Position = new Position(Position.X - 1, Position.Y);
                    CheckTile(game, world);
                }
                else
                {
                }
                break;

            case 's':
                if (world.Tiles.Find(ti => ti.Position.X == Position.X && ti.Position.Y == Position.Y + 1).Passable)
                {
                    Position = new Position(Position.X, Position.Y + 1);
                    CheckTile(game, world);
                }
                else
                {
                }
                break;

            case 'd':
                if (world.Tiles.Find(ti => ti.Position.X == Position.X + 1 && ti.Position.Y == Position.Y).Passable)
                {
                    Position = new Position(Position.X + 1, Position.Y);
                    CheckTile(game, world);
                }
                else
                {
                }
                break;
            }
        }
示例#5
0
        public WorldLogic(AbstractWorld world, AbstractRectangularClickableGrid grid)
        {
            this.world    = world;
            this.grid     = grid;
            cells         = grid.Cells as Cell[, ];
            selectedCells = new Cell[2];
            logicState    = WorldLogicState.FindAndDeleteMatches;

            for (var y = 0; y < grid.CellCount.Y; y++)
            {
                for (int x = 0; x < grid.CellCount.X; x++)
                {
                    SpawnDonut(cells[y, x]);
                    cells[y, x].Clicked += UpdateSelectedCellsList;
                }
            }
        }
示例#6
0
    public static void Main()
    {
        A a = new A(5);

        a.Test();

        D d = new D(8, 3.14F, 500L);

        d.Hello();

        C c = d;

        c.Virtual();

        AbstractTest hello = new AbstractHello();
        AbstractTest world = new AbstractWorld();

        Console.WriteLine(hello.Test());
        Console.WriteLine(world.Test());
        Console.WriteLine(c.f);
        d.Hello();
    }
示例#7
0
    public static void Main()
    {
        A a = new A (5);
        a.Test ();

        D d = new D (8, 3.14F, 500L);
        d.Hello ();

        C c = d;
        c.Virtual ();

        AbstractTest hello = new AbstractHello ();
        AbstractTest world = new AbstractWorld ();

        Console.WriteLine (hello.Test ());
        Console.WriteLine (world.Test ());
        Console.WriteLine (c.f);
        d.Hello ();
    }