コード例 #1
0
 // Unnecessary helper
 public static TilePosition buildingPositionRelativeTo(string type, BW.Unit building, CustomTypes.Direction direction)
 {            
     TilePosition building_position = building.theUnit.getTilePosition();
     int x_offset = 0, y_offset = 0;
     switch (direction)
     {
         case CustomTypes.Direction.Left:
             {
                 x_offset = -bwapi.getUnitType(type).tileWidth();
                 y_offset = 0;
                 break;
             }
         case CustomTypes.Direction.Right:
             {
                 x_offset = bwapi.getUnitType(building.Type).tileWidth();
                 y_offset = 0;
                 break;
             }
         case CustomTypes.Direction.Down:
             {
                 x_offset = 0;
                 y_offset = bwapi.getUnitType(building.Type).tileHeight();
                 break;
             }
         case CustomTypes.Direction.Up:
             {
                 x_offset = 0;
                 y_offset = -bwapi.getUnitType(type).tileHeight();
                 break;
             }
     }
     return new TilePosition(building_position.xConst() + x_offset, building_position.yConst() + y_offset);
 }
コード例 #2
0
    static PhotonNetwork()
    {
        Application.runInBackground = true;
        var obj2 = new GameObject();

        photonMono     = obj2.AddComponent <PhotonHandler>();
        obj2.name      = "PhotonMono";
        obj2.hideFlags = HideFlags.HideInHierarchy;
        networkingPeer = new NetworkingPeer(photonMono, String.Empty, Settings.ConnectionProtocolSettings == 0 ? ConnectionProtocol.Udp : Settings.ConnectionProtocolSettings == 1 ? ConnectionProtocol.Tcp : ConnectionProtocol.WebSocket);
        CustomTypes.Register();
    }
コード例 #3
0
    static PhotonNetwork()
    {
        Application.runInBackground = true;
        GameObject obj2 = new GameObject();

        photonMono     = obj2.AddComponent <PhotonHandler>();
        obj2.name      = "PhotonMono";
        obj2.hideFlags = HideFlags.HideInHierarchy;
        networkingPeer = new NetworkingPeer(photonMono, string.Empty, ConnectionProtocol.Udp);
        CustomTypes.Register();
    }
コード例 #4
0
ファイル: PhotonNetwork.cs プロジェクト: kmlkmljkl2/Anarchy
    static PhotonNetwork()
    {
        Application.runInBackground = true;
        GameObject gameObject = new GameObject();

        photonMono           = gameObject.AddComponent <PhotonHandler>();
        gameObject.name      = "PhotonMono";
        gameObject.hideFlags = HideFlags.HideInHierarchy;
        networkingPeer       = new NetworkingPeer(photonMono, string.Empty, NetworkSettings.ConnectProtocol);
        CustomTypes.Register();
    }
コード例 #5
0
 public void AddCustomTag(string tagname, int tagValue)
 {
     if (CustomTypes != null)
     {
         CustomTypes.Add(new s_customType(tagname, tagValue));
     }
     else
     {
         CustomTypes = new List <s_customType>();
         CustomTypes.Add(new s_customType(tagname, tagValue));
     }
 }
コード例 #6
0
 public void AddCustomTag(string tagname, Vector2Int tagval)
 {
     if (CustomTypes != null)
     {
         CustomTypes.Add(new s_customType(tagname, tagval.x, tagval.y));
     }
     else
     {
         CustomTypes = new List <s_customType>();
         CustomTypes.Add(new s_customType(tagname, tagval.x, tagval.y));
     }
 }
コード例 #7
0
    void Start()
    {
        Application.runInBackground = true;
        CustomTypes.Register();

        this.GameInstance = new DemoGame();
        this.GameInstance.MasterServerAddress = "localhost:5055";
        this.GameInstance.AppId = this.AppId;   // edited in Inspector!
        this.GameInstance.AppVersion = "1.0";
        this.GameInstance.NickName = "unityPlayer";
        this.GameInstance.Connect();
    }
    public Rect leftToolbar; // set in inspector to position the lobby screen

    public void Start()
    {
        Application.runInBackground = true;
        CustomTypes.Register();

        leftToolbar = new Rect(leftToolbar.x, leftToolbar.y, leftToolbar.width, Screen.height - leftToolbar.y);

        this.GameInstance            = new DemoGame();
        this.GameInstance.AppId      = this.AppId;  // set in Inspector
        this.GameInstance.AppVersion = "1.0";
        this.GameInstance.PlayerName = !string.IsNullOrEmpty(NamepickerGui.NickName) ? NamepickerGui.NickName : "unityPlayer";

        this.GameInstance.OnStateChangeAction += this.OnStateChanged;
        this.GameInstance.ConnectToRegionMaster("EU");  // Turnbased games have to use this connect via Name Server
    }
