Inheritance: MonoBehaviour
Example #1
0
        public Background(MainGame game, int qtdTiles, bool player)
        {
            //Instanciando os membros:
            _random = new Random();
            _updateTimer = TimeSpan.Zero;
            _hasPlayer = player;

            //Instanciando os tiles que serão exibidos aleatoriamente no fundo da tela:
            _randomTiles = new Tile[qtdTiles];

            for (int i = 0; i < qtdTiles; i++)
            {
                _randomTiles[i] = new Tile(game, TILE_TYPES.NORMAL, new Vector2(0, 0));
                _randomTiles[i].Sprite.DrawPosition = new Vector2(_random.Next(0, game.GraphicsDevice.Viewport.Width),
                                                            _random.Next(0, game.GraphicsDevice.Viewport.Height));
                _randomTiles[i].Sprite.Color = new Color(0.5f, 0.5f, 0.5f);
                _randomTiles[i].Sprite.Scale = (float)_random.NextDouble() + 0.5f;
            }

            //Criando o player:
            if(_hasPlayer)
            {
                _playerTile = new Tile(game, TILE_TYPES.NORMAL, new Vector2(0, 0));
                _playerTile.Sprite.Color = new Color(0.5f, 0.5f, 0.5f);
                _playerTile.Sprite.DrawPosition = new Vector2(_random.Next(50, game.GraphicsDevice.Viewport.Width - 50),
                                                                _random.Next(50, game.GraphicsDevice.Viewport.Height - 50));

                _player = new Player(game, _playerTile);
                _player.Sprite.Color = new Color(0.5f, 0.5f, 0.5f);
            }
            else
            {
                _player = null;
            }
        }
    public static void LoadContent(MainGame game)
    {
        // Load assets
        player = game.Content.Load<Texture2D>("player");
        gun = game.Content.Load<Texture2D>("gun");
        dot = game.Content.Load<Texture2D>("dot");
        create = game.Content.Load<Texture2D>("create");
        bullet = game.Content.Load<Texture2D>("bullet");
        aim = game.Content.Load<Texture2D>("aim");
        font = game.Content.Load<SpriteFont>("spriteFont");

        // Init tiles 
        tileTable.Put('O', new TileData(ETileType.FLOOR, dot, Color.DarkGray));
        tileTable.Put('W', new TileData(ETileType.WALL, dot, Color.Black));
        tileTable.Put('S', new TileData(ETileType.SPAWN, dot, Color.Red));
        tileTable.Put('C', new TileData(ETileType.CRATE, create, Color.Brown));


        // Init key bindings
        inputTable.Put(Player.Commands.MoveUp, new LinkedList<Keys>() { Keys.Up, Keys.W });
        inputTable.Put(Player.Commands.MoveDown, new LinkedList<Keys>() { Keys.Down, Keys.S });
        inputTable.Put(Player.Commands.MoveLeft, new LinkedList<Keys>() { Keys.Left, Keys.A });
        inputTable.Put(Player.Commands.MoveRight, new LinkedList<Keys>() { Keys.Right, Keys.D });


        loadMap(game);
    }
        public bool Init(MainGame game, StateMachine stateMachine)
        {
            //Salvando os valores:
            _game = game;
            _stateMachine = stateMachine;

            //Carregando os recursos de Linguagem:
            var languadeLoader = new Windows.ApplicationModel.Resources.ResourceLoader();

            //Carregando os recursos:
            _mediumFont = _game.Content.Load<SpriteFont>("Fonts/QuestrianMedium");
            _smallFont = _game.Content.Load<SpriteFont>("Fonts/QuestrianSmall");
            _largeFont = _game.Content.Load<SpriteFont>("Fonts/QuestrianLarge");

            _title1 = new Label(languadeLoader.GetString("StageLabel"), new Vector2(game.GraphicsDevice.Viewport.Width / 2, game.GraphicsDevice.Viewport.Height / 10), _largeFont);
            _title2 = new Label(languadeLoader.GetString("WonLabel"), new Vector2(game.GraphicsDevice.Viewport.Width / 2, game.GraphicsDevice.Viewport.Height / 5), _largeFont);

            _nextStage = new Label(languadeLoader.GetString("NextStageLabel"), new Vector2(game.GraphicsDevice.Viewport.Width / 2, game.GraphicsDevice.Viewport.Height - (game.GraphicsDevice.Viewport.Height / 10)), _mediumFont);

            ////Buscando o ID do mapa que vencemos:
            //_stageWonInfo = StageManager.Instance.CurrentMap;

            ////Criando a Câmera:
            //_camera = new Camera2D(game);
            //game.Components.Add(_camera);

            //int x = (int)(_stageWonInfo._mapSize.X / 2), y = (int)(_stageWonInfo._mapSize.Y / 2);
            //_camera.Focus = new Tile(game, _stageWonInfo.MapTiles[x, y]._type, _stageWonInfo.MapTiles[x, y]._mapPosition);

            //Tudo correu bem:
            return true;
        }
