示例#1
0
文件: Player.cs 项目: Xellss/RougyMon
        public Player(Vector2 position, Map map, DoorForest doorForest, GateGraveyard gateGraveyard)
        {
            this.gateGraveyard = gateGraveyard;
            this.doorForest = doorForest;
            this.map = map;

            Tag = "Player";

            transform = AddComponent<Transform>();
            transform.Position = position;

            renderer = AddComponent<ViewRenderer>();
            renderer.SetImage(Managers.Content.Load<Texture2D>("Sprites/Sprite_Sheet/RougyMon"), 32, 32);
            //renderer.Pivot = new Vector2(renderer.ImageWidth / 2, renderer.ImageHeight / 1f);
            renderer.Pivot = new Vector2(16, 32);

            moveWithInput = AddComponent<MoveWithInput>();
            moveWithInput.Speed = 5;
            moveWithInput.MoveWithArrow = OptionsMenuScreen.MoveArrows;

            collider = AddComponent<BoxCollider>();
            collider.OnCollisionEnter += OnCollisionEnter;

            Animation = new SpriteAnimation(
                string.Empty,
                Managers.Content.Load<Texture2D>("Sprites/Sprite_Sheet/RougyMon"),
                Path.Combine(Managers.Content.RootDirectory, "Sprites", "Sprite_Sheet", "RougyMon.xml"));
            Animation.FrameDelay = 100;

            EventManager.OnUpdate += OnUpdate;
            EventManager.OnLateUpdate += OnLateUpdate;
        }
示例#2
0
        public override void Activate(bool instancePreserved)
        {
            if (!instancePreserved)
            {
                if (content == null)
                    content = Managers.Content;

                gameFont = content.Load<SpriteFont>("Fonts/ComicSansMS");

                Thread.Sleep(1000);
            }

            #if WINDOWS_PHONE
            if (Microsoft.Phone.Shell.PhoneApplicationService.Current.State.ContainsKey("PlayerPosition"))
            {
                playerPosition = (Vector2)Microsoft.Phone.Shell.PhoneApplicationService.Current.State["PlayerPosition"];
                enemyPosition = (Vector2)Microsoft.Phone.Shell.PhoneApplicationService.Current.State["EnemyPosition"];
            }
            #endif

            map = new Map(content.Load<Texture2D>("Map/Tiles"));
            map.LoadMapFromImage(content.Load<Texture2D>("Map/MainMap"));
            //Objects

            goldSpawn();
            healPotionSpawn();

            orkForestSpawn();
            SpiderSpawn();
            SkeletonSpawn();
            orkGraveyardSpawn();

            skeletonKing = new SkeletonKing(new Vector2(104 * 32, 40 * 32), map, new Vector2(112 * 32, 40 * 32), timer);

            skeletonKing.moveSpeed = 3;

            key_1 = new Key(new Vector2(992, 2560));
            key_2 = new Key_2(new Vector2(1136, 2096));

            doorForest = new DoorForest(new Vector2(35 * 32, 67 * 32));
            gateGraveyard = new GateGraveyard(new Vector2(81 * 32, 56 * 32));
            player = new Player(new Vector2(2976, 2240), map, doorForest, gateGraveyard);

            camera = new Camera(Managers.Graphics.GraphicsDevice.Viewport);
            //timer.GetPlayer(player);
            timer.Start();
        }