Inheritance: MonoBehaviour
Example #1
0
    // Use this for initialization
    void Start()
    {
        if (!(joinButton && createButton && disconnectButton && inputField && roomID && canvas && keybindMenu && KeyButtonPrefab))
        {
            throw new System.Exception("GUI elements not defined");
        }
        state = GetComponent <StateManager> ();
        state.input.Subscribe(this.KeybindMenu, Global.MENU);

        connectMenu     = canvas.transform.Find("ConnectMenu").gameObject;
        RTSGUIParent    = canvas.transform.Find("RTS GUI").gameObject;
        mapSelectParent = canvas.transform.Find("MapSelect").gameObject;
        mapSelect       = new MapSelect(mapSelectParent);
        unitIcon        = RTSGUIParent.transform.Find("UnitIcon").GetComponent <Image> ();
        unitLoadingBar  = unitIcon.transform.Find("RadialLoad").GetComponent <Image> ();
        selectionFilter = RTSGUIParent.transform.Find("SelectionFilter");
        filterIcons     = selectionFilter.GetComponentsInChildren <Image>();
        KeybindMenu();

        for (int i = 1; i <= 4; ++i)
        {
            Transform scoreText = scores.transform.Find("Player" + i);
            if (scoreText != null)
            {
                scoreText.GetComponent <Text> ().color = GetColorByNetID((short)(i - 1));
            }
        }

        ConnectMenu();
    }
Example #2
0
        public MapCommand(MapModel model, MapSelect mapSelect)
        {
            var mapCommand = mapSelect.GetSelectPointArray().Select(p => new MapChipPoint(p, model.MapChipModel.Get(p)));
            var objCommand = mapSelect.GetSelectPointArray().Select(p => new ObjectChipPoint(p, model.ObjectChipModel.Get(p)));

            MapChipCommand = new MapChipCommand(mapCommand);
            ObjectChipCommand = new ObjectChipCommand(objCommand);
        }
 public void Draw(MapModel model, int x, int y, MapSelect mapSelect)
 {
     //IDが0の場合は何もしない
     if (_selected.ID != 0)
     {
         model.ObjectChipModel.Set(x, y, _selected);
     }
 }
Example #4
0
    //init returns the newly-active voteInfo data
    public virtual VoteInfo init(MapSelect mapSelect, short voteableID)
    {
        if (decisionCallback == null)
        {
            Debug.Log("ERROR IN: " + this.gameObject.name + " object, decision callback was null!");
        }

        //init state info and stuff
        voteInfo        = new VoteInfo();
        this.voteableID = voteableID;
        this.mapSelect  = mapSelect;
        this.menuState  = mapSelect.GetMapSelectState();
        this.bounds     = GetComponent <RectTransform> ();
        float votePrefabHeight = votePrefab.GetComponent <RectTransform> ().rect.height;

        //init and position votepip objects
        if (votePips == null)
        {
            votePips = new GameObject[4];
        }
        for (short i = 0; i < 4; ++i)
        {
            if (votePips[i] == null)
            {
                votePips[i] = Instantiate(votePrefab, this.gameObject.transform);
            }
            votePips[i].GetComponent <Image> ().color = GuiManager.GetColorByNetID(i);
            votePips[i].SetActive(false);
            float   scaleFactor = (float)i / 3.0f;
            Vector3 newPosition = new Vector3(bounds.rect.width * scaleFactor - bounds.rect.width / 2, bounds.rect.height / 2 + votePrefabHeight + topOffset, 0);
            votePips[i].GetComponent <RectTransform> ().localPosition = newPosition;
        }

        //setup onclick listener to toggle vote
        GetComponent <Button> ().onClick.RemoveAllListeners();
        GetComponent <Button> ().onClick.AddListener(() => {
            if (StateManager.state.isServer)
            {
                RecieveVote(0, !voteInfo.votes[StateManager.state.network.networkID]);
            }
            else
            {
                //send a vote command for this object
                StateManager.state.network.SendMessage(new Vote {
                    networkID = StateManager.state.network.networkID,
                    votableID = this.voteableID,
                    vote      = !voteInfo.votes[StateManager.state.network.networkID]
                });
            }
        });

        //setup callback for when decision is true
        triggered = false;

        //return voteInfo back to MapSelect to be used as a reference
        return(voteInfo);
    }
Example #5
0
    void Awake()
    {
        if (instance != null)
        {
            Destroy(gameObject);
            return;
        }

        instance = this;
        DontDestroyOnLoad(this);
    }
