Пример #1
0
        public VisionInputComponent(Entity VisionOrb)
        {
            this.componentName = GlobalVars.VISION_ORB_INPUT_COMPONENT_NAME;

            this.vision         = ( VisionOrb )vision;
            platformerMoveSpeed = 150f;
        }
Пример #2
0
        //--------------------------------------------------------------------------------



        public void createVisionOrb()
        {
            if (level.getPlayer() == null)
            {
                return;
            }
            PositionComponent posComp   = ( PositionComponent )level.getPlayer().getComponent(GlobalVars.POSITION_COMPONENT_NAME);
            Player            player    = ( Player )level.getPlayer();
            VelocityComponent playerVel = ( VelocityComponent )player.getComponent(GlobalVars.VELOCITY_COMPONENT_NAME);

            playerVel.x = 0;

            float x = posComp.x + getSpawnDistance(player);
            float y = posComp.y;


            if (level.getCollisionSystem().findObjectsBetweenPoints(x - visionOrbSize / 2, y - visionOrbSize / 2, x + visionOrbSize / 2, y + visionOrbSize / 2).Count > 0)
            {
                return;
            }
            if (level.getCollisionSystem().findObjectsBetweenPoints(x - visionOrbSize / 2, y + visionOrbSize / 2, x + visionOrbSize / 2, y - visionOrbSize / 2).Count > 0)
            {
                return;
            }

            player.stopAnimation();

            player.removeComponent(GlobalVars.PLAYER_INPUT_COMPONENT_NAME);

            VisionOrb newEntity = new VisionOrb(level, GenerateRandId(), x, y);

            if (newEntity == null)
            {
                return;
            }

            level.addEntity(newEntity.randId, newEntity);   //This should just stay the same

            level.sysManager.drawSystem.getMainView().setFollowEntity(newEntity);
            level.sysManager.drawSystem.getMainView().width  = mainWinOrbZoomWidth;
            level.sysManager.drawSystem.getMainView().height = mainWinOrbZoomHeight;

            if (doBorder)
            {
                level.sysManager.drawSystem.getMainView().borderBrush = borderBrush;
                level.sysManager.drawSystem.getMainView().borderSize  = mainBorderSize;
                level.sysManager.drawSystem.getMainView().hasBorder   = true;
            }
            if (doPlayerWindow)
            {
                //Find player's quadrant
                if (posComp.x - level.sysManager.drawSystem.getMainView().x < level.sysManager.drawSystem.getMainView().width / 2)
                {
                    plWinXLoc = plBorderSize / 2;
                }
                else
                {
                    plWinXLoc = level.sysManager.drawSystem.getMainView().displayWidth - plWinWidth - plBorderSize / 2;
                }
                if (posComp.y - level.sysManager.drawSystem.getMainView().y < level.sysManager.drawSystem.getMainView().height / 2)
                {
                    plWinYLoc = plBorderSize / 2;
                }
                else
                {
                    plWinYLoc = level.sysManager.drawSystem.getMainView().displayHeight - plWinHeight - plBorderSize / 2;
                }

                plView          = new View(plWinXLoc, plWinYLoc, plWinWidth, plWinHeight, level);
                plView.displayX = plWinXLoc;
                plView.displayY = plWinYLoc;
                plView.setFollowEntity(level.getPlayer());
                plView.hasBorder   = true;
                plView.borderFade  = false;
                plView.borderSize  = plBorderSize;
                plView.borderBrush = plBorderBrush;
                level.sysManager.drawSystem.addView(plView);
            }
            orbActive  = true;
            orbControl = true;

            if (!hasBeenUsedOnce && level.worldNum == level.visionOrbUnlockWorldNum && level.levelNum == level.visionOrbUnlockLevelNum)
            {
                level.sysManager.drawSystem.deactivateTextFlash();
                level.sysManager.drawSystem.activateTextFlash("Press [T] to toggle control between the player and Hue!\nPress [V] to put Hue away.", Color.WhiteSmoke, 0.3f, 4.0f, 1.0f);
            }

            hasBeenUsedOnce = true;
        }