Example #4
0
 static void Main()
 {
     using (MainGame game = new MainGame())
     {
         game.Run();
     }
 }
Example #5
0
		public GDGameScreen(MainGame game, GraphicsDeviceManager gdm, LevelFile bp, FractionDifficulty diff) : base(game, gdm)
		{
			blueprint = bp;
			difficulty = diff;

			Initialize();
		}
Example #6
0
        VertexBuffer vertexBuffer; //頂点バッファ

        #endregion Fields

        #region Constructors

        /// <summary>
        /// コンストラクタ
        /// </summary>
        /// <param name="mainGame"></param>
        /// <param name="camera"></param>
        /// <param name="texture"></param>
        /// <param name="vectors">ここでは各頂点の座標を指定する(ただし、順番はZ字に)</param>
        public TexturePolygon(MainGame mainGame, Camera camera, Texture2D texture, Vector3[] vectors)
            : base(mainGame)
        {
            this.camera = camera;
            this.texture = texture;
            this.vectors = vectors;
        }
Example #7
0
    // Use this for initialization
    void Start()
    {
        style = GameObject.FindGameObjectWithTag("GameController").GetComponent<MainGame>().Style;

        g = GameObject.FindGameObjectWithTag ("Game").GetComponent<Game> ();
        mg = GameObject.FindGameObjectWithTag ("GameController").GetComponent<MainGame> ();
    }
Example #8
0
 /// <summary>
 /// The main entry point for the application.
 /// </summary>
 static void Main(string[] args)
 {
     using (MainGame game = new MainGame())
       {
     game.Run();
       }
 }
Example #9
0
 protected override void OnCreate(Bundle bundle)
 {
     base.OnCreate(bundle);
     var g = new MainGame();
     SetContentView((View)g.Services.GetService(typeof(View)));
     g.Run();
 }
        public LevelManager(Game game)
        {
            gameRef = (MainGame)game;

                var tutLevel = new TileMap(0, 0);
                tutLevel.Load(@"test_level.slf");
                levels.Add(tutLevel.GUID, tutLevel);
                levelIds.Add("tutorial level", tutLevel.GUID);

                //var connect_1Level = new TileMap(0, 0);
                //connect_1Level.Load(@"connect_1.slf");
                //levels.Add(connect_1Level.GUID, connect_1Level);
                //levelIds.Add("connect 1 level", connect_1Level.GUID);

                var obstacle_1Level = new TileMap(0, 0);
                obstacle_1Level.Load(@"obstacle_1.slf");
                levels.Add(obstacle_1Level.GUID, obstacle_1Level);
                levelIds.Add("obstacle 1 level", obstacle_1Level.GUID);

                levels[levelIds["tutorial level"]].AddExitZone(new ExitZone(new Rectangle(tutLevel.WidthInTiles - 1, 3, 1, 2), levelIds["tutorial level"], levelIds["obstacle 1 level"]));
                levels[levelIds["obstacle 1 level"]].AddExitZone(new ExitZone(new Rectangle(0, 1, 1, 2), levelIds["obstacle 1 level"], levelIds["tutorial level"]));

                ChangeLevel(levelIds["Tutorial Level".ToLower()]);

                red = new DrawableRectangle(gameRef.GraphicsDevice, new Vector2(10, 10), Color.White, true).Texture;
        }
