コード例 #1
0
        // Update is called once per frame
        void Update()
        {
            RaycastHit hit = new RaycastHit();

            if (Physics.Raycast(Camera.main.ScreenPointToRay(Input.mousePosition), out hit)) {
            if (hit.transform.gameObject.tag == "Zone") {
                currentTile = hit.transform.gameObject.GetComponent<Zone>();

                if (currentTile.player_id != prevPlayerID) {
                    if (prevPlayerID > 0) {
                        GameObject.Find("Map").GetComponent<Map>().SelectTerritory(prevPlayerID, false);
                    }

                    GameObject.Find("Map").GetComponent<Map>().SelectTerritory(currentTile.player_id, true);
                    prevPlayerID = currentTile.player_id;
                }

                string owner_name = "";

                if (currentTile.player_id > 0) {
                    owner_name = GameObject.Find("Map").GetComponent<Map>().playerList[currentTile.player_id].name;

                    Color playerColor = GameObject.Find("Map").GetComponent<Map>().playerList[currentTile.player_id].color;;
                    tileInfoGUI.bgColor = new Color(playerColor.r, playerColor.g, playerColor.b, 0.8f);
                } else {
                    tileInfoGUI.DefaultColor();
                }

                tileInfoGUI.SetInformation(currentTile.terrain_type, currentTile.v_capacity, owner_name);
                tileInfoGUI.position = Camera.main.WorldToScreenPoint(currentTile.transform.position);

                tileInfoGUI.SetActive(true);

                roamingCursor.SetActive(true);
                roamingCursor.transform.position = currentTile.transform.position + new Vector3(0, 0.1f, 0);
            //				roamingCursor.renderer.material.color = new Color32(0, 181, 248, 255);
            }
            } else {
            tileInfoGUI.SetActive(false);
            roamingCursor.SetActive(false);
            currentTile = null;
            }

            switch (InputExtended.GetMouseNumClick(0)) {
            case 1: // Single Click
            //				mouseDownPos = Input.mousePosition;
            //				oldCameraPos = transform.position;
            //				if (currentTile != null && currentTile.player_id > 0) {
            //					mapCamera.Center(currentTile.player_id);
            //					mapCamera.isLeaving = mapCamera.isZooming = true;
            //				}
                break;
            case 2: // Double Click
                if (currentTile.player_id == GameState.player.GetID()) {
                    mapCamera.Move(currentTile.transform.position);
                }
                break;
            }
        }
コード例 #2
0
        public static NetworkResponse Parse(MemoryStream dataStream)
        {
            ResponseEcosystem response = new ResponseEcosystem();
            response.status = DataReader.ReadShort(dataStream);

            List<Zone> zones = new List<Zone>();

            if (response.status == 0) {
            int eco_id = DataReader.ReadInt(dataStream);

            Ecosystem ecosystem = new Ecosystem(eco_id);
            ecosystem.type = DataReader.ReadShort(dataStream);
            ecosystem.score = DataReader.ReadInt(dataStream);

            int player_id = DataReader.ReadInt(dataStream);

            Player player = new Player(player_id);
            player.name = DataReader.ReadString(dataStream);

            string[] rgb = DataReader.ReadString(dataStream).Split(',');
            player.color = new Color32(byte.Parse(rgb[0]), byte.Parse(rgb[1]), byte.Parse(rgb[2]), 255);

            ecosystem.player = player;

            string zone_str = DataReader.ReadString(dataStream);
            foreach (string item in zone_str.Split(';')) {
                if (item == "") {
                    continue;
                }

                string[] temp = item.Split(',');

                Zone zone = new Zone(int.Parse(temp[0]));
                zone.row = short.Parse(temp[1]);
                zone.column = short.Parse(temp[2]);
                zone.terrain_type = short.Parse(temp[3]);
                zone.v_capacity = int.Parse(temp[4]);

                zones.Add(zone);
            }
            ecosystem.zones = zones;

            response.ecosystem = ecosystem;
            }

            return response;
        }
