Exemple #1
0
        private void SetBuildList()
        {
            var tileFactroy         = new TileFactory();
            var buildingNodeFactory = new BuildingNodeFactory();
            var buildings           = PhotonNetwork.CurrentRoom.GetBuild();

            foreach (int buildId in buildings)
            {
                var tileObj         = tileFactroy.Create(buildId.ToString());
                var buildingNodeObj = buildingNodeFactory.Create();
                var tile            = tileObj.GetComponent <Tile>();
                var buildingNode    = buildingNodeObj.GetComponent <BuildingNode>();
                var tmp             = buildingNode.OwnerNameObj.transform.GetChild(0).gameObject;
                Nodes.Add(buildingNode);
                buildingNode.Tile      = tile;
                buildingNode.OwnerName = "勝利点:" + tile.Points + "\nコスト\n";
                foreach (var cost in tile.BuildCost)
                {
                    var go = Instantiate(tmp);
                    go.GetComponent <Image>().sprite = Resources.Load("Textures/" + Enum.GetName(typeof(ResourceType), cost), typeof(Sprite)) as Sprite;
                    go.transform.SetParent(buildingNode.OwnerNameObj.transform);
                    go.SetActive(true);
                }
                buildingNode.ExecuteButton.onClick.AddListener(() => Builder.BuildSetup(tile));
                buildingNodeObj.transform.SetParent(Contents.transform);
                Destroy(tileObj);
            }
        }
Exemple #2
0
        public void Show(IEnumerable <Tile> tiles)
        {
            if (Contents.transform.childCount != 0)
            {
                foreach (Transform tf in Contents.transform)
                {
                    tf.gameObject.SetActive(false);
                }
                Nodes.Clear();
            }
            if (tiles.Count() <= 0)
            {
                PhotonNetwork.LocalPlayer.SetPlayerMove(PlayerMoveType.NonTurn);
                GetComponent <Canvas>().enabled = false;
                return;
            }
            var BuildingNodeFactory = new BuildingNodeFactory();

            foreach (Tile tile in tiles)
            {
                var go   = BuildingNodeFactory.Create();
                var node = go.GetComponent <BuildingNode>();
                Nodes.Add(node);
                node.Tile      = tile;
                node.OwnerName = (tile.Owner == null) ? "" : tile.Owner.NickName;
                node.ExecuteButton.onClick.AddListener(() =>
                {
                    if (tile.Owner != null && tile.Owner != PhotonNetwork.LocalPlayer)
                    {
                        Resource.Send(ResourceType.Money, PhotonNetwork.LocalPlayer, tile.Owner);
                    }
                    tile.NormalAbility.Invoke();
                    node.AbilityActivate();
                });
                go.transform.SetParent(Contents.transform);
                PhotonNetwork.LocalPlayer.SetPlayerMove(PlayerMoveType.Selecting);
                GetComponent <Canvas>().enabled = true;
            }
        }