Example #1
0
 bool InitGlobalIns()
 {
     if (Ins == null)
     {
         Ins = this;
     }
     else if (Ins != this)
     {
         DestroyImmediate(gameObject);
         return(false);
     }
     DontDestroyOnLoad(gameObject);
     return(true);
 }
Example #2
0
        public GameState()
        {
            InputManager  = new ManageInput();
            tileSet       = new TileSet();
            OutputManager = new ManageOutput(tileSet);
            droidGroup    = new DroidGroup(new IDroidState[] {
                new ReadyState(new int[] { 0, 0 }, new int[] { 1, 0 }),
                new ReadyState(new int[] { 2, 3 }, new int[] { 0, 1 })
            });

            InputManager.InputParsed += droidGroup.OnInputParsed;
            foreach (IDroidState droid in droidGroup.Droids)
            {
                droid.DroidReportedStatus         += OutputManager.OnDroidReportedStatus;
                droid.TileWithNeighboursRequested += tileSet.OnTileInfoRequested;
                droid.MoveRequested += tileSet.OnTileInfoRequested;
            }
        }
        /// <summary>
        /// 管理设备
        /// </summary>
        /// <param name="input"></param>
        /// <returns></returns>
        public async Task ManageAsync(ManageInput input)
        {
            var device = await _deviceRepository.GetAsync(input.Id);

            var obj = new
            {
                success = true,
                error   = new
                {
                    policeNo = device.User.PoliceNo,
                    isIn     = true,
                    time     = DateTime.Now
                }
            };

            if (input.Operation == "changeMode")
            {
                if (device.Status != "生活模式")
                {
                    obj = new
                    {
                        success = true,
                        error   = new
                        {
                            policeNo = device.User.PoliceNo,
                            isIn     = false,
                            time     = DateTime.Now
                        }
                    }
                }
                ;
                await _notificationManager.SendMessageAsync(
                    new UserIdentifier(AbpSession.TenantId, device.CreatorUserId.Value),
                    PlatformConsts.NotificationConstNames.CameraChange,
                    PlatformConsts.NotificationConstNames.CameraChange, obj);
            }
            else
            {
                await _notificationManager.SendMessageAsync(new UserIdentifier(AbpSession.TenantId, device.User.Id), PlatformConsts.NotificationConstNames.Device_Manage, input.Operation, device.MapTo <DeviceDto>());
            }
        }