예제 #1
0
    public void SetupPropertieLucky(PlayerController player, UnityEngine.Events.UnityAction<TileController> action, bool ownerTile, bool onlyCountry)
    {
        List<TileController> tiles = new List<TileController>();
        foreach(var aux in tileControllers)
        {
            var tile = aux.SetupPropertieLucky(player, action, ownerTile, player.botController, onlyCountry);
            if(tile)
            {
                tiles.Add(tile);
            }
        }

        if(player.botController != null && tiles.Count > 0)
        {
            StartCoroutine(player.botController.ExecuteAction(() => { action.Invoke(tiles[UnityEngine.Random.Range(0, tiles.Count)]) ; ResetBoard(); }));
        }

        if(tiles.Count<=0)
        {
            Debug.Log("Reseting");
            MessageManager.Instance.ShowMessage("Nenhuma propriedade para aplicar esse efeito");
            action.Invoke(null);
            ResetBoard();
        }
    }
예제 #2
0
    IEnumerator OnInitializeComplete()
    {
        progress = 100;

        while (displayProgress < progress)
        {
            ++displayProgress;
            LoadingLayer.SetProgressbarValue(displayProgress);
            yield return(new WaitForEndOfFrame());
        }

        loadSceneName   = null;
        async           = null;
        progress        = 0;
        displayProgress = 0;
        sceneBundle.Unload(false);

        LoadingLayer.Hide();

        if (OnInitializeSceneComplete != null)
        {
            OnInitializeSceneComplete.Invoke();
            OnInitializeSceneComplete = null;
        }
    }
예제 #3
0
 public void setDownAction(UnityEngine.Events.UnityAction listener)
 {
     downButton.onClick.RemoveAllListeners();
     downButton.onClick.AddListener(() => {
         listener.Invoke();
     });
 }
예제 #4
0
 public void setUpgradeAction(UnityEngine.Events.UnityAction listener)
 {
     upgradeButton.onClick.RemoveAllListeners();
     upgradeButton.onClick.AddListener(() => {
         listener.Invoke();
     });
 }
예제 #5
0
    public void ShowSessionProgress(PlayerSessionData sessionData, CurrentSessionTaskData sessionTask, UnityEngine.Events.UnityAction onOKclick)
    {
        gameObject.SetActive(true);
        for (int i = 0; i < sessionTask.tasks.Length; i++)
        {
            taskViewer[i].SetActive(true);
            taskViewer[i].GetComponentInChildren <Toggle>().gameObject.SetActive(true);
            taskViewer[i].GetComponent <Text>().text = GetLocalizedTaskText(sessionTask.tasks[i].taskType, sessionTask.tasks[i].taskAmount);
            taskViewer[i].GetComponentInChildren <Toggle>().GetComponent <UnityEngine.UI.Toggle>().isOn = sessionTask.tasks[i].isDone;
            taskViewer[i].transform.GetChild(1).GetComponent <Text>().text = sessionTask.tasks[i].reward.ToString() + "$";
            switch (sessionTask.tasks[i].taskType)
            {
            case GameEnums.TaskType.DestroyEnemies:
                taskViewer[i].transform.GetChild(2).GetComponent <Text>().text = $"{sessionData.defeatedEnemies}";
                break;

            case GameEnums.TaskType.TravelDistance:
                taskViewer[i].transform.GetChild(2).GetComponent <Text>().text = $"{sessionData.traveledDistance} m";
                break;

            case GameEnums.TaskType.TravelTime:
                taskViewer[i].transform.GetChild(2).GetComponent <Text>().text = $"{sessionData.traveledTime} sec";
                break;

            default:
                break;
            }
        }
        totalRewardText.gameObject.SetActive(true);
        totalRewardText.text = GetLocalizedRewardText(sessionTask.totalReward, PlayerStaticDataHandler.RewardCoinsForSession(sessionData.defeatedEnemies, sessionData.traveledDistance));
        okButton.onClick.RemoveAllListeners();
        okButton.onClick.AddListener(() => onOKclick.Invoke());
        okButton.onClick.AddListener(() => HideWindow());
    }
