Ejemplo n.º 1
0
        private Entity LoadEnemy(Vector2 pos, string enemyType, string startDirection, string itemHeld)
        {
            Entity entity;

            Console.WriteLine("Initializing enemy at pos " + pos);

            if (startDirection.Equals(""))
            {
                startDirection = "right";
            }

            // Parse direction (passed in as string) into Direction enumerable type
            Constants.Direction direction;
            switch (startDirection)
            {
            case "up":
                direction = Constants.Direction.UP;
                break;

            case "right":
                direction = Constants.Direction.RIGHT;
                break;

            case "down":
                direction = Constants.Direction.DOWN;
                break;

            case "left":
                direction = Constants.Direction.LEFT;
                break;

            default:     // start direction not neccessary, default is right
                direction = Constants.Direction.RIGHT;
                break;
            }

            switch (enemyType)
            {
            case "aquamentus":
                entity = new Aquamentus(pos);
                break;

            case "bladetrap":
                entity = new BladeTrap(pos);
                break;

            case "gel":
                entity = new Gel(pos);
                break;

            case "goriya":
                entity = new Goriya(pos);
                break;

            case "keese":
                entity = new Keese(pos);
                break;

            case "rope":
                entity = new Rope(pos);
                break;

            case "stalfo":
                entity = new Stalfo(pos);
                if (itemHeld == "regularkey")
                {
                    BasicSprite keySprite = ItemSpriteFactory.Instance.CreateRegularKey();
                    keySprite.offsets = new List <Vector2> {
                        new Vector2(4, 0)
                    };
                    entity.AddComponent(new Sprite(keySprite));
                    entity.GetComponent <StalfoMovement>().SetItemHeldTrue();
                }
                break;

            case "wallmaster":
                entity = new WallMaster(pos, direction);
                break;

            default:
                Console.WriteLine("Level @ LoadEnemy(): Unrecognized enemyType \"" + enemyType + "\"!");
                return(null);
            }
            var poof = new Poof(pos, entity);

            Scene.Add(entity);
            Scene.Add(poof);
            var transform = Root.GetComponent <Transform>();

            transform.AddChild(poof);
            numEnemiesLeft++;

            enemyList.Add((Enemy)entity);

            return(entity);
        }
Ejemplo n.º 2
0
        private Entity LoadEnemy(Vector2 pos, string enemyType, string startDirection, string itemHeld)
        {
            Entity entity = null;

            // Parse direction (passed in as string) into Direction enumerable type
            Constants.Direction direction;
            switch (startDirection)
            {
            case "up":
                direction = Constants.Direction.UP;
                break;

            case "right":
                direction = Constants.Direction.RIGHT;
                break;

            case "down":
                direction = Constants.Direction.DOWN;
                break;

            case "left":
                direction = Constants.Direction.LEFT;
                break;

            default:     // start direction not neccessary, default is right
                direction = Constants.Direction.RIGHT;
                break;
            }

            switch (enemyType)
            {
            case "aquamentus":
                entity = new Aquamentus(pos);
                break;

            case "bladetrap":
                entity = new BladeTrap(pos);
                break;

            case "gel":
                entity = new Gel(pos);
                break;

            //case "goriya":
            //    entity = new Goriya(pos);
            //    break;
            case "keese":
                entity = new Keese(pos);
                break;

            case "rope":
                entity = new Rope(pos);
                break;

            case "stalfo":
                entity = new Stalfo(pos);
                if (itemHeld == "regularkey")
                {
                    entity.AddComponent(new Sprite(ItemSpriteFactory.Instance.CreateRegularKey()));
                    entity.GetComponent <StalfoMovement>().SetItemHeldTrue();
                }
                break;

            case "wallmaster":
                entity = new WallMaster(pos, direction);
                break;

            default:
                Console.WriteLine("Level @ LoadEnemy(): Unrecognized enemyType \"" + enemyType + "\"!");
                return(null);
            }
            Scene.Add(entity);
            Scene.Add(new Poof(pos, entity));
            return(entity);
        }