Exemplo 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));
        }
Exemplo n.º 2
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());
        }