Example #6
0
        public Expr MapSelect(Expr map, params Expr[] indices)
        {
            if (!map.Type.IsMap)
            {
                throw new ExprTypeCheckException("map must be of map type");
            }

            if (indices.Length < 1)
            {
                throw new ArgumentException("Must pass at least one index");
            }

            if (map.Type.AsMap.MapArity != indices.Length)
            {
                throw new ArgumentException("the number of arguments does not match the map arity");
            }

            // Use Cache
            MapSelect ms = null;

            try
            {
                ms = MapSelectCache[indices.Length];
            }
            catch (KeyNotFoundException)
            {
                ms = new MapSelect(Token.NoToken, indices.Length);
                MapSelectCache[indices.Length] = ms;
            }

            var argList = new List <Expr>()
            {
                map
            };

            for (int index = 0; index < indices.Length; ++index)
            {
                argList.Add(indices[index]);
            }

            // Type check each argument
            foreach (var typePair in map.Type.AsMap.Arguments.Zip(indices.Select(i => i.ShallowType)))
            {
                if (!typePair.Item1.Equals(typePair.Item2))
                {
                    throw new ExprTypeCheckException("Map argument type mismatch. " + typePair.Item1.ToString() + " != " + typePair.Item2.ToString());
                }
            }

            var result = GetNAry(ms, argList);

            result.Type = map.Type.AsMap.Result;
            return(result);
        }
Example #7
0
 public override VoteInfo init(MapSelect mapSelect, short voteableID)
 {
     voteableGroup = this.transform.parent.GetComponent <VoteableGroup> ();
     if (voteableGroup == null)
     {
         Debug.Log("Voteable Group parent not set!");
     }
     rt = GetComponent <RectTransform> ();
     voteableGroup.RegisterGroupMember(this);
     return(base.init(mapSelect, voteableID));
 }
 // Update is called once per frame
 void Update()
 {
     if (IsGameOver)
     {
         redWin    = GameCount.Instance.redWin;
         blueWin   = GameCount.Instance.blueWin;
         role_Red  = GameCount.Instance.roles_Red;
         role_Blue = GameCount.Instance.roles_Blue;
         camp      = GameCount.Instance.camp;
         mapSelect = UIManager.instance.mapSelect;
     }
 }
Example #9
0
 void Awake()
 {
     if (ms == null)
     {
         DontDestroyOnLoad(gameObject);
         ms = this;
     }
     else if (ms != this)
     {
         Destroy(gameObject);
     }
 }
Example #10
0
 void Start()
 {
     charSelect = new CharacterSelect[4] {
         GameObject.Find("Character0").GetComponent <CharacterSelect>(),
         GameObject.Find("Character1").GetComponent <CharacterSelect>(),
         GameObject.Find("Character2").GetComponent <CharacterSelect>(),
         GameObject.Find("Character3").GetComponent <CharacterSelect>()
     };
     map      = GameObject.Find("MapCanvas").GetComponent <MapSelect>();
     gameMode = GameObject.Find("SelectPlayMode").GetComponent <SetModeType>();
     gameMode = gameMode.GetComponent <SetModeType>();
 }
