Esempio n. 1
0
        //checked
        #region GameFrame
        public int AddGameFrame(GameFrameModel gf) // returns 1 if the insertion was successful //-1 if parameters are incoherent//-2 if the GF already exists// checked//
        {
            var       cont = new SeniorLinqDataContext();
            GameFrame temp = new GameFrame();

            if (gf.MinPlayers <= gf.MaxPlayers && gf.MinStrategies <= gf.MaxStrategies)
            {
                var query1 = (from gfs in cont.GameFrames where gfs.Title == gf.Title select gfs).SingleOrDefault();
                if (query1 == null)
                {
                    temp.Title         = gf.Title;
                    temp.MinPlayers    = gf.MinPlayers;
                    temp.MaxPlayers    = gf.MaxPlayers;
                    temp.MinStrategies = gf.MinStrategies;
                    temp.MaxStrategies = gf.MaxStrategies;
                    cont.GameFrames.InsertOnSubmit(temp);
                    cont.SubmitChanges();
                    var query = (from gff in cont.GameFrames where gff.Title == temp.Title select gff.Title).SingleOrDefault();
                    if (query != null)
                    {
                        return(1);
                    }
                }
                return(-2);
            }
            return(-1);
        }
Esempio n. 2
0
        void RenderBackground(GameFrame targetFrame)
        {
            float oldNearClip = cleanProxyCamera.nearClipPlane;

            cleanProxyCamera.nearClipPlane = Mathf.Clamp(targetFrame.playerDist - 0.5f * layerOverlap, 0.001f, cleanProxyCamera.farClipPlane - 0.001f);

            RenderGameCamera(cleanProxyCamera, targetFrame.backgroundBuffer);

            if (forceToBackground > 0)
            {
                float            oldFarClip = cleanProxyCamera.farClipPlane;
                LayerMask        oldCull    = cleanProxyCamera.cullingMask;
                CameraClearFlags oldClear   = cleanProxyCamera.clearFlags;

                cleanProxyCamera.farClipPlane  = targetFrame.playerDist + 0.5f * layerOverlap;
                cleanProxyCamera.nearClipPlane = oldNearClip;
                cleanProxyCamera.cullingMask   = forceToBackground;
                cleanProxyCamera.clearFlags    = CameraClearFlags.Depth;

                RenderGameCamera(cleanProxyCamera, targetFrame.backgroundBuffer);

                cleanProxyCamera.cullingMask  = oldCull;
                cleanProxyCamera.farClipPlane = oldFarClip;
                cleanProxyCamera.clearFlags   = oldClear;
            }

            cleanProxyCamera.nearClipPlane = oldNearClip;
        }
        void GrabForeground(GameFrame targetFrame)
        {
            gameCamera.farClipPlane  = targetFrame.playerDepth + 0.5f * layerOverlap;
            gameCamera.nearClipPlane = gameNearClipPlane;
            //
            gameCamera.clearFlags      = CameraClearFlags.Color | CameraClearFlags.Depth;
            gameCamera.backgroundColor = new Color(0, 0, 0, 0);

            Shader originalScreenSpaceShadowShader = GraphicsSettings.GetCustomShader(BuiltinShaderType.ScreenSpaceShadows);

            GraphicsSettings.SetCustomShader(BuiltinShaderType.ScreenSpaceShadows, noForegroundShadowFadeShader);

            LayerMask oldCull = gameCamera.cullingMask;

            if (forceToBackground > 0)
            {
                gameCamera.cullingMask = forceToBackground;
                gameCamera.RenderWithShader(blockoutBackgroundShader, null);
                gameCamera.clearFlags = CameraClearFlags.Nothing;       //Whole point: next Render() respects this depth buffer
            }

            gameCamera.cullingMask = oldCull ^ forceToBackground;
            RenderGameCamera(gameCamera, targetFrame.foregroundBuffer);
            gameCamera.cullingMask = oldCull;

            GraphicsSettings.SetCustomShader(BuiltinShaderType.ScreenSpaceShadows, originalScreenSpaceShadowShader);

            gameCamera.nearClipPlane = gameNearClipPlane;
            gameCamera.farClipPlane  = gameFarClipPlane;
        }
        void CompositeCurrentFrame()
        {
            GameFrame     currentFrame = gameFrames[gameFrameIndex % gameFrames.Count];
            RenderTexture outputRt     = (Output as RenderTexture);

            outputRt.DiscardContents(true, false);

            Rect fullscreenRect = new Rect(0, 0, Output.width, Output.height);

            GL.PushMatrix();
            GL.LoadPixelMatrix(0, Output.width, Output.height, 0);
            Graphics.SetRenderTarget(outputRt);
            Graphics.DrawTexture(fullscreenRect, currentFrame.backgroundBuffer, blitBackgroundMat);
            GL.Clear(true, false, Color.black);
            if (inputTexture != null && inputMaterial != null)
            {
                Graphics.DrawTexture(fullscreenRect, inputTexture, inputMaterial);
            }
            Graphics.DrawTexture(fullscreenRect, currentFrame.foregroundBuffer, blitForegroundMat);
            //Graphics.Blit(currentFrame.backgroundBuffer, outputRt);
            //Graphics.Blit(inputTexture, outputRt, inputMaterial);   //Insert real world
            //Graphics.Blit(currentFrame.foregroundBuffer, outputRt);

            GL.PopMatrix();
        }
Esempio n. 5
0
        public static void SetWindowRegion(GameFrame frame, ref Point[] points)
        {
            if (Environment.OSVersion.Platform == PlatformID.Win32NT)
            {
                int size = Marshal.SizeOf(new Point());
                if (hPoints == IntPtr.Zero)
                {
                    hPoints = Marshal.AllocCoTaskMem(points.Length * size);
                }

                for (int i = 0; i < points.Length; i++)
                {
                    Marshal.StructureToPtr(points[i], hPoints + i * size, false);
                }


                long hRegion = Win32CreatePolygonRgn(hPoints.ToInt64(), points.Length, 1);

                var    win       = frame.Window as AvaloniaWindow;
                IntPtr winHandle = win.PlatformImpl.Handle.Handle;
                Win32SetWindowRgn(winHandle.ToInt32(),
                                  hRegion,
                                  0);

                Win32DeleteObject(hRegion);
            }
            else
            {
                throw new NotImplementedException($"Platform '{Environment.OSVersion.Platform}' not supported.");
            }
        }
Esempio n. 6
0
        public override void RenderScene()
        {
            StartFrame();

            frames.delayDuration = context.Data.unplugged == false ? context.Data.bufferTime : 0f;
            frames.Update();

            GameFrame newFrame = PrepareNewFrame();

            newFrame.playerDist       = gameCamera.transform.TransformVector(Vector3.forward).magnitude *CalculatePlayerDistance(); //Scale distance by camera scale
            newFrame.cameraToWorld    = cleanProxyCamera.cameraToWorldMatrix;
            newFrame.cameraProjection = cleanProxyCamera.projectionMatrix;

            cleanProxyCamera.CopyFrom(gameCamera);
            RenderBackground(newFrame);
            RenderForeground(newFrame);

            GameFrame bufferedFrame = frames.OldestFrameData;

            GL.LoadIdentity();
            ClearBuffer();
            BlitBackground(bufferedFrame);
            if (BackgroundRendered != null)
            {
                BackgroundRendered();
            }

            //Update shader properties for Feeds to access
            Shader.SetGlobalFloat("_CamNear", cleanProxyCamera.nearClipPlane);
            Shader.SetGlobalFloat("_CamFar", cleanProxyCamera.farClipPlane);
            Shader.SetGlobalMatrix("_WorldToCam", bufferedFrame.cameraToWorld.inverse);
            Shader.SetGlobalMatrix("_CamToWorld", bufferedFrame.cameraToWorld);
            Shader.SetGlobalMatrix("_CamProjection", bufferedFrame.cameraProjection);

            for (int i = 0; i < InputFeedProjection.ActiveProjections.Count; i++)
            {
                if (InputFeedProjection.ActiveProjections[i].context.Data == context.Data)
                {
                    InputFeed feed = InputFeedProjection.ActiveProjections[i].FindFeed();
                    if (feed != null)
                    {
                        feed.StartRender();
                        RenderInputProjection(InputFeedProjection.ActiveProjections[i]);
                        feed.StopRender();
                    }
                }
            }

            if (bufferedFrame.playerDist > 0)
            {
                BlitForeground(bufferedFrame);
            }

            Graphics.SetRenderTarget(Output as RenderTexture);
            Graphics.Blit(null, postBlit);
            RenderFinalPass();
            CompleteFrame();
        }
        void CollectGameFrame()
        {
            GameFrame newFrame = gameFrames[gameFrameIndex % gameFrames.Count];

            newFrame.playerDepth = CalculatePlayerDepth();

            GrabBackground(newFrame);
            GrabForeground(newFrame);
        }
Esempio n. 8
0
        public async Task RegisterToGame(int gameId, String teamType)
        {
            TeamType         type         = Enum.Parse <TeamType>(teamType);
            GameRegistration registration = GamePlayManager.RegisterPlayer(Context.ConnectionId, gameId, type);
            await Clients.Caller.CompleteRegistration(registration);

            GameFrame frame = GamePlayManager.GetCurrentFrame(gameId);
            await Clients.Caller.UpdateGameFrame(frame);
        }
Esempio n. 9
0
        void RenderForeground(GameFrame targetFrame)
        {
            float            oldFarClip = cleanProxyCamera.farClipPlane;
            LayerMask        oldCull    = cleanProxyCamera.cullingMask;
            CameraClearFlags oldClear   = cleanProxyCamera.clearFlags;
            Color            oldBGCol   = cleanProxyCamera.backgroundColor;

            Color blackAndClear = new Color(0, 0, 0, 0);

            Graphics.SetRenderTarget(targetFrame.foregroundBuffer);
            GL.Clear(true, true, blackAndClear);

            cleanProxyCamera.farClipPlane    = Mathf.Max(cleanProxyCamera.nearClipPlane + 0.001f, targetFrame.playerDist + 0.5f * layerOverlap);
            cleanProxyCamera.clearFlags      = CameraClearFlags.Color | CameraClearFlags.Depth; //Just cleared
            cleanProxyCamera.backgroundColor = blackAndClear;

            if (forceToBackground > 0)
            {
                cleanProxyCamera.cullingMask = forceToBackground;
                //TODO: optimize by disabling all lighting in this render
                cleanProxyCamera.targetTexture = targetFrame.foregroundBuffer;
                cleanProxyCamera.RenderWithShader(blockoutBackgroundShader, null);

                //now depth buffer wont allow writes where the ground would have been
                cleanProxyCamera.clearFlags = CameraClearFlags.Nothing;
            }

            Shader originalScreenSpaceShadowShader = GraphicsSettings.GetCustomShader(BuiltinShaderType.ScreenSpaceShadows);

            GraphicsSettings.SetCustomShader(BuiltinShaderType.ScreenSpaceShadows, noForegroundShadowFadeShader);

            cleanProxyCamera.cullingMask = oldCull ^ forceToBackground;

            if (MixCast.ProjectSettings.grabUnfilteredAlpha)
            {
                cleanProxyCamera.AddCommandBuffer(CameraEvent.BeforeImageEffects, grabAlphaCommand);  //Instruction to copy out the state of the RenderTexture before Image Effects are applied
            }
            RenderGameCamera(cleanProxyCamera, targetFrame.foregroundBuffer);

            if (MixCast.ProjectSettings.grabUnfilteredAlpha)
            {
                cleanProxyCamera.RemoveCommandBuffer(CameraEvent.BeforeImageEffects, grabAlphaCommand);
                Graphics.Blit(LastFrameAlpha, targetFrame.foregroundBuffer, copyAlphaMat);      //Overwrite the potentially broken post-effects alpha channel with the pre-effect copy
            }
            else
            {
                LastFrameAlpha = targetFrame.foregroundBuffer;
            }

            GraphicsSettings.SetCustomShader(BuiltinShaderType.ScreenSpaceShadows, originalScreenSpaceShadowShader);

            cleanProxyCamera.farClipPlane    = oldFarClip;
            cleanProxyCamera.cullingMask     = oldCull;
            cleanProxyCamera.clearFlags      = oldClear;
            cleanProxyCamera.backgroundColor = oldBGCol;
        }