예제 #6
0
        protected void SaveFile(string path, byte[] datas, UnityEngine.Events.UnityAction onFailed = null)
        {
            var bundleName = System.IO.Path.GetFileName(path);
            var dir        = System.IO.Path.GetDirectoryName(path);

            try
            {
                if (!System.IO.Directory.Exists(dir))
                {
                    System.IO.Directory.CreateDirectory(dir);
                }

                System.IO.File.WriteAllBytes(path, datas);

                LoggerManager.Instance().LogProcessFormat("TrySave {0} To {1} Succeed ...", bundleName, path);
            }
            catch (System.Exception e)
            {
                LoggerManager.Instance().LogErrorFormat("TrySave {0} To {1} Failed ...", bundleName, path);
                LoggerManager.Instance().LogErrorFormat(e.ToString());
                if (null != onFailed)
                {
                    onFailed.Invoke();
                }
            }
        }
예제 #7
0
    private void OnInvitationReceived(Invitation invitation, bool shouldAutoAccept)
    {
        Debug.Log("Invitation recieved " + shouldAutoAccept + " " + invitation.Inviter.DisplayName);

        // We use it to automatically to invoke what we want to do or have the user decide
        UnityEngine.Events.UnityAction action = () => {
            ScaneManager.Instance.GoToSceneThenDo("GooglePlayConnectScreen", () => {
                GooglePlayGameManager manager = FindObjectOfType <GooglePlayGameManager>();

                PlayGamesPlatform.Instance.RealTime.AcceptInvitation(invitation.InvitationId, manager);
                manager.ShowRoomMakingPanel();
            });
        };

        if (shouldAutoAccept)
        {
            action.Invoke();
        }
        else
        {
            PopupManager.Instance.PopUp(
                new PopUpTwoButton(invitation.Inviter.DisplayName + "\nwould like to play with you!", "Decline", "Accept")
                .SetButtonColors(new Color(0.95686f, 0.26275f, 0.21176f), new Color(0.29804f, 0.68627f, 0.31373f))
                .SetButtonTextColors(Color.white, Color.white)
                .SetButtonPressActions(() => { }, action)
                );
        }
    }
예제 #8
0
        IEnumerator DownLoadAssetBundleByBuffer(string url, UnityEngine.Events.UnityAction <byte[]> cb, UnityEngine.Events.UnityAction onFailed)
        {
            using (UnityWebRequest www = UnityWebRequest.Get(url))
            {
                DownloadHandlerBuffer handler = new DownloadHandlerBuffer();
                www.downloadHandler = handler;
                yield return(www.Send());

                if (www.isError)
                {
                    LoggerManager.Instance().LogErrorFormat("DownLoadAssetBundleByBuffer Failed:{0} url={1}", www.error, url);

                    if (null != onFailed)
                    {
                        onFailed.Invoke();
                    }
                }
                else
                {
                    LoggerManager.Instance().LogFormat("DownLoadAssetBundleByBuffer Succeed : Length = {0} ...", handler.data.Length);

                    if (null != cb)
                    {
                        cb.Invoke(www.downloadHandler.data);
                    }
                }
            }
        }
예제 #9
0
    IEnumerator IEScale(Vector3 fro, Vector3 to, float time, float delayTime = 0, UnityEngine.Events.UnityAction callback = null)
    {
        if (delayTime > 0)
        {
            yield return(new WaitForSeconds(delayTime));
        }

        transform.localScale = fro;

        float elapse = 0;

        while (elapse < time)
        {
            elapse += Time.deltaTime;
            transform.localScale = Vector3.Lerp(fro, to, elapse / time);
            yield return(null);
        }

        transform.localScale = to;

        if (callback != null)
        {
            callback.Invoke();
        }
    }
    public void Show()
    {
        if (state == State.Appearing || state == State.Visible || state == State.RevertingHiding)
        {
            return;
        }

        if (state == State.Hidden || state == State.RevertingAppear)
        {
            state           = State.Appearing;
            elapsedHideTime = 0;
        }
        else if (state == State.Hiding)
        {
            state = State.RevertingHiding;
        }

        if (onStartAppearing != null)
        {
            onStartAppearing.Invoke();
        }

        IsActive  = true;
        isStopped = false;
    }
