Exemple #1
0
        public GameView(Point viewSize, Point tileSize, Level level)
        {
            ViewSize = viewSize;
            TileSize = tileSize;

            SelectedSprite = new Sprite {
                BaseAlpha = 0.35F
            };

            var baseLayer = new Layer
            {
                BackgroundTexture = Assets.GetTexture("background"),
                Size = ViewSize
            };

            AnimalLayer = new Layer();
            baseLayer.AddChild(AnimalLayer);
            AddChild(baseLayer);

            ValidSwapAnimation      = new AnimationValidSwap();
            InvalidSwapAnimation    = new AnimationInvalidSwap();
            MatchAnimation          = new AnimationMatches();
            FallingAnimalsAnimation = new AnimationFallingAnimals();
            NewAnimalsAnimation     = new AnimationNewAnimals();

            Level = level;
            Level.ComboMultiplier = 1;
            RefreshLayers();
        }
Exemple #2
0
        /// <summary>
        /// Load all images in the specified directory as slides.
        /// </summary>
        public void LoadSlides(string folder)
        {
            hiliteSlide = null;
            slideBar.RemoveAllChildren();
            slides.Clear();
            Layer.AddChild(slideBar);

            if (folder == null)
            {
                AddDefaultSlides();
            }
            else
            {
                AddSlides(folder);
            }

            // Create visual indicator of current position in slide bar
            Bitmap arrowBitmap = new Bitmap(GetType().Module.Assembly.GetManifestResourceStream(IMAGE_RESOURCE_STREAM + ".up-arrow.gif"));

            currentPosition          = new PImage(arrowBitmap);
            currentPosition.Pickable = false;
            slideBar.AddChild(currentPosition);

            slideActivities = new PActivity[slides.Count];

            LayoutSlides();
            GoToSlide((PMultiSizeImage)slideBar[0]);
        }
        protected override void InitialiseScenes()
        {
            base.InitialiseScenes();

            var    bounds       = Layer.VisibleBoundsWorldspace;
            CCRect viewportRect = Viewport.ViewportInPixels;

            CCRenderTexture outTexture   = new CCRenderTexture(bounds.Size, viewportRect.Size);
            CCSprite        outTexSprite = outTexture.Sprite;

            var worldTransform = Layer.AffineWorldTransform;

            outTexture.BeginWithClear(0, 0, 0, 0);
            OutSceneNodeContainer.Visit(ref worldTransform);
            outTexture.End();

            outTexSprite.AnchorPoint = CCPoint.AnchorMiddle;
            outTexSprite.Position    = new CCPoint(bounds.Origin.X + bounds.Size.Width / 2, bounds.Size.Height / 2);
            outTexSprite.BlendFunc   = CCBlendFunc.NonPremultiplied;
            outTexSprite.Opacity     = 255;

            CCAction layerAction = new CCSequence(new CCFadeTo(Duration, 0), new CCCallFunc((Finish)));

            outTexSprite.RunAction(layerAction);

            Layer.AddChild(outTexture.Sprite, 3);

            InSceneNodeContainer.Visible  = true;
            OutSceneNodeContainer.Visible = false;
        }
Exemple #4
0
        protected override void InitialiseScenes()
        {
            if (Layer == null || Viewport == null)
            {
                return;
            }

            base.InitialiseScenes();

            SetupTransition();

            // create a transparent color layer
            // in which we are going to add our rendertextures
            var    bounds       = Layer.VisibleBoundsWorldspace;
            CCRect viewportRect = Viewport.ViewportInPixels;

            // create the second render texture for outScene
            CCRenderTexture texture = new CCRenderTexture(bounds.Size, viewportRect.Size);

            texture.Position    = bounds.Center;
            texture.AnchorPoint = CCPoint.AnchorMiddle;

            // Temporarily add render texture to get layer/scene properties
            Layer.AddChild(texture);
            texture.Visible = false;

            // Render outScene to its texturebuffer
            texture.BeginWithClear(0, 0, 0, 1);
            SceneNodeContainerToBeModified.Visit();
            texture.End();

            texture.Visible = true;

            // No longer want to render texture
            RemoveChild(texture);

            // Since we've passed the outScene to the texture we don't need it.
            if (SceneNodeContainerToBeModified == OutSceneNodeContainer)
            {
                HideOutShowIn();
            }

            CCProgressTimer node = ProgressTimerNodeWithRenderTexture(texture);

            // create the blend action
            var layerAction = new CCProgressFromTo(Duration, From, To);

            // add the layer (which contains our two rendertextures) to the scene
            AddChild(node, 2, SceneRadial);

            // run the blend action
            node.RunAction(layerAction);
        }
        public TabularFisheye()
        {
            // This call is required by the Windows.Forms Form Designer.
            InitializeComponent();

            calendar = new CalendarNode();
            Layer.AddChild(calendar);

            this.PanEventHandler  = null;
            this.ZoomEventHandler = null;

            // Since we don't zoom, we will use grid-fitted text
            // for the highest possible quality.
            this.GridFitText = true;
        }
