public async Task ClientConnectSignalR(string username, OnWorkDone onCompleted)
        {
            InitialiseHubConnection(username);
            Debug.Log("Connecting for client!");
            Loader loader = null;
            if (!MultiplayerManager.instance.isServer)
            {
                loader = Instantiate(MultiplayerManager.instance.loader, MultiplayerManager.instance.Canvas, false);
                loader.StartLoading();
            }
            await _connection.ConnectAsync();
            Debug.Log("Connection Complete...");

            ClientSend.username = username;
            ClientSend.connectionID = _connection.NegotiationResult.ConnectionId;
            MultiplayerManager.instance.localPlayerConnectionId = _connection.NegotiationResult.ConnectionId;

            onCompleted?.Invoke();
            if (!MultiplayerManager.instance.isServer)
            {
                if (loader != null)
                {
                    loader.SetMessage("User succssfully connected");
                    loader.transform.SetAsLastSibling();
                }
            }
        }
        public async Task SendAsyncData<T, V>(string method, T data, OnWorkDone<V> onComplete)
        {
            Debug.Log("SendAsync " + method);
            Loader loader = null;
            if (!MultiplayerManager.instance.isServer)
            {
                loader = Instantiate(MultiplayerManager.instance.loader, MultiplayerManager.instance.Canvas, false);
                loader.StartLoading();
            }

            try
            {
                Debug.Log("Getting reposne now!! for data : " + data);
                Response<V> response = await _connection.InvokeAsync<Response<V>>(method, data);
                Debug.Log("Json data is " + JsonUtility.ToJson(response));
                if (response.Success)
                {
                    Debug.Log("Done Success");
                    onComplete?.Invoke(response.data);
                }
                if (!MultiplayerManager.instance.isServer)
                {
                    if (loader != null)
                    {
                        loader.SetMessage(response.Message);
                        loader.transform.SetAsLastSibling();
                    }
                }
            }
            catch (TaskCanceledException ex)
            {
                Debug.LogError("ex" + ex);
            }
        }
 public async Task ServerConnectSignalR(string username, MatchBeginDto matchBeginDto, OnWorkDone<MatchBeginDto> onCompleted)
 {
     InitialiseHubConnection(username);
     Debug.Log("Connecting for server!");
     await _connection.ConnectAsync();
     Debug.Log("Connection Complete...");
     onCompleted?.Invoke(matchBeginDto);
 }
Beispiel #4
0
        /// <summary>
        /// Прервать процесс обработки
        /// </summary>
        public void Abort()
        {
            if (_thread.IsAlive)
            {
                _statusInfo.SetStatus(ProcessStatusEnum.Deleting);
                _thread.Abort();
            }

            OnWorkDone?.Invoke(this, new EventArgs());
        }