예제 #11
0
    public static bool PlayAd(UnityEngine.Events.UnityAction onAdPlay, UnityEngine.Events.UnityAction adNotAviable)
    {
        // fetch the video
        HZVideoAd.Fetch();
        // Check for availability
        if (HZVideoAd.IsAvailable())
        {
            // Show the ad
            HZVideoAd.Show();
            // Callback
            if (null != onAdPlay)
            {
                onAdPlay.Invoke();
            }
            // E x i t
            return(true);
        }

        // Failed debug it
        if (null != adNotAviable)
        {
            adNotAviable.Invoke();
        }

        return(false);
    }
예제 #12
0
    IEnumerator MathTest(UnityEngine.Events.UnityAction action = null)
    {
        System.DateTime time    = System.DateTime.Now;
        System.DateTime newtime = System.DateTime.Now;
        // Mathf 三角函数
        float x = 0, y = 0, z = 0;

        for (int i = 0; i < 2048; i++)
        {
            for (int j = 0; j < 2048; j++)
            {
                x = 128 + Mathf.Sin(x * 0.11f) * 127;
                y = 128 + Mathf.Cos(y * 0.11f) * 127;
                z = 128 + Mathf.Sin(z * 0.11f) * 127;
            }
        }
        //计时
        newtime = System.DateTime.Now;
        //Debug.Log("Result: " + x + ", " + y + ", " + z);
        TestLogger.OutputResult("UnityEngine.Mathf Trigonometric Time Cost :  ", (newtime - time).TotalMilliseconds, true);
        yield return(x + y + z);

        // System.Math 三角函数
        time = newtime;
        x    = 0; y = 0; z = 0;
        for (int i = 0; i < 2048; i++)
        {
            for (int j = 0; j < 2048; j++)
            {
                x = 128 + (float)System.Math.Sin(x * 0.11f) * 127;
                y = 128 + (float)System.Math.Cos(y * 0.11f) * 127;
                z = 128 + (float)System.Math.Sin(z * 0.11f) * 127;
            }
        }
        //计时
        newtime = System.DateTime.Now;
        Debug.Log("Result: " + x + ", " + y + ", " + z);
        TestLogger.OutputResult("System.Math Trigonometric Time Cost :  ", (newtime - time).TotalMilliseconds);
        yield return(x + y + z);

        // Talor 三角函数
        time = System.DateTime.Now;
        x    = 0; y = 0; z = 0;
        for (int i = 0; i < 2048; i++)
        {
            for (int j = 0; j < 2048; j++)
            {
                x = 128 + MySin(x * 0.11f) * 127;
                y = 128 + MyCos(y * 0.11f) * 127;
                z = 128 + MySin(z * 0.11f) * 127;
            }
        }
        //计时
        newtime = System.DateTime.Now;
        Debug.Log("Result: " + x + ", " + y + ", " + z);
        TestLogger.OutputResult("Talor  Math Trigonometric Time Cost :  ", (newtime - time).TotalMilliseconds);
        yield return(x + y + z);

        action?.Invoke();
    }
예제 #13
0
    public void SetLoggerTarget(Logger newLogger, Vector3Int pos, UnityEngine.Events.UnityAction <Logger> onReached)
    {
        newLogger.AssignTarget(pos);
        newLogger.choppingTile = pos;

        newLogger.OnReached.AddListener((PathfindingAgent agent) => onReached.Invoke(agent as Logger));
        // newLogger.OnReturn.AddListener(() => { Debug.Log("logger returned"); });
    }