Exemple #6
0
        protected override void InitialiseScenes()
        {
            if (Layer == null)
            {
                return;
            }

            base.InitialiseScenes();

            SetupTransition();

            // create a transparent color layer
            // in which we are going to add our rendertextures
            var    bounds       = Layer.VisibleBoundsWorldspace;
            CCRect viewportRect = new CCRect(Viewport.Bounds);

            // create the second render texture for outScene
            CCRenderTexture texture = new CCRenderTexture(bounds.Size, viewportRect.Size);

            texture.Sprite.Position    = bounds.Center;
            texture.Sprite.AnchorPoint = CCPoint.AnchorMiddle;


            // Render outScene to its texturebuffer
            texture.BeginWithClear(0, 0, 0, 255);
            var worldTransform = SceneNodeContainerToBeModified.AffineWorldTransform;

            SceneNodeContainerToBeModified.Visit(ref worldTransform);
            texture.End();

            // Since we've passed the outScene to the texture we don't need it.
            if (SceneNodeContainerToBeModified == OutSceneNodeContainer)
            {
                HideOutShowIn();
            }

            CCProgressTimer node = ProgressTimerNodeWithRenderTexture(texture);

            // create the blend action
            var layerAction = new CCProgressFromTo(Duration, From, To);

            // add the layer (which contains our two rendertextures) to the scene
            Layer.AddChild(node, 2);

            // run the blend action
            node.RunAction(layerAction);
        }
        // Powerups
        public void AddPowerup(int type, double time = 0)
        {
            for (int i = 0; i < PowerupGUIItems.Count; i++)
            {
                if (PowerupGUIItems[i].Type == type)
                {
                    PowerupGUIItems[i].ResetTime(time);
                    return;
                }
            }

            PowerupGUI item = new PowerupGUI(this, type, time, Game.GraphicsMode);

            item.Y = Game.Size.Y - 40;
            PowerupGUIItems.Add(item);
            UpdatePowerupPositions();
            Layer_Powerups.AddChild(item);
        }
        public RangeSlider(float minimum, float maximum, float low, float high)
        {
            this.minimum = minimum;
            this.maximum = maximum;
            this.low     = low;
            this.high    = high;

            rangeSliderNode = new RangeSliderNode(this);
            Layer.AddChild(rangeSliderNode);

            // Force anti-aliasing all the time
            DefaultRenderQuality     = RenderQuality.HighQuality;
            InteractingRenderQuality = RenderQuality.HighQuality;

            PanEventHandler  = null;
            ZoomEventHandler = null;
            rangeSliderNode.AddInputEventListener(new RangeSliderEventHandler(this));
            Resize += new EventHandler(RangeSlider_Resize);
        }
Exemple #9
0
        protected override void InitialiseScenes()
        {
            base.InitialiseScenes();

            CCLayerColor fadeLayer = new CCLayerColor(fadeColor);

            fadeLayer.Visible            = false;
            InSceneNodeContainer.Visible = false;

            Layer.AddChild(fadeLayer, 3);

            var a = (CCFiniteTimeAction) new CCSequence
                    (
                new CCShow(),
                new CCFadeIn(Duration / 2),
                new CCCallFunc((HideOutShowIn)),
                new CCFadeOut(Duration / 2)
                    );

            fadeLayer.RunAction(a);
        }
Exemple #10
0
        public override void OnEnter()
        {
            base.OnEnter(); CCSize windowSize = Layer.VisibleBoundsWorldspace.Size;

            Layer.AddChild(batch);

            float step = windowSize.Width / 4;

            int i = 0;

            foreach (CCNode node in batch.Children)
            {
                CCSprite sprite = (CCSprite)node;
                sprite.Position = (new CCPoint((i + 1) * step, windowSize.Height / 2));
                sprite.RunAction(action);
                ++i;
            }

            batch.IgnoreAnchorPointForPosition = true;
            batch.AnchorPoint = new CCPoint(0.5f, 0.5f);
            batch.ContentSize = (new CCSize(windowSize.Width, windowSize.Height));
        }