コード例 #9
0
    public void Start()
    {
        Application.runInBackground = true;
        CustomTypes.Register();

        leftToolbar = new Rect(leftToolbar.x, leftToolbar.y, leftToolbar.width, Screen.height - leftToolbar.y);

        this.GameInstance            = new DemoGame();
        this.GameInstance.AppId      = this.AppId;  // set in Inspector
        this.GameInstance.AppVersion = "1.0";
        this.GameInstance.PlayerName = !string.IsNullOrEmpty(NamepickerGui.NickName) ? NamepickerGui.NickName : "unityPlayer";

        this.GameInstance.OnStateChangeAction += this.OnStateChanged;

        playfabComponent.LoginToPlayFab();
    }
コード例 #10
0
        /// <summary>
        ///     Look for SLUI custom component types in currently all loaded assemblies.
        /// </summary>
        public static void LookForCustomTypes()
        {
            CustomTypes.Clear();
            foreach (var a in AppDomain.CurrentDomain.GetAssemblies())
            {
                foreach (var t in a.GetTypes())
                {
                    var attributes = t.GetCustomAttributes(typeof(SLUIComponentAttribute), true);
                    if (attributes.Length > 0)
                    {
                        CustomTypes.Add(t.Name, t);
                    }
                }
            }

            Debug.Log($"{CustomTypes.Count} SLUI's custom component types found.");
        }
コード例 #11
0
    void Start()
    {
        if (string.IsNullOrEmpty(this.AppId))
        {
            Debug.LogError("AppId not set! Edit GameObject 'Scripts', 'Demo GUI', AppId first.");
            Debug.Break();
        }

        Application.runInBackground = true;
        CustomTypes.Register();

        this.GameInstance            = new DemoGame();
        this.GameInstance.AppId      = this.AppId; // edited in Inspector!
        this.GameInstance.AppVersion = "1.0";
        this.GameInstance.NickName   = "unityPlayer";
        this.GameInstance.ConnectToRegionMaster("eu");
    }
コード例 #12
0
ファイル: DemoGUI.cs プロジェクト: mortske/Citadels
    void Start()
    {
        if (string.IsNullOrEmpty(this.AppId))
        {
            Debug.LogError("AppId not set! Edit GameObject 'Scripts', 'Demo GUI', AppId first.");
            Debug.Break();
        }

        Application.runInBackground = true;
        CustomTypes.Register();

        this.GameInstance = new DemoGame();
        this.GameInstance.MasterServerAddress = "app-eu.exitgamescloud.com:5055";
        this.GameInstance.AppId      = this.AppId; // edited in Inspector!
        this.GameInstance.AppVersion = "1.0";
        this.GameInstance.PlayerName = "unityPlayer";
        this.GameInstance.Connect();
    }
コード例 #13
0
        public override void NetInitHandler(NetInit data)
        {
            base.NetInitHandler(data);
            PlayFab.PlayFabSettings.TitleId = TitleId;
            ClientStateRP = new ReactiveProperty <ClientState> (ClientState.Uninitialized);

            RefreshNetInfo("请输入 CustomId 进行登录");

            Application.runInBackground = true;
            CustomTypes.Register();

            Client            = new EPokerClient(this);
            Client.AppId      = AppId;
            Client.AppVersion = AppVersion;

            Client.OnStateChangeAction += this.OnStateChanged;

            Observable.EveryUpdate().Subscribe(_ => {
                Client.Service();
            }).AddTo(this.gameObject);
        }
コード例 #14
0
    public void Awake()
    {
        if (string.IsNullOrEmpty(this.AppId))
        {
            Debug.LogError("You must enter your AppId from the Dashboard in the component: Scripts, MemoryGui, AppId before you can use this demo.");
            Debug.Break();
        }

        Application.runInBackground = true;
        CustomTypes.Register();

        this.GameClientInstance            = new MemoryGameClient();
        this.GameClientInstance.memoryGui  = this;
        this.GameClientInstance.AppId      = this.AppId;  // set in Inspector
        this.GameClientInstance.AppVersion = "1.0";


        board = this.GetComponentInChildren <MemoryBoard>();
        board.GameClientInstance = this.GameClientInstance;
        GameClientInstance.board = board;
        board.MemoryGui          = this;
        this.DisableButtons();
    }