Esempio n. 10
0
 //UDP消息
 public void OnSyncPlayers(GameFrame frame)
 {
     FrameSyncServer.Ins.OnSynced();
     for (int i = 0; i < frame.commands.Count; i++)
     {
         FrameCommand fmd = frame.commands[i];
         NetWorkBattle.Ins.SyncPlayer(fmd);
     }
     NetWorkBattle.Ins.GameTime = frame.time;
 }
Esempio n. 11
0
        public static void Main(string[] args)
        {
            builder = new GameBuilder();

            IGameWindowBuilder windowBuilder;

#if netcoreapp31
            windowBuilder = new AvaloniaWindowBuilder();
#endif
#if net48
            windowBuilder = new WinFormWindowBuilder();
#endif

            builder
            .GameEngine(new FixedTickEngine(TPS))
            .GameView(new GameView2D(SCREENWIDTH, SCREENHEIGHT, scale, scale, Color.DarkSlateGray))
            .GameFrame(new GameFrame(windowBuilder, 0, 0, 160, 144, scale, scale))
            .Controller(new WindowsKeyController(keyMap.ToDictionary(kvp => (int)kvp.Key, kvp => (int)kvp.Value)))
            .Controller(new WindowsMouseController(mouseMap.ToDictionary(kvp => Convert(kvp.Key), kvp => (int)kvp.Value)))
            .StartingLocation(new Location(new Description2D(0, 0, 100, 100)))
            .Build();

            Engine = builder.Engine;

            Frame = builder.Frame;

            SetupAnimations();

            SetupSprites();

            SetupSkills();

            Entity marker = Marker.Create(new Marker(0, 0));
            Engine.AddEntity(marker);

            Random r = new Random(0);
            for (int i = 0; i < 5; i++)
            {
                Entity enemy = Enemy.Create(new Enemy(r.Next(8, SCREENWIDTH - 8), r.Next(8, SCREENHEIGHT - 8)));
                Engine.AddEntity(enemy);
            }

            Entity player = Player.Create(new Player(50, 50, 0, 1));
            Engine.AddEntity(player);

            Entity hud = Hud.Create(new Hud(0, 1, SCREENWIDTH * scale, SCREENHEIGHT * scale));
            Engine.AddEntity(hud);

            Engine.Start();

            while (true)
            {
            }
            ;
        }
Esempio n. 12
0
        void BlitForeground(GameFrame frame)
        {
            bool oldSRGB = GL.sRGBWrite;

            GL.sRGBWrite = true;
            Graphics.SetRenderTarget(Output as RenderTexture);
            RenderTexture src = frame.foregroundBuffer;

            Graphics.DrawTexture(new Rect(0, 0, Screen.width, Screen.height), src, blitForegroundMat);
            GL.sRGBWrite = oldSRGB;
        }
        public void GetResources(List<GameObjectManager> _resources)
        {
            _mainFrame = (GameFrame)_resources[0].CreateObject(7);
            _backGround = (GameFrame)_resources[0].CreateObject(8);
            _currentChild = 0;

            _btOnButton = (Button)_resources[1].CreateObject(40);
            _btOnButton.IsPressButton = true;
            _btOnButton.Mouse_Down += new Button.OnMouseDownHandler(OnButton_Down);

            _btOffButton = (Button)_resources[1].CreateObject(41);
            _btOffButton.IsPressButton = true;
            _btOffButton.Mouse_Down += new Button.OnMouseDownHandler(OffButton_Down);

            _btHelp = (Button)_resources[1].CreateObject(42);
            _btHelp.Mouse_Click += new Button.OnMouseClickHandler(HelpButton_Click);
            _btHelp.Mouse_Hover += new Button.OnMouseHoverHandler(HelpButton_Hover);
            _btHelp.Mouse_Released += new Button.OnMouseReleasedHandler(HelpButton_Release);

            _btQuit = (Button)_resources[1].CreateObject(43);
            _btQuit.Mouse_Click += new Button.OnMouseClickHandler(QuitButton_Click);
            _btQuit.Mouse_Hover += new Button.OnMouseHoverHandler(QuitButton_Hover);
            _btQuit.Mouse_Released += new Button.OnMouseReleasedHandler(QuitButton_Release);

            _btResume = (Button)_resources[1].CreateObject(44);
            _btResume.Mouse_Click += new Button.OnMouseClickHandler(ResumeButton_Click);
            _btResume.Mouse_Hover += new Button.OnMouseHoverHandler(ResumeButton_Hover);
            _btResume.Mouse_Released += new Button.OnMouseReleasedHandler(ResumeButton_Release);

            _mainFrame.AddChild(_btOnButton);
            _mainFrame.AddChild(_btOffButton);
            _mainFrame.AddChild(_btHelp);
            _mainFrame.AddChild(_btQuit);
            _mainFrame.AddChild(_btResume);

            _backGround.AddChild(_mainFrame);

            _btOK = (Button)_resources[1].CreateObject(45);
            _btOK.Mouse_Click += new Button.OnMouseClickHandler(OKButton_Click);
            _btOK.Mouse_Hover += new Button.OnMouseHoverHandler(OKButton_Hover);
            _btOK.Mouse_Released += new Button.OnMouseReleasedHandler(OKButton_Release);

            _btCancel = (Button)_resources[1].CreateObject(46);
            _btCancel.Mouse_Click += new Button.OnMouseClickHandler(CancelButton_Click);
            _btCancel.Mouse_Hover += new Button.OnMouseHoverHandler(CancelButton_Hover);
            _btCancel.Mouse_Released += new Button.OnMouseReleasedHandler(CancelButton_Release);

            _messageBox = (GameFrame)_resources[0].CreateObject(9);
            _messageBox.AddChild(_btOK);
            _messageBox.AddChild(_btCancel);

            _backGround.AddChild(_messageBox);
        }
        void GenerateFrames(int count)
        {
            DisposeOfFrames();

            for (int i = 0; i < count; i++)
            {
                GameFrame newFrame = new GameFrame();
                newFrame.backgroundBuffer = new RenderTexture(Screen.width, Screen.height, 16);
                newFrame.foregroundBuffer = new RenderTexture(Screen.width, Screen.height, 16);
                gameFrames.Add(newFrame);
            }

            gameFrameIndex = 0;
        }
        public override void RenderScene()
        {
            frames.delayDuration = context.Data.bufferTime;
            frames.Update();

            GameFrame newFrame = PrepareNewFrame();

            newFrame.playerDepth      = CalculatePlayerDistance();
            newFrame.cameraToWorld    = cleanProxyCamera.cameraToWorldMatrix;
            newFrame.cameraProjection = cleanProxyCamera.projectionMatrix;

            cleanProxyCamera.CopyFrom(gameCamera);
            RenderBackground(newFrame);
            RenderForeground(newFrame);

            GameFrame bufferedFrame = frames.OldestFrameData;

            GL.LoadIdentity();
            ClearBuffer();
            BlitBackground(bufferedFrame);
            if (BackgroundRendered != null)
            {
                BackgroundRendered();
            }

            //Update shader properties for Feeds to access
            Shader.SetGlobalFloat("_CamNear", cleanProxyCamera.nearClipPlane);
            Shader.SetGlobalFloat("_CamFar", cleanProxyCamera.farClipPlane);
            Shader.SetGlobalMatrix("_WorldToCam", bufferedFrame.cameraToWorld.inverse);
            Shader.SetGlobalMatrix("_CamToWorld", bufferedFrame.cameraToWorld);
            Shader.SetGlobalMatrix("_CamProjection", bufferedFrame.cameraProjection);

            for (int i = 0; i < ActiveFeeds.Count; i++)
            {
                BlitFeed(ActiveFeeds[i]);
            }

            if (bufferedFrame.playerDepth > 0)
            {
                BlitForeground(bufferedFrame);
            }

            Graphics.SetRenderTarget(Output as RenderTexture);
            Graphics.Blit(null, postBlit);
            Graphics.SetRenderTarget(null);

            RenderFinalPass();

            CompleteFrame();
        }
Esempio n. 16
0
 protected async override void OnNavigatedTo(NavigationEventArgs e)
 {
     base.OnNavigatedTo(e);
     parameter            = (GameFrame)e.Parameter;
     trackName            = parameter.trackGuessed.title_short.ToString().ToLower().Replace(" ", string.Empty);
     artistName           = parameter.trackGuessed.artist.name.ToString().ToLower().Replace(" ", string.Empty);
     albumName            = parameter.trackGuessed.album.title.ToString().ToLower().Replace(" ", string.Empty);
     textTrackNumber.Text = "Track n°" + (parameter.listTrack.IndexOf(parameter.trackGuessed) + 1);
     if (parameter.listTrack.IndexOf(parameter.trackGuessed) == 0)
     {
         ReadyContentDialog dialog = new ReadyContentDialog();
         await dialog.ShowAsync();
     }
     InitializeNewSound();
     InitializeNewTimer();
 }
Esempio n. 17
0
        public static void SetWindowRegion(GameFrame frame, double x, double y, double w, double h)
        {
            var    win       = frame.Window as AvaloniaWindow;
            IntPtr winHandle = win.PlatformImpl.Handle.Handle;

            if (Environment.OSVersion.Platform == PlatformID.Win32NT)
            {
                uint hRegion = Win32CreateRectRgn(
                    (int)(x * frame.ScaleX),
                    (int)(y * frame.ScaleY),
                    (int)((x + w) * frame.ScaleX),
                    (int)((y + h) * frame.ScaleY));
                Win32SetWindowRgn(winHandle.ToInt32(), hRegion, 0);

                Win32DeleteObject(hRegion);
            }
        }
Esempio n. 18
0
    int actionPrev = 0;//上一个动作
    public void SyncMainPlayer()
    {
        Frame = new GameFrame();
        FrameCommand cmd = new FrameCommand();

        cmd.playerId = (uint)Main.Ins.LocalPlayer.InstanceId;
        cmd.command  = MeteorMsg.Command.ClientSync;
        MemoryStream ms     = new MemoryStream();
        PlayerSync   sync   = new PlayerSync();
        MeteorUnit   player = Main.Ins.LocalPlayer;

        sync.playerId   = (uint)player.InstanceId;
        sync.position   = new _Vector3();
        sync.position.x = Mathf.FloorToInt(player.transform.position.x * 1000);
        sync.position.y = Mathf.FloorToInt(player.transform.position.y * 1000);
        sync.position.z = Mathf.FloorToInt(player.transform.position.z * 1000);
        sync.rotation   = new _Quaternion();
        sync.rotation.x = Mathf.FloorToInt(player.transform.rotation.x * 1000);
        sync.rotation.y = Mathf.FloorToInt(player.transform.rotation.y * 1000);
        sync.rotation.z = Mathf.FloorToInt(player.transform.rotation.z * 1000);
        sync.rotation.w = Mathf.FloorToInt(player.transform.rotation.w * 1000);
        sync.model      = (uint)player.ModelId;
        sync.weapon     = (uint)player.Attr.Weapon;
        sync.weapon1    = (uint)player.Attr.Weapon2;
        sync.hp         = (uint)player.Attr.hpCur;
        sync.ang        = (uint)player.AngryValue;
        sync.action     = -1;

        if (actionPrev != player.ActionMgr.mActiveAction.Idx)
        {
            sync.action = player.ActionMgr.mActiveAction.Idx;
            actionPrev  = player.ActionMgr.mActiveAction.Idx;
        }

        List <int> buffs = U3D.GetUnitBuffs(player);

        for (int i = 0; i < buffs.Count; i++)
        {
            sync.buff.Add((uint)buffs[i]);
        }

        ProtoBuf.Serializer.Serialize <PlayerSync>(ms, sync);
        cmd.Data = ms.ToArray();
        Frame.commands.Add(cmd);
    }