Exemple #11
0
        public EndScene()
        {
            _waitTimer = new Timer();
            ScheduleUpdate();
            _sceneCamera = (Camera2D)Camera;
            Vector2 ideal_screen_size = new Vector2(960.0f, 544.0f);
            _sceneCamera.SetViewFromHeightAndCenter(ideal_screen_size.Y, ideal_screen_size / 2.0f);

            _groundLayer = new Layer(_sceneCamera);

            Animations = new Dictionary<string, Animation>();
            var texInfo = new TextureInfo(AssetManager.GetTexture("catanimation"), new Vector2i(5,1),TRS.Quad0_1);
            _currentAnimation = new Animation(0, 5, 0.1f, false);
            _currentAnimation.Play();

            _cat = new SpriteTile(texInfo);
            _cat.TileIndex1D = _currentAnimation.CurrentFrame;
            _cat.Quad.S = new Vector2(258, 214);
            _cat.CenterSprite();
            _cat.Position = new Vector2(_sceneCamera.CalcBounds().Point00.X, _sceneCamera.CalcBounds().Point00.Y + _cat.TextureInfo.TextureSizef.Y/2 +64 );

            var background = new SpriteTile(new TextureInfo(AssetManager.GetTexture("background_paper")));
            background.Quad.S = background.TextureInfo.TextureSizef;
            background.CenterSprite();
            background.Position = _sceneCamera.CalcBounds().Center;

            for(var i = 0; i < 5; i++)
            {
                var _sprite = new GroundTile(new TextureInfo(AssetManager.GetTexture("ground_tile")));
                _groundLayer.AddChild(_sprite);
                _sprite.Quad.S = _sprite.TextureInfo.TextureSizef;
                _sprite.Position = new Vector2(_sceneCamera.CalcBounds().Point00.X + i * _sprite.TextureInfo.TextureSizef.X, _sceneCamera.CalcBounds().Point00.Y - _sprite.TextureInfo.TextureSizef.Y / 2);
            }
            _musicPlayer = AssetManager.GetBGM("endscreen").CreatePlayer();
            _musicPlayer.Play();
            AddChild(background);
            AddChild (_cat);
            AddChild (_groundLayer);
        }
