Пример #1
0
        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;
                    }
                }
            }
        }
Пример #2
0
        public void OnDeletedEntity(Safir.Dob.EntityProxy entityProxy, bool deprecated)
        {
            if (entityProxy.TypeId == Consoden.TankGame.GameState.ClassTypeId &&
                entityProxy.InstanceId == currentGameId) {
                if (myJoystickId != null) {
                    connection.Delete (new EntityId (Consoden.TankGame.Joystick.ClassTypeId, myJoystickId), myHandlerId);
                }

                logic = null;
                myJoystickId = null;
                currentGameId = null;
                myTankId = -1;
            }
        }
Пример #3
0
        public void OnDeletedEntity(Safir.Dob.EntityProxy entityProxy, bool deprecated)
        {
            if (entityProxy.TypeId == Consoden.TankGame.GameState.ClassTypeId &&
                entityProxy.InstanceId == currentGameId)
            {
                if (myJoystickId != null)
                {
                    connection.Delete(new EntityId(Consoden.TankGame.Joystick.ClassTypeId, myJoystickId), myHandlerId);
                }

                logic         = null;
                myJoystickId  = null;
                currentGameId = null;
                myTankId      = -1;
            }
        }
Пример #4
0
        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;
                    }
                }
            }
        }