Esempio n. 1
0
        public virtual void Initialize()
        {
            ComponentFactory factory = new ComponentFactory(monoNet.Content);

            stage = new Stage(10, new Pool <Actor>(50, 10)); // TODO: LAYERS

            Actor serviceActor = stage.CreateActor(0);

            gameManager = serviceActor.AddComponent <GameManager>();
            GameManager.screenDimensions = new Vector2(monoNet.GraphicsDevice.Viewport.Width, monoNet.GraphicsDevice.Viewport.Height);

            Physic physic = Physic.Instance;

            physic.collisionRules.Add(new MultiKey <int>(GameManager.physicsPlayerLayer, GameManager.physicsWeaponLayer), false);
            physic.collisionRules.Add(new MultiKey <int>(GameManager.physicsBulletLayer, GameManager.physicsBulletLayer), false);

            tiledBase = serviceActor.AddComponent <TiledBase>();
            tiledBase.Set(monoNet.Content);

            hitboxLoader = new HitboxLoader(stage);
            tiledBase.OnCollisionHitboxLoaded += hitboxLoader.OnCollisionHitboxLoaded;

            camera = new Camera(monoNet.GraphicsDevice.Viewport);
            UI     = new LevelUI();
        }
Esempio n. 2
0
        public void Update()
        {
            int playerNotReady = 0;

            for (int i = 0; i < net.ConnectedAdresses.Count; i++)
            {
                if (net.ConnectedAdresses[i].hasChangedLevel == false)
                {
                    playerNotReady++;
                }
            }

            if (playerNotReady <= 0)
            {
                LevelUI.DisplayString("All players (" + (net.ConnectedAdresses.Count + 1) + ") ready!\nPress F5 to start the game!");

                if (Input.IsKeyDownThisFrame(Microsoft.Xna.Framework.Input.Keys.F5))
                {
                    LevelUI.DisplayString("");
                    ServerConnectionComponent.Instance.StartGame();
                    Actor.Stage.DeleteActor(Actor);
                }
            }
            else
            {
                LevelUI.DisplayString("Still waiting on " + playerNotReady + " players!");
            }
        }
Esempio n. 3
0
 public void Update()
 {
     if (canRestart == true && Input.IsKeyDownThisFrame(Microsoft.Xna.Framework.Input.Keys.F6))
     {
         canRestart = false;
         LevelUI.DisplayString();
         ServerConnectionComponent.Instance.ChangeLevel(GameManager.GetRandomLevelNumber());
     }
 }
Esempio n. 4
0
        protected override void LoadLevel(byte levelNumber)
        {
            base.LoadLevel(levelNumber);

            LevelUI.DisplayString("");

            clientConnection.LevelLoaded();
            LevelUI.DisplayString("Level loaded\nWaiting for host to start!");
        }
Esempio n. 5
0
 public void GameEnd(bool draw, string name)
 {
     if (draw == false)
     {
         LevelUI.DisplayString("Player " + name + " won!\nWaiting for game to restart!");
     }
     else
     {
         LevelUI.DisplayString("Nobody wins!\nWaiting for game to restart");
     }
 }
Esempio n. 6
0
        public override void Initialize()
        {
            base.Initialize();

            LevelUI.DisplayString("Connecting...");

            reciever = new NetManagerReciever(ip, playerName);

            clientConnection = stage.CreateActor(0).AddComponent <ClientConnectionComponent>();
            clientConnection.Set(this);
        }
Esempio n. 7
0
        public void TakeControl(byte netId, Vector2 location)
        {
            NetSyncComponent nsc = NetManager.Instance.GetNetSyncComponent(netId);

            nsc.playerControlled = true;
            nsc.Actor.AddComponent <PlayerInput>();
            nsc.Actor.GetComponent <Transform2>().WorldPosition = location;
            nsc.Actor.GetComponent <Rigidbody>().velocity       = new Vector2(0);

            LevelUI.DisplayString("");
        }
Esempio n. 8
0
 private void OnGameEnd(PlayerManager winningPlayer)
 {
     canRestart = true;
     if (winningPlayer != null)
     {
         LevelUI.DisplayString("Player " + winningPlayer.name + " won!\nPress F6 to restart game!");
     }
     else
     {
         LevelUI.DisplayString("Nobody wins!\nPress F6 to restart game!");
     }
 }
Esempio n. 9
0
        public LevelUI()
        {
            Instance = this;

            desktop = new Desktop();
            label   = new Label {
                HorizontalAlignment = HorizontalAlignment.Center,
                VerticalAlignment   = VerticalAlignment.Center,
                TextAlign           = TextAlign.Center,
                TextColor           = Color.White,
                Padding             = new Thickness(8),
                Background          = new SolidBrush(new Color(30, 30, 30, 150))
            };

            desktop.Widgets.Add(label);
        }
Esempio n. 10
0
 public void WaitForRestart()
 {
     LevelUI.DisplayString("Game in progress.\nWaiting until the round ends!");
 }