Exemple #12
0
        public Game()
        {
            Started = false;
            Running = false;

            // Setup Window
            Bounds         = new FloatRect(0, 0, ResolutionDefault.X, ResolutionDefault.Y);
            WindowSettings = new ContextSettings();
            WindowSettings.AntialiasingLevel = 6;
            CreateWindow();

            // Black Bars (for fullscreen)
            Layer_BlackBars = new Layer();
            RectangleShape BlackBarLeft = new RectangleShape(new Vector2f(2000, 5000));

            BlackBarLeft.Position  = new Vector2f(-BlackBarLeft.Size.X, 0);
            BlackBarLeft.FillColor = new Color(0, 0, 0);
            Layer_BlackBars.AddChild(BlackBarLeft);
            RectangleShape BlackBarRight = new RectangleShape(new Vector2f(2000, 5000));

            BlackBarRight.Position  = new Vector2f(Size.X, 0);
            BlackBarRight.FillColor = new Color(0, 0, 0);
            Layer_BlackBars.AddChild(BlackBarRight);

            // Setup
            Layer_Background = new Layer();
            Layer_Other      = new Layer();
            Layer_Objects    = new Layer();
            Layer_OtherAbove = new Layer();
            Layer_GUI        = new Layer();

            // Start Menu
            StartMenu = new StartMenu(this);
            Layer_GUI.AddChild(StartMenu);

            Music      = new Music("assets/audio/music/Speed Pirate - LuigiSounds.ogg");
            Music.Loop = true;
            Music.Play();

            // Game Loop
            Stopwatch clock = new Stopwatch();

            clock.Start();
            while (Window.IsOpen())
            {
                // Process events
                Window.DispatchEvents();

                if (clock.Elapsed.TotalSeconds >= (1.0f / FPS))
                {
                    if (CloseNextUpdate)
                    {
                        Window.Close();
                        return;
                    }

                    // Clear screen
                    Window.Clear();

                    // Update Game
                    Update((float)clock.Elapsed.TotalSeconds);
                    clock.Restart();

                    // Draw Game
                    Draw();

                    // Update the window
                    Window.Display();
                }
            }
        }
        // CONSTRUCTOR ----------------------------------------------------------------------------------------------------------------------
        public LevelSelectScreen(MenuSystemScene pMenuSystem)
        {
            SelectedLevel = 0;
            var init = ColorIcon.Instance;
            MenuSystem = pMenuSystem;

            var pages = FMath.Ceiling((GameScene.TOTAL_LEVELS-1) / (float)LevelPage.ITEMS_PER_PAGE);

            Panels = new List<Node>{};

            for (int i=0; i < pages; i++) {
                Panels.Add( new LevelPage(i) );
                (Panels[i] as LevelPage).Disable();
            }
            (Panels[0] as LevelPage).Enable();

            this.SwipePanels = new SwipePanels(Panels) {
                Width = 457.0f,
                Position = new Vector2(95.0f,46.0f)
            };

            Indicator = new LevelSelectIndicator();

            // BLACK MASKS TO HIDE MORE LEVELS BEHIND
            BlackBlock1 = Support.UnicolorSprite("white", 255,255,255,255);
            BlackBlock1.Color = Support.ExtractColor("333330");
            BlackBlock1.Scale = new Vector2(361.0f/16.0f, Director.Instance.GL.Context.Screen.Height/16.0f);
            BlackBlock1.Position = new Vector2(Director.Instance.GL.Context.Screen.Width-361.0f, 0.0f);

            BlackBlock2 = Support.UnicolorSprite("white", 255,255,255,255);
            BlackBlock2.Color = LevelManager.Instance.BackgroundColor;
            BlackBlock2.Position = Vector2.Zero;
            BlackBlock2.Scale = new Vector2(50.0f/16.0f, Director.Instance.GL.Context.Screen.Height/16.0f);

            BlackBlock3 = Support.UnicolorSprite("white", 255,255,255,255);
            BlackBlock3.Color = Support.ExtractColor("333330");
            BlackBlock3.Scale = new Vector2(361.0f/16.0f, 115.0f/16.0f);
            BlackBlock3.Position = new Vector2(Director.Instance.GL.Context.Screen.Width-361.0f, Director.Instance.GL.Context.Screen.Height - 115.0f);

            BlackBlock4 = Support.UnicolorSprite("white", 255,255,255,255);
            BlackBlock4.Color = Support.ExtractColor("333330");
            BlackBlock4.Scale = new Vector2(361.0f/16.0f, 253.0f/16.0f);
            BlackBlock4.Position = new Vector2(Director.Instance.GL.Context.Screen.Width-361.0f, 0.0f);

            LevelNumberText = new Label(){
                Text = SelectedLevel.ToString(),
                Position = new Vector2(Director.Instance.GL.Context.Screen.Width-339.0f, Director.Instance.GL.Context.Screen.Height-78.0f),
                FontMap = UI.FontManager.Instance.GetMap(Crystallography.UI.FontManager.Instance.GetInGame("Bariol", 64, "Bold") ),
                Color = LevelManager.Instance.BackgroundColor
            };
            //			CenterText(LevelNumberText);

            //			SolutionPanel = new HudPanel(){
            //			};

            PossibleSolutionsText = new Label(){
                Text = "possible solutions",
                Position = new Vector2(Director.Instance.GL.Context.Screen.Width - 339.0f, Director.Instance.GL.Context.Screen.Height-100.0f),
                FontMap = UI.FontManager.Instance.GetMap(Crystallography.UI.FontManager.Instance.GetInGame("Bariol", 25, "Bold") ),
                Color = LevelManager.Instance.BackgroundColor
            };

            Solutions = new SolutionSlider();

            //			Solutions = new List<SolutionIcon>(); //{
            //				new SolutionIcon(){
            //					CubeText = "99",
            //					ScoreText = "88"
            //				},
            //				new SolutionIcon(){
            //					CubeText = "99",
            //					ScoreText = "88"
            //				},
            //				new SolutionIcon(){
            //					CubeText = "99",
            //					ScoreText = "88"
            //				},
            //				new SolutionIcon(){
            //					CubeText = "99",
            //					ScoreText = "88"
            //				},
            //				new SolutionIcon(){
            //					CubeText = "99",
            //					ScoreText = "88"
            //				}
            //			};
            //			for( int i=0; i < Solutions.Count; i++) {
            //				Solutions[i].Visible = false;
            //				var column = i % 4;
            //				var row = ( i - column ) / 4;
            //				Solutions[i].Position = new Vector2(Director.Instance.GL.Context.Screen.Width - 339.0f + 60.0f * column,
            //				                                    Director.Instance.GL.Context.Screen.Height - 200.0f - row * 80.0f);
            //				this.AddChild(Solutions[i]);
            //			}

            QualitiesText = new Label() {
                Text = "qualities",
                Position = new Vector2(623.0f, 223.0f),
                FontMap = UI.FontManager.Instance.GetMap(Crystallography.UI.FontManager.Instance.GetInGame("Bariol", 25, "Bold") ),
                Color = LevelManager.Instance.BackgroundColor
            };

            //			CompletionPercentageText = new Label() {
            //				Text = (1.0f).ToString("P0"),
            //				Position = new Vector2(638.0f, 150.0f),
            //				FontMap = UI.FontManager.Instance.GetMap(Crystallography.UI.FontManager.Instance.GetInGame("Bariol", 25, "Bold") ),
            ////				Color = new Vector4( 0.16078431f, 0.88627451f, 0.88627451f, 1.0f)
            //			};
            //			CenterText(CompletionPercentageText);
            //			this.AddChild(CompletionPercentageText);

            Icons = new Node[4];
            IconLabels = new Label[4];
            for( int i=0; i < Icons.Length; i++) {
                Icons[i] = Support.TiledSpriteFromFile("/Application/assets/images/icons/icons.png", 4, 2);
                Icons[i].Position = new Vector2(623.0f + 68.0f * (float)i, 2.0f * BUTTON_HEIGHT + 20.0f);
            //				Icons[i].Scale = new Vector2(0.25f, 0.25f);
                IconLabels[i] = new Label() {
                    FontMap = UI.FontManager.Instance.GetMap(Crystallography.UI.FontManager.Instance.GetInGame("Bariol", 36, "Bold") ),
                    Color = LevelManager.Instance.BackgroundColor
                };
            }

            LevelSelectTitleText = new Label(){
                Text="level select",
                Position = new Vector2(50.0f, 488.0f),
                FontMap = UI.FontManager.Instance.GetMap(Crystallography.UI.FontManager.Instance.GetInGame("Bariol", 36, "Regular") ),
                Color = Support.ExtractColor("333330")
            };

            LevelSelectInstructionsText = new Label(){
                Text="select a cube and then press play.",
                Position = new Vector2(50.0f, 465.0f),
                FontMap = UI.FontManager.Instance.GetMap(Crystallography.UI.FontManager.Instance.GetInGame("Bariol", 25, "Regular") ),
                Color = Support.ExtractColor("333330")
            };

            BackButton = new BetterButton(361.0f, BUTTON_HEIGHT) {
                Text = "back",
                Position = new Vector2(Director.Instance.GL.Context.Screen.Width-361.0f, BUTTON_HEIGHT)
            };
            BackButton.background.RegisterPalette(2);

            PlayButton = new BetterButton(361.0f, BUTTON_HEIGHT) {
                Text = "play",
                Position = new Vector2(Director.Instance.GL.Context.Screen.Width-361.0f, 0.0f)
            };
            PlayButton.background.RegisterPalette(1);

            // SWIPE LAYER
            this.AddChild(this.SwipePanels);
            foreach( LevelPage panel in Panels) {
                this.AddChild(panel);
            }
            (Panels[0] as LevelPage).Items[0].AddChild(Indicator);

            // UI LAYERS
            BackLayer = new Layer();
            this.AddChild(BackLayer);
            FrontLayer = new Layer();
            this.AddChild(FrontLayer);

            // BACK LAYER ELEMENTS
            BackLayer.AddChild(BlackBlock1);
            BackLayer.AddChild(BlackBlock2);
            BackLayer.AddChild(Solutions);

            // FRONT LAYER ELEMENTS
            FrontLayer.AddChild(BlackBlock3);
            FrontLayer.AddChild(BlackBlock4);

            FrontLayer.AddChild(LevelNumberText);
            FrontLayer.AddChild(PossibleSolutionsText);
            FrontLayer.AddChild(QualitiesText);
            for( int i=0; i < Icons.Length; i++) {
                FrontLayer.AddChild(Icons[i]);
            }
            FrontLayer.AddChild(LevelSelectTitleText);
            FrontLayer.AddChild(LevelSelectInstructionsText);
            FrontLayer.AddChild(BackButton);
            FrontLayer.AddChild(PlayButton);
        }
