Esempio n. 1
0
        public override void Load()
        {
            TankBuilder builder = new UsaTankBuilder(true);

            playerTank = builder.Build() as PlayerTank;

            /*playerTank = new TankBuilder(true)
             *  .SetChassis(0, 0)
             *  .SetTurret(0)
             *  .SetTracks(0)
             *  .Build() as PlayerTank;*/
            CreateEntity(playerTank);
            playerTank.transform.SetPosition(new Vector2(200, 300));
            playerTank.StartTurn();

            TankState state = new TankState();

            state.Pos_X = playerTank.transform.position.x;
            state.Pos_Y = playerTank.transform.position.y;
            playerTank.UpdateTankState(state);

            Tank npcTank = builder.Build();

            /*Tank npcTank = new TankBuilder(false)
             *  .SetChassis(1, 1)
             *  .SetTurret(1)
             *  .SetTracks(1)
             *  .Build();*/
            CreateEntity(npcTank);
            npcTank.transform.SetPosition(new Vector2(500, 300));
        }
Esempio n. 2
0
        public override void Load()
        {
            players = NetworkManager.Instance.GetPlayerList();
            foreach (Player player in players)
            {
                if (player.ConnectionId == NetworkManager.Instance.myConnId())
                {
                    tank = new TankBuilder(true)
                           .SetChassis(player.Tank.Color_id, player.Tank.Chasis_id)
                           .SetTurret(player.Tank.Chasis_id)
                           .SetTracks(player.Tank.Trucks_id)
                           .Build() as PlayerTank;
                    CreateEntity(tank);
                    tank.transform.SetPosition(new Vector2(player.TankState.Pos_X, player.TankState.Pos_Y));
                    tankDict.Add(player.ConnectionId, tank);
                    if (NetworkManager.Instance.getCurrentPlayer() == "YOU")
                    {
                        tank.StartTurn();
                    }
                }
                else
                {
                    Tank NPCTank = new TankBuilder(false)
                                   .SetChassis(player.Tank.Color_id, player.Tank.Chasis_id)
                                   .SetTurret(player.Tank.Chasis_id)
                                   .SetTracks(player.Tank.Trucks_id)
                                   .Build();
                    CreateEntity(NPCTank);
                    NPCTank.transform.SetPosition(new Vector2(player.TankState.Pos_X, player.TankState.Pos_Y));
                    tankDict.Add(player.ConnectionId, NPCTank);
                }
            }
            //NetworkManager.Instance.GetCrate();

            NetworkManager.Instance.PlayerChanged += Instance_PlayerChanged;


            //background = CreateEntity(new Background()) as Background;

            //terrain = CreateEntity(new Terrain()) as Terrain;

            gameplayUI = CreateEntity(new GameplayUI()) as GameplayUI;
            grenade    = new ProjectileFactory().Create("grenade") as Grenade;
            grenade.transform.SetPosition(new Vector2(300f, 300f));

            crate = CreateEntity(new Crate(Image.FromFile("../../res/crates/crate_0.png"), new Vector2(200f, 200f), grenade, new Vector2(50f, 50f))) as Crate;
            crate.transform.SetPosition(new Vector2(200f, 300f));
            crate.transform.SetSize(new Vector2(50f, 50f));

            /*
             * Tank usaTank = new TankBuilder()
             *  .SetChassis(1, 1)
             *  .SetTurret(1)
             *  .SetTracks(0)
             *  .Build();
             * CreateEntity(usaTank);
             * usaTank.transform.SetPosition(new Vector2(500, 100));
             */
        }
Esempio n. 3
0
 private void Instance_PlayerChanged(object sender, EventArgs e)
 {
     if (NetworkManager.Instance.IsMyTurn)
     {
         PlayerTank tank = tankDict[NetworkManager.Instance.myConnId()] as PlayerTank;
         tank.StartTurn();
         Console.WriteLine("My turn start");
     }
     else
     {
         Console.WriteLine("other player started the turn");
     }
 }
Esempio n. 4
0
        private void Instance_PlayerChanged(object sender, EventArgs e)
        {
            if (NetworkManager.Instance.getCurrentPlayer() == "YOU")
            {
                PlayerTank tank = tankDict[NetworkManager.Instance.myConnId()] as PlayerTank;
                NetworkManager.Instance.PlayerMoved  += Instance_PlayerMoved;
                NetworkManager.Instance.BarrelRotate += Instance_BarrelRotate;
                tank.StartTurn();
                Console.WriteLine("My turn start");
            }
            else
            {
                NetworkManager.Instance.PlayerMoved  -= Instance_PlayerMoved;
                NetworkManager.Instance.BarrelRotate -= Instance_BarrelRotate;

                Console.WriteLine("other's turn");
            }
            //NetworkManager.Instance.PlayerChanged -= Instance_PlayerChanged;
        }
Esempio n. 5
0
        private void SpawnTanks(List <Player> playersAndTanks)
        {
            foreach (Player player in playersAndTanks)
            {
                if (player.ConnectionId == NetworkManager.Instance.myConnId())
                {
                    TankBuilder usaTankBuilder = new UsaTankBuilder(true);
                    tank = usaTankBuilder.Build() as PlayerTank;

                    /*tank = new TankBuilder(true)
                     *   .SetChassis(player.Tank.Color_id, player.Tank.Chasis_id)
                     *   .SetTurret(player.Tank.Chasis_id)
                     *   .SetTracks(player.Tank.Trucks_id)
                     *   .Build() as PlayerTank;*/
                    CreateEntity(tank);
                    tank.UpdateTankState(player.TankState);
                    tankDict.Add(player.ConnectionId, tank);
                }
                else
                {
                    TankBuilder russianTankBuilder = new RussianTankBuilder(false);
                    Tank        NPCTank            = russianTankBuilder.Build();

                    /*Tank NPCTank = new TankBuilder(false)
                     *  .SetChassis(player.Tank.Color_id, player.Tank.Chasis_id)
                     *  .SetTurret(player.Tank.Chasis_id)
                     *  .SetTracks(player.Tank.Trucks_id)
                     *  .Build();*/
                    CreateEntity(NPCTank);
                    NPCTank.UpdateTankState(player.TankState);
                    tankDict.Add(player.ConnectionId, NPCTank);
                }
            }
            NetworkManager.Instance.OnTankConfigsReceived -= SpawnTanks;

            NetworkManager.Instance.OnTurnStarted  += Instance_PlayerChanged;
            NetworkManager.Instance.PlayerMoved    += Instance_PlayerMoved;
            NetworkManager.Instance.BarrelRotate   += Instance_BarrelRotate;
            NetworkManager.Instance.OnCrateSpawned += Instance_OnCrateSpawned;

            CreateEntity(new GameplayUI());
        }
Esempio n. 6
0
 public TankAiming(PlayerTank tank) : base(tank)
 {
     Console.WriteLine("STATE new TankAiming() Phase");
 }
Esempio n. 7
0
 public TankMovement(PlayerTank tank) : base(tank)
 {
 }
Esempio n. 8
0
 public TankIdle(PlayerTank tank) : base(tank)
 {
 }
Esempio n. 9
0
 public TankMovement(PlayerTank tank) : base(tank)
 {
     Console.WriteLine("STATE new TankMovement() Phase");
 }
Esempio n. 10
0
 public TankAiming(PlayerTank tank) : base(tank)
 {
 }
Esempio n. 11
0
 public TankWeaponSelection(PlayerTank tank) : base(tank)
 {
     inventoryUI = new InventoryUI(new Rectangle(250, 150, 285, 285));
     SceneManager.Instance.CurrentScene.CreateEntity(inventoryUI);
 }