Example #11
0
 /// <summary>
 /// The main entry point for the application.
 /// </summary>
 private static void Main(string[] args)
 {
     using (var game = new MainGame())
     {
         game.Run();
     }
 }
    private static void loadMap(MainGame game)
    {
        IList<string> strings = new LinkedList<string>();
        StreamReader sr = new StreamReader("Content/level.map");
        while (!sr.EndOfStream)
            strings.Add(sr.ReadLine());
        sr.Close();
        int width = strings[0].Length;
        int height = strings.Count;

        Console.WriteLine(width + " " + height);

        char[,] charMap = new char[width, height];
        int x = 0;
        int y = height-1;
        foreach (string s in strings)
        {
            foreach (char c in s)
            {
                charMap[x, y] = c;
                x++;
            }
            y--;
            x = 0;
        }
        map = new Map(width, height, charMap);
    }
Example #13
0
 public Flag(MainGame game)
     : base(game.Content.Load<Texture2D>("Sprite/Flag"), MainGame.Tag.Flag, Vector2.One, "Flag", game)
 {
     defaultPosition = new Vector2(game.graphics.PreferredBackBufferWidth * 0.9f, game.graphics.PreferredBackBufferHeight * 0.5f);
     position = defaultPosition;
     baseRectangle = new Rectangle(0, 0, sprite.Width, sprite.Height);
     game.sceneControl.GetScene().flagList.Add(this);
 }
 public SceneGameplay(MainGame game, int roundNumber, Scoreboard scoreBoard)
 {
     this.game = game;
     this.roundNumber = roundNumber;
     this.scoreboard = scoreBoard;
     System.Diagnostics.Debug.WriteLine("Round " + roundNumber + " Score " + scoreboard.Score[0]);
     Load();
 }
Example #15
0
 public void AddScore(MainGame.Tag tag, float score)
 {
     if (tag == MainGame.Tag.Runner)
         this.Score[0] += score;
     else
         this.Score[1] += score;
     System.Diagnostics.Debug.WriteLine("Score!");
 }
 public MultiplayerHostComponent(MainGame game, InputManager input)
     : base(game)
 {
     _game = game;
     _input = input;
     if (input == null)
         throw new ArgumentNullException(nameof(input));
     LoadContent(_game.Content);
 }
Example #17
0
 protected BaseGameState(Game game, GameStateManager manager)
     : base(game, manager)
 {
     Log = LogManager.GetLogger(this);
     Log.Debug("Constructing GameState... (" + GetType() + ")");
     Log = LogManager.GetLogger(this);
     GameRef = (MainGame) game;
     PlayerIndexInControl = PlayerIndex.One;
 }
Example #18
0
 private void OnLoaded(Object sender, RoutedEventArgs routedEventArgs)
 {
     bool inDesignTime = System.ComponentModel.DesignerProperties.GetIsInDesignMode(
         new DependencyObject());
     if (!inDesignTime)
     {
         _mainGame = new MainGame(this.frbControl);
     }
 }
 public BaseCharacter(Texture2D sprite, MainGame.Tag tag, Vector2 spawnPosition, string name, MainGame game, IPlayerInput input)
     : base(sprite, tag, spawnPosition, name, game)
 {
     baseRectangle = new Rectangle(0, 0, 50, 50);
     velocity = Vector2.Zero;
     this.SpawnPosition = spawnPosition;
     this.input = input;
     Reset();
 }
Example #20
0
        public Player(MainGame game, Character character)
        {
            _gameRef = game;
            _camera = new Camera(_gameRef.ScreenRectangle, ControlsManager.Controls);
            _char = character;
            _mapSize = new Point(0, 0);
            _camera.SetMapSize(_mapSize.X, _mapSize.Y);

            LogManager.GetLogger(this).Debug("Player object created.");
        }
Example #21
0
 /// <summary>
 /// コンストラクタ(実際に有効に動かすにはisEnabledを指定する必要がある)
 /// </summary>
 /// <param name="mainGame">メインゲーム</param>
 /// <param name="fadeKind">種類</param>
 /// <param name="speed">変化のスピード(0f ~ 1f)</param>
 /// <param name="texture">テクスチャ</param>
 public Fade(MainGame mainGame, FadeKind fadeKind, float speed, Texture2D texture)
 {
     this.mainGame = mainGame;
     this.texture = texture;
     this.fadeKind = fadeKind;
     this.speed = speed;
     this.isEnd = false;
     this.count = (this.fadeKind == FadeKind.FadeIn ? 1f : 0f);
     this.isEnabled = false;
 }
Example #22
0
 public GameObject(Texture2D sprite, MainGame.Tag tag, Vector2 position, string name, MainGame game)
 {
     this.game = game;
     this.name = name;
     this.sprite = sprite;
     this.tag = tag;
     this.position = position;
     baseRectangle = new Rectangle(0, 0, 1, 1);
     baseColor = Color.White;
 }
