Пример #1
0
        static void Main(string[] args)
        {
            #region FanFactory

            //FanFactory fanFactory = new FanFactory();
            //var fan1 = fanFactory.CreateFan(FanType.TableFan);
            //fan1.SwitchOn();

            //var fan2 = fanFactory.CreateFan(FanType.CeilingFan);
            //fan2.SwitchOn();

            //var fan3 = fanFactory.CreateFan(FanType.ExhaustFan);
            //fan3.SwitchOn();

            //fan1.SwitchOff();
            //fan2.SwitchOff();
            //fan3.SwitchOff();

            #endregion

            #region DoorFactory

            DoorFactory doorFactory = new DoorFactory();
            var         door1       = doorFactory.MakeDoor(500, 1300);
            door1.PrintDimensions();

            #endregion

            Console.ReadKey();
        }
Пример #2
0
        static void SimpleFactory()
        {
            DoorFactory d = new DoorFactory();

            Creational.SimpleFactory.WoodenDoor door = DoorFactory.MakeDoor(100, 200);//resolving class name conflicts with adding namespace
            Console.WriteLine(door.width);
            Console.WriteLine(door.height);
        }
        public static void Run()
        {
            Console.WriteLine("=-=-=-=SimpleFactory=-=-=-=");
            Console.WriteLine("Make me a door of 100x200");
            var door = DoorFactory.MakeDoor(100, 200);

            Console.WriteLine($"door - Width: {door.GetWidth()}");
            Console.WriteLine($"door - Height: {door.GetHeight()}");

            Console.WriteLine();

            Console.WriteLine("Make me a door of 50x100");
            var door2 = DoorFactory.MakeDoor(50, 100);

            Console.WriteLine($"door2 - Width: {door2.GetWidth()}");
            Console.WriteLine($"door2 - Height: {door2.GetHeight()}");

            Console.WriteLine("----------------------------------" + Environment.NewLine);
        }
        /// <summary>
        /// Allows the game to perform any initialization it needs to before starting to run.
        /// This is where it can query for any required services and load any non-graphic
        /// related content.  Calling base.Initialize will enumerate through any components
        /// and initialize them as well.
        /// </summary>
        protected override void Initialize()
        {
            AggregateFactory   = new AggregateFactory(this);
            WeaponFactory      = new WeaponFactory(this);
            DoorFactory        = new DoorFactory(this);
            RoomFactory        = new RoomFactory(this);
            CollectableFactory = new CollectibleFactory(this);
            WallFactory        = new WallFactory(this);
            EnemyFactory       = new EnemyFactory(this);
            SkillEntityFactory = new SkillEntityFactory(this);
            NPCFactory         = new NPCFactory(this);

            // Initialize Components
            PlayerComponent          = new PlayerComponent();
            LocalComponent           = new LocalComponent();
            RemoteComponent          = new RemoteComponent();
            PositionComponent        = new PositionComponent();
            MovementComponent        = new MovementComponent();
            MovementSpriteComponent  = new MovementSpriteComponent();
            SpriteComponent          = new SpriteComponent();
            DoorComponent            = new DoorComponent();
            RoomComponent            = new RoomComponent();
            HUDSpriteComponent       = new HUDSpriteComponent();
            HUDComponent             = new HUDComponent();
            InventoryComponent       = new InventoryComponent();
            InventorySpriteComponent = new InventorySpriteComponent();
            ContinueNewGameScreen    = new ContinueNewGameScreen(graphics, this);
            EquipmentComponent       = new EquipmentComponent();
            WeaponComponent          = new WeaponComponent();
            BulletComponent          = new BulletComponent();
            PlayerInfoComponent      = new PlayerInfoComponent();
            WeaponSpriteComponent    = new WeaponSpriteComponent();
            StatsComponent           = new StatsComponent();
            EnemyAIComponent         = new EnemyAIComponent();
            NpcAIComponent           = new NpcAIComponent();

            CollectibleComponent = new CollectibleComponent();
            CollisionComponent   = new CollisionComponent();
            TriggerComponent     = new TriggerComponent();
            EnemyComponent       = new EnemyComponent();
            NPCComponent         = new NPCComponent();
            //QuestComponent = new QuestComponent();
            LevelManager             = new LevelManager(this);
            SpriteAnimationComponent = new SpriteAnimationComponent();
            SkillProjectileComponent = new SkillProjectileComponent();
            SkillAoEComponent        = new SkillAoEComponent();
            SkillDeployableComponent = new SkillDeployableComponent();
            SoundComponent           = new SoundComponent();
            ActorTextComponent       = new ActorTextComponent();
            TurretComponent          = new TurretComponent();
            TrapComponent            = new TrapComponent();
            ExplodingDroidComponent  = new ExplodingDroidComponent();
            HealingStationComponent  = new HealingStationComponent();
            PortableShieldComponent  = new PortableShieldComponent();
            PortableStoreComponent   = new PortableStoreComponent();
            ActiveSkillComponent     = new ActiveSkillComponent();
            PlayerSkillInfoComponent = new PlayerSkillInfoComponent();
            MatchingPuzzleComponent  = new MatchingPuzzleComponent();
            pI = new PlayerInfo();

            Quests = new List <Quest>();


            #region Initialize Effect Components
            AgroDropComponent          = new AgroDropComponent();
            AgroGainComponent          = new AgroGainComponent();
            BuffComponent              = new BuffComponent();
            ChanceToSucceedComponent   = new ChanceToSucceedComponent();
            ChangeVisibilityComponent  = new ChangeVisibilityComponent();
            CoolDownComponent          = new CoolDownComponent();
            DamageOverTimeComponent    = new DamageOverTimeComponent();
            DirectDamageComponent      = new DirectDamageComponent();
            DirectHealComponent        = new DirectHealComponent();
            FearComponent              = new FearComponent();
            HealOverTimeComponent      = new HealOverTimeComponent();
            PsiOrFatigueRegenComponent = new PsiOrFatigueRegenComponent();
            InstantEffectComponent     = new InstantEffectComponent();
            KnockBackComponent         = new KnockBackComponent();
            TargetedKnockBackComponent = new TargetedKnockBackComponent();
            ReduceAgroRangeComponent   = new ReduceAgroRangeComponent();
            ResurrectComponent         = new ResurrectComponent();
            StunComponent              = new StunComponent();
            TimedEffectComponent       = new TimedEffectComponent();
            EnslaveComponent           = new EnslaveComponent();
            CloakComponent             = new CloakComponent();
            #endregion

            base.Initialize();
        }