Esempio n. 19
0
        public static void SetWindowRegion(GameFrame frame, ref Point[][] points)
        {
            if (Environment.OSVersion.Platform == PlatformID.Win32NT)
            {
                int size = Marshal.SizeOf(new Point());

                int totalPoints = points.Aggregate(0, (v, p) => v + p.Length);

                if (hPoints == IntPtr.Zero)
                {
                    hPoints = Marshal.AllocCoTaskMem(totalPoints * size);
                }

                if (hCount == IntPtr.Zero)
                {
                    hCount = Marshal.AllocCoTaskMem(points.Length * sizeof(int));
                }

                int c = 0;
                for (int p = 0; p < points.Length; p++)
                {
                    Marshal.WriteInt32(hCount + p * sizeof(int), points[p].Length);

                    for (int i = 0; i < points[p].Length; i++)
                    {
                        Marshal.StructureToPtr(points[p][i], hPoints + c++ *size, false);
                    }
                }

                long hRegion = Win32CreatePolyPolygonRgn(hPoints.ToInt64(), hCount.ToInt64(), points.Length, 1);

                var    win       = frame.Window as AvaloniaWindow;
                IntPtr winHandle = win.PlatformImpl.Handle.Handle;
                Win32SetWindowRgn(winHandle.ToInt32(),
                                  hRegion,
                                  0);

                Win32DeleteObject(hRegion);
            }
            else
            {
                throw new NotImplementedException($"Platform '{Environment.OSVersion.Platform}' not supported.");
            }
        }
Esempio n. 20
0
        public ActionResult ViewAllGameFrames()
        {
            var prox      = new NashClient.NsashServicesClient();
            var twopgames = prox.ChooseGame(2);
            List <GameFrame> twopgamesmodel = new List <GameFrame>();

            for (int i = 0; i < twopgames.Count(); i++)
            {
                GameFrame temp = new GameFrame();
                temp.Title         = twopgames[i].Title;
                temp.MinPlayers    = twopgames[i].MinPlayers;
                temp.MaxPlayers    = twopgames[i].MaxPlayers;
                temp.MinStrategies = twopgames[i].MinStrategies;
                temp.MaxStrategies = twopgames[i].MaxStrategies;
                twopgamesmodel.Add(temp);
            }
            ViewData["GameFrames"] = twopgamesmodel;
            return(View(twopgamesmodel.ToList()));
        }
        void GrabBackground(GameFrame targetFrame)
        {
            gameCamera.farClipPlane  = gameFarClipPlane;
            gameCamera.nearClipPlane = targetFrame.playerDepth - 0.5f * layerOverlap;
            //Start on black background
            gameCamera.clearFlags      = CameraClearFlags.Color | CameraClearFlags.Depth | CameraClearFlags.Skybox;
            gameCamera.backgroundColor = new Color(0, 0, 0, 1);

            RenderGameCamera(gameCamera, targetFrame.backgroundBuffer);

            if (forceToBackground > 0)
            {
                LayerMask oldCull = gameCamera.cullingMask;
                gameCamera.farClipPlane  = targetFrame.playerDepth + 0.5f * layerOverlap;
                gameCamera.nearClipPlane = gameNearClipPlane;
                gameCamera.cullingMask   = forceToBackground;
                gameCamera.clearFlags    = CameraClearFlags.Depth;
                RenderGameCamera(gameCamera, targetFrame.backgroundBuffer);
                gameCamera.cullingMask = oldCull;
            }
        }
Esempio n. 22
0
        public static void MakeTransparent(GameFrame frame, bool transparent)
        {
            var    win       = frame.Window as AvaloniaWindow;
            IntPtr winHandle = win.PlatformImpl.Handle.Handle;

            if (Environment.OSVersion.Platform == PlatformID.Win32NT)
            {
                uint initialStyle = Win32GetWindowLong(winHandle.ToInt32(), -20);

                if (transparent)
                {
                    Win32SetWindowLong(winHandle.ToInt32(), -20, initialStyle | 0x80000 | 0x20);
                }
                else
                {
                    Win32SetWindowLong(winHandle.ToInt32(), -20, initialStyle & ~0x80000 & ~0x20);
                }
            }
            else
            {
                throw new NotImplementedException($"Platform '{Environment.OSVersion.Platform}' not supported.");
            }
        }
Esempio n. 23
0
 private void OnPacketProcessed(UInt16 packet)
 {
     if (packet == (UInt16)SMSGPackets.AvailableCards)
     {
         Application.Current.Dispatcher.Invoke(() =>
         {
             GameFrame.Navigate(new SelectCards());
         });
     }
     else if (packet == (UInt16)SMSGPackets.SelectCards)
     {
         Application.Current.Dispatcher.Invoke(() =>
         {
             GameFrame.Navigate(new PlayingGame());
         });
     }
     else if (packet == (UInt16)SMSGPackets.Achievements)
     {
         Application.Current.Dispatcher.Invoke(() =>
         {
             GameFrame.Navigate(new AchievementsPage());
         });
     }
 }