Example #23
0
 //LayerMask mask = (1<<LayerMask.NameToLayer("Ground") | 1<<LayerMask.NameToLayer("Characters"));
 public UIGameHUD(GUIController GUI, MainGame mg)
 {
     this.gui = GUI;
     MainGameInstance = mg;
     board = Grid_Setup.Instance;
     panel = GameObject.Instantiate(gui.panelFab.gameObject, Vector3.zero, Quaternion.identity)as GameObject;
     panel.transform.SetParent(gui.UIcan.transform,false);
     panel.transform.SetAsLastSibling();
     pc = panel.GetComponent<PanelController> ();
     pc.HidePanel();
 }
Example #24
0
        private static void Main()
        {
            PrepareGraphicMode();

            //			LevelsShowRoom.ShowStation();

            SoldierConfig.Initialize();
            var mainGame = new MainGame();
            mainGame.InitializeGame();
            mainGame.MainGameLoop();
        }
Example #25
0
 //コンストラクタ
 public Figure(MainGame mainGame, Model model, Camera camera)
     : base(mainGame)
 {
     this.camera = camera;
     this.model = model;
     position = new Vector3(0.0f, 0.0f, 0.0f);
     rotateX = 0.0f;
     rotateY = 0.0f;
     rotateZ = 0.0f;
     scale = new Vector3(1.0f, 1.0f, 1.0f);
 }
Example #26
0
        private StageManager()
        {
            //Instanciando as variáveis:
            _loadedMapFiles = new LinkedList<sLoadedMap>();
            _currentMap = _loadedMapFiles.First;
            _game = null;

            #pragma warning disable CS4014 // Because this call is not awaited, execution of the current method continues before the call is completed
            //Dando inicio no processo de carregar os arquivos:
            LoadMapFiles();
            #pragma warning restore CS4014 // Because this call is not awaited, execution of the current method continues before the call is completed
        }
Example #27
0
    public void Start()
    {
        g = null;
        life = 3;
        score = 0;
        timeFactor = 1;
        gamesCompleted = 0;
        timeToWait = 2.5f;
        lastGame = -1;

        mg = GameObject.FindGameObjectWithTag("GameController").GetComponent<MainGame>();
        gameObject.tag = "Game";
    }
        public Voting(MainGame game, Panel votingPanel, Label countdownLabel)
        {
            timer = new System.Timers.Timer();

            timer.Interval = 1000;
            timer.Elapsed += Timer_Elapsed;
            timer.Enabled = true;

            this.game = game;
            this.votingPanel = votingPanel;
            this.countdownLabel = countdownLabel;

            synchronizationContext = SynchronizationContext.Current;
        }
        public MainGameScreen(MainGame game)
            : base(game)
        {
            this.Player = new WindowsMediaPlayerClass();
            this.Textures = new GameTextures();
            this.mainMapLayer = new MainMapLayer();
            this.architectureLayer = new ArchitectureLayer();
            this.mapVeilLayer = new MapVeilLayer();
            this.troopLayer = new TroopLayer();
            this.selectingLayer = new SelectingLayer();
            this.tileAnimationLayer = new TileAnimationLayer();
            this.routewayLayer = new RoutewayLayer();
            this.Plugins = new GamePlugin();
            this.SelectorTroops = new TroopList();
            this.scrollSpeedScale = 1f;
            this.scrollSpeedScaleDefault = 1f;
            this.scrollSpeedScaleSpeedy = 1.7f;
            this.oldScrollWheelValue = 0;
            this.EnableLaterMouseLeftDownEvent = true;
            this.EnableLaterMouseLeftUpEvent = true;
            this.EnableLaterMouseRightDownEvent = true;
            this.EnableLaterMouseRightUpEvent = true;
            this.EnableLaterMouseMoveEvent = true;
            this.EnableLaterMouseScrollEvent = true;
            this.frameRate = 0;
            this.frameCounter = 0;
            this.elapsedTime = TimeSpan.Zero;
            this.UpdateCount = 0;
            this.thisGame = game;
            this.screenManager = new ScreenManager(this);
            base.Scenario = new GameScenario(this);
            this.LoadCommonData();
            base.Game.Window.ClientSizeChanged += new EventHandler(this.Window_ClientSizeChanged);
            base.Game.Activated += new EventHandler(this.Game_Activated);
            base.Game.Deactivated += new EventHandler(this.Game_Deactivated);
            base.Scenario.OnAfterLoadScenario += new GameScenario.AfterLoadScenario(this.Scenario_OnAfterLoadScenario);
            base.Scenario.OnNewFactionAppear += new GameScenario.NewFactionAppear(this.Scenario_OnNewFactionAppear);
            base.Scenario.Date.OnDayStarting += new GameDate.DayStartingEvent(this.Date_OnDayStarting);
            base.Scenario.Date.OnDayPassed += new GameDate.DayPassedEvent(this.Date_OnDayPassed);
            base.Scenario.Date.OnMonthPassed += new GameDate.MonthPassedEvent(this.Date_OnMonthPassed);
            base.Scenario.Date.OnSeasonChange += new GameDate.SeasonChangeEvent(this.Date_OnSeasonChange);
            base.Scenario.Date.OnYearStarting += new GameDate.YearStartingEvent(this.Date_OnYearStarting);
            base.Scenario.Date.OnYearPassed += new GameDate.YearPassedEvent(this.Date_OnYearPassed);
            //this.Player.add_PlayStateChange(new _WMPOCXEvents_PlayStateChangeEventHandler(this.Player_PlayStateChange));
            this.Player.PlayStateChange+=(new _WMPOCXEvents_PlayStateChangeEventHandler(this.Player_PlayStateChange));
            //this.ShowyoucelanInFrame(UndoneWorkKind.Frame, FrameKind.Architecture, FrameFunction.Jump, false, true, false, false, base.Scenario.CurrentPlayer.Architectures, null, "跳转", "");


        }