コード例 #15
0
    public void Awake()
    {
        if (string.IsNullOrEmpty(this.AppId))
        {
            Debug.LogError("AppId not set!");
            Debug.Break();
        }

        Application.runInBackground = true;
        CustomTypes.Register();
        gameManager = GetComponent <GameManager>();

        this.gameClient = new CitadelsGameClient();
        this.gameClient.MasterServerAddress = "app-eu.exitgamescloud.com:5055";
        this.gameClient.AppId       = this.AppId; // edited in Inspector!
        this.gameClient.AppVersion  = "1.0";
        this.gameClient.PlayerName  = "unityPlayer";
        this.gameClient.citadelsGUI = this;
        this.gameClient.gameManager = gameManager;
        this.gameClient.Connect();

        nameField.text = PlayerPrefs.GetString("PlayerName", "");
    }
コード例 #16
0
 static void Main(string[] args)
 {
     Console.WriteLine("Fruit Output:");
     FilteringExercises.FilteringOperationsFruit();
     Console.WriteLine("Number Output:");
     FilteringExercises.FilteringOperationsNumbers();
     Console.WriteLine("Ordering Names Output:");
     OrderingExercises.OrderingOperationsNames();
     Console.WriteLine("Ordering Numbers Output:");
     OrderingExercises.OrderingOperationsNumbers();
     Console.WriteLine("Aggregate Function 1 Output:");
     AggregateOperations.Ex1();
     Console.WriteLine("Aggregate Function 2 Output:");
     AggregateOperations.Ex2();
     Console.WriteLine("Aggregate Function 3 Output:");
     AggregateOperations.Ex3();
     Console.WriteLine("Partitioning Exercise Output:");
     Partitioning.Ex1();
     Console.WriteLine("Customs Types Output:");
     CustomTypes.MillionairesClub();
     // CLOSE TERMINAL
     Console.WriteLine("Press enter to exit");
     Console.ReadLine();
 }