Esempio n. 24
0
 /// <summary>
 /// Constructor.
 /// </summary>
 public MainWindow()
 {
     InitializeComponent();
     GameFrame.NavigationUIVisibility = System.Windows.Navigation.NavigationUIVisibility.Hidden;
     GameFrame.Navigate(new MainMenu());
 }
 public void SkillBoard_MouseDown_RightButtonControl(object sender, EventArgs e)
 {
     if (_iCurrentBoard == 1)
         return;
     _btLeftSkillControl._sprite[0].Itexture2D = 0;
     _btPassiveSkillControl._sprite[0].Itexture2D = 0;
     _iCurrentBoard = 1;
     _currentBoard = (GameFrame)_boardFrame.Child[_iCurrentBoard];
 }
        //---------------------------------------------------------------------------------------------------
        public void GetResources(List<GameObjectManager> _resources)
        {
            //Khoi tao cac bien Addition
            _lhAddition = 50;
            _rhAddition = 50;
            _passiveAddition = 50;
            _preLevelOfChar = _character.Level;

            _boardFrame = (GameFrame)_resources[0].CreateObject(1);
            _boardFrame.IsVisible = false;

            //Press Button sử dụng chung trên 3 tab.
            _btLeftSkillControl = (Button)_resources[1].CreateObject(2);
            _btLeftSkillControl._sprite[0].Itexture2D = 1; //Được click trước tiên
            _btLeftSkillControl.Mouse_Down += new Button.OnMouseDownHandler(SkillBoard_MouseDown_LeftButtonControl);
            _btLeftSkillControl.IsPressButton = true;

            _btRightSkillControl = (Button)_resources[1].CreateObject(3);
            _btRightSkillControl.Mouse_Down += new Button.OnMouseDownHandler(SkillBoard_MouseDown_RightButtonControl);
            _btRightSkillControl.IsPressButton = true;

            _btPassiveSkillControl = (Button)_resources[1].CreateObject(4);
            _btPassiveSkillControl.Mouse_Down += new Button.OnMouseDownHandler(SkillBoard_MouseDown_PassiveButtonControl);
            _btPassiveSkillControl.IsPressButton = true;

            //LeftHand tab
            #region
            _btLefthandExit = (Button)_resources[1].CreateObject(11);
            _btLefthandExit.Mouse_Click += new Button.OnMouseClickHandler(SkillBoard_MouseClick_LeftExit);
            //Cleaving
            _btSkillCleaving = (Button)_resources[1].CreateObject(5);
            _btSkillCleaving.Owner = _character.ListLeftHandSkill[1];
            _btSkillCleaving.GetNewIdleTexture(_character.ListLeftHandSkill[1].IdleIcon);
            _btSkillCleaving.GetNewClickedTexture(_character.ListLeftHandSkill[1].ClickedIcon);
            _btSkillCleaving.Mouse_Click += new Button.OnMouseClickHandler(SkillBoard_MouseClick_CleavingAttack);
            _btSkillCleaving.Mouse_Hover += new Button.OnMouseHoverHandler(SkillBoard_MouseHover_CleavingAttack);
            _btSkillCleaving.Mouse_Released += new Button.OnMouseReleasedHandler(SkillBoard_MouseRelease_CleavingAttack);

            _lbSkillCleaving = (Label)_resources[2].CreateObject(0);
            _lbSkillCleaving.Owner = _character.ListLeftHandSkill[1];
            //Critical
            _btSkillCritical = (Button)_resources[1].CreateObject(6);
            _btSkillCritical.Owner = _character.ListLeftHandSkill[2];
            _btSkillCritical.GetNewIdleTexture(_character.ListLeftHandSkill[2].IdleIcon);
            _btSkillCritical.GetNewClickedTexture(_character.ListLeftHandSkill[2].ClickedIcon);
            _btSkillCritical.Mouse_Click += new Button.OnMouseClickHandler(SkillBoard_MouseClick_CriticalAttack);
            _btSkillCritical.Mouse_Hover += new Button.OnMouseHoverHandler(SkillBoard_MouseHover_CriticalAttack);
            _btSkillCritical.Mouse_Released += new Button.OnMouseReleasedHandler(SkillBoard_MouseRelease_CriticalAttack);

            _lbSkillCritical = (Label)_resources[2].CreateObject(1);
            _lbSkillCritical.Owner = _character.ListLeftHandSkill[2];
            //Curse
            _btSkillCurse = (Button)_resources[1].CreateObject(7);
            _btSkillCurse.Owner = _character.ListLeftHandSkill[3];
            _btSkillCurse.GetNewIdleTexture(_character.ListLeftHandSkill[3].IdleIcon);
            _btSkillCurse.GetNewClickedTexture(_character.ListLeftHandSkill[3].ClickedIcon);
            _btSkillCurse.Mouse_Click += new Button.OnMouseClickHandler(SkillBoard_MouseClick_CurseAttack);
            _btSkillCurse.Mouse_Hover += new Button.OnMouseHoverHandler(SkillBoard_MouseHover_CurseAttack);
            _btSkillCurse.Mouse_Released += new Button.OnMouseReleasedHandler(SkillBoard_MouseRelease_CurseAttack);

            _lbSkillCurse = (Label)_resources[2].CreateObject(2);
            _lbSkillCurse.Owner = _character.ListLeftHandSkill[3];
            //Overspeed
            _btSkillOverSpeed = (Button)_resources[1].CreateObject(8);
            _btSkillOverSpeed.Owner = _character.ListLeftHandSkill[4];
            _btSkillOverSpeed.GetNewIdleTexture(_character.ListLeftHandSkill[4].IdleIcon);
            _btSkillOverSpeed.GetNewClickedTexture(_character.ListLeftHandSkill[4].ClickedIcon);
            _btSkillOverSpeed.Mouse_Click += new Button.OnMouseClickHandler(SkillBoard_MouseClick_OverSpeedAttack);
            _btSkillOverSpeed.Mouse_Hover += new Button.OnMouseHoverHandler(SkillBoard_MouseHover_OverSpeedAttack);
            _btSkillOverSpeed.Mouse_Released += new Button.OnMouseReleasedHandler(SkillBoard_MouseRelease_OverSpeedAttack);

            _lbSkillOverspeed = (Label)_resources[2].CreateObject(3);
            _lbSkillOverspeed.Owner = _character.ListLeftHandSkill[4];
            //Lifesteal
            _btSkillLifeSteal = (Button)_resources[1].CreateObject(9);
            _btSkillLifeSteal.Owner = _character.ListLeftHandSkill[5];
            _btSkillLifeSteal.GetNewIdleTexture(_character.ListLeftHandSkill[5].IdleIcon);
            _btSkillLifeSteal.GetNewClickedTexture(_character.ListLeftHandSkill[5].ClickedIcon);
            _btSkillLifeSteal.Mouse_Click += new Button.OnMouseClickHandler(SkillBoard_MouseClick_LifeStealAttack);
            _btSkillLifeSteal.Mouse_Hover += new Button.OnMouseHoverHandler(SkillBoard_MouseHover_LifeStealAttack);
            _btSkillLifeSteal.Mouse_Released += new Button.OnMouseReleasedHandler(SkillBoard_MouseRelease_LifeStealAttack);

            _lbSkillLifeSteal = (Label)_resources[2].CreateObject(4);
            _lbSkillLifeSteal.Owner = _character.ListLeftHandSkill[5];
            //Bash
            _btSkillBash = (Button)_resources[1].CreateObject(10);
            _btSkillBash.Owner = _character.ListLeftHandSkill[6];
            _btSkillBash.GetNewIdleTexture(_character.ListLeftHandSkill[6].IdleIcon);
            _btSkillBash.GetNewClickedTexture(_character.ListLeftHandSkill[6].ClickedIcon);
            _btSkillBash.Mouse_Click += new Button.OnMouseClickHandler(SkillBoard_MouseClick_BashAttack);
            _btSkillBash.Mouse_Hover += new Button.OnMouseHoverHandler(SkillBoard_MouseHover_BashAttack);
            _btSkillBash.Mouse_Released += new Button.OnMouseReleasedHandler(SkillBoard_MouseRelease_BashAttack);

            _lbSkillBash = (Label)_resources[2].CreateObject(5);
            _lbSkillBash.Owner = _character.ListLeftHandSkill[6];

            //Label diem cong
            _lbLHAddition = (Label)_resources[2].CreateObject(15);
            _lbLHAddition.StringInfo = _lhAddition.ToString();

            _lefthandFrame = (GameFrame)_resources[0].CreateObject(2);

            //4 vị trí đầu là các control trên tab
            _lefthandFrame.AddChild(_btLeftSkillControl);
            _lefthandFrame.AddChild(_btRightSkillControl);
            _lefthandFrame.AddChild(_btPassiveSkillControl);
            _lefthandFrame.AddChild(_btLefthandExit);
            //Các vị trí còn lại là các button Skill
            _lefthandFrame.AddChild(_btSkillCleaving);
            _lefthandFrame.AddChild(_lbSkillCleaving);

            _lefthandFrame.AddChild(_btSkillCritical);
            _lefthandFrame.AddChild(_lbSkillCritical);

            _lefthandFrame.AddChild(_btSkillCurse);
            _lefthandFrame.AddChild(_lbSkillCurse);

            _lefthandFrame.AddChild(_btSkillOverSpeed);
            _lefthandFrame.AddChild(_lbSkillOverspeed);

            _lefthandFrame.AddChild(_btSkillLifeSteal);
            _lefthandFrame.AddChild(_lbSkillLifeSteal);

            _lefthandFrame.AddChild(_btSkillBash);
            _lefthandFrame.AddChild(_lbSkillBash);

            _lefthandFrame.AddChild(_lbLHAddition);

            //Add vào tab control (Frame mẹ)
            _boardFrame.AddChild(_lefthandFrame);
            #endregion
            //RightHand tab
            #region
            _btRighthandExit = (Button)_resources[1].CreateObject(12);
            _btRighthandExit.Mouse_Click += new Button.OnMouseClickHandler(SkillBoard_MouseClick_RightExit);
            //Deadly bees
            _btDeadlyBeesSkill = (Button)_resources[1].CreateObject(23);
            _btDeadlyBeesSkill.Owner = (Skill)_character.ListRightHandSkill[1];
            _btDeadlyBeesSkill.GetNewIdleTexture(_character.ListRightHandSkill[1].IdleIcon);
            _btDeadlyBeesSkill.GetNewClickedTexture(_character.ListRightHandSkill[1].ClickedIcon);
            _btDeadlyBeesSkill.Mouse_Click += new Button.OnMouseClickHandler(SkillBoard_MouseClick_DeadlyBees);
            _btDeadlyBeesSkill.Mouse_Hover += new Button.OnMouseHoverHandler(SkillBoard_MouseHover_DeadlyBees);
            _btDeadlyBeesSkill.Mouse_Released += new Button.OnMouseReleasedHandler(SkillBoard_MouseRelease_DeadlyBees);

            _lbDeadlyBeesSkill = (Label)_resources[2].CreateObject(6);
            _lbDeadlyBeesSkill.Owner = _character.ListRightHandSkill[1];
            //SoulRelease
            _btSoulRelease = (Button)_resources[1].CreateObject(24);
            _btSoulRelease.Owner = _character.ListRightHandSkill[2];
            _btSoulRelease.GetNewIdleTexture(_character.ListRightHandSkill[2].IdleIcon);
            _btSoulRelease.GetNewClickedTexture(_character.ListRightHandSkill[2].ClickedIcon);
            _btSoulRelease.Mouse_Click += new Button.OnMouseClickHandler(SkillBoard_MouseClick_SoulRelease);
            _btSoulRelease.Mouse_Hover += new Button.OnMouseHoverHandler(SkillBoard_MouseHover_SoulRelease);
            _btSoulRelease.Mouse_Released += new Button.OnMouseReleasedHandler(SkillBoard_MouseRelease_SoulRelease);

            _lbSoulRelease = (Label)_resources[2].CreateObject(7);
            _lbSoulRelease.Owner = _character.ListRightHandSkill[2];
            //Earth shake
            _btEathShakeSkill = (Button)_resources[1].CreateObject(25);
            _btEathShakeSkill.Owner = _character.ListRightHandSkill[3];
            _btEathShakeSkill.GetNewIdleTexture(_character.ListRightHandSkill[3].IdleIcon);
            _btEathShakeSkill.GetNewClickedTexture(_character.ListRightHandSkill[3].ClickedIcon);
            _btEathShakeSkill.Mouse_Click += new Button.OnMouseClickHandler(SkillBoard_MouseClick_EarthShake);
            _btEathShakeSkill.Mouse_Hover += new Button.OnMouseHoverHandler(SkillBoard_MouseHover_EarthShake);
            _btEathShakeSkill.Mouse_Released += new Button.OnMouseReleasedHandler(SkillBoard_MouseRelease_EarthShake);

            _lbEathShakeSkill = (Label)_resources[2].CreateObject(8);
            _lbEathShakeSkill.Owner = _character.ListRightHandSkill[3];
            //Wave form
            _btWaveFormSkill = (Button)_resources[1].CreateObject(26);
            _btWaveFormSkill.Owner = _character.ListRightHandSkill[4];
            _btWaveFormSkill.GetNewIdleTexture(_character.ListRightHandSkill[4].IdleIcon);
            _btWaveFormSkill.GetNewClickedTexture(_character.ListRightHandSkill[4].ClickedIcon);
            _btWaveFormSkill.Mouse_Click += new Button.OnMouseClickHandler(SkillBoard_MouseClick_WaveForm);
            _btWaveFormSkill.Mouse_Hover += new Button.OnMouseHoverHandler(SkillBoard_MouseHover_WaveForm);
            _btWaveFormSkill.Mouse_Released += new Button.OnMouseReleasedHandler(SkillBoard_MouseRelease_WaveForm);

            _lbWaveFormSkill = (Label)_resources[2].CreateObject(9);
            _lbWaveFormSkill.Owner = _character.ListRightHandSkill[4];

            //Lighting Field
            _btLightingField = (Button)_resources[1].CreateObject(27);
            _btLightingField.Owner = _character.ListRightHandSkill[5];
            _btLightingField.GetNewIdleTexture(_character.ListRightHandSkill[5].IdleIcon);
            _btLightingField.GetNewClickedTexture(_character.ListRightHandSkill[5].ClickedIcon);
            _btLightingField.Mouse_Click += new Button.OnMouseClickHandler(SkillBoard_MouseClick_LightingField);
            _btLightingField.Mouse_Hover += new Button.OnMouseHoverHandler(SkillBoard_MouseHover_LightingField);
            _btLightingField.Mouse_Released += new Button.OnMouseReleasedHandler(SkillBoard_MouseRelease_LightingField);

            _lbLightingField = (Label)_resources[2].CreateObject(10);
            _lbLightingField.Owner = _character.ListRightHandSkill[5];
            //Invisible
            _btInvisible = (Button)_resources[1].CreateObject(28);
            _btInvisible.Owner = _character.ListRightHandSkill[6];
            _btInvisible.GetNewIdleTexture(_character.ListRightHandSkill[6].IdleIcon);
            _btInvisible.GetNewClickedTexture(_character.ListRightHandSkill[6].ClickedIcon);
            _btInvisible.Mouse_Click += new Button.OnMouseClickHandler(SkillBoard_MouseClick_Invisible);
            _btInvisible.Mouse_Hover += new Button.OnMouseHoverHandler(SkillBoard_MouseHover_Invisible);
            _btInvisible.Mouse_Released += new Button.OnMouseReleasedHandler(SkillBoard_MouseRelease_Invisible);

            _lbInvisible = (Label)_resources[2].CreateObject(11);
            _lbInvisible.Owner = _character.ListRightHandSkill[6];

            //Label diem cong
            _lbRHAddition = (Label)_resources[2].CreateObject(15);
            _lbRHAddition.StringInfo = _rhAddition.ToString();

            //RightthandFrame-hand frame
            _rightthandFrame = (GameFrame)_resources[0].CreateObject(3);
            _rightthandFrame.AddChild(_btLeftSkillControl);
            _rightthandFrame.AddChild(_btRightSkillControl);
            _rightthandFrame.AddChild(_btPassiveSkillControl);
            _rightthandFrame.AddChild(_btRighthandExit);

            _rightthandFrame.AddChild(_btDeadlyBeesSkill);
            _rightthandFrame.AddChild(_lbDeadlyBeesSkill);

            _rightthandFrame.AddChild(_btSoulRelease);
            _rightthandFrame.AddChild(_lbSoulRelease);

            _rightthandFrame.AddChild(_btEathShakeSkill);
            _rightthandFrame.AddChild(_lbEathShakeSkill);

            _rightthandFrame.AddChild(_btWaveFormSkill);
            _rightthandFrame.AddChild(_lbWaveFormSkill);

            _rightthandFrame.AddChild(_btLightingField);
            _rightthandFrame.AddChild(_lbLightingField);

            _rightthandFrame.AddChild(_btInvisible);
            _rightthandFrame.AddChild(_lbInvisible);

            _rightthandFrame.AddChild(_lbRHAddition);

            _boardFrame.AddChild(_rightthandFrame);
            #endregion
            //Passive tab
            #region
            _btPassiveExit = (Button)_resources[1].CreateObject(13);
            _btPassiveExit.Mouse_Click += new Button.OnMouseClickHandler(SkillBoard_MouseClick_PassiveExit);

            //Great Fortitude
            _btGreatFortitude = (Button)_resources[1].CreateObject(37);
            _btGreatFortitude.Owner = _character.ListPassiveSkill[0];
            _btGreatFortitude.GetNewIdleTexture(_character.ListPassiveSkill[0].IdleIcon);
            _btGreatFortitude.GetNewClickedTexture(_character.ListPassiveSkill[0].ClickedIcon);
            _btGreatFortitude.Mouse_Click += new Button.OnMouseClickHandler(SkillBoard_MouseClick_GreatFortitude);
            _btGreatFortitude.Mouse_Hover += new Button.OnMouseHoverHandler(SkillBoard_MouseHover_GreatFortitude);
            _btGreatFortitude.Mouse_Released += new Button.OnMouseReleasedHandler(SkillBoard_MouseRelease_GreatFortitude);

            _lbbtGreatFortitude = (Label)_resources[2].CreateObject(12);
            _lbbtGreatFortitude.Owner = _character.ListPassiveSkill[0];

            //God Strenght
            _btGodStrength = (Button)_resources[1].CreateObject(38);
            _btGodStrength.Owner = _character.ListPassiveSkill[1];
            _btGodStrength.GetNewIdleTexture(_character.ListPassiveSkill[1].IdleIcon);
            _btGodStrength.GetNewClickedTexture(_character.ListPassiveSkill[1].ClickedIcon);
            _btGodStrength.Mouse_Click += new Button.OnMouseClickHandler(SkillBoard_MouseClick_GodStrenght);
            _btGodStrength.Mouse_Hover += new Button.OnMouseHoverHandler(SkillBoard_MouseHover_GodStrenght);
            _btGodStrength.Mouse_Released += new Button.OnMouseReleasedHandler(SkillBoard_MouseRelease_GodStrenght);

            _lbGodStrength = (Label)_resources[2].CreateObject(13);
            _lbGodStrength.Owner = _character.ListPassiveSkill[1];

            //BLur
            _btBlur = (Button)_resources[1].CreateObject(39);
            _btBlur.Owner = _character.ListPassiveSkill[2];
            _btBlur.GetNewIdleTexture(_character.ListPassiveSkill[2].IdleIcon);
            _btBlur.GetNewClickedTexture(_character.ListPassiveSkill[2].ClickedIcon);
            _btBlur.Mouse_Click += new Button.OnMouseClickHandler(SkillBoard_MouseClick_Blur);
            _btBlur.Mouse_Hover += new Button.OnMouseHoverHandler(SkillBoard_MouseHover_Blur);
            _btBlur.Mouse_Released += new Button.OnMouseReleasedHandler(SkillBoard_MouseRelease_Blur);

            _lbBlur = (Label)_resources[2].CreateObject(14);
            _lbBlur.Owner = _character.ListPassiveSkill[2];

            //label diem cong
            _lbPassiveAddtion = (Label)_resources[2].CreateObject(15);
            _lbPassiveAddtion.StringInfo = _passiveAddition.ToString();

            //Passive frame
            _passiveFrame = (GameFrame)_resources[0].CreateObject(4);
            _passiveFrame.AddChild(_btLeftSkillControl);
            _passiveFrame.AddChild(_btRightSkillControl);
            _passiveFrame.AddChild(_btPassiveSkillControl);
            _passiveFrame.AddChild(_btPassiveExit);

            _passiveFrame.AddChild(_btGreatFortitude);
            _passiveFrame.AddChild(_lbbtGreatFortitude);

            _passiveFrame.AddChild(_btGodStrength);
            _passiveFrame.AddChild(_lbGodStrength);

            _passiveFrame.AddChild(_btBlur);
            _passiveFrame.AddChild(_lbBlur);

            _passiveFrame.AddChild(_lbPassiveAddtion);

            _boardFrame.AddChild(_passiveFrame);
            #endregion
            _iCurrentBoard = 0;
            _currentBoard = (GameFrame)_boardFrame.Child[_iCurrentBoard];
            _rect = new Rectangle((int)_boardFrame.X, (int)_boardFrame.Y, (int)_boardFrame.Width, (int)_boardFrame.Height);

            //Khởi tạo 1 số giá trị mặt định về skill của nhân vật
            //Left hand
            //_btSkillCurse.Endalbe = false;
            //_btSkillOverSpeed.Endalbe = false;
            //_btSkillLifeSteal.Endalbe = false;
            //_btSkillBash.Endalbe = false;
            //Right
            //_btEathShakeSkill.Endalbe = false;
            //_btWaveFormSkill.Endalbe = false;
            //_btLightingField.Endalbe = false;
            //_btInvisible.Endalbe = false;
            //Passive
            //_btGodStrength.Endalbe = false;
            //_btBlur.Endalbe = false;
        }
        public void GetResources(List<GameObjectManager> _resouces)
        {
            HealbarFrame = (GameFrame)_resouces[0].CreateObject(0);
            BloodPro = (ProcessBar)_resouces[1].CreateObject(0);
            ManaPro = (ProcessBar)_resouces[1].CreateObject(1);

            //Button left
            _btLeftCommand = (Button)_resouces[2].CreateObject(0);
            _btLeftCommand.Mouse_Click += new Button.OnMouseClickHandler(LeftCommandButon_Clicked);
            HealbarFrame.AddChild(_btLeftCommand);

            _btRightCommand = (Button)_resouces[2].CreateObject(1);
            _btRightCommand.Mouse_Click += new Button.OnMouseClickHandler(RightCommandButon_Clicked);
            HealbarFrame.AddChild(_btRightCommand);

            _btLefthandSkill = (Button)_resouces[2].CreateObject(14);
            _btLefthandSkill.Owner = _character.ListLeftHandSkill[0];
            _btLefthandSkill.GetNewIdleTexture(_character.ListLeftHandSkill[0].IdleIcon);
            _btLefthandSkill.GetNewClickedTexture(_character.ListLeftHandSkill[0].ClickedIcon);
            _btLefthandSkill.Mouse_Click += new Button.OnMouseClickHandler(LeftSkillButon_Clicked);
            _btLefthandSkill.Mouse_Hover += new Button.OnMouseHoverHandler(LeftSkillButon_Hover);
            _btLefthandSkill.Mouse_Released += new Button.OnMouseReleasedHandler(LeftSkillButon_Release);
            HealbarFrame.AddChild(_btLefthandSkill);

            //Button right
            _btRighthandSkill = (Button)_resouces[2].CreateObject(22);
            _btRighthandSkill.Owner = _character.ListRightHandSkill[0];
            _btRighthandSkill.GetNewIdleTexture(_character.ListRightHandSkill[0].IdleIcon);
            _btRighthandSkill.GetNewClickedTexture(_character.ListRightHandSkill[0].ClickedIcon);
            _btRighthandSkill.Mouse_Click += new Button.OnMouseClickHandler(RightSkillButon_Clicked);
            _btRighthandSkill.Mouse_Hover += new Button.OnMouseHoverHandler(RightSkillButon_Hover);
            _btRighthandSkill.Mouse_Released += new Button.OnMouseReleasedHandler(RightSkillButon_Release);
            HealbarFrame.AddChild(_btRighthandSkill);

            _coolDownRightSkill = (ProcessBar)_resouces[1].CreateObject(2);
            _healbarFrame.AddChild(_coolDownRightSkill);

            _coolDownLeftSkill = (ProcessBar)_resouces[1].CreateObject(3);
            _healbarFrame.AddChild(_coolDownLeftSkill);

            _levelProcess = (ProcessBar)_resouces[1].CreateObject(4);
            _healbarFrame.AddChild(_levelProcess);

            _btCMUpButton = (Button)_resouces[2].CreateObject(35);
            _btCMUpButton.Mouse_Click += new Button.OnMouseClickHandler(UpCommandbutton_Clicked);
            _healbarFrame.AddChild (_btCMUpButton);

            //item blood, mana, both
            _itemFrame = (GameFrame)_resouces[0].CreateObject(10);
            _itemFrame.X += _healbarFrame.X;
            _itemFrame.Y += _healbarFrame.Y;

            _btBlood = (Button)_resouces[2].CreateObject(47);
            _btBlood.Mouse_Click += new Button.OnMouseClickHandler(BloodButton_Clicked);

            _lbBlood = (Label)_resouces[3].CreateObject(16);
            _lbBlood.StringInfo = _character.HPPortion.Count.ToString();

            _itemFrame.AddChild(_btBlood);
            _itemFrame.AddChild(_lbBlood);
            //mana
            _btMana = (Button)_resouces[2].CreateObject(48);
            _btMana.Mouse_Click += new Button.OnMouseClickHandler(ManaButton_Clicked);

            _lbMana = (Label)_resouces[3].CreateObject(17);
            _lbMana.StringInfo = _character.MPPortion.Count.ToString();

            _itemFrame.AddChild(_btMana);
            _itemFrame.AddChild(_lbMana);

            //both
            _btBloodNMana = (Button)_resouces[2].CreateObject(49);
            _btBloodNMana.Mouse_Click += new Button.OnMouseClickHandler(BloodNManaButton_Clicked);

            _lbBloodNMana = (Label)_resouces[3].CreateObject(18);
            _lbBloodNMana.StringInfo = _character.RestorePortion.Count.ToString();

            _itemFrame.AddChild(_btBloodNMana);
            _itemFrame.AddChild(_lbBloodNMana);

            _rect = new Rectangle((int)_healbarFrame.X, (int)_healbarFrame.Y, (int)_healbarFrame.Width, (int)_healbarFrame.Height);
        }