예제 #14
0
    IEnumerator RegexMatch(string file, UnityEngine.Events.UnityAction callBack)
    {
        string filePath = Application.persistentDataPath + "/" + file + ".txt";

        filePath = Regex.Replace(filePath, "/", @"\");
        var www = new WWW("file://" + filePath);

        yield return(www);

        string            nText   = www.text;
        string            pattern = @"[a-zA-Z]+.*[\u4e00-\u9fa5]+|[\u4e00-\u9fa5]+.*[a-zA-Z]+";
        var               mat     = Regex.Match(nText, pattern);
        int               count   = 0;
        List <Vocabulary> vocList = new List <Vocabulary>();

        while (mat.Success)
        {
            count++;
            string str = Regex.Replace(mat.Value, @"(\[.*\])+|[\uFE30-\uFFA0]+", " ");
            str = Regex.Replace(str, @"[ \n\s*\r]+", " ");

            //匹配词性 如abj.
            var    c  = Regex.Match(str, @"[a-z]+\.");
            string en = string.Empty;
            if (c.Success)
            {
                if (c.Value.Contains("sb") || c.Value.Contains("sth"))
                {
                    en  = str.Substring(0, c.Index + c.Length);
                    str = str.Substring(c.Index + c.Length);
                }
                else
                {
                    en  = str.Substring(0, c.Index - 1);
                    str = str.Substring(c.Index);
                }
                vocList.Add(new Vocabulary(en, str));
            }
            else
            {
                var enMat = Regex.Match(str, @"[a-zA-Z]+([ -][a-zA-Z]+)*");
                str = Regex.Replace(str, @"[a-zA-Z]+([ -][a-zA-Z]+)*", "");

                vocList.Add(new Vocabulary(enMat.Value, str));
            }
            mat = mat.NextMatch();
        }
        if (vocList.Count > 0)
        {
            //SaveVocList(SortVocList(vocList), file + ".xml");
            SaveVocList(vocList, file + ".xml");
            callBack.Invoke();
        }
        else
        {
            UIToast.ShowTips("词库解析失败,请检查词库格式是否正确", 2.0f);
        }
    }
예제 #15
0
    public static IEnumerator DoSomeThing(float seconds, UnityEngine.Events.UnityAction callback)
    {
        yield return(new WaitForSeconds(seconds));

        if (callback != null)
        {
            callback.Invoke();
        }
    }
예제 #16
0
    IEnumerator LoadImageR(UnityEngine.Events.UnityAction _callback = null)
    {
        var www = UnityWebRequestTexture.GetTexture(data.image_url);

        yield return(www.SendWebRequest());

        texture = ((DownloadHandlerTexture)www.downloadHandler).texture;
        _callback?.Invoke();
    }
 public override void OnPointerExit(GameObject previousObject)
 {
     //ReticleDistanceInMeters = maxReticleDistance;
     ReticleInnerAngle = RETICLE_MIN_INNER_ANGLE;
     ReticleOuterAngle = RETICLE_MIN_OUTER_ANGLE;
     if (OnPointerExitEvent != null)
     {
         OnPointerExitEvent.Invoke(previousObject);
     }
 }
예제 #18
0
 public override void EndState(IAiProcess nextState)
 {
     if (m_UnityActionDeadEnd != null &&
         m_UnityActionDeadEnd.Target != null)
     {
         m_UnityActionDeadEnd.Invoke();
     }
     GameMgr.Ins.m_unitMgr.RemoveUnit(m_ownerUnit);
     m_dead = true;
 }
    public override void OnPointerEnter(RaycastResult raycastResultResult, bool isInteractive)
    {
        SetPointerTarget(raycastResultResult.worldPosition, isInteractive);
        if (OnPointerEnterEvent != null)
        {
            OnPointerEnterEvent.Invoke(raycastResultResult);
        }

        //Debug.Log("LEFT:"+GvrViewer.Controller.Eyes[0].cam.WorldToScreenPoint(raycastResultResult.worldPosition).ToString("F4"));
        //Debug.Log("RIGHT:"+ GvrViewer.Controller.Eyes[1].cam.WorldToScreenPoint(raycastResultResult.worldPosition).ToString("F4"));
    }
예제 #20
0
    public static IEnumerator DoSomeThingAfterFrame(int frameWait, UnityEngine.Events.UnityAction callback)
    {
        for (int i = 0; i < frameWait; i++)
        {
            yield return(null);
        }

        if (callback != null)
        {
            callback.Invoke();
        }
    }
예제 #21
0
    public override void Show()
    {
        if (items.Length == 0)
        {
            Debug.LogError("item list is empty");
        }
        var grid = content.GetComponent <VerticalLayoutGroup>();

        for (int i = 0; i < grid.transform.childCount; i++)
        {
            Destroy(grid.transform.GetChild(i).gameObject);
        }
        grid.transform.DetachChildren();

        foreach (string s in items)
        {
            var obj = Instantiate(itemTemplate, grid.transform);
            obj.name = s;
            obj.GetComponentInChildren <Text>().text = s;
            if (IsFileBrowserMode)
            {
                obj.GetComponent <Button>().onClick.AddListener(() =>
                {
                    var filePath = Path.Combine(currentPath, s);
                    if (Directory.Exists(filePath))
                    {
                        ShowAsFileBrowser(filePath, fileBrowserHandler);
                    }
                    else
                    {
                        Hide();
                        fileBrowserHandler(filePath);
                    }
                });
            }
            else
            {
                obj.GetComponent <Button>().onClick.AddListener(() =>
                {
                    Hide();
                    OnItemSelected.Invoke(s);
                });
            }
        }

        float height = items.Length * itemTemplate.GetComponent <RectTransform>().sizeDelta.y
                       + content.transform.childCount * grid.spacing
                       + grid.padding.top + grid.padding.bottom;

        mainPanel.sizeDelta = new Vector2(mainPanel.sizeDelta.x, Mathf.Min(height, MaxHeight));
        base.Show();
    }
예제 #22
0
    IEnumerator WrapTest(UnityEngine.Events.UnityAction action = null)
    {
        System.DateTime time    = System.DateTime.Now;
        System.DateTime newtime = System.DateTime.Now;

        //Test double2double
        double dv = 0;

        for (double i = 0; i < 100; i++)
        {
            dv = DoubleReturnDouble(i);
        }
        newtime = System.DateTime.Now;
        TestLogger.OutputResult("In Double Out Double_  ", (newtime - time).Milliseconds);//
        yield return(dv);

        //Test float2float
        time = System.DateTime.Now;
        float fv = 0;

        for (float i = 0; i < 100; i++)
        {
            fv = FloatReturnFloat(i);
        }
        newtime = System.DateTime.Now;
        TestLogger.OutputResult("In Float Out Float_  ", (newtime - time).Milliseconds);
        yield return(fv);

        //Test warpped
        time = System.DateTime.Now;
        fv   = 0;
        for (float i = 0; i < 100; i++)
        {
            fv = WrapD2D_F2F(i);
        }
        newtime = System.DateTime.Now;
        TestLogger.OutputResult("Wrapped Double To Float_  ", (newtime - time).Milliseconds);
        yield return(fv);

        //Test convert
        time = System.DateTime.Now;
        fv   = 0;
        for (float i = 0f; i < 100; i++)
        {
            fv = (float)DoubleReturnDouble(i);
        }
        newtime = System.DateTime.Now;
        TestLogger.OutputResult("Convert Double To Float_  ", (newtime - time).Milliseconds);
        yield return(fv);

        action?.Invoke();
    }
예제 #23
0
    void InitializeScene()
    {
        UIUtil.ClearUICache();
        Util.ClearMemory();

        if (OnInitializeScene != null)
        {
            OnInitializeScene.Invoke();
            OnInitializeScene = null;
        }

        StartCoroutine(OnInitializeComplete());
    }
 public override void OnPointerHover(RaycastResult raycastResultResult, bool isInteractive)
 {
     SetPointerTarget(raycastResultResult.worldPosition, isInteractive);
     if (OnPointerHoverEvent != null)
     {
         OnPointerHoverEvent.Invoke(raycastResultResult);
     }
     if (Svr.SvrSetting.IsVR9Device)
     {
         SVR.AtwAPI.SetScreenPoint(GvrViewer.Controller.Eyes[0].cam.WorldToScreenPoint(raycastResultResult.worldPosition).x,
                                   GvrViewer.Controller.Eyes[1].cam.WorldToScreenPoint(raycastResultResult.worldPosition).x);
     }
 }
예제 #25
0
    public override void Update()
    {
        base.Update();
        if (Input.GetButtonUp("Fire1"))
        {
            Ray mouseRay = Camera.main.ScreenPointToRay(Input.mousePosition);
            var hits     = Physics.RaycastAll(mouseRay);

            foreach (var hit in hits)
            {
                if (hit.transform.gameObject.GetComponentInParent <EntityHolder>())
                {
                    holder = hit.transform.gameObject.GetComponentInParent <EntityHolder>();
                    OnClick.Invoke(holder);
                    RemoveEvent();
                    return;
                }
            }

            OnClick.Invoke(null);
            RemoveEvent();
        }
    }
예제 #26
0
    private IEnumerator Filling(float startValue, float endValue, float duration, UnityEngine.Events.UnityAction <float> onLerpingEnd)
    {
        float elapsed = 0;
        float nextValue;

        while (elapsed < duration)
        {
            nextValue         = Mathf.Lerp(startValue, endValue, elapsed / duration);
            _image.fillAmount = nextValue;
            elapsed          += Time.deltaTime;
            yield return(null);
        }
        onLerpingEnd?.Invoke(endValue);
    }
예제 #27
0
    // 오브젝트에서 포인터를 누르고 동일한 오브젝트에서 뗄 때 호출됩니다.
    void IPointerClickHandler.OnPointerClick(PointerEventData eventData)
    {
        Log.Debug("click ConfirmMessagePanel");

        Hide();

        if (null != _clickHandler)
        {
            _clickHandler.Invoke();
        }
        else
        {
            Log.Debug("not found click handler");
        }
    }
예제 #28
0
    // 오브젝트에서 포인터를 누르고 동일한 오브젝트에서 뗄 때 호출됩니다.
    void IPointerClickHandler.OnPointerClick(PointerEventData eventData)
    {
        Log.Debug("clicked ActionDialoguePanel");

        Hide();

        if (null != _clickHandler)
        {
            _clickHandler.Invoke();
        }
        else
        {
            Log.Debug("not found click handler");
        }
    }
예제 #29
0
    public void ActivateMode(CanvasStates newMode)
    {
        for (int i = 0; i < _canvasModes.Count; i++)
        {
            if (_canvasModes[i].ActiveStates.Contains(newMode))
            {
                _canvasModes[i].Activate(this);
            }
        }

        if (OnStateActive != null)
        {
            OnStateActive.Invoke(newMode);
        }
    }
    private void SetOutput()
    {
        if (IsAppearFlow)
        {
            visibilityPercentage = Mathf.Lerp(hiddenValue, visibleValue, materializeCurve.Evaluate(elapsedShowTime / showDuration));
        }
        else
        {
            visibilityPercentage = Mathf.Lerp(visibleValue, hiddenValue, dissolveCurve.Evaluate(elapsedHideTime / hideDuration));
        }

        if (onOutputChanged != null)
        {
            onOutputChanged.Invoke(visibilityPercentage);
        }
    }