コード例 #17
0
    void Awake()
    {
        Application.runInBackground = true;      //防止后台掉线
        CustomTypes.Register();
        _client       = new PhotonClient();
        _client.AppId = "49395063-2a0e-4e1f-a35d-3d4600790bc2";      //Turnbased 的 ID
        //_client.AppId="bc31b098-957d-4231-9ad5-b75adc3c6fb7";// RealTime 的ID
        bool connectInProcess = _client.ConnectToRegionMaster("asia");

        _go_GuessBricks = GameObject.Find("GuessBricks").transform;
        MyDock          = GameObject.Find("DockD").transform;
        PickPop         = GameObject.Find("PickPop").transform;
        _planet         = GameObject.Find("Planet");
        _table          = _planet.transform.GetChild(0).gameObject;
        _unOccupied     = _table.transform.GetChild(5).gameObject;
        //--------------找到UI元素------------
        Notify      = GetComponent <Notification>();
        Panel       = GameObject.Find("Panel").transform;
        StartBtn    = GameObject.Find("Start").transform;
        _canvas     = GameObject.Find("Canvas");
        _winBanner  = GameObject.Find("Win").transform;
        _panel      = GameObject.Find("Panel");
        _readyPanel = GameObject.Find("ReadyPanel");
        _overPanel  = GameObject.Find("OverPanel");
        DoneBtn     = GameObject.Find("AdjustDone").transform;
        CancelBtn   = GameObject.Find("Cancel").transform;
        ContinueBtn = GameObject.Find("ContinueGuess").transform;
        _loading    = GameObject.Find("Loading").transform;
        //-----------------------



        if (GameControl._instance == null)
        {
            GameControl._instance = this;
        }
        DontDestroyOnLoad(gameObject);

        #region 注册UI事件
        GameObject.Find("Create").GetComponent <Button>().onClick.AddListener(
            () => {
            if (_roomName != "")
            {
                _client.OpCreateRoom(_roomName, new RoomOptions()
                {
                    MaxPlayers = _playerNum
                }, TypedLobby.Default);
            }
        });
        GameObject.Find("Join").GetComponent <Button>().onClick.AddListener(
            () => {
            if (_roomName != "")
            {
                _client.OpJoinRoom(_roomName);
            }
        });
        GameObject.Find("PlayerNum").GetComponent <Dropdown>().onValueChanged
        .AddListener(x => {
            _playerNum = (byte)(x + 2);
        });
        GameObject.Find("RoomName").GetComponent <InputField>().onValueChanged
        .AddListener(x => {
            _roomName = x;
        });
        GameObject.Find("Leave").GetComponent <Button>().onClick.AddListener(
            () => {
            //销毁玩家头像
            foreach (var icon in _playerIcons)
            {
                Destroy(icon.gameObject);
            }
            _playerIcons.Clear();

            //通知其他人  我离开了
            _client.OpRaiseEvent(MyEventCode.OneLeave, _myID, true, RaiseEventOptions.Default);

            _client.OpLeaveRoom(false);
            _overPanel.SetActive(false);
            _panel.SetActive(true);
        });
        GameObject.Find("Again").GetComponent <Button>().onClick.AddListener(
            () => {
            //currentID 为自己
            CurrentID = _myID;
            //重新设置玩家头像的parent
            for (int i = 0; i < _playerNum; i++)
            {
                var icon = _playerIcons[i];
                icon.SetParent(_readyPanel.transform);
            }
            //自己的头像放到readypos  并且通知别人
            //playerIcons readyPos的顺序和id一样 注意ID从1 开始
            var myIcon = _playerIcons[_myID - 1];
            AnimElement.Prepare()
            .InitUGUI(myIcon.localPosition,
                      readyPos[_myID - 1],
                      myIcon,
                      0,
                      40)
            .AddScaleAnimation(myIcon.localScale, Vector3.one * 0.6f)
            .Play();
            _client.OpRaiseEvent(MyEventCode.OnePlayAgain, _myID, true, RaiseEventOptions.Default);


            //载入等待面板
            _overPanel.SetActive(false);
            _readyPanel.SetActive(true);

            EnterRoom(_playerNum);
        });
        //房主开始游戏
        GameObject.Find("Start").GetComponent <Button>().onClick.AddListener(
            () => {
            //洗牌
            ShuffleDeck();
            //-----------------------------
            //把所有的牌发送给其他玩家
            //-----------------------
            _client.OpRaiseEvent(MyEventCode.SyncAllBricks, indexMap, true
                                 , RaiseEventOptions.Default);
            //放置牌到桌子上
            PlaceAllBricksOnTable(indexMap);
            StartGame();
        });
        // 完成 按钮的点击逻辑
        DoneBtn.GetComponent <Button>().onClick.AddListener(() => {
            // 玩家确认完成Adjust过程中的joker放置后 点击
            if (GameState.Instance.CurrentState == GameState.State.Adjust)
            {
                //通知其他玩家在逻辑层更新我的Joker位置
                int msgType = 0;
                int[] msg   = new int[4];
                msg[0]      = _myID;
                if (_decks[_myDeckIndex].Contains(_jokerWhite))
                {
                    msgType = -1;
                    msg[2]  = _decks[_myDeckIndex].IndexOf(_jokerWhite);
                }
                if (_decks[_myDeckIndex].Contains(_jokerBlack))
                {
                    msgType = -msgType;
                    msg[3]  = _decks[_myDeckIndex].IndexOf(_jokerBlack);
                }
                msg[1] = msgType;
                _client.OpRaiseEvent(MyEventCode.SyncJoker, msg, true, RaiseEventOptions.Default);

                //
                LocalReadyToGo();
                //隐藏所有arrows for joker
                _jokerBlack.GetComponent <Brick>().DestroyArrows();
                _jokerWhite.GetComponent <Brick>().DestroyArrows();
            }
            //  每一round中抽到joker的玩家确认完成joker的放置后点击
            else if (GameState.Instance.CurrentState == GameState.State.PlacingJoker)
            {
                //进入Guess状态
                GameState.Instance.CurrentState = GameState.State.GuessABrick;
                //视觉提示 让我猜牌
                Notify.autoNtf("请猜牌", Vector2.zero, new Vector2(1, 1), 1);

                //隐藏所有arrows for joker
                _jokerBlack.GetComponent <Brick>().DestroyArrows();
                _jokerWhite.GetComponent <Brick>().DestroyArrows();
            }
            else if (GameState.Instance.CurrentState == GameState.State.GuessingABrick)
            {
                //不猜了   轮到下一个玩家
                ToNextOne();
                //隐藏按钮
                ContinueBtn.gameObject.SetActive(false);
                DoneBtn.gameObject.SetActive(false);
                //切换状态
                GameState.Instance.CurrentState = GameState.State.WaitForOthers;
            }

            DoneBtn.gameObject.SetActive(false);
        });
        //取消猜牌按钮的点击逻辑
        CancelBtn.GetComponent <Button>().onClick.AddListener(() => {
            CancelBtn.gameObject.SetActive(false);
            //隐藏所有PossibleBrick
            HidePossibleBricks();
            //状态回到GuessABrick
            GameState.Instance.CurrentState = GameState.State.GuessABrick;
        });
        //继续猜
        ContinueBtn.GetComponent <Button>().onClick.AddListener(() => {
            GameState.Instance.CurrentState = GameState.State.GuessABrick;
            ContinueBtn.gameObject.SetActive(false);
            DoneBtn.gameObject.SetActive(false);
        });
        #endregion

        //----初始化UI状态----------
        _readyPanel.SetActive(false);
        DoneBtn.gameObject.SetActive(false);
        CancelBtn.gameObject.SetActive(false);
        ContinueBtn.gameObject.SetActive(false);
        Panel.gameObject.SetActive(false);
        StartBtn.gameObject.SetActive(false);
        _overPanel.SetActive(false);

        //--------------------------------------
    }