Esempio n. 28
0
 private void Setup()
 {
     game      = new Game();
     gameFrame = new GameFrame();
 }
        public void GetResources(List<GameObjectManager> _resources)
        {
            _mainFrame = (GameFrame)_resources[0].CreateObject(5);
            _mainFrame.IsVisible = false;

            _btNormalAttack = (Button)_resources[1].CreateObject(15);
            _btNormalAttack.Owner = Character.ListLeftHandSkill[0];
            _btNormalAttack.GetNewIdleTexture(Character.ListLeftHandSkill[0].IdleIcon);
            _btNormalAttack.GetNewClickedTexture(Character.ListLeftHandSkill[0].ClickedIcon);
            _btNormalAttack.Mouse_Click += new Button.OnMouseClickHandler(NormalAttack_MouseClicked);
            _btNormalAttack.Mouse_Hover += new Button.OnMouseHoverHandler(NormalAttack_MouseHover);
            _btNormalAttack.Mouse_Released += new Button.OnMouseReleasedHandler(NormalAttack_MouseRelease);

            _btSkillCleaving = (Button)_resources[1].CreateObject(16);
            _btSkillCleaving.Owner = Character.ListLeftHandSkill[1];
            _btSkillCleaving.GetNewIdleTexture(Character.ListLeftHandSkill[1].IdleIcon);
            _btSkillCleaving.GetNewClickedTexture(Character.ListLeftHandSkill[1].ClickedIcon);
            _btSkillCleaving.Mouse_Click += new Button.OnMouseClickHandler(SkillCleaving_MouseClicked);
            _btSkillCleaving.Mouse_Hover += new Button.OnMouseHoverHandler(SkillCleaving_MouseHover);
            _btSkillCleaving.Mouse_Released += new Button.OnMouseReleasedHandler(SkillCleaving_MouseRelease);

            _btSkillCritical = (Button)_resources[1].CreateObject(17);
            _btSkillCritical.Owner = Character.ListLeftHandSkill[2];
            _btSkillCritical.GetNewIdleTexture(Character.ListLeftHandSkill[2].IdleIcon);
            _btSkillCritical.GetNewClickedTexture(Character.ListLeftHandSkill[2].ClickedIcon);
            _btSkillCritical.Mouse_Click += new Button.OnMouseClickHandler(SkillCritical_MouseClicked);
            _btSkillCritical.Mouse_Hover += new Button.OnMouseHoverHandler(SkillCritical_MouseHover);
            _btSkillCritical.Mouse_Released += new Button.OnMouseReleasedHandler(SkillCritical_MouseRelease);

            _btSkillCurse = (Button)_resources[1].CreateObject(18);
            _btSkillCurse.Owner = Character.ListLeftHandSkill[3];
            _btSkillCurse.GetNewIdleTexture(Character.ListLeftHandSkill[3].IdleIcon);
            _btSkillCurse.GetNewClickedTexture(Character.ListLeftHandSkill[3].ClickedIcon);
            _btSkillCurse.Mouse_Click += new Button.OnMouseClickHandler(SkillCurse_MouseClicked);
            _btSkillCurse.Mouse_Hover += new Button.OnMouseHoverHandler(SkillCurse_MouseHover);
            _btSkillCurse.Mouse_Released += new Button.OnMouseReleasedHandler(SkillCurse_MouseRelease);

            _btSkillOverspeed = (Button)_resources[1].CreateObject(19);
            _btSkillOverspeed.Owner = Character.ListLeftHandSkill[4];
            _btSkillOverspeed.GetNewIdleTexture(Character.ListLeftHandSkill[4].IdleIcon);
            _btSkillOverspeed.GetNewClickedTexture(Character.ListLeftHandSkill[4].ClickedIcon);
            _btSkillOverspeed.Mouse_Click += new Button.OnMouseClickHandler(SkillOverspeed_MouseClicked);
            _btSkillOverspeed.Mouse_Hover += new Button.OnMouseHoverHandler(SkillOverSpeed_MouseHover);
            _btSkillOverspeed.Mouse_Released += new Button.OnMouseReleasedHandler(SkillOverSpeed_MouseRelease);

            _btSkillLifeSteal = (Button)_resources[1].CreateObject(20);
            _btSkillLifeSteal.Owner = Character.ListLeftHandSkill[5];
            _btSkillLifeSteal.GetNewIdleTexture(Character.ListLeftHandSkill[5].IdleIcon);
            _btSkillLifeSteal.GetNewClickedTexture(Character.ListLeftHandSkill[5].ClickedIcon);
            _btSkillLifeSteal.Mouse_Click += new Button.OnMouseClickHandler(SkillLifeSteal_MouseClicked);
            _btSkillLifeSteal.Mouse_Hover += new Button.OnMouseHoverHandler(SkillLifeSteal_MouseHover);
            _btSkillLifeSteal.Mouse_Released += new Button.OnMouseReleasedHandler(SkillLifeSteal_MouseRelease);

            _btSkillBash = (Button)_resources[1].CreateObject(21);
            _btSkillBash.Owner = Character.ListLeftHandSkill[6];
            _btSkillBash.GetNewIdleTexture(Character.ListLeftHandSkill[6].IdleIcon);
            _btSkillBash.GetNewClickedTexture(Character.ListLeftHandSkill[6].ClickedIcon);
            _btSkillBash.Mouse_Click += new Button.OnMouseClickHandler(SkillBash_MouseClicked);
            _btSkillBash.Mouse_Hover += new Button.OnMouseHoverHandler(SkillBash_MouseHover);
            _btSkillBash.Mouse_Released += new Button.OnMouseReleasedHandler(SkillBash_MouseRelease);

            _mainFrame.AddChild(_btNormalAttack);
            _mainFrame.AddChild(_btSkillCleaving);
            _mainFrame.AddChild(_btSkillCritical);
            _mainFrame.AddChild(_btSkillCurse);
            _mainFrame.AddChild(_btSkillOverspeed);
            _mainFrame.AddChild(_btSkillLifeSteal);
            _mainFrame.AddChild(_btSkillBash);
        }
