public void OnNewEntity(Safir.Dob.EntityProxy entityProxy) { Consoden.TankGame.GameState gameState = entityProxy.Entity as Consoden.TankGame.GameState; if (gameState == null) { return; } for (int i = 0; i < gameState.Tanks.Count; i++) { if (!gameState.Tanks [i].IsNull()) { Consoden.TankGame.Tank tank = gameState.Tanks [i].Obj; if (tank.PlayerId.Val == myPlayerId) { currentGameId = entityProxy.InstanceId; myTankId = tank.TankId.Val; myJoystickId = InstanceId.GenerateRandom(); Consoden.TankGame.Joystick joystick = new Consoden.TankGame.Joystick(); joystickCounter = 0; joystick.PlayerId.Val = myPlayerId; joystick.GameId.Val = currentGameId; joystick.TankId.Val = myTankId; joystick.Counter.Val = joystickCounter++; connection.SetAll(joystick, myJoystickId, myHandlerId); logic = new TankLogic(myTankId, UpdateJoystick); break; } } } }
private void UpdateJoystick(Consoden.TankGame.Direction.Enumeration moveDirection, Consoden.TankGame.Direction.Enumeration towerDirection, bool fire, bool dropMine, bool fireLaser, bool deployLaser, bool fireRedeemer, int redeemerTimer) { if (myJoystickId == null) { return; //we are not active in a game } Consoden.TankGame.Joystick joystick = new Consoden.TankGame.Joystick(); joystick.PlayerId.Val = myPlayerId; joystick.GameId.Val = currentGameId; joystick.TankId.Val = myTankId; joystick.Counter.Val = joystickCounter++; joystick.MoveDirection.Val = moveDirection; joystick.TowerDirection.Val = towerDirection; joystick.Fire.Val = fire; joystick.FireLaser.Val = fireLaser; joystick.MineDrop.Val = dropMine; joystick.DeploySmoke.Val = deployLaser; joystick.FireRedeemer.Val = fireRedeemer; joystick.RedeemerTimer.Val = redeemerTimer; connection.SetAll(joystick, myJoystickId, myHandlerId); }
private void UpdateJoystick(Consoden.TankGame.Direction.Enumeration moveDirection, Consoden.TankGame.Direction.Enumeration towerDirection, bool fire, bool dropMine, bool fireLaser, bool deployLaser, bool fireRedeemer, int redeemerTimer) { if (myJoystickId == null) { return; //we are not active in a game } Consoden.TankGame.Joystick joystick = new Consoden.TankGame.Joystick (); joystick.PlayerId.Val = myPlayerId; joystick.GameId.Val = currentGameId; joystick.TankId.Val = myTankId; joystick.Counter.Val = joystickCounter++; joystick.MoveDirection.Val = moveDirection; joystick.TowerDirection.Val = towerDirection; joystick.Fire.Val = fire; joystick.FireLaser.Val = fireLaser; joystick.MineDrop.Val = dropMine; joystick.DeploySmoke.Val = deployLaser; joystick.FireRedeemer.Val = fireRedeemer; joystick.RedeemerTimer.Val = redeemerTimer; connection.SetAll (joystick, myJoystickId, myHandlerId); }
public void OnNewEntity(Safir.Dob.EntityProxy entityProxy) { Consoden.TankGame.GameState gameState = entityProxy.Entity as Consoden.TankGame.GameState; if (gameState == null) { return; } for (int i=0; i<gameState.Tanks.Count; i++) { if (!gameState.Tanks [i].IsNull ()) { Consoden.TankGame.Tank tank = gameState.Tanks [i].Obj; if (tank.PlayerId.Val == myPlayerId) { currentGameId = entityProxy.InstanceId; myTankId = tank.TankId.Val; myJoystickId = InstanceId.GenerateRandom (); Consoden.TankGame.Joystick joystick = new Consoden.TankGame.Joystick (); joystickCounter = 0; joystick.PlayerId.Val = myPlayerId; joystick.GameId.Val = currentGameId; joystick.TankId.Val = myTankId; joystick.Counter.Val = joystickCounter++; connection.SetAll (joystick, myJoystickId, myHandlerId); logic = new TankLogic (myTankId, UpdateJoystick); break; } } } }