Example #30
0
        //コンストラクタ
        public Camera(MainGame mainGame)
            : base(mainGame)
        {
            //ビュー変換行列
            yaw = 0.0f;
            pitch = 0.0f;
            roll = 0.0f;
            position = new Vector3(0.0f, 0.0f, 3.0f);
            UpdateMatrix();

            //射影変換行列
            PerspectiveFieldOfView(
                MathHelper.ToRadians(45.0f),
                mainGame.GraphicsDevice.Viewport.AspectRatio,
                0.005f,
                10000.0f
            );
        }
Example #31
0
 public Brick(MainGame game) : base(game)
 {
 }
Example #32
0
 public GameManager(MainGame game) : base(game)
 {
 }
Example #33
0
        internal ResearchCompleteController(Player owner, ResearchTopic topic, GameController gameController, MainGame game)
        {
            this.game           = game;
            this.gameController = gameController;
            this.Owner          = owner;
            this.TopicProgress  = this.game.States.ResearchAdvances.Of[owner].First(x => x.Topic == topic);

            this.priorities.AddRange(this.TopicProgress.Topic.Unlocks[this.TopicProgress.NextLevel]);
        }
Example #34
0
 // Graphics devica
 public Gameplays(MainGame g) : base(g)
 {
     gameplays = new Dictionary <GameplaysDefinition, Gameplay>();
 }
Example #35
0
 public BeginGameStage(MainGame game) : base(game)
 {
 }
Example #36
0
 public static void SetGame(MainGame mainGame)
 {
     m_game = mainGame;
 }
Example #37
0
 public virtual void Update(MainGame game)
 {
 }
        public frmGetTileSheet(MainGame game)
        {
            InitializeComponent();

            gameRef = game;
        }
Example #39
0
 public EndGameStage(MainGame game) : base(game)
 {
 }