Esempio n. 30
0
        public GameBuilder GameFrame(GameFrame frame)
        {
            this.Frame = frame;

            return(this);
        }
Esempio n. 31
0
        public static void Main(string[] args)
        {
            WavPlayer.Init(WavProvider);
            WavPlayer.Play();
            Keyboard = new WindowsKeyController(keyMap.ToDictionary(kvp => (int)kvp.Key, kvp => (int)kvp.Value));
            Mouse    = new WindowsMouseController(mouseMap.ToDictionary(kvp => (int)kvp.Key, kvp => (int)kvp.Value));

            Builder = new GameBuilder();
            Builder.GameEngine(new FixedTickEngine(TPS))
            .GameView(new GameView2D(ScreenWidth, ScreenHeight, Scale, Scale, Color.DarkSlateGray))
            .GameFrame(new GameFrame(new AvaloniaWindowBuilder(), 0, 0, ScreenWidth, ScreenHeight, Scale, Scale))
            .Controller(Keyboard)
            .Controller(Mouse)
            .Build();

            Engine = Builder.Engine;

            GameFrame      frame  = Builder.Frame;
            AvaloniaWindow window = frame.Window as AvaloniaWindow;

            Referee         = new Referee();
            Engine.TickEnd += Referee.Tick;

            Sprites();

            Rules();

            SetupLevels();

            SetupTitleScreen();

            Engine.TickEnd += (s, gs) =>
            {
                if (Iframe > 0)
                {
                    Iframe--;
                }

                if (Program.Keyboard[(int)Actions.ESCAPE].IsPress())
                {
                    Program.WavPlayer.Stop();
                    Program.WavProvider.RemoveAllMixerInputs();
                    StopMovingWindow();
                    SetupTitleScreen();
                }

                if (Program.Keyboard[(int)Actions.DIAGS].IsPress())
                {
                    ShowDiags = !ShowDiags;
                }

                if (Program.Keyboard[(int)Actions.RESTART].IsPress())
                {
                    if ((Program.Referee.OutofControl || Program.Level == 7) && !Engine.Location.GetEntities <Banner>().Any())
                    {
                        return;
                    }

                    if (Engine.Location.GetEntities <Banner>().FirstOrDefault()?.Text == "you win")
                    {
                        if (Level == -1)
                        {
                            for (int i = 0; i < 10; i++)
                            {
                                Referee.AddRule(Rule.GetNameRandomRule());
                            }
                        }
                        else
                        {
                            Level++;
                        }
                    }

                    StopMovingWindow();
                    Program.WavPlayer.Stop();
                    Program.WavProvider.RemoveAllMixerInputs();
                    // Levels can call the reset with something different
                    Referee.ResetTimer();

                    switch (Level)
                    {
                    case -1:
                        SetupCrazyMode();
                        break;

                    case 0:
                        break;

                    case 8:
                        SetupCredits();
                        Level = 9;
                        break;

                    case 9:
                        if (CreditsFinished)
                        {
                            SetupThanksForPlaying();
                            Level = 10;
                        }
                        break;

                    case 10:
                        SetupTitleScreen();
                        break;

                    default:
                        if (CreditsFinished)
                        {
                            StartingLevel = Level;
                            Levels[Level - 1].SetupLevel();
                        }
                        break;
                    }

                    if (Program.Diff == Difficulty.NORMAL && Level == 7)
                    {
                        Lives = 3;
                    }
                    else if (Program.Diff == Difficulty.EASY && Level == 7)
                    {
                        Lives = 4;
                    }
                    else
                    {
                        Lives = 1;
                    }
                }
            };

            Engine.Start();

            while (true)
            {
            }
        }
        public override bool InitOne(ContentManager content, int id)
        {
            XmlDocument _doc = new XmlDocument();
            _doc.Load(_xmlInfo);
            XmlNode _frame = _doc.SelectSingleNode(@"//Frame[@id = '" + id.ToString() + "']");

            _prototype[id] = new GameFrame();

            string _backgroundPath = _frame.SelectSingleNode("BackGround").InnerText;
            if (_backgroundPath == "Null")
            {
                _prototype[id]._nsprite = 0;
                _prototype[id]._sprite = null;
            }
            else
            {
                _prototype[id]._nsprite = 1;
                _prototype[id]._sprite = new GameSprite [_prototype[id]._nsprite];
                Texture2D _temp = content.Load<Texture2D>(_backgroundPath);
                _prototype[id]._sprite[0] = new GameSprite(_temp, 0, 0);
            }

            _prototype[id].X = int.Parse(_frame.SelectSingleNode("X").InnerText);
            _prototype[id].Y = int.Parse(_frame.SelectSingleNode("Y").InnerText);
            _prototype[id].OffSetX = _prototype[id].X;
            _prototype[id].OffSetY = _prototype[id].Y;
            _prototype[id].Width = int.Parse(_frame.SelectSingleNode("Width").InnerText);
            _prototype[id].Height = int.Parse(_frame.SelectSingleNode("Height").InnerText);
            _prototype[id].Rect = new Rectangle((int)_prototype[id].X,
                (int)_prototype[id].Y,
                (int)_prototype[id].Width,
                (int)_prototype[id].Height);
            ((GameFrame)_prototype[id]).DelayTime = int.Parse(_frame.SelectSingleNode("DelayTime").InnerText);

            MotionInfo _frameMoveInfo = new MotionInfo();
            XmlNode moveInfo = _frame.SelectSingleNode(@"MoveInfo");

            _frameMoveInfo.FirstDection = moveInfo.SelectSingleNode(@"FirstDirection").InnerText;

            if (_frameMoveInfo.FirstDection == "Null")
                _frameMoveInfo = null;
            else
            {
                _frameMoveInfo.IsStanding = false;

                string temp = moveInfo.SelectSingleNode(@"StandingGround").InnerText;
                if (temp == "Null")
                    _frameMoveInfo.StandingGround = float.MinValue;
                else
                    _frameMoveInfo.StandingGround = float.Parse(temp);

                _frameMoveInfo.Vel = new Vector2(float.Parse(moveInfo.SelectSingleNode(@"Velocity").SelectSingleNode(@"X").InnerText),
                    float.Parse(moveInfo.SelectSingleNode(@"Velocity").SelectSingleNode(@"Y").InnerText));

                _frameMoveInfo.Accel = new Vector2(float.Parse(moveInfo.SelectSingleNode(@"Acceleration").SelectSingleNode(@"X").InnerText),
                    float.Parse(moveInfo.SelectSingleNode(@"Acceleration").SelectSingleNode(@"Y").InnerText));

                _frameMoveInfo.DecelerationRate = float.Parse(moveInfo.SelectSingleNode(@"DecelerationRate").InnerText) / 10;

                //Cái này la thang Owner nó sẽ trỏ tới cái gameframe trên prototype
                //Khi clone ra 1 gameframe mới thì phai set lai cai owner này
                //trỏ tới đúng đối tượng button mới duoc clone ra
                //---->>Khong là mọi chuyện hỏng bét.
                _frameMoveInfo.Owner = _prototype[id];
            }
            ((GameFrame)_prototype[id]).Motion = _frameMoveInfo;
            return true;
        }