Beispiel #5
0
 private void WorkThread()
 {
     try
     {
         _pngProcessor.Process(_filePath);
         _statusInfo.SetStatus(ProcessStatusEnum.Done);
     }
     catch
     {
         _statusInfo.SetStatus(ProcessStatusEnum.Error);
     }
     finally
     {
         OnWorkDone?.Invoke(this, new EventArgs());
     }
 }
        public void PlaceTornadoObject(Hero heroOwner, int direction, Vector3Int cellToPlaceOn, OnWorkDone onItemSuccessfullyUsed)
        {
            if (heroOwner.IsHeroAbleToFireProjectiles((FaceDirection)direction))
            {
                Debug.Log("CastTornadoForPlayerImplementation ");
                //SpawnThe collider here
                GameObject colliderRef = Instantiate(tornadoColliderUnit
                                                     , GridManager.instance.cellToworld(cellToPlaceOn)
                                                     , Quaternion.identity);

                TornadoCollider tornadoCollider = colliderRef.GetComponent <TornadoCollider>();
                tornadoCollider.InitialiseOwner(heroOwner.ownerId);

                //place tile tornado
                GridManager.instance.SetTile(cellToPlaceOn, EnumData.TileType.Tornado, true, false);
                GridManager.instance.SetTile(cellToPlaceOn, EnumData.TileType.Solid, true, false);
                List <Vector3Int> getCellToSolidify = GridManager.instance.GetSizeCells(GameConfig.tornadoSize / 2, cellToPlaceOn);

                if (actorIdToPlacedTornadoDic.ContainsKey(heroOwner.ownerId))
                {
                    actorIdToPlacedTornadoDic[heroOwner.ownerId].Add(colliderRef.GetInstanceID(), new TornadoChild(colliderRef, new List <Actor>()));
                }
                else
                {
                    Dictionary <int, TornadoChild> tornadoChildrenDictionary = new Dictionary <int, TornadoChild>();
                    tornadoChildrenDictionary.Add(colliderRef.GetInstanceID(), new TornadoChild(colliderRef, new List <Actor>()));

                    actorIdToPlacedTornadoDic.Add(heroOwner.ownerId, tornadoChildrenDictionary);
                }
                GridManager.instance.SolidifyTiles(getCellToSolidify);

                //Start the coroutine here
                IEnumerator ie = WaitForTornado(heroOwner, cellToPlaceOn, colliderRef.GetInstanceID());
                StopCoroutine(ie);
                StartCoroutine(ie);

                heroOwner.tornadoPlacedUsedCount--;
                onItemSuccessfullyUsed?.Invoke();
            }
            else
            {
                Debug.Log("Tornado-Hero is not able to fire projectiles");
            }
        }
 public void PlaceMedusaBoulderObject(Hero serverHero, Vector3Int cellPositionToPlaceBoulder, OnWorkDone onItemSuccessfullyUsed)
 {
     //place boulder
     if (!GridManager.instance.IsCellBlockedForSpawnObjectPlacementAtPos(cellPositionToPlaceBoulder))
     {
         if (!cellPositionToOwnerDic.ContainsKey(cellPositionToPlaceBoulder))
         {
             Debug.Log("Setting tile non item boulder on " + cellPositionToPlaceBoulder);
             GridManager.instance.SetTile(cellPositionToPlaceBoulder, EnumData.TileType.Boulder, true, false);
             serverHero.boulderUsedCount--;
             cellPositionToOwnerDic.Add(cellPositionToPlaceBoulder, serverHero.ownerId);
             onItemSuccessfullyUsed?.Invoke();
         }
         else
         {
             Debug.LogError("Dictionary already contains the key : " + cellPositionToPlaceBoulder);
         }
     }
 }
        public void PlaceGorgonTile(OnWorkDone onSuccessfullyItemPlaced)
        {
            List <Vector3Int> allNormalFloorCellPos    = GridManager.instance.GetAllPositionForTileMap(EnumData.TileType.Normal);
            List <Vector3Int> allNoBoulderFloorCellPos = GridManager.instance.GetAllPositionForTileMap(EnumData.TileType.NoBoulder);

            foreach (Vector3Int item in allNormalFloorCellPos)
            {
                GridManager.instance.SetTile(item, EnumData.TileType.Mirror, true, false);
                GridManager.instance.SetTile(item, EnumData.TileType.Normal, false, false);
            }

            foreach (Vector3Int item in allNoBoulderFloorCellPos)
            {
                GridManager.instance.SetTile(item, EnumData.TileType.Mirror, true, false);
                GridManager.instance.SetTile(item, EnumData.TileType.NoBoulder, false, false);
            }

            IEnumerator ie = GorgonGlassTimer(allNormalFloorCellPos, allNoBoulderFloorCellPos);

            StopCoroutine(ie);
            StartCoroutine(ie);
            onSuccessfullyItemPlaced?.Invoke();
        }
        public void PlacePortal(int portalOwner, Vector3Int portalInLet, OnWorkDone onSuccess)
        {
            if (!portalEntranceDic.ContainsKey(portalInLet))
            {
                List <Vector3Int> placablePositions = GetAllPlacablePortalPoints(GetActorsWithMaxLives(portalOwner));

                if (placablePositions.Count > 0)
                {
                    Vector3Int portalOutlet = placablePositions[UnityEngine.Random.Range(0, placablePositions.Count)];
                    GridManager.instance.SetTile(portalInLet, EnumData.TileType.Portal, true, false);
                    GridManager.instance.SetTile(portalOutlet, EnumData.TileType.Portal, true, false);
                    portalEntranceDic.Add(portalInLet, new PortalInfo(portalOwner, portalOutlet));

                    IEnumerator ie = PortalTimer(portalInLet);
                    StopCoroutine(ie);
                    StartCoroutine(ie);
                    onSuccess?.Invoke();
                }
                else
                {
                    Debug.LogError("No placable position");
                }
            }
        }
 public SettingImportViewModel()
 {
     IsSettingsTextReadOnly = false;
     DoCommand = new RelayCommand(() => { IsNeedImport = true; OnWorkDone?.Invoke(); });
 }