Exemple #14
0
        public Game()
        {
            Started = false;
            Running = false;

            // Setup Window
            Bounds = new FloatRect(0, 0, ResolutionDefault.X, ResolutionDefault.Y);
            WindowSettings = new ContextSettings();
            WindowSettings.AntialiasingLevel = 6;
            CreateWindow();

            // Black Bars (for fullscreen)
            Layer_BlackBars = new Layer();
            RectangleShape BlackBarLeft = new RectangleShape(new Vector2f(2000, 5000));
            BlackBarLeft.Position = new Vector2f(-BlackBarLeft.Size.X, 0);
            BlackBarLeft.FillColor = new Color(0, 0, 0);
            Layer_BlackBars.AddChild(BlackBarLeft);
            RectangleShape BlackBarRight = new RectangleShape(new Vector2f(2000, 5000));
            BlackBarRight.Position = new Vector2f(Size.X, 0);
            BlackBarRight.FillColor = new Color(0, 0, 0);
            Layer_BlackBars.AddChild(BlackBarRight);

            // Setup
            Layer_Background = new Layer();
            Layer_Other = new Layer();
            Layer_Objects = new Layer();
            Layer_OtherAbove = new Layer();
            Layer_GUI = new Layer();

            // Start Menu
            StartMenu = new StartMenu(this);
            Layer_GUI.AddChild(StartMenu);

            Music = new Music("assets/audio/music/Speed Pirate - LuigiSounds.ogg");
            Music.Loop = true;
            Music.Play();

            // Game Loop
            Stopwatch clock = new Stopwatch();
            clock.Start();
            while (Window.IsOpen())
            {
                // Process events
                Window.DispatchEvents();

                if (clock.Elapsed.TotalSeconds >= (1.0f / FPS))
                {
                    if (CloseNextUpdate)
                    {
                        Window.Close();
                        return;
                    }

                    // Clear screen
                    Window.Clear();

                    // Update Game
                    Update((float)clock.Elapsed.TotalSeconds);
                    clock.Restart();

                    // Draw Game
                    Draw();

                    // Update the window
                    Window.Display();
                }
            }
        }