Example #11
0
    public List <int> needStars; //过关需要的星星数

    private void Awake()
    {
        RectTransform mapSelectRect = mapSelectPrefab.GetComponent <RectTransform>();
        RectTransform comeSoonRect  = comeSoonPrefab.GetComponent <RectTransform>();


        float passWidth  = mapSelectRect.sizeDelta.x; //关卡的宽
        float passHeight = mapSelectRect.sizeDelta.y; //关卡的高


        float spaceWidth = 0.15f * Screen.height;        //每个预制体之间的间隔

        float scale = Screen.height * 0.6f / passHeight; //计算缩放比例

        passWidth *= scale;

        mapSelectRect.sizeDelta = new Vector2(passWidth, Screen.height * 0.6f); //设置主物体大小

        RectTransform rect1 = mapSelectPrefab.transform.GetChild(0).GetComponent <RectTransform>();
        RectTransform rect2 = mapSelectPrefab.transform.GetChild(1).GetComponent <RectTransform>();

        rect1.sizeDelta  = new Vector2(passWidth, Screen.height * 0.6f);                        //背景大小
        rect2.localScale = new Vector2(scale * rect2.localScale.x, scale * rect2.localScale.y); //缩放一下

        comeSoonRect.sizeDelta = new Vector2(passWidth, Screen.height * 0.6f);                  //马上见的尺寸


        int panelWidth = (int)(spaceWidth * (mapBg.Count + 2) + passWidth * (mapBg.Count + 1));  //面板的宽度


        GetComponent <HorizontalLayoutGroup>().padding = new RectOffset((int)spaceWidth, 0,
                                                                        (int)(0.1f * Screen.height), (int)(0.3f * Screen.height)); //上面0.1 屏幕高的距离 下面 0.3屏幕高的距离

        for (int i = 0; i < mapBg.Count; i++)
        {
            GameObject mapSelectGameObject = Instantiate(mapSelectPrefab);        //生成一个地图选择预制体

            mapSelectGameObject.transform.parent = transform;                     //挂载到自身身上

            MapSelect mapSelect = mapSelectGameObject.GetComponent <MapSelect>(); //地图选择

            mapSelect.SetBg(mapBg[i]);                                            //设一下背景
            mapSelect.needStartNum = needStars[i];                                //设一下需要的星星数
            mapSelect.SetNowIndex(i);                                             //设置是哪个关卡
        }

        GameObject comeSoon = Instantiate(comeSoonPrefab); //生成一个预制体

        comeSoon.transform.parent = transform;             //挂载到自身上

        GetComponent <RectTransform>().offsetMax =
            new Vector2(panelWidth - Screen.width, GetComponent <RectTransform>().offsetMax.y);
    }
Example #12
0
 public void Draw(MapModel model, int x, int y, MapSelect mapSelect)
 {
     if (mapSelect.Contains(x, y))
     {
         //�͈͂�h��‚Ԃ�
         DrawArea(model, mapSelect);
     }
     else
     {
         //���łɓ����`�b�v���u����Ă���ꍇ��Draw��s��Ȃ�
         var chip = _mapChipLibrary.GetByID(_selected);
         model.MapChipModel.Set(x, y, chip);
     }
 }
Example #13
0
    private void Awake()
    {
        string data = File.ReadAllText("Assets/Resources/database/mapSelect.json");

        //print(data);
        MapLists   = JsonUtility.FromJson <MapLists>(data);
        index      = 0;
        indexC     = 0;
        Instance   = this;
        PhotonView = GetComponent <PhotonView>();
        //if (PhotonNetwork.isMasterClient == false)
        //{
        //    Map.GetComponent<Transform>().Find("Next").gameObject.GetComponent<Image>().sprite = null;
        //    Map.GetComponent<Transform>().Find("Back").gameObject.GetComponent<Image>().sprite = null;

        //}
    }
Example #14
0
        public MapCommand(Point point, MapModel model, MapSelect mapSelect)
        {
            //�lj��ꏊ���I��͈͂Ȃ�΁A���͈̔͂�L�^�����R�}���h�𐶐�
            if (mapSelect.Contains(point))
            {
                var mapCommand = mapSelect.GetMapChipList(model.MapChipModel);
                var objCommand = mapSelect.GetObjectChipList(model.ObjectChipModel);

                MapChipCommand = new MapChipCommand(mapCommand);
                ObjectChipCommand = new ObjectChipCommand(objCommand);
            }
            else
            {
                MapChipCommand = new MapChipCommand(point, model.MapChipModel.Get(point));
                ObjectChipCommand = new ObjectChipCommand(point, model.ObjectChipModel.Get(point));
            }
        }
 public void Select_3V3()
 {
     canvas03.SetActive(true);
     mapChoice.SetActive(false);
     canvas02.SetActive(false);
     cameraShow.SetActive(true);
     mapSelect = MapSelect.threeVSthree;
     if (Login.mapSelect == MapSelect.threeVSthree)
     {
         x     = new GameObject[4];
         x [0] = GameObject.Find("Canvas/HeroPanel/HeroHead_A/X1");
         x [1] = GameObject.Find("Canvas/HeroPanel/HeroHead_A/X2");
         x [2] = GameObject.Find("Canvas/HeroPanel/HeroHead_B/X1");
         x [3] = GameObject.Find("Canvas/HeroPanel/HeroHead_B/X2");
         for (int i = 0; i < x.Length; i++)
         {
             x [i].SetActive(false);
         }
     }
 }
