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);
            }
        }
Ejemplo n.º 2
0
 public void StartPath(Vector2 targetPosition, OnWorkDone doneEvent)
 {
     this.doneEvent = null;
     OnEndedPath();
     this.targetPosition = targetPosition;
     this.doneEvent      = doneEvent;
 }
        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();
                }
            }
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Прервать процесс обработки
        /// </summary>
        public void Abort()
        {
            if (_thread.IsAlive)
            {
                _statusInfo.SetStatus(ProcessStatusEnum.Deleting);
                _thread.Abort();
            }

            OnWorkDone?.Invoke(this, new EventArgs());
        }
Ejemplo n.º 5
0
    public override void Work(OnWorkDone done)
    {
        base.Work(done);
        Debug.Log("testWork" + pos);

        follower.StartPath(pos, () => {
            if (!interupted)
            {
                animation.AnimTest(() => done());
            }
        });
    }
Ejemplo n.º 6
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 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");
                }
            }
        }
Ejemplo n.º 9
0
 public virtual void Stop(OnWorkDone done)
 {
     interupted = true;
 }
Ejemplo n.º 10
0
 public virtual void Work(OnWorkDone done)
 {
     interupted = false;
 }
        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 async Task CreateRoom(RoomDto roomDto)
 {
     OnWorkDone <Room> onRoomCreated = OnRoomCreated;
     await SignalRCoreConnect.instance.SendAsyncData("CreateRoom", roomDto, onRoomCreated);
 }
Ejemplo n.º 13
0
 public override void Stop(OnWorkDone done)
 {
     base.Stop(done);
     Debug.Log("testWork");
     follower.StopPath();
 }
 public SettingImportViewModel()
 {
     IsSettingsTextReadOnly = false;
     DoCommand = new RelayCommand(() => { IsNeedImport = true; OnWorkDone?.Invoke(); });
 }
 public async Task JoinRoom(Room room)
 {
     OnWorkDone <Room> OnJoinedRoomSuccess = OnJoinedRoom;
     await SignalRCoreConnect.instance.SendAsyncData("JoinRoom", room, OnJoinedRoomSuccess);
 }
Ejemplo n.º 16
0
 public void AnimTest(OnWorkDone done)
 {
     Debug.Log("anim");
     done();
 }
 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);
 }
 public async Task GetLobby()
 {
     OnWorkDone <Lobby> OnGetLobbySuccess = OnGetLobby;
     await SignalRCoreConnect.instance.SendAsyncData("GetLobby", OnGetLobbySuccess);
 }
 public async Task LeaveRoom(Room room)
 {
     OnWorkDone <Room> OnRoomLeave = OnRoomLeft;
     await SignalRCoreConnect.instance.SendAsyncData("LeaveRoom", room, OnRoomLeave);
 }
 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 async Task StartMatch(MatchBeginDto matchBeginDto)
 {
     OnWorkDone<Match> OnMatchStartedOnServerResponse = OnMatchStartedOnServer;
     Debug.Log("On Match started on server at port " + matchBeginDto.matchId);
     await SendAsyncData("OnMatchStartedOnServer", matchBeginDto, OnMatchStartedOnServerResponse);
 }