Пример #5
0
        private IEnumerator loadLevelHelper(string levelPath)
        {
            Debug.Log("Loading...");

            MapEditor.Get().destroy();

            yield return null; // Wait for managers to be destroyed

            Map map = MapEditor.Get().map(); // Creates the new managers

            yield return null; // Wait for all managers Start() methods to be called

            if (!Directory.Exists(levelPath))
                yield break;

            XmlDocument doc = new XmlDocument();
            doc.Load(levelPath + "/gamedata.xml");

            XmlElement root = doc.FirstChild as XmlElement;

            XmlElement tilesElement = null;
            XmlElement staticWallsElement = null;
            XmlElement doorsElement = null;
            XmlElement activatorsElement = null;

            foreach (XmlNode child in root)
            {
                XmlElement iterator = child as XmlElement;
                if (iterator == null)
                    continue;

                switch (iterator.Name)
                {
                    case "tiles":
                        tilesElement = iterator;
                        break;
                    case "staticwalls":
                        staticWallsElement = iterator;
                        break;
                    case "doors":
                        doorsElement = iterator;
                        break;
                    case "activators":
                        activatorsElement = iterator;
                        break;
                }
            }

            // Create Tiles
            foreach (XmlNode _tile in tilesElement.ChildNodes)
            {
                XmlElement tileElement = _tile as XmlElement;
                if (tileElement == null)
                    continue;

                string stringPosition = tileElement.GetAttribute("position");
                Vec2Int tilePos = new Vec2Int(stringPosition);

                Tile tile = map.getTile(tilePos);
                QuadNodeProcessors.createTile(tile.node(), tile.position());
            }

            // Create Static Walls
            StaticWallFactory staticWallFactory = new StaticWallFactory();
            if (staticWallsElement != null)
            {
                foreach (XmlNode _staticWallElem in staticWallsElement.ChildNodes)
                {
                    XmlElement staticWallElement = _staticWallElem as XmlElement;
                    if (staticWallElement == null)
                        continue;

                    staticWallFactory.create(staticWallElement);
                }
            }

            // Create Static Walls to Place Doors Over
            if (doorsElement != null)
            {
                foreach (XmlNode _doorElem in doorsElement.ChildNodes)
                {
                    XmlElement doorElement = _doorElem as XmlElement;
                    if (doorElement == null)
                        continue;

                    staticWallFactory.create(doorElement);
                }
            }

            // Create Doors
            DoorFactory doorFactory = new DoorFactory();
            if (doorsElement != null)
            {
                foreach (XmlNode _doorElem in doorsElement.ChildNodes)
                {
                    XmlElement doorElement = _doorElem as XmlElement;
                    if (doorElement == null)
                        continue;

                    doorFactory.create(doorElement);
                }
            }

            // Create Activators
            ActivatorFactory activatorFactory = new ActivatorFactory(doorFactory);
            if (activatorsElement != null)
            {
                foreach (XmlNode _activatorElem in activatorsElement.ChildNodes)
                {
                    XmlElement activatorElement = _activatorElem as XmlElement;
                    if (activatorElement == null)
                        continue;

                    activatorFactory.create(activatorElement);
                }
            }

            ObjectManipulator.Get().activate();
        }