Esempio n. 33
0
        public static async Task Main(string[] args)
        {
            Engine = new FixedTickEngine(144);

#if WinForm
            GameView2D view = new GameView2D(new Drawer2DSystemDrawing(), 240, 160, 4, 4, Color.FromArgb(0, Color.Magenta), 2);
#endif
#if Avalonia
            var        drawer = new Drawer2DAvalonia();
            GameView2D view   = new GameView2D(drawer, 240, 160, 4, 4, Color.FromArgb(0, Color.Transparent));
#endif
            view.ScrollTop     = view.Height / 2;
            view.ScrollBottom  = view.Height / 2 - 16;
            view.ScrollLeft    = view.Width / 2;
            view.ScrollRight   = view.Width / 2 - 16;
            Engine.TickEnd(0) += view.Tick;
            Engine.SetView(0, view);
            Engine.SetLocation(0, Location.Load("GridWalkRPG.Maps.map.dat"));
#if WinForm
            Frame = new GameFrame(new WinFormWindowBuilder(), 0, 0, 240, 160, 4, 4);
#endif
#if Avalonia
            Frame = new GameFrame(
                new AvaloniaWindowBuilder()
                //.TopMost(true)
                //.Decorations(Avalonia.Controls.SystemDecorations.None)
                .Transparency(Avalonia.Controls.WindowTransparencyLevel.Transparent)
                .StartupLocation(Avalonia.Controls.WindowStartupLocation.CenterScreen)
                .CanResize(false)
                .ShowInTaskBar(false),
                0, 0, 240, 160, 4, 4);
#endif
            Engine.DrawEnd(0) += Frame.DrawHandle;
            Frame.Start();

            await Avalonia.Threading.Dispatcher.UIThread.InvokeAsync(() =>
            {
                Frame.SetBounds(0, 0, 2560, 1440);
                view.Resize(2560, 1440);
            });

            var frame2 = new GameFrame(
                new AvaloniaWindowBuilder()
                .TopMost(true)
                .StartupLocation(Avalonia.Controls.WindowStartupLocation.CenterScreen),
                0, 0, 240, 160, 4, 4);
            Engine.DrawEnd(0) += (s, v) => frame2.DrawHandle(s, v);
            frame2.Start();

            WindowsKeyController controller = new WindowsKeyController(keymap);
            Engine.AddController(0, controller);

            Frame.Window.Hook(controller);

            DescriptionPlayer dp     = new DescriptionPlayer(new Sprite("circle", "Sprites.circle.png", 16, 16), 48, 48);
            Entity            player = new Entity(dp);
            Guid          playerId   = player.Id;
            PlayerActions pActions   = new PlayerActions(Engine.GetControllerIndex(0, controller));
            Engine.TickEnd(0) += (s, e) => Entity.Entities[playerId].TickAction = pActions.TickAction;
            player.TickAction  = pActions.TickAction;
            Engine.AddEntity(0, player);

#if Avalonia
            //AvaloniaWindowBuilder.MakeTransparent(Frame, true);

            //dp.AddMovementListener(d => AvaloniaWindowBuilder.SetWindowRegion(Frame, d.X - (Engine.View as GameView2D).ViewBounds.X, d.Y - (Engine.View as GameView2D).ViewBounds.Y, d.Width, d.Height));

            var points = new AvaloniaWindowBuilder.Point[] {
                new AvaloniaWindowBuilder.Point {
                },
                new AvaloniaWindowBuilder.Point {
                },
                new AvaloniaWindowBuilder.Point {
                },
                new AvaloniaWindowBuilder.Point {
                },
            };

            //dp.AddMovementListener(d => {
            //    points[0].x = (int)d.X - (Engine.View as GameView2D).ViewBounds.X;
            //    points[0].y = (int)d.Y - (Engine.View as GameView2D).ViewBounds.Y;

            //    points[1].x = (int)d.X - (Engine.View as GameView2D).ViewBounds.X;
            //    points[1].y = (int)d.Y - (Engine.View as GameView2D).ViewBounds.Y - 10;

            //    points[2].x = (int)d.X - (Engine.View as GameView2D).ViewBounds.X + 10;
            //    points[2].y = (int)d.Y - (Engine.View as GameView2D).ViewBounds.Y - 10;

            //    points[3].x = (int)d.X - (Engine.View as GameView2D).ViewBounds.X + 20;
            //    points[3].y = (int)d.Y - (Engine.View as GameView2D).ViewBounds.Y + 20;

            //    for (int i = 0; i < points.Length; i++)
            //    {
            //        points[i].x *= 4;
            //        points[i].y *= 4;
            //    }

            //    AvaloniaWindowBuilder.SetWindowRegion(Frame, ref points);
            //});

            var pointarray = new AvaloniaWindowBuilder.Point[][] {
                new AvaloniaWindowBuilder.Point[] {
                    new AvaloniaWindowBuilder.Point(),
                    new AvaloniaWindowBuilder.Point(),
                    new AvaloniaWindowBuilder.Point(),
                    new AvaloniaWindowBuilder.Point(),
                },
                new AvaloniaWindowBuilder.Point[] {
                    new AvaloniaWindowBuilder.Point(),
                    new AvaloniaWindowBuilder.Point(),
                    new AvaloniaWindowBuilder.Point(),
                    new AvaloniaWindowBuilder.Point(),
                },
            };

            //dp.AddMovementListener(d =>
            //{
            //    pointarray[0][0].x = (int)d.X - (Engine.View as GameView2D).ViewBounds.X;
            //    pointarray[0][0].y = (int)d.Y - (Engine.View as GameView2D).ViewBounds.Y;
            //    pointarray[0][1].x = (int)d.X - (Engine.View as GameView2D).ViewBounds.X;
            //    pointarray[0][1].y = (int)d.Y - (Engine.View as GameView2D).ViewBounds.Y - 10;
            //    pointarray[0][2].x = (int)d.X - (Engine.View as GameView2D).ViewBounds.X + 10;
            //    pointarray[0][2].y = (int)d.Y - (Engine.View as GameView2D).ViewBounds.Y - 10;
            //    pointarray[0][3].x = (int)d.X - (Engine.View as GameView2D).ViewBounds.X + 20;
            //    pointarray[0][3].y = (int)d.Y - (Engine.View as GameView2D).ViewBounds.Y + 20;

            //    pointarray[1][0].x = (int)d.X - (Engine.View as GameView2D).ViewBounds.X + 20;
            //    pointarray[1][0].y = (int)d.Y - (Engine.View as GameView2D).ViewBounds.Y + 20;
            //    pointarray[1][1].x = (int)d.X - (Engine.View as GameView2D).ViewBounds.X + 30;
            //    pointarray[1][1].y = (int)d.Y - (Engine.View as GameView2D).ViewBounds.Y + 40;
            //    pointarray[1][2].x = (int)d.X - (Engine.View as GameView2D).ViewBounds.X + 30;
            //    pointarray[1][2].y = (int)d.Y - (Engine.View as GameView2D).ViewBounds.Y + 30;
            //    pointarray[1][3].x = (int)d.X - (Engine.View as GameView2D).ViewBounds.X + 20;
            //    pointarray[1][3].y = (int)d.Y - (Engine.View as GameView2D).ViewBounds.Y + 30;

            //    for (int p = 0; p < pointarray.Length; p++)
            //    {
            //        for (int i = 0; i < pointarray[p].Length; i++)
            //        {
            //            pointarray[p][i].x *= 4;
            //            pointarray[p][i].y *= 4;
            //        }
            //    }

            //    AvaloniaWindowBuilder.SetWindowRegion(Frame, ref pointarray);
            //});

            short prevState = AvaloniaWindowBuilder.GetKeyState(0xA1);
            Engine.TickEnd(0) += (s, e) =>
            {
                short state = AvaloniaWindowBuilder.GetKeyState(0xA1);
                if (prevState != state)
                {
                    Console.WriteLine(state);
                    if (state != 0 && state != 1)
                    {
                        AvaloniaWindowBuilder.MakeTransparent(Frame, false);
                    }
                    else
                    {
                        AvaloniaWindowBuilder.MakeTransparent(Frame, true);
                    }
                }

                prevState = state;
            };
#endif

            view.Follow(player.Description as Description2D);
            Engine.TickEnd(0) += (s, e) => view.Follow(Entity.Entities[playerId].Description as Description2D);


            MML mml = new MML(new string[] {
                ////// Good // https://www.reddit.com/r/archebards/comments/26rjdt/ocarina_of_time/
                ////"r1l8<faaafaaafaaafaaaegggeggcegggeggcfaaafaaafaaafaaaegggeggcegggeggc1",
                ////"r1l8>fab4fab4fab>ed4c-c<bge2&edege2.fab4fab4fab>ed4c-ce<bg2&gbgde1",
                ////"r1l2<ffffccccffffcccc"

                // Very good // https://www.gaiaonline.com/guilds/viewtopic.php?page=1&t=23690909#354075091
                "l16o3f8o4crcrcro3f8o4crcrcro3f8o4crcrcro3f8o4crcro3cre8o4crcrcro3e8o4crcrcro3e8o4crcrcro3e8o4crcro3c8f8o4crcrcro3f8o4crcrcro3f8o4crcrcro3f8o4crcro3cro3e8o4crcrcro3e8o4crcrcro3e8o4crcrcro3e8o4crcrc8o3drardraro2gro3gro2gro3grcro4cro3cro4cro2aro3aro2aro3aro3drardraro2gro3gro2gro3grcro4cro3cro4cro2aro3aro2aro3aro3drardraro2gro3gro2gro3grcro4cro3cro4cro2aro3aro2aro3aro3drararrrdrararrrcrbrbrrrcrbrbrrrerarrrarerarrrarerg#rg#rg#rg#rrre&er",
                "l16o5frarb4frarb4frarbr>erd4<b8>cr<brgre2&e8drergre2&e4frarb4frarb4frarbr>erd4<b8>crer<brg2&g8brgrdre2&e4r1r1frgra4br>crd4e8frg2&g4r1r1<f8era8grb8ar>c8<br>d8cre8drf8er<b>cr<ab1&b2r4e&e&er",
                "l16r1r1r1r1r1r1r1r1o4drerf4grarb4>c8<bre2&e4drerf4grarb4>c8dre2&e4<drerf4grarb4>c8<bre2&e4d8crf8erg8fra8grb8ar>c8<br>d8crefrde1&e2r4"
            });
            //Frame.PlayTrack(new AvaloniaTrack(mml));

            TileMap map = Engine.Location(0).Description as TileMap;

            if (map != null)
            {
                // This is a hack to make the walls spawn where tree tiles are.
                for (int x = 0; x < map.Width; x += 16)
                {
                    for (int y = 0; y < map.Height; y += 16)
                    {
                        switch (map[x / map.Sprite.Width, y / map.Sprite.Height])
                        {
                        case 3:
                        case 4:
                        case 19:
                        case 20:
                            Engine.Location(0).AddEntity(new Entity(new WallDescription(x, y, 16, 16)));
                            break;
                        }
                    }
                }
            }

            watchSecond = new Stopwatch();
            watchSecond.Start();
            watchTickTime = new Stopwatch();

            Engine.TickEnd(0)   += TickInfo;
            Engine.TickStart(0) += TickTimer;
            Engine.TickEnd(0)   += TickTimer;
            Engine.TickEnd(0)   += (s, e) =>
            {
                states.Enqueue(Engine.Serialize());
                if (states.Count > 60)
                {
                    states.Dequeue();
                }
            };

            Engine.Start();

            while (true)
            {
                await Task.Delay(TimeSpan.FromSeconds(1));
            }
        }