Exemple #15
0
        public Game()
        {
            //			Director.Instance.DebugFlags |= DebugFlags.Navigate; // press left alt + mouse to navigate in 2d space
            //			Director.Instance.DebugFlags |= DebugFlags.DrawGrid;
            Director.Instance.DebugFlags |= DebugFlags.DrawContentWorldBounds;
            Director.Instance.DebugFlags |= DebugFlags.DrawContentLocalBounds;
            //			Director.Instance.DebugFlags |= DebugFlags.DrawTransform;
            //			Director.Instance.DebugFlags |= DebugFlags.DrawPivot;

            DebugString = new DebugString(Sce.PlayStation.HighLevel.GameEngine2D.Director.Instance.GL.Context);
            Scene = new Sce.PlayStation.HighLevel.GameEngine2D.Scene();
            Background = new Layer();
            World = new Layer();
            EffectsLayer = new Layer();
            Foreground = new Layer();
            Curtains = new Layer();
            Interface = new Layer();
            Random = new Random();
            Collider = new EntityCollider();
            ParticleEffects = new Support.ParticleEffectsManager();
            TextureTileMaps = new Support.TextureTileMapManager();
            UI = new UI();
            ScoreManager = new ScoreManager();

            SpriteBatch = new SpriteBatch();

            BuildTextureTileMaps();

            AddQueue = new List<GameEntity>();
            RemoveQueue = new List<GameEntity>();

            Scene.AddChild(Background);
            Scene.AddChild(World);
            Scene.AddChild(EffectsLayer);
            Scene.AddChild(Foreground);
            Scene.AddChild(Interface);
            Scene.AddChild(Curtains);

            Scene.Camera.SetViewFromViewport();

            // temporary: munge viewport to match vita + assets
            Vector2 ideal_screen_size = ScreenSize;
            Camera2D camera = Scene.Camera as Camera2D;
            camera.SetViewFromHeightAndCenter(ideal_screen_size.Y, ideal_screen_size / 2.0f);
            TitleCameraCenter = camera.Center;
            CameraTarget = TitleCameraCenter;

            if(ParticleEffects!=null)
                EffectsLayer.AddChild(ParticleEffects);
            Interface.AddChild(UI);

            // world
            var bg_forest = Support.SpriteFromFile("/Application/assets/background_test2.png");
            bg_forest.Scale *= 1;

            bg_forest.Position = new Vector2(0f, 0.0f);

            Background.AddChild(bg_forest);

            UI.TitleMode();

            Sce.PlayStation.HighLevel.GameEngine2D.Scheduler.Instance.Schedule(Scene, TickTitle, 0.0f, false);

            World.AdHocDraw += this.DrawWorld;
        }
        public GamePlayScene()
        {
            this.ScheduleUpdate ();
            _garnishTimer = new Timer();
            _groundTimer = new Timer();
            _waterLevel = 272;
            _groundLevel = 120;
            _random = new Random();
            _garnishDelay = _random.Next(0,5);

            Vector2 ideal_screen_size = new Vector2(960.0f, 544.0f);
            SceneCamera = (Camera2D)Camera;

            SceneCamera.SetViewFromHeightAndCenter(ideal_screen_size.Y, ideal_screen_size / 2.0f);

            _groundGarnish = new Layer(SceneCamera);
            _mainLayer = new Layer(SceneCamera);
            _playerCreature = new PlayerCreature ();
            _playerCreature.sprite.Position = Camera.CalcBounds ().Center;
            _mainLayer.AddChild (_playerCreature.sprite);

            _backgroundLayer = new Layer(SceneCamera, 0, 0);
            var background = new SpriteTile(new TextureInfo(AssetManager.GetTexture("background_paper")));
            _backgroundLayer.AddChild(background);
            background.Quad.S = background.TextureInfo.TextureSizef;
            background.CenterSprite();
            background.Position = SceneCamera.CalcBounds().Center;

            _water = new SpriteTile(new TextureInfo(AssetManager.GetTexture("water")));
            _water.Quad.S = _water.TextureInfo.TextureSizef;
            _water.CenterSprite();
            _water.Position = SceneCamera.CalcBounds().Center + new Vector2(0, -244);

             _waterTop = new WaterTile(new TextureInfo(AssetManager.GetTexture("waveline")));
            _waterTop.Quad.S = _waterTop.TextureInfo.TextureSizef;
            _waterTop.CenterSprite();
            _waterTop.Position = _water.Position + new Vector2(0 ,_water.TextureInfo.TextureSizef.Y /2 );
            _waterTop.Position = SceneCamera.CalcBounds().Center + new Vector2(0, -244 + _water.TextureInfo.TextureSizef.Y/2f);

            _groundLayer = new Layer(SceneCamera, 1, 1);
            _groundGarnish = new Layer(SceneCamera, 1, 1);

            var texInfo = new TextureInfo(AssetManager.GetTexture ("ground_tile"));
            _ground = new SpriteList(texInfo);
            _sprite = new SpriteTile(texInfo);
            _ground.AddChild(_sprite);
            _sprite.Quad.S = texInfo.TextureSizef;
            _sprite.CenterSprite();
            _sprite.TileIndex2D = new Vector2i(0,0);

            GenerateMap();

            _enemies = new List<Enemy>();
            _bullets = new List<Bullet>();
            /*
            // enemy sprite test code
            var fish0 = new FishEnemy (new Vector2 (30.0f, 30.0f), _playerCreature);
            var fish1 = new FishEnemy (new Vector2 (15.0f, 15.0f), _playerCreature);
            var fish2 = new FishEnemy (new Vector2 (100.0f, 70.0f), _playerCreature);

            _enemies.Add (fish0);
            _enemies.Add (fish1);
            _enemies.Add (fish2);
            */
            var dummyFish = new FishEnemy (new Vector2 (-25.0f, -25.0f), _playerCreature);
            dummyFish.sprite.UnscheduleAll();
            _mainLayer.AddChild (FishEnemy.spriteList);

            var dummyBullet = new Bullet(new Vector2(-25.0f,-25.0f));
            dummyBullet.sprite.UnscheduleAll();
            //dummyBullet.sprite.Visible = false;
            _mainLayer.AddChild(Bullet.spriteList);

            _waterLayer = new Layer(SceneCamera);
            _waterLayer.AddChild(_water);
            _waterLayer.AddChild(_waterTop);

            _musicPlayer = AssetManager.GetBGM("gameplaymusic").CreatePlayer();
            _musicPlayer.Loop = true;
            _musicPlayer.Play();

            AddChild (_backgroundLayer);

            AddChild (_mainLayer);
            AddChild(_groundLayer);
            AddChild(_groundGarnish);
            AddChild(_waterLayer);

            _eventManager = new EventManager(_mainLayer,_playerCreature);
        }