Example #40
0
        public GameMenu(MainGame game, GraphicsDevice graphics, Time time,
                        ScreenshotHandler screenshotTaker, Parameters parameters)
        {
            this.game     = game;
            this.graphics = graphics;
            spriteBatch   = new SpriteBatch(graphics);

            this.time = time;
            this.screenshotHandler = screenshotTaker;

            menuTextures = Assets.MenuTextures;

            state       = MenuState.Main;
            debugScreen = false;

            font14 = Assets.Fonts[0];
            font24 = Assets.Fonts[1];

            inventory = new Inventory(game, spriteBatch, font14, parameters, () =>
            {
                Mouse.SetPosition((int)screenCenter.X, (int)screenCenter.Y);
                game.IsMouseVisible = false;
                game.Paused         = false;
                game.ExitedMenu     = true;
                state = MenuState.Main;
            });

            previousKeyboardState = Keyboard.GetState();
            previousMouseState    = Mouse.GetState();

            screenWidth  = game.Window.ClientBounds.Width;
            screenHeight = game.Window.ClientBounds.Height;

            screenCenter = new Vector2(screenWidth / 2, screenHeight / 2);


            back = new Button(graphics, spriteBatch, "Back to game", font14,
                              (screenWidth / 2) - 150, 100, 300, 40,
                              menuTextures["button"], menuTextures["button_selector"], () =>
            {
                game.Paused = false;

                Mouse.SetPosition((int)screenCenter.X, (int)screenCenter.Y);
                game.IsMouseVisible = false;
                game.ExitedMenu     = true;

                state = MenuState.Main;
            });

            quit = new Button(graphics, spriteBatch, "Save & Quit", font14,
                              (screenWidth / 2) - 150, 260, 300, 40,
                              menuTextures["button"], menuTextures["button_selector"], () =>
            {
                game.Paused         = false;
                game.IsMouseVisible = false;
                inventory.SaveParameters(parameters);
                game.State = GameState.Exiting;
            });


            crosshair = new Rectangle((screenWidth / 2) - 15, (screenHeight / 2) - 15, 30, 30);

            screenShading        = new Rectangle(0, 0, screenWidth, screenHeight);
            screenShadingTexture = new Texture2D(graphics, screenWidth, screenHeight);

            Color[] darkBackGroundColor = new Color[screenWidth * game.Window.ClientBounds.Height];
            for (int i = 0; i < darkBackGroundColor.Length; i++)
            {
                darkBackGroundColor[i] = new Color(Color.Black, 0.5f);
            }

            screenShadingTexture.SetData(darkBackGroundColor);
        }
Example #41
0
 private static void Main()
 {
     using var game = new MainGame(new DesktopPlatform());
     game.Run();
 }
 public SelectInputStage(MainGame game) : base(game)
 {
 }
 internal ColonyController(MainGame game, Colony colony, bool readOnly, Player player) :
     base(colony, readOnly, game, player)
 {
 }
Example #44
0
 public StartScreen(MainGame game)
     : base(game)
 {
 }
Example #45
0
 public void Run()
 {
     MainGame.StopCo(coroutine);
     coroutine = MainGame.StartCo(Next());
 }
Example #46
0
 static void Main()
 {
     using (var game = new MainGame())
         game.Run();
 }
Example #47
0
 public virtual void End(MainGame game)
 {
 }
Example #48
0
 public FirstDownStage(MainGame game) : base(game)
 {
 }
Example #49
0
 public virtual void Start(MainGame game)
 {
 }
Example #50
0
 public override void Start(MainGame game)
 {
     m_reloj = 0;
     game.GameOver();
 }
Example #51
0
 public frmGameCoCaRo()
 {
     InitializeComponent();
     game = new MainGame();
     g    = pnlChessBoard.CreateGraphics();
 }
Example #52
0
 public void GameDicesViewConstructorTest()
 {
     MainGame m = null; // TODO: initialisez a une valeur appropriee
     GameDicesView target = new GameDicesView(m);
     Assert.Inconclusive("TODO: implementez le code pour verifier la cible");
 }
Example #53
0
 public GameLogic(MainGame mainGame)
     : base(mainGame)
 {
 }