コード例 #3
0
        public static NetworkResponse Parse(MemoryStream dataStream)
        {
            ResponseZoneList response = new ResponseZoneList();
            response.status = DataReader.ReadShort(dataStream);

            Dictionary<int, Player> players = new Dictionary<int, Player>();
            List<Zone> zones = new List<Zone>();

            if (response.status == 0) {
            short size = DataReader.ReadShort(dataStream);
            for (int i = 0; i < size; i++) {
                int player_id = DataReader.ReadInt(dataStream);

                Player player = new Player(player_id);
                player.name = DataReader.ReadString(dataStream);

                string[] rgb = DataReader.ReadString(dataStream).Split(',');
                player.color = new Color32(byte.Parse(rgb[0]), byte.Parse(rgb[1]), byte.Parse(rgb[2]), 255);

                players.Add(player_id, player);
            }
            response.players = players;

            response.height = DataReader.ReadShort(dataStream);
            response.width = DataReader.ReadShort(dataStream);

            string zone_str = DataReader.ReadString(dataStream);
            foreach (string item in zone_str.Split(';')) {
                if (item == "") {
                    continue;
                }

                string[] temp = item.Split(',');

                Zone zone = new Zone(int.Parse(temp[0]));
                zone.row = short.Parse(temp[1]);
                zone.column = short.Parse(temp[2]);
                zone.terrain_type = short.Parse(temp[3]);
                zone.v_capacity = int.Parse(temp[4]);
                zone.player_id = int.Parse(temp[5]);

                zones.Add(zone);
            }
            response.zones = zones;
            }

            return response;
        }
コード例 #4
0
        // Update is called once per frame
        void Update()
        {
            RaycastHit hit = new RaycastHit();

            if (Physics.Raycast(Camera.main.ScreenPointToRay(Input.mousePosition), out hit))
            {
                if (hit.transform.gameObject.tag == "Zone")
                {
                    currentTile = hit.transform.gameObject.GetComponent <Zone>();

                    if (currentTile.player_id != prevPlayerID)
                    {
                        if (prevPlayerID > 0)
                        {
                            GameObject.Find("Map").GetComponent <Map>().SelectTerritory(prevPlayerID, false);
                        }

                        GameObject.Find("Map").GetComponent <Map>().SelectTerritory(currentTile.player_id, true);
                        prevPlayerID = currentTile.player_id;
                    }

                    string owner_name = "";

                    if (currentTile.player_id > 0)
                    {
                        owner_name = GameObject.Find("Map").GetComponent <Map>().playerList[currentTile.player_id].name;

                        Color playerColor = GameObject.Find("Map").GetComponent <Map>().playerList[currentTile.player_id].color;;
                        tileInfoGUI.bgColor = new Color(playerColor.r, playerColor.g, playerColor.b, 0.8f);
                    }
                    else
                    {
                        tileInfoGUI.DefaultColor();
                    }

                    tileInfoGUI.SetInformation(currentTile.terrain_type, currentTile.v_capacity, owner_name);
                    tileInfoGUI.position = Camera.main.WorldToScreenPoint(currentTile.transform.position);

                    tileInfoGUI.SetActive(true);

                    roamingCursor.SetActive(true);
                    roamingCursor.transform.position = currentTile.transform.position + new Vector3(0, 0.1f, 0);
//				roamingCursor.renderer.material.color = new Color32(0, 181, 248, 255);
                }
            }
            else
            {
                tileInfoGUI.SetActive(false);
                roamingCursor.SetActive(false);
                currentTile = null;
            }

            switch (InputExtended.GetMouseNumClick(0))
            {
            case 1:             // Single Click
//				mouseDownPos = Input.mousePosition;
//				oldCameraPos = transform.position;
//				if (currentTile != null && currentTile.player_id > 0) {
//					mapCamera.Center(currentTile.player_id);
//					mapCamera.isLeaving = mapCamera.isZooming = true;
//				}
                break;

            case 2:             // Double Click
                if (currentTile.player_id == GameState.player.GetID())
                {
                    mapCamera.Move(currentTile.transform.position);
                }
                break;
            }
        }