Esempio n. 34
0
    public override void Update()
    {
        for (int i = 0; i < packets.Count; i++)
        {
            SortedDictionary <int, byte[]> pack = packets[i];
            lock (pack) {
                try {
                    //在这个循环里,不能跑去修改这个packet,所有重要消息,都通过计时器处理.
                    foreach (var each in pack)
                    {
                        ms.SetLength(0);
                        ms.Write(each.Value, 0, each.Value.Length);
                        ms.Seek(0, SeekOrigin.Begin);
                        switch (each.Key)
                        {
                        //UDP消息
                        case (int)MeteorMsg.Command.ServerSync:
                            GameFrame frame = Serializer.Deserialize <GameFrame>(ms);
                            OnSyncPlayers(frame);
                            break;

                        case (int)MeteorMsg.Command.NewTurn:
                            if (!FrameReplay.Ins.Started)
                            {
                                return;
                            }
                            if (Main.Ins.GameBattleEx != null)
                            {
                                Main.Ins.GameBattleEx.NetGameOver();
                            }
                            break;

                        case (int)MeteorMsg.Command.GetItem:
                            //ms = new MemoryStream(each.Value);
                            GetItemMsg getitem = Serializer.Deserialize <GetItemMsg>(ms);
                            OnItemPickuped(getitem);
                            break;

                        case (int)MeteorMsg.Command.Drop:
                            //ms = new MemoryStream(each.Value);
                            DropMsg dropItem = Serializer.Deserialize <DropMsg>(ms);
                            OnItemDropped(dropItem);
                            break;

                        case (int)MeteorMsg.Command.Kill:
                            //ms = new MemoryStream(each.Value);
                            OperateMsg kill = Serializer.Deserialize <OperateMsg>(ms);
                            Kill(kill);
                            break;

                        case (int)MeteorMsg.Command.Kick:
                            //ms = new MemoryStream(each.Value);
                            OperateMsg kick = Serializer.Deserialize <OperateMsg>(ms);
                            OnKicked(kick);
                            break;

                        case (int)MeteorMsg.Command.Skick:
                            //ms = new MemoryStream(each.Value);
                            OperateMsg skick = Serializer.Deserialize <OperateMsg>(ms);
                            OnSkicked(skick);
                            break;
                        }
                    }
                } catch (Exception exp) {
                    UnityEngine.Debug.LogError(exp.Message + exp.StackTrace);
                } finally {
                    pack.Clear();
                }
            }
        }

        //lock (messageQueue) {
        //    int length = messageQueue.Count;
        //    for (int i = 0; i < length; i++) {
        //        switch (messageQueue[i].Message) {
        //            case (short)LocalMsgType.Connect: OnConnect(messageQueue[i].Result, messageQueue[i].message); break;
        //        }
        //    }
        //    messageQueue.Clear();
        //}
    }
 void SetGameFrameGoOut(GameFrame _gameFrame, int _delayTime)
 {
     _gameFrame.IDelayTime = 0;
     _gameFrame.DelayTime = _delayTime;
     _gameFrame.Motion.IsStanding = false;
     _gameFrame.Motion.FirstDection = "Right";
     _gameFrame.Motion.StandingGround = float.MinValue;
     _gameFrame.Motion.Vel = new Vector2(20, 0);
     _gameFrame.Motion.Accel = new Vector2(4, 0);
 }
        public override void InitState(GameObjectManager[] objectManagerArray, MainGame owner)
        {
            base.InitState(objectManagerArray, owner);

            //_introFrame = (GameFrame)objectManagerArray[1].CreateObject(7);
            //_introMotion = _introFrame.Motion.Clone();
            //_introDelayTime = _introFrame.DelayTime;
            _introFrames = (GameFrame)objectManagerArray[1].CreateObject(7);
            _introFrameMotion = _introFrames.Motion.Clone();
            _introFrameDelayTime = _introFrames.DelayTime;

            _dacPhuFrame = (GameFrame)objectManagerArray[1].CreateObject(13);
            _minhQuanFrame = (GameFrame)objectManagerArray[1].CreateObject(14);
            _introGameFrame = (GameFrame)objectManagerArray[1].CreateObject(15);
            _introFrames.AddChild(_introGameFrame);
            _introFrames.AddChild(_dacPhuFrame);
            _introFrames.AddChild(_minhQuanFrame);
            _currentIntroFrame = 0;

            _selectMode = (GameFrame)objectManagerArray[1].CreateObject(8);
            _selectMode.Move_Complete += new GameFrame.OnMoveCompletedHandler(Move_Complete_SelectFrame);
            _selectMotion = _selectMode.Motion.Clone();
            _selectDelayTime = _selectMode.DelayTime;

            _aboutGameButtonFrame = (GameFrame)objectManagerArray[1].CreateObject(9);
            _aboutGameButton = (Button)objectManagerArray[2].CreateObject(6);
            _aboutGameButton.IsPressButton = true;
            _aboutGameButtonFrame.AddChild(_aboutGameButton);
            _aboutGameButton.Mouse_Down += new Button.OnMouseDownHandler(AboutGame_Down);
            _aboutGameButton.Mouse_Hover += new Button.OnMouseHoverHandler(AboutGame_Hover);
            _aboutMotion = _aboutGameButtonFrame.Motion.Clone();
            _aboutDelayTime = _aboutGameButtonFrame.DelayTime;
            //Set Button này được Click trước
            _aboutGameButton._sprite[0].Itexture2D = 1;

            _programer1ButtonFrame = (GameFrame)objectManagerArray[1].CreateObject(10);
            _programer1Button = (Button)objectManagerArray[2].CreateObject(7);
            _programer1Button.IsPressButton = true;
            _programer1ButtonFrame.AddChild(_programer1Button);
            _programer1Button.Mouse_Down += new Button.OnMouseDownHandler(Programer1_Down);
            _programer1Button.Mouse_Hover += new Button.OnMouseHoverHandler(Programer1_Hover);
            _programer1Motion = _programer1ButtonFrame.Motion.Clone();
            _programer1DelayTime = _programer1ButtonFrame.DelayTime;

            _programer2ButtonFrame = (GameFrame)objectManagerArray[1].CreateObject(11);
            _programer2Button = (Button)objectManagerArray[2].CreateObject(8);
            _programer2Button.IsPressButton = true;
            _programer2ButtonFrame.AddChild(_programer2Button);
            _programer2Button.Mouse_Down += new Button.OnMouseDownHandler(Programer2_Down);
            _programer2Button.Mouse_Hover += new Button.OnMouseHoverHandler(Programer2_Hover);
            _programer2Motion = _programer2ButtonFrame.Motion.Clone();
            _programer2DelayTime = _programer2ButtonFrame.DelayTime;

            _exitButtonFrame = (GameFrame)objectManagerArray[1].CreateObject(12);
            _exitButtonFrame.Move_Complete += new GameFrame.OnMoveCompletedHandler(Move_Complete_ExitFrame);
            _exitButton = (Button)objectManagerArray[2].CreateObject(5);
            _exitButtonFrame.AddChild(_exitButton);
            _exitButton.Mouse_Click += new Button.OnMouseClickHandler(Exit_Clicked);
            _exitButton.Mouse_Hover += new Button.OnMouseHoverHandler(Exit_Hover);
            _exitMotion = _exitButtonFrame.Motion.Clone();
            _exitDelayTime = _exitButtonFrame.DelayTime;
        }
        public override void InitState(GameObjectManager[] objectManagerArray, MainGame owner)
        {
            //Trong innit tao
            base.InitState(objectManagerArray, owner);

            _newgameFrame = (GameFrame)objectManagerArray[1].CreateObject(0);
            _newgameFrame.Move_Complete += new GameFrame.OnMoveCompletedHandler(StateMenu_Move_Complete_NewGame);
            _newgameButton = (Button)objectManagerArray[2].CreateObject(0);
            _newgameFrame.AddChild(_newgameButton);
            _newgameButton.Owner = _newgameFrame;
            _newgameButton.Mouse_Click += new Button.OnMouseClickHandler(StateMenu_Mouse_Click_NewGame);
            _newgameButton.Mouse_Hover += new Button.OnMouseHoverHandler(StateMenu_Mouse_Hover_NewGame);
            _newgameFrameMotion = _newgameFrame.Motion.Clone();
            _newgameDelayTimeGoIn = _newgameFrame.DelayTime;

            _loadgameFrame = (GameFrame)objectManagerArray[1].CreateObject(1);
            _loadgameFrame.Move_Complete += new GameFrame.OnMoveCompletedHandler(StateMenu_Move_Complete_Load);
            _loadgameButton = (Button)objectManagerArray[2].CreateObject(1);
            _loadgameFrame.AddChild(_loadgameButton);
            _loadgameButton.Owner = _loadgameFrame;
            _loadgameButton.Mouse_Click += new Button.OnMouseClickHandler(StateMenu_Mouse_Click_Load);
            _loadgameButton.Mouse_Hover += new Button.OnMouseHoverHandler(StateMenu_Mouse_Hover_Load);
            _loadgameFrameMotion = _loadgameFrame.Motion.Clone();
            _loadgameDelayTimeGoIn = _loadgameFrame.DelayTime;

            _optionFrame = (GameFrame)objectManagerArray[1].CreateObject(2);
            _optionFrame.Move_Complete += new GameFrame.OnMoveCompletedHandler(StateMenu_Move_Complete_Option);
            _optionButton = (Button)objectManagerArray[2].CreateObject(2);
            _optionFrame.AddChild(_optionButton);
            _optionButton.Owner = _optionFrame;
            _optionButton.Mouse_Click += new Button.OnMouseClickHandler(StateMenu_Mouse_Click_Option);
            _optionButton.Mouse_Hover += new Button.OnMouseHoverHandler(StateMenu_Mouse_Hover_Option);
            _optionFrameMotion = _optionFrame.Motion.Clone();
            _optionDelayTimeGoIn = _optionFrame.DelayTime;

            _helpFrame = (GameFrame)objectManagerArray[1].CreateObject(3);
            _helpFrame.Move_Complete += new GameFrame.OnMoveCompletedHandler(StateMenu_Move_Complete_Help);
            _helpButton = (Button)objectManagerArray[2].CreateObject(3);
            _helpFrame.AddChild(_helpButton);
            _helpButton.Owner = _helpFrame;
            _helpButton.Mouse_Click += new Button.OnMouseClickHandler(StateMenu_Mouse_Click_Help);
            _helpButton.Mouse_Hover += new Button.OnMouseHoverHandler(StateMenu_Mouse_Hover_Help);
            _helpFrameMotion = _helpFrame.Motion.Clone();
            _helpDelayTimeGoIn = _helpFrame.DelayTime;

            _aboutFrame = (GameFrame)objectManagerArray[1].CreateObject(4);
            _aboutFrame.Move_Complete += new GameFrame.OnMoveCompletedHandler(StateMenu_Move_Complete_About);
            _aboutButton = (Button)objectManagerArray[2].CreateObject(4);
            _aboutFrame.AddChild(_aboutButton);
            _aboutButton.Owner = _aboutFrame;
            _aboutButton.Mouse_Click += new Button.OnMouseClickHandler(StateMenu_Mouse_Click_About);
            _aboutButton.Mouse_Hover += new Button.OnMouseHoverHandler(StateMenu_Mouse_Hover_About);
            _aboutFrameMotion = _aboutFrame.Motion.Clone();
            _aboutDelayTimeGoIn = _aboutFrame.DelayTime;

            _quitFrame = (GameFrame)objectManagerArray[1].CreateObject(5);
            _quitFrame.Move_Complete += new GameFrame.OnMoveCompletedHandler(StateMenu_Move_Complete_Quit);
            _quitButton = (Button)objectManagerArray[2].CreateObject(5);
            _quitFrame.AddChild(_quitButton);
            _quitButton.Owner = _quitFrame;
            _quitButton.Mouse_Click += new Button.OnMouseClickHandler(StateMenu_Mouse_Click_Quit);
            _quitButton.Mouse_Hover += new Button.OnMouseHoverHandler(StateMenu_Mouse_Hover_Quit);
            _quitFrameMotion = _quitFrame.Motion.Clone();
            _quitDelayTimeGoIn = _quitFrame.DelayTime;

            _menuFrame = (GameFrame)objectManagerArray[1].CreateObject(6);
            _menuFrame.Move_Complete += new GameFrame.OnMoveCompletedHandler(StateMenu_Move_Complete_MenuFrame);
            _menuFrameMotion = _menuFrame.Motion.Clone();
            _menuFrameDelayTimeGoIn = _menuFrame.DelayTime;
        }
Esempio n. 38
0
 public void RestartGame()
 {
     game = new Game();
     GameFrame.Navigate(typeof(Game), null, new DrillInNavigationTransitionInfo());
 }
        public void GetResources(List<GameObjectManager> _resources)
        {
            _mainFrame = (GameFrame)_resources[0].CreateObject(6);
            _mainFrame.IsVisible = false;

            _btLightingStrike = (Button)_resources[1].CreateObject(29);
            _btLightingStrike.Owner = _character.ListRightHandSkill[0];
            _btLightingStrike.GetNewIdleTexture(_character.ListRightHandSkill[0].IdleIcon);
            _btLightingStrike.GetNewClickedTexture(_character.ListRightHandSkill[0].ClickedIcon);
            _btLightingStrike.Mouse_Click += new Button.OnMouseClickHandler(LightingStrike_Clicked);
            _btLightingStrike.Mouse_Hover += new Button.OnMouseHoverHandler(LightingStrike_Hover);
            _btLightingStrike.Mouse_Released += new Button.OnMouseReleasedHandler(LightingStrike_Release);

            _btDeadlyBees = (Button)_resources[1].CreateObject(30);
            _btDeadlyBees.Owner = _character.ListRightHandSkill[1];
            _btDeadlyBees.GetNewIdleTexture(_character.ListRightHandSkill[1].IdleIcon);
            _btDeadlyBees.GetNewClickedTexture(_character.ListRightHandSkill[1].ClickedIcon);
            _btDeadlyBees.Mouse_Click += new Button.OnMouseClickHandler(DeadlyBees_Clicked);
            _btDeadlyBees.Mouse_Hover += new Button.OnMouseHoverHandler(DeadlyBees_Hover);
            _btDeadlyBees.Mouse_Released += new Button.OnMouseReleasedHandler(DeadlyBees_Release);

            _btSoulsRelease = (Button)_resources[1].CreateObject(31);
            _btSoulsRelease.Owner = _character.ListRightHandSkill[2];
            _btSoulsRelease.GetNewIdleTexture(_character.ListRightHandSkill[2].IdleIcon);
            _btSoulsRelease.GetNewClickedTexture(_character.ListRightHandSkill[2].ClickedIcon);
            _btSoulsRelease.Mouse_Click += new Button.OnMouseClickHandler(SouldRelease_Clicked);
            _btSoulsRelease.Mouse_Hover += new Button.OnMouseHoverHandler(SouldRelease_Hover);
            _btSoulsRelease.Mouse_Released += new Button.OnMouseReleasedHandler(SouldRelease_Release);

            _btEathShake = (Button)_resources[1].CreateObject(32);
            _btEathShake.Owner = _character.ListRightHandSkill[3];
            _btEathShake.GetNewIdleTexture(_character.ListRightHandSkill[3].IdleIcon);
            _btEathShake.GetNewClickedTexture(_character.ListRightHandSkill[3].ClickedIcon);
            _btEathShake.Mouse_Click += new Button.OnMouseClickHandler(EarthShake_Clicked);
            _btEathShake.Mouse_Hover += new Button.OnMouseHoverHandler(EarthShake_Hover);
            _btEathShake.Mouse_Released += new Button.OnMouseReleasedHandler(EarthShake_Release);

            _btWaveForm = (Button)_resources[1].CreateObject(33);
            _btWaveForm.Owner = _character.ListRightHandSkill[4];
            _btWaveForm.GetNewIdleTexture(_character.ListRightHandSkill[4].IdleIcon);
            _btWaveForm.GetNewClickedTexture(_character.ListRightHandSkill[4].ClickedIcon);
            _btWaveForm.Mouse_Click += new Button.OnMouseClickHandler(WaveForm_Clicked);
            _btWaveForm.Mouse_Hover += new Button.OnMouseHoverHandler(WaveForm_Hover);
            _btWaveForm.Mouse_Released += new Button.OnMouseReleasedHandler(WaveForm_Release);

            _btLightingField = (Button)_resources[1].CreateObject(34);
            _btLightingField.Owner = _character.ListRightHandSkill[5];
            _btLightingField.GetNewIdleTexture(_character.ListRightHandSkill[5].IdleIcon);
            _btLightingField.GetNewClickedTexture(_character.ListRightHandSkill[5].ClickedIcon);
            _btLightingField.Mouse_Click += new Button.OnMouseClickHandler(LightingField_Clicked);
            _btLightingField.Mouse_Hover += new Button.OnMouseHoverHandler(LightingField_Hover);
            _btLightingField.Mouse_Released += new Button.OnMouseReleasedHandler(LightingField_Release);

            //Vì sửa lai XML nen thang cuối cùng bi nhảy lên 36
            _btInvisible = (Button)_resources[1].CreateObject(36);
            _btInvisible.Owner = _character.ListRightHandSkill[6];
            _btInvisible.GetNewIdleTexture(_character.ListRightHandSkill[6].IdleIcon);
            _btInvisible.GetNewClickedTexture(_character.ListRightHandSkill[6].ClickedIcon);
            _btInvisible.Mouse_Click += new Button.OnMouseClickHandler(InvisiblePoison_Clicked);
            _btInvisible.Mouse_Hover += new Button.OnMouseHoverHandler(InvisiblePoison_Hover);
            _btInvisible.Mouse_Released += new Button.OnMouseReleasedHandler(InvisiblePoison_Release);

            _mainFrame.AddChild(_btLightingStrike);
            _mainFrame.AddChild(_btDeadlyBees);
            _mainFrame.AddChild(_btSoulsRelease);
            _mainFrame.AddChild(_btEathShake);
            _mainFrame.AddChild(_btWaveForm);
            _mainFrame.AddChild(_btLightingField);
            _mainFrame.AddChild(_btInvisible);
        }