Example #54
0
        private void btnReplay_Click(object sender, RoutedEventArgs e)
        {
            if (!Directory.Exists("./Replays"))
            {
                Directory.CreateDirectory("./Replays");
            }
            OpenFileDialog dlg = new OpenFileDialog();

            dlg.InitialDirectory = Directory.GetCurrentDirectory() + "\\Replays";
            dlg.DefaultExt       = ".sgs";                                                                        // Default file extension
            dlg.Filter           = "Replay File (.sgs)|*.sgs|Crash Report File (.rpt)|*.rpt|All Files (*.*)|*.*"; // Filter files by extension
            bool?result = dlg.ShowDialog();

            if (result != true)
            {
                return;
            }

            string fileName = dlg.FileName;

            Client   client;
            MainGame game = null;

            try
            {
                client = new Client();
                game   = new MainGame();
                game.OnNavigateBack += game_OnNavigateBack;
                Stream stream = File.Open(fileName, FileMode.Open);
                byte[] seed   = new byte[8];
                stream.Seek(-16, SeekOrigin.End);
                stream.Read(seed, 0, 8);
                if (System.Text.Encoding.Default.GetString(seed).Equals(Misc.MagicAnimal.ToString("X8")))
                {
                    stream.Read(seed, 0, 8);
                    game.HasSeed = Convert.ToInt32(System.Text.Encoding.Default.GetString(seed), 16);
                }
                stream.Seek(0, SeekOrigin.Begin);

                byte[] bytes = new byte[4];
                stream.Read(bytes, 0, 4);
                int length = BitConverter.ToInt32(bytes, 0);
                if (length != 0)
                {
                    byte[] msg = new byte[length];
                    stream.Read(msg, 0, length);
                    UnicodeEncoding uniEncoding = new UnicodeEncoding();
                    MessageBox.Show(new String(uniEncoding.GetChars(msg)));
                }
                client.StartReplay(stream);
                game.NetworkClient = client;
            }
            catch (Exception)
            {
                MessageBox.Show("Failed to open replay file.");
                return;
            }
            if (game != null)
            {
                MainGame.BackwardNavigationService = this.NavigationService;
                game.Start();
                // this.NavigationService.Navigate(game);
            }
        }
Example #55
0
 public BombardmentProcessor(BombardBattleGame battleGame, MainGame mainGame) : base(mainGame)
 {
     this.game = battleGame;
     this.makePlayerOrder();
 }
Example #56
0
    private IEnumerator ExtractZipFile()
    {
        bool   bNeedUnzip = false;
        string version    = PlayerPrefs.GetString("Version");

        if (version != AppConst.AppVersion)
        {
            bNeedUnzip = true;
        }
        if (bNeedUnzip == false)
        {
            Finish();
            yield break;
        }

        string path = AppConst.ABZipPath;

        LogUtil.StartLog("Extract Zip File: " + path);
        UpdateTips("正在解压文件");
        byte[] bytes = null;
        if (path.Contains("://"))
        {
            UnityWebRequest request = UnityWebRequest.Get(path);
            yield return(request.SendWebRequest());

            if (request.isNetworkError || request.isHttpError)
            {
                LogUtil.StartLog("Failed To Load ab.zip File: " + path + "\n" + request.error);
            }
            else
            {
                bytes = request.downloadHandler.data;
            }
        }
        else if (File.Exists(path))
        {
            bytes = File.ReadAllBytes(path);
        }

        if (bytes != null)
        {
            object[]    param = new object[] { bytes, AppConst.CachePath };
            ThreadEvent ev    = new ThreadEvent();
            ev.Key = NotiConst.EXTRACT_FILE;
            ev.evParams.AddRange(param);

            float         progress      = 0f;
            bool          isFinish      = false;
            ThreadManager threadManager = MainGame.GetManager <ThreadManager>();
            threadManager.AddEvent(ev, (e) =>
            {
                if (e.evName == NotiConst.EXTRACT_UPDATE)
                {
                    progress = (float)e.evParam;
                }
                else if (e.evName == NotiConst.EXTRACT_FINISH)
                {
                    isFinish = true;
                }
            });   //线程解压

            while (!isFinish)
            {
                UpdateTips("正在解压文件", progress);
                yield return(new WaitForEndOfFrame());
            }
            PlayerPrefs.SetString("Version", AppConst.AppVersion);
            Util.Log("Extract Zip File Finish.");
            UpdateTips("解压文件完成", 1);
        }
        else
        {
            Util.Log("Zip File Is Not Found.");
            UpdateTips("解压文件失败");
        }
    }
Example #57
0
 private void OnBackStartMouseClick(object sender, MouseClickEventArgs e) // object sender renvoie le type du parametre, ici un Button
 {
     MainGame.GetInstance().SetScreen(new StartMenu());
 }
Example #58
0
 private void OnBackStartMouseClick(object sender, MouseClickEventArgs e)
 {
     MainGame.GetInstance().SetScreen(new StartMenu());
 }
Example #59
0
 public LevelSelectionScene(MainGame game) : base(game)
 {
 }
Example #60
0
    // Use this for initialization
    void Start()
    {
        _coreWorld = GameObject.Find("Attackers");

        _mainGame = GameObject.FindGameObjectWithTag("MainGame").GetComponent <MainGame> ();
    }