Пример #1
0
        static void Main(string[] args)
        {
            // World w = World.GetInstance;(new Position(20,20),"The Game",new Hero("Heroic Hector", new Position(10, 10), 25, 30, Movement.State.North));

            Opponent o = new Opponent("Azeroth", new Position(8, 7), 30, 34);
            Opponent p = new Opponent("Beelzebub", new Position(6, 12), 30, 34);
            Opponent q = new Opponent("Azeroth", new Position(18, 7), 30, 34);
            Opponent r = new Opponent("Azeroth", new Position(8, 17), 30, 34);

            World.GetInstance().ObstacleList();

            DefenseFactory d = new DefenseFactory();
            ItemCreator    i = new ItemCreator(d);

            i.PlaceInWorld();
            World.GetInstance().ObstacleList();

            World.GetInstance().RegisterOpponents(o);
            World.GetInstance().RegisterOpponents(p);
            World.GetInstance().RegisterOpponents(q);
            World.GetInstance().RegisterOpponents(r);

            DrawGame dg = new DrawGame();

            dg.Draw();

            World.GetInstance().Hero.ToString();
        }
Пример #2
0
        public GameObject Spawn(GameObject spawner)
        {
            AbstractPowerUpFactory powerUpFactory;

            type++;

            switch (type)
            {
            case 0:
                powerUpFactory = new AttackFactory();
                break;

            case 1:
                powerUpFactory = new DefenseFactory();
                break;

            case 2:
                powerUpFactory = new HealthFactory();
                break;

            case 3:
                powerUpFactory = new SpeedFactory();
                type           = -1;
                break;

            default:
                throw new ArgumentOutOfRangeException();
            }

            int     percent = rnd.Next(100);
            Vector2 size    = spawner.transform.size * new Vector2(0.6f, 0.7f);

            if (percent < 50)
            {
                powerUp = powerUpFactory.CreateTemporaryPowerUp(0, 0, size.X, size.Y);
            }
            else
            {
                powerUp = powerUpFactory.CreatePermanentPowerUp(0, 0, size.X, size.Y);
            }
            GameObject.Instantiate(powerUp, spawner);
            return(powerUp);
        }