Exemple #17
0
        public void Start()
        {
            if (Started)
            {
                return;
            }
            Started = true;
            Running = true;

            // Background
            if (GraphicsMode == GRAPHICSMODE_NORMAL)
            {
                RectangleShape Water = new RectangleShape(new Vector2f(Size.X, Size.Y));
                Water.FillColor = new Color(40, 118, 188);
                Layer_Background.AddChild(Water);

                WaterRipples WaterRipplesBelow = new WaterRipples(this, new Vector2f(Size.X + 40, Size.Y + 40), 120, 10, new Color(68, 131, 186));
                WaterRipplesBelow.Position = new Vector2f(-40, -40);
                Layer_Background.AddChild(WaterRipplesBelow);

                WaterRipples WaterRipples = new WaterRipples(this, new Vector2f(Size.X, Size.Y), 120, 10, new Color(80, 158, 228));
                Layer_Background.AddChild(WaterRipples);

                //VoronoiDiagram WaterEffect = new VoronoiDiagram(this, new Vector2f(Size.X, Size.Y));
                //Layer_Background.AddChild(WaterEffect);
            }
            else if (GraphicsMode == GRAPHICSMODE_BLUEPRINT)
            {
                Sprite BluePrintBackground = Graphics.GetSprite("assets/sprites/background_blueprint_tile.png");
                BluePrintBackground.Texture.Repeated = true;
                BluePrintBackground.TextureRect      = new IntRect(0, 0, (int)Size.X, (int)Size.Y);
                Layer_Background.AddChild(BluePrintBackground);
            }

            // Island
            float IslandRadius = 240;

            if (GraphicsMode == GRAPHICSMODE_NORMAL)
            {
                Sprite IslandTexture = Graphics.GetSprite("assets/sprites/island.png");
                IslandTexture.Origin   = new Vector2f(IslandRadius, IslandRadius);
                IslandTexture.Position = new Vector2f((Size.X / 2) + 1, (Size.Y / 2));
                Layer_Background.AddChild(IslandTexture);
            }

            Island          = new CircleShape(IslandRadius);
            Island.Origin   = new Vector2f(IslandRadius, IslandRadius);
            Island.Position = new Vector2f(Size.X / 2, Size.Y / 2);
            if (GraphicsMode == GRAPHICSMODE_NORMAL)
            {
                Island.FillColor        = new Color(0, 0, 10, 0);
                Island.OutlineThickness = 20;
                Island.OutlineColor     = new Color(138, 104, 0, 100);
            }
            else if (GraphicsMode == GRAPHICSMODE_BLUEPRINT)
            {
                Island.FillColor        = new Color(0, 0, 10, 30);
                Island.OutlineThickness = 2;
                Island.OutlineColor     = new Color(250, 250, 250);
            }
            Island.SetPointCount(80);
            Layer_Background.AddChild(Island);

            IslandWaves = new CircleWaves(this, IslandRadius, 0.1f, 1.5f, 6, 80);
            if (GraphicsMode == GRAPHICSMODE_NORMAL)
            {
                IslandWaves.Colour = new Color(80, 158, 228);
            }
            IslandWaves.Position = Island.Position;
            Layer_Background.AddChild(IslandWaves);

            // Hill
            float HillRadius = 30;

            Hill          = new CircleShape(HillRadius);
            Hill.Origin   = new Vector2f(HillRadius, HillRadius);
            Hill.Position = new Vector2f(Size.X / 2, Size.Y / 2);
            if (GraphicsMode == GRAPHICSMODE_NORMAL)
            {
                Hill.FillColor        = new Color(50, 50, 50, 150);
                Hill.OutlineThickness = 4;
                Hill.OutlineColor     = new Color(0, 0, 0, 215);
            }
            else if (GraphicsMode == GRAPHICSMODE_BLUEPRINT)
            {
                Hill.FillColor        = new Color(0, 0, 10, 50);
                Hill.OutlineThickness = 2;
                Hill.OutlineColor     = new Color(250, 250, 250);
            }
            Hill.SetPointCount(50);
            Layer_Background.AddChild(Hill);

            // Player (Cannon)
            Player = new Cannon(this);
            Player.SetPosition(Size.X / 2, Size.Y / 2);
            Layer_OtherAbove.AddChild(Player);
            Player.SetPlayer(true);

            // AI Manager
            AIManager = new AIManager(this);
            AIManager.StartWaveCountdown();

            // HUD
            HUD = new HeadsUpDisplay(this);
            HUD.SetHealth(Player.Health);
            Layer_GUI.AddChild(HUD);
        }