Example #16
0
    void Start()
    {
        Instance     = this;
        AllMaps      = new List <string>(MapController.GetAllMapNames());
        SelectedMaps = new List <string>();
        //string path = Path.Combine(Application.streamingAssetsPath, "Maps");
        //string[] files = Directory.GetFiles(path,"*.map");
        //foreach(string file in files) {
        //    AllMaps.Add(Path.GetFileNameWithoutExtension(file));
        //}

        CurrentlyInList = new List <string>(AllMaps);
        playerNumToMaps = new Dictionary <int, List <string> >();
        nameToMapSelect = new Dictionary <string, MapSelect>();
        foreach (string map in AllMaps)
        {
            MapSelect go = Instantiate(MapPrefab);
            go.mapName   = map;
            go.OnSelect += OnMapClick;
            go.transform.SetParent(MapContent.transform, false);
            go.GetComponentInChildren <Text>().text = map;
            go.Select(false);
            nameToMapSelect[map] = go;
            int.TryParse(MapController.GetMapFile(map)[1], out int playerNum);
            if (playerNumToMaps.ContainsKey(playerNum))
            {
                playerNumToMaps[playerNum].Add(map);
            }
            else
            {
                playerNumToMaps.Add(playerNum, new List <string> {
                    map
                });
            }
        }
        SelectedMaps.AddRange(AllMaps);
    }
Example #17
0
        public override void Initialize()
        {
            this.Window.Title = "战舰少女 Remix";
            isNightMode       = true;
            FileStream harborbg;

            if (isNightMode)
            {
                harborbg = new FileStream(@"Content\dark_harbor.png", FileMode.Open, FileAccess.Read);
            }
            else
            {
                harborbg = new FileStream(@"Content\day_harbor.png", FileMode.Open, FileAccess.Read);
            }
            _msgfont = new Font("msyh.ttc", 20)
            {
                EnableBorder = true,
                BorderColor  = Color.Black
            };
            harbor = new Harbor()
            {
                Texture = Texture2D.FromStream(GraphicsDevice, harborbg),
            };

            factory = new Factory()
            {
                Texture = Sprite.CreateTextureFromFile(@"Content\factbg.png"),
            };
            this.KeyDown += Game1_KeyDown;
            select        = new MapSelect();
            Scenes.Add("Harbor", harbor);
            Scenes.Add("Factory", factory);
            Scenes.Add("Select", select);

            base.Initialize();
            Scenes.Navigate("Harbor");
        }
 public void Draw(MapModel model, Point point, MapSelect mapSelect)
 {
     Draw(model, point.X, point.Y, mapSelect);
 }
 public Term Visit(MapSelect mapSelect)
 {
     throw new NotImplementedException();
 }
 public void Delete(MapModel model, MapSelect mapSelect)
 {
     mapSelect.GetSelectPointArray()
         .ToList()
         .ForEach(p => model.ObjectChipModel.Set(p.X, p.Y, ObjectChip.Empty()));
 }
Example #21
0
 public void Delete(MapModel model, MapSelect mapSelect)
 {
     mapSelect.GetSelectPointArray()
         .ToList()
         .ForEach(p => model.MapChipModel.Set(p.X, p.Y, _mapChipLibrary.GetChip(0, 0)));
 }
Example #22
0
 public MapCommand(int x, int y, MapModel model, MapSelect mapSelect)
     : this(new Point(x, y), model, mapSelect)
 {
 }
Example #23
0
 /// <summary>
 /// �͈͂�h��‚Ԃ�
 /// </summary>
 private void DrawArea(MapModel model, MapSelect mapSelect)
 {
     mapSelect.GetSelectPointArray()
         .ToList()
         .ForEach(p => model.MapChipModel.Set(p.X, p.Y, _mapChipLibrary.GetByID(_selected)));
 }
Example #24
0
        protected void LoadHigh()
        {
            int mapWidth  = MapTileWidth;
            int mapHeight = MapTileHeight;

            w2             = (mapWidth) * 2;
            h2             = (mapHeight) * 2;
            mapHighWorldX2 = new int[w2, h2];
            for (int tx = 0; tx < mapWidth; ++tx)
            {
                for (int ty = 0; ty < mapHeight; ++ty)
                {
                    // MapSelect.GetHighRef(tx, ty);
                    bool isHasPaint = GetAutoTile(tx, ty, 0).Id >= 0;
                    int  h          = -1;
                    if (isHasPaint)
                    {
                        h = MapSelect.GetHighRef(tx, ty);
                        if (h < 0)
                        {
                            h = 0;
                        }
                    }
                    int tx2 = tx * 2;
                    int ty2 = ty * 2;
                    mapHighWorldX2[tx2, ty2]         = h;
                    mapHighWorldX2[tx2 + 1, ty2]     = h;
                    mapHighWorldX2[tx2, ty2 + 1]     = h;
                    mapHighWorldX2[tx2 + 1, ty2 + 1] = h;
                }
            }
            if (true)
            {//Noi suy
                int offset = 0;
                for (int h = 8; h >= 2; h--)
                {
                    for (int x = offset; x < w2 - offset; x++)
                    {
                        for (int y = offset; y < h2 - offset; y++)
                        {
                            int v = getHighX2(x, y);
                            if (v == h)
                            {
                                {
                                    //[4] 4 2 2 0 0 -> [4] 4 3 2 1 0
                                    int[] a = { v, v - 2, v - 2, v - 4, v - 4 };
                                    SetHighHelp(x, y, a, 2, v - 1, 4, v - 3);
                                }
                                // int v_low_1 = v - 1;
                                // int v_low_2 = v - 2;
                                // int v_low_3 = v - 3;
                                // int v_low_4 = v - 4;
                                // Case [4] 2 2 0 0 -> [4] 3 2 0 0
                                // SetHighHelp(x, y, v - 2, v - 2, v - 4, v - 4, 1, v - 1);
                                // Case 4 3 1 1 -> 4 3 2 1
                                // SetHighHelp(x, y, v - 1, v - 3, v - 3, 2, v - 2);
                                // Case [2] 1 1 0 -> [2] 1 0 0
                                // SetHighHelp(x, y, v - 2, v - 2, v - 2, 1, v - 1);

                                //Fix BR
                                // FixOffset( x, y, 1, 1, v);
                                // FixOffset( x, y, -1, 1, v);
                                // FixOffset( x, y, 1, -1, v);
                                // FixOffset( x, y, -1, -1, v);

                                /*
                                 * bool isX0Y0 = (getHighX2( x - 1, y) == v_half
                                 *          && getHighX2( x, y - 1) == v_half
                                 *          && getHighX2( x - 1, y - 1) == v_low);
                                 * bool isX0Y1 = (getHighX2( x - 1, y) == v_half
                                 *          && getHighX2( x, y + 1) == v_half
                                 *          && getHighX2( x - 1, y + 1) == v_low);
                                 * bool isX1Y0 = (getHighX2( x + 1, y) == v_half
                                 *          && getHighX2( x, y - 1) == v_half
                                 *          && getHighX2( x + 1, y - 1) == v_low);
                                 * bool isX1Y1 = (getHighX2( x + 1, y) == v_half
                                 *          && getHighX2( x, y + 1) == v_half
                                 *          && getHighX2( x + 1, y + 1) == v_low);
                                 * if(isX0Y0){
                                 *  setHighX2(x - 1, y - 1, v_half);
                                 * }
                                 * if(isX0Y1){
                                 *  setHighX2(x - 1, y + 1, v_half);
                                 * }
                                 * if(isX1Y0){
                                 *  setHighX2(x + 1, y - 1, v_half);
                                 * }
                                 * if(isX1Y1){
                                 *  setHighX2(x + 1, y + 1, v_half);
                                 * }
                                 */
                                //Check DOUBLE_EXT_CORNER
                                // {
                                //     CheckDOUBLE_EXT_CORNER( NS, x, y, mapHighWorldX2);
                                // }
                            }
                        }
                    }
                }

                /*
                 * for(int NS = 8; NS >= 1; NS--){
                 *  for ( int x = 1; x < w2 - 1; x++ ){
                 *      for ( int y = 1; y < h2 - 1; y++ ){
                 *          int v = mapHighWorldX2[ x, y];
                 *          if(v == NS){
                 *              CheckDOUBLE_EXT_CORNER( NS, x, y, mapHighWorldX2);
                 *          }
                 *      }
                 *  }
                 * }
                 */
            }
            //Fill AB
            // mapAB_X_WorldX2 = new int[w2 ,h2];
            // for ( int y = 0; y < h2; y++ ){
            //     int lastX = 0;
            //     int lastValue = mapHighWorldX2[ lastX, y];
            //     for ( int x = 0; x < w2; x++ ){
            //         if(lastValue == mapHighWorldX2[x, y]){
            //             mapAB_X_WorldX2[x, y] = lastX;
            //         }else{
            //             lastX = x;
            //             lastValue = mapHighWorldX2[x, y];
            //             mapAB_X_WorldX2[x, y] = lastX;
            //         }
            //     }
            // }
        }
 public void SelectRandomMode()
 {
     mapSelect  = MapSelect.threeVSthree;
     randomMode = true;
 }