Exemplo n.º 1
0
        public List <SpaceData> Get(string field, string city, string street, string number, string date)
        {
            List <SpaceData> list = new List <SpaceData>();
            DBServices       dbs  = new DBServices();

            foreach (Space item in dbs.readSpacesBySearch(field, city, street, number))
            {
                if (dbs.readAllAvailbilities(item.Id, date).Count > 0)
                {
                    SpaceData s = new SpaceData();
                    s.Space = item;
                    //s.Realavailability = dbs.readAllAvailbilities(s.Space.Id, date);
                    s.Facility           = dbs.readFacilities(s.Space.Id);
                    s.Equipment          = dbs.readEquipments(s.Space.Id).ToArray();
                    s.Orders             = dbs.readOrdersOfSpace(s.Space.Id);
                    s.WeekAvailabilities = dbs.readWeekAvailbilitiesById(s.Space.Id);

                    List <string> tempAvail = new List <string>();
                    foreach (string item2 in dbs.readAllAvailbilities(s.Space.Id, date))
                    {
                        tempAvail.Add(item2.Split('-')[0].Split(':')[0] + ":" + item2.Split('-')[0].Split(':')[1] + "-" + item2.Split('-')[1].Split(':')[0] + ":" + item2.Split('-')[1].Split(':')[1]);
                    }
                    s.Realavailability = tempAvail;

                    list.Add(s);
                }
            }
            return(list);
        }
Exemplo n.º 2
0
 public int InsertParkingSpace(Parking parking)
 {
     SpaceData spaceData = new SpaceData();
     try
     {
         parking.Id = parkingData.GetParkingId(parking.Name, parking.CampusId);
         foreach (Space space in parking.SpaceList)
         {
             spaceData.InsertSpace(space, 0);
         }
         return 0;
     }
     catch (SqlException)
     {
         try
         {
             parkingData.DeleteParking(parking.Id);
             return 1;
         }
         catch (SqlException)
         {
             return 2;
         }
     }
 }
Exemplo n.º 3
0
    public static ExplorationSpace Decode(
        SpaceData data,
        IEventLibrary library)
    {
        List<ExplorationNode> nodes = new List<ExplorationNode>();

        // Recreate the nodes
        Dictionary<uint, ExplorationNode> idToNode;
        List<ExplorationNode> newNodes =
            DecodeNodes(data.Nodes, out idToNode);
        nodes.AddRange(newNodes);

        // Recreate the edges
        Dictionary<uint, ExplorationEdge> idToEdge;
        List<ExplorationEdge> newEdges =
            DecodeEdges(library, idToNode, data.Edges, out idToEdge);

        // Link the instantiated edges to the instantiated nodes
        for (int i = 0; i < data.Nodes.Length; i++)
        {
            NodeData nodeData = data.Nodes[i];
            ExplorationNode node = nodes[i];
            AssignEdgesToNode(idToEdge, nodeData, node);
        }

        return new ExplorationSpace(nodes);
    }
Exemplo n.º 4
0
        public List <SpaceData> Get(string userEmail)
        {
            List <SpaceData> list  = new List <SpaceData>();
            DBServices       dbs   = new DBServices();
            string           today = DateTime.Today.ToString("dd/MM/yyyy");

            foreach (Space item in dbs.readMySpaces(userEmail))
            {
                SpaceData s = new SpaceData();
                s.Space = item;
                //s.Realavailability = dbs.readAllAvailbilities(s.Space.Id, date);
                s.Facility           = dbs.readFacilities(s.Space.Id);
                s.Equipment          = dbs.readEquipments(s.Space.Id).ToArray();
                s.Orders             = dbs.readOrdersOfSpace(s.Space.Id);
                s.WeekAvailabilities = dbs.readWeekAvailbilitiesById(s.Space.Id);

                List <string> tempAvail = new List <string>();
                foreach (string item2 in dbs.readAllAvailbilities(s.Space.Id, today))
                {
                    tempAvail.Add(item2.Split('-')[0].Split(':')[0] + ":" + item2.Split('-')[0].Split(':')[1] + "-" + item2.Split('-')[1].Split(':')[0] + ":" + item2.Split('-')[1].Split(':')[1]);
                }
                s.Realavailability = tempAvail;

                list.Add(s);
            }
            return(list);
        }
Exemplo n.º 5
0
        protected static void SetSpaceData(System.Security.SecurityElement xml)
        {
            //var xml = XMLParser.LoadXML(text);
            var map   = XMLParser.LoadIntMap(xml, String.Empty);
            var type  = typeof(SpaceData);
            var props = type.GetProperties();

            foreach (var item in map)
            {
                var t = new SpaceData();
                foreach (var prop in props)
                {
                    if (prop.Name == "id")
                    {
                        prop.SetValue(t, item.Key, null);
                    }
                    else
                    {
                        if (item.Value.ContainsKey(prop.Name))
                        {
                            var value = Utils.GetValue(item.Value[prop.Name], prop.PropertyType);
                            prop.SetValue(t, value, null);
                        }
                    }
                }
                if (!SpaceDataMap.ContainsKey(item.Key))
                {
                    SpaceDataMap.Add(item.Key, t);
                }
            }
        }
Exemplo n.º 6
0
        public int InsertParkingSpace(Parking parking)
        {
            SpaceData spaceData = new SpaceData();

            try
            {
                parking.Id = parkingData.GetParkingId(parking.Name, parking.CampusId);
                foreach (Space space in parking.SpaceList)
                {
                    spaceData.InsertSpace(space, 0);
                }
                return(0);
            }
            catch (SqlException)
            {
                try
                {
                    parkingData.DeleteParking(parking.Id);
                    return(1);
                }
                catch (SqlException)
                {
                    return(2);
                }
            }
        }
Exemplo n.º 7
0
 public void CreateList()
 {
     SpaceDataArray = new SpaceData[CommonConstants.SpaceDataListLength];
     for (int i = 0; i < CommonConstants.SpaceDataListLength; i++)
     {
         SpaceDataArray[i] = new SpaceData(i, string.Empty);
     }
 }
Exemplo n.º 8
0
    public static SpaceData GenerateRandomMap(int planetCount)
    {
        SpaceData spaceData = new SpaceData();
        //List<PlanetData> planets = new List<PlanetData>();//hold the list of planets to check if they are correctly disributed

        PlanetData planet;

        float minPlanetDistance = 70;

        float spacePerPlanet = 500;
        float spaceArea = planetCount * spacePerPlanet;
        Vector2 size = new Vector2(spaceArea /9, spaceArea / 16 );
        Rect mapSize = new Rect(new Vector2(0, 0), size);

        Vector2 newPosition = new Vector2();
        bool canPositionPlanet = true;
        for (int i = 0; i < planetCount; i++) {
            int timeout = 100;
            do {
                newPosition.x = Random.Range(mapSize.xMin, mapSize.xMax);
                newPosition.y = Random.Range(mapSize.yMin, mapSize.yMax);
                canPositionPlanet = true;
                foreach (PlanetData p in spaceData.planets) {
                    if (Vector2.Distance(newPosition, p.Position) < minPlanetDistance) {
                        canPositionPlanet = false;
                        break;
                    }
                }
                timeout--;
            } while (!canPositionPlanet && timeout > 0);
            int hangarSize = Random.Range(30, 500);
            int ships = (int)((float)hangarSize * Random.Range(0.05f, 0.4f));
            int factorySpeed = System.Math.Min((int)((float)hangarSize * Random.Range(0.2f, 0.45f)), 100);
            planet = new PlanetData(new Vector2(newPosition.x, newPosition.y), Random.Range(15, 58f), ships, hangarSize, factorySpeed, true);
            spaceData.AddPlanet(planet);
        }

        Vector2 minMapSize = mapSize.size / 2;  // M
        Vector2 upsizingFactor = new Vector2(spaceData.GetSize().x / minMapSize.x, spaceData.GetSize().y / minMapSize.y);

        if (upsizingFactor.x < 1) {
            upsizingFactor.x = 1;
        }
        if (upsizingFactor.y < 1) {
            upsizingFactor.y = 1;
        }

        foreach (PlanetData p in spaceData.planets) {
             p.Position = new Vector2(p.Position.x * upsizingFactor.x, p.Position.y * upsizingFactor.y);
        }
        spaceData.ForceBoundRecalculation();

        return spaceData;
    }
Exemplo n.º 9
0
    public static void SavePlayerSpace(DrawSpaceScript dss)
    {
        BinaryFormatter formatter = new BinaryFormatter();
        string          path      = Application.persistentDataPath + "/space.fun";
        FileStream      stream    = new FileStream(path, FileMode.Create);

        SpaceData data = new SpaceData(dss);

        formatter.Serialize(stream, data);
        stream.Close();
    }
Exemplo n.º 10
0
        private SpaceData[] GetArray(string arrayString)
        {
            SpaceData[] spaceDataArray = new SpaceData[arrayString.Length];

            for (int i = 0; i < arrayString.Length; i++)
            {
                spaceDataArray[i] = new SpaceData(i, arrayString[i].ToString() == "-" ? "" : arrayString[i].ToString());
            }

            return(spaceDataArray);
        }
        async public Task <bool> GetSpaces()
        {
            bool isSuccess = false;

            //919 Ala Moana Blvd
            double lat = 21.2951427;
            double lon = -157.8609393;

            try
            {
                var locator = CrossGeolocator.Current;
                locator.DesiredAccuracy = 50;
                var p = await locator.GetPositionAsync(timeoutMilliseconds : 1000);

                lat = p.Latitude;
                lon = p.Longitude;
            }
            catch (Exception) { }

            try
            {
                AppData.Spaces.PostsCollection.Clear();

                var token = await Get(RequestSpaces);

                var rootObject = JsonConvert.DeserializeObject <RootObject>(token);

                List <Post> posts = rootObject.posts;

                foreach (var post in posts)
                {
                    var serialize        = JsonConvert.SerializeObject(post);
                    var deserializePosts = JsonConvert.DeserializeObject <Post>(serialize);

                    SpaceData spacedata = new SpaceData(deserializePosts);
                    AppData.Spaces.PostsCollection.Add(spacedata);

                    tmpSpaceData tmp = new tmpSpaceData(spacedata, lat, lon);
                    AppData.Spaces.tmpSpaceCollection.Add(tmp);

                    //debugging may delete after
                    Debug.WriteLine(post.title);
                }

                isSuccess = true;
            }
            catch (Exception)
            {
                isSuccess = false;
            }

            return(isSuccess);
        }
Exemplo n.º 12
0
    private void TranslateAndRotateLoad()
    {
        SpaceData data = SaveSpace.LoadPlayerSpace();

        Vector3 oldFront     = FloatToVector(data.frontGatePosition);
        Vector3 oldBack      = FloatToVector(data.backGatePosition);
        Vector3 oldDirection = oldBack - oldFront;

        oldDirection.y = 0;

        Vector3 newDirection = backGatePosition - frontGatePosition;

        newDirection.y = 0;
        float angles = Vector3.SignedAngle(oldDirection, newDirection, Vector3.up);

        relative = new Vector3(0, angles, 0);
        pivot    = frontGatePosition;

        Vector3 translation = oldFront - frontGatePosition;

        translation.y = 0.8f;

        LoadCenterAndExtents(out room1Bounds, data.room1Center, data.room1Extents, translation, 0);
        // LoadFences (room1Bounds);

        LoadCenterAndExtents(out room2Bounds, data.room2Center, data.room2Extents, translation, 2);
        // LoadFences (room2Bounds);

        for (int i = 0; i < data.connectingRoomCenters.GetLength(0); i++)
        {
            Bounds  connectBounds;
            float[] connectCenter = new float[3];
            connectCenter[0] = data.connectingRoomCenters[i, 0];
            connectCenter[1] = data.connectingRoomCenters[i, 1];
            connectCenter[2] = data.connectingRoomCenters[i, 2];

            float[] connectExtent = new float[3];
            connectExtent[0] = data.connectingRoomExtents[i, 0];
            connectExtent[1] = data.connectingRoomExtents[i, 1];
            connectExtent[2] = data.connectingRoomExtents[i, 2];
            LoadCenterAndExtents(out connectBounds, connectCenter, connectExtent, translation, 1);
            // LoadFences (connectBounds);
            connectingRooms.Add(connectBounds);
        }

        TakeOutOverlapingFences();
    }
Exemplo n.º 13
0
    public static SpaceData LoadPlayerSpace()
    {
        string path = Application.persistentDataPath + "/space.fun";

        if (File.Exists(path))
        {
            BinaryFormatter formatter = new BinaryFormatter();
            FileStream      stream    = new FileStream(path, FileMode.Open);

            SpaceData data = formatter.Deserialize(stream) as SpaceData;
            stream.Close();

            return(data);
        }
        else
        {
            Debug.LogError("Save file not found in " + path);
            return(null);
        }
    }
Exemplo n.º 14
0
        public int InsertParking(Parking parking)
        {
            SpaceData spaceData = new SpaceData();

            if (parking.Name.Equals(string.Empty))
                return 1;
            else if (parking.Height <= 0)
                return 13;
            else if (parking.Width <= 0)
                return 14;
            else if (parking.TotalSpace <= 0)
                return 2;
            else if (parking.CarSpace < 0)
                return 3;
            else if (parking.MotorcycleSpace < 0)
                return 4;
            else if (parking.HandicapSpace < 0)
                return 5;
            else if (parking.BusSpace < 0)
                return 6;
            else if (parking.CarSpace + parking.MotorcycleSpace + parking.HandicapSpace + parking.BusSpace <= 0)
                return 7;
            else if (parking.CarSpace + parking.MotorcycleSpace + parking.HandicapSpace + parking.BusSpace > parking.TotalSpace)
                return 8;
            else if (parking.CarSpace + parking.MotorcycleSpace + parking.HandicapSpace + parking.BusSpace < parking.TotalSpace)
                return 11;
            else if (parking.CampusId.Equals(string.Empty))
                return 12;
            else
            {
                try
                {
                    parkingData.InsertParking(parking);
                    return 0;
                }
                catch (SqlException)
                {
                    return 10;
                }
            }
        }
Exemplo n.º 15
0
        private static SpaceData[] LoadSpaces()
        {
            string path = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), @"Resources\voidFile.txt");
            var    text = System.IO.File.ReadAllText(path);
            var    data = text.Split(',');

            if (data.Length % 2 != 0)
            {
                throw new System.Exception("Incorrect void file, not an even number of adresses (start,end)");
            }
            var voids = new SpaceData[data.Length / 2];

            for (int i = 0; i < data.Length; i += 2)
            {
                var start = Convert.ToUInt32(data[i], 16);
                var end   = Convert.ToUInt32(data[i + 1], 16);
                var size  = end - start;
                voids[i / 2] = new SpaceData(start, size);
            }

            return(voids);
        }
Exemplo n.º 16
0
        // GET api/<controller>/5
        //public string Get(int id)
        //{
        //    return "value";
        //}

        // POST api/<controller>
        public SpaceData Post([FromBody] SpaceData spaceData)
        {
            bool     userType;
            Space    s = spaceData.Space;
            Facility f = spaceData.Facility;

            Equipment[] e = spaceData.Equipment;
            //Availability a = spaceData.Availability;

            DBServices dbs = new DBServices();


            int newSpaceId = dbs.insert(s);

            f.SpaceId = newSpaceId;
            foreach (Equipment item in e)
            {
                item.SpaceId = newSpaceId;
            }
            //e.SpaceId = newSpaceId;
            //a.SpaceId = newSpaceId;
            userType = dbs.userTypeCheckandUpdate(s.UserEmail);

            //  countertest variabe for test how many rows affected
            int countertest = 0;

            countertest += dbs.insert(f);

            foreach (Equipment item in e)
            {
                countertest += dbs.insert(item);
            }

            //countertest += dbs.insert(a);

            return(spaceData);
        }
Exemplo n.º 17
0
    public static SpaceData GenerateDefaultMap()
    {
        SpaceData spaceData = new SpaceData();

        // pos, diameter, ships, hangar, factory, isStartPlanet
        spaceData.AddPlanet(new PlanetData(new Vector2(0, 0), 18, 100, 150, 15, true));
        spaceData.AddPlanet(new PlanetData(new Vector2(1500, 1000), 18, 100, 150, 15, true));
        spaceData.AddPlanet(new PlanetData(new Vector2(1500, 0), 18, 100, 150, 15, true));
        spaceData.AddPlanet(new PlanetData(new Vector2(0, 1000), 18, 100, 150, 15, true));

        spaceData.AddPlanet(new PlanetData(new Vector2(600, 420), 66, 2200, rnd(250, 380, 10), rnd(150, 250, 10), false));
        spaceData.AddPlanet(new PlanetData(new Vector2(900, 580), 66, 2200, rnd(250, 380, 10), rnd(150, 250, 10), false));
        //spaceData.AddPlanet(new PlanetData(new Vector2(750, 500), 15, 0, rnd(15, 25, 5), rnd(5, 15, 5), false));

        spaceData.AddPlanet(new PlanetData(new Vector2(640, 550), 12, rnd(1500, 2500, 100), rnd(10, 40, 5), 0, false));
        spaceData.AddPlanet(new PlanetData(new Vector2(860, 450), 12, rnd(1500, 2500, 100), rnd(10, 40, 5), 0, false));

        spaceData.AddPlanet(new PlanetData(new Vector2(80, 200), 24, rnd(40, 60, 10), rnd(110, 140, 10), rnd(15, 20, 5), false));
        spaceData.AddPlanet(new PlanetData(new Vector2(300, 80), 30, rnd(40, 60, 10), rnd(170, 200, 10), rnd(10, 15, 5), false));

        spaceData.AddPlanet(new PlanetData(new Vector2(80, 800), 24, rnd(40, 60, 10), rnd(110, 140, 10), rnd(15, 20, 5), false));
        spaceData.AddPlanet(new PlanetData(new Vector2(300, 920), 30, rnd(40, 60, 10), rnd(170, 200, 10), rnd(10, 15, 5), false));

        spaceData.AddPlanet(new PlanetData(new Vector2(1420, 200), 24, rnd(40, 60, 10), rnd(110, 140, 10), rnd(15, 20, 5), false));
        spaceData.AddPlanet(new PlanetData(new Vector2(1200, 80), 30, rnd(40, 60, 10), rnd(170, 200, 10), rnd(10, 15, 5), false));

        spaceData.AddPlanet(new PlanetData(new Vector2(1420, 800), 24, rnd(40, 60, 10), rnd(110, 140, 10), rnd(15, 20, 5), false));
        spaceData.AddPlanet(new PlanetData(new Vector2(1200, 902), 30, rnd(40, 60, 10), rnd(170, 200, 10), rnd(10, 15, 5), false));

        spaceData.AddPlanet(new PlanetData(new Vector2(250, 500), 36, rnd(180, 250, 10), 180, 45, false));
        spaceData.AddPlanet(new PlanetData(new Vector2(1250, 500), 36, rnd(180, 250, 10), 180, 45, false));

        spaceData.AddPlanet(new PlanetData(new Vector2(750, 50), 42, rnd(200, 350, 10), 250, 65, false));
        spaceData.AddPlanet(new PlanetData(new Vector2(750, 950), 42, rnd(200, 350, 10), 250, 65, false));

        return spaceData;
    }
Exemplo n.º 18
0
        public override SpaceData GetSpaceDataForVisit(int spaceOwnerID, DataAccessLevel dataAccessLevel)
        {
            string privacyCondition = null;

            if (dataAccessLevel == DataAccessLevel.Normal)
            {
                privacyCondition = " AND [PrivacyType] IN (0, 3)";
            }
            else if (dataAccessLevel == DataAccessLevel.Friend)
            {
                privacyCondition = " AND [PrivacyType] IN (0, 1, 3)";
            }

            StringBuffer sql = new StringBuffer();

            sql += "SELECT TOP 5 * FROM bx_BlogArticles WHERE UserID = @UserID" + privacyCondition + " ORDER BY ArticleID DESC; \r\n";
            sql += "SELECT TOP 4 * FROM bx_Albums WHERE UserID = @UserID" + privacyCondition + " ORDER BY AlbumID DESC; \r\n";
            sql += "SELECT TOP 5 * FROM bx_Comments WHERE Type = 1 AND TargetUserID = @UserID AND IsApproved = 1 ORDER BY CommentID DESC; \r\n";
            sql += "SELECT TOP 5 * FROM bx_Doings WHERE UserID = @UserID ORDER BY DoingID DESC; \r\n";
            sql += "SELECT TOP 6 * FROM bx_Visitors WHERE UserID = @UserID ORDER BY CreateDate DESC; \r\n";
            sql += "SELECT TOP 12 * FROM bx_Friends WHERE UserID = @UserID AND GroupID >= 0 ORDER BY Hot, CreateDate DESC; \r\n";

            sql += "SELECT TOP 5 * FROM bx_SharesView WHERE UserID = @UserID" + privacyCondition + " AND [PrivacyType] != 2 ORDER BY ShareID DESC;";

            sql += "SELECT TOP 12 *, B.Text, B.KeywordVersion FROM bx_Impressions A LEFT JOIN bx_ImpressionTypes B ON B.TypeID = A.TypeID WHERE UserID = @UserID ORDER BY UpdateDate DESC;";

            using (SqlQuery query = new SqlQuery())
            {
                query.CommandText = sql.ToString();

                query.CreateParameter <int>("@UserID", spaceOwnerID, SqlDbType.Int);

                using (XSqlDataReader reader = query.ExecuteReader())
                {
                    SpaceData result = new SpaceData();

                    result.ArticleList = new BlogArticleCollection(reader);

                    reader.NextResult();

                    result.AlbumList = new AlbumCollection(reader);

                    reader.NextResult();

                    result.CommentList = new CommentCollection(reader);

                    reader.NextResult();

                    result.DoingList = new DoingCollection(reader);

                    reader.NextResult();

                    result.VisitorList = new VisitorCollection(reader);

                    reader.NextResult();

                    result.FriendList = new FriendCollection(reader);

                    reader.NextResult();

                    result.ShareList = new ShareCollection(reader);

                    reader.NextResult();

                    result.ImpressionList = new ImpressionCollection(reader);

                    return(result);
                }
            }
        }
Exemplo n.º 19
0
 void PlaceExistingPlayersOnMap(PlayerListData playerListData, SpaceData spaceData)
 {
     playerManager.Init(playerListData);
     foreach (PlanetData planet in spaceData.planets) {
         if (planet.Owner != null) {
             PlayerData correctPlayerObject = playerListData.GetPlayerByName(planet.Owner.Name);
             planet.Owner = correctPlayerObject;
             planet.Owner.AddPlanetToOwnership(planet);
         }
     }
 }
Exemplo n.º 20
0
        public int InsertParking(Parking parking)
        {
            SpaceData spaceData = new SpaceData();

            if (parking.Name.Equals(string.Empty))
            {
                return(1);
            }
            else if (parking.Height <= 0)
            {
                return(13);
            }
            else if (parking.Width <= 0)
            {
                return(14);
            }
            else if (parking.TotalSpace <= 0)
            {
                return(2);
            }
            else if (parking.CarSpace < 0)
            {
                return(3);
            }
            else if (parking.MotorcycleSpace < 0)
            {
                return(4);
            }
            else if (parking.HandicapSpace < 0)
            {
                return(5);
            }
            else if (parking.BusSpace < 0)
            {
                return(6);
            }
            else if (parking.CarSpace + parking.MotorcycleSpace + parking.HandicapSpace + parking.BusSpace <= 0)
            {
                return(7);
            }
            else if (parking.CarSpace + parking.MotorcycleSpace + parking.HandicapSpace + parking.BusSpace > parking.TotalSpace)
            {
                return(8);
            }
            else if (parking.CarSpace + parking.MotorcycleSpace + parking.HandicapSpace + parking.BusSpace < parking.TotalSpace)
            {
                return(11);
            }
            else if (parking.CampusId.Equals(string.Empty))
            {
                return(12);
            }
            else
            {
                try
                {
                    parkingData.InsertParking(parking);
                    return(0);
                }
                catch (SqlException)
                {
                    return(10);
                }
            }
        }
Exemplo n.º 21
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (VisitorIsOwner)
            {
                if (_Request.Get("op", Method.Get) == "apply")
                {
                    string theme = _Request.Get("theme", Method.Get);

                    if (theme != null)
                    {
                        SpaceBO.Instance.UpdateSpaceTheme(theme);

                        BbsRouter.JumpTo("space/" + SpaceOwnerID);
                    }
                }
            }
            else
            {
                AddNavigationItem(string.Concat(AppOwner.Name, "的空间"));
            }


            if (_Request.IsClick("articlepassword"))
            {
                int articleID = _Request.Get <int>("id", Method.Post, 0);

                BlogBO.Instance.SaveBlogArticlePassword(MyUserID, articleID, _Request.Get("password", Method.Post));

                BbsRouter.JumpTo("space/" + SpaceOwnerID + "/blog/article-" + articleID);
            }
            else if (_Request.IsClick("adddoing"))
            {
                AddDoing();
            }
            else if (_Request.IsClick("addcomment"))
            {
                AddComment(null, null, "boardform");
            }
            else if (_Request.IsClick("CreateImpression"))
            {
                MessageDisplay msgDisplay = CreateMessageDisplayForForm("ImpressionForum", "text");
                string         text       = _Request.Get("Text");

                bool success;
                try
                {
                    success = ImpressionBO.Instance.CreateImpression(My, SpaceOwner, text);
                    if (success == false)
                    {
                        CatchError <ErrorInfo>(delegate(ErrorInfo error)
                        {
                            msgDisplay.AddError(error);
                        });
                    }
                    else
                    {
                        m_IsShowImpressionInput = false;
                    }
                }
                catch (Exception ex)
                {
                    msgDisplay.AddException(ex);
                }
            }
            else if (_Request.IsClick("DeleteImpression"))
            {
                int?typeID = _Request.Get <int>("TypeID");

                if (typeID != null)
                {
                    ImpressionBO.Instance.DeleteImpressionTypeForUser(My, typeID.Value);
                }
            }
            else if (_Request.IsClick("addfeedcomment"))
            {
                CreateComment();
            }


            SpaceData spaceData = SpaceBO.Instance.GetSpaceDataForVisit(MyUserID, SpaceOwnerID);

            m_AlbumList      = spaceData.AlbumList;
            m_ArticleList    = spaceData.ArticleList;
            m_CommentList    = spaceData.CommentList;
            m_DoingList      = spaceData.DoingList;
            m_VisitorList    = spaceData.VisitorList;
            m_FriendList     = spaceData.FriendList;
            m_ShareList      = spaceData.ShareList;
            m_ImpressionList = spaceData.ImpressionList;

            WaitForFillSimpleUsers <Album>(spaceData.AlbumList);
            WaitForFillSimpleUsers <BlogArticle>(spaceData.ArticleList);
            WaitForFillSimpleUsers <Comment>(spaceData.CommentList);
            WaitForFillSimpleUsers <Doing>(spaceData.DoingList);
            WaitForFillSimpleUsers <Visitor>(spaceData.VisitorList, 0);
            WaitForFillSimpleUsers <Friend>(spaceData.FriendList);
            WaitForFillSimpleUsers <Share>(spaceData.ShareList, 0);
            WaitForFillSimpleUsers <Impression>(spaceData.ImpressionList);

            if (IsShowImpressionInput)
            {
                m_ImpressionTypeList = ImpressionBO.Instance.GetImpressionTypesForUse(SpaceOwnerID, 8, 4);
            }

            if (VisitorIsOwner)
            {
                int page = _Request.Get <int>("page", Method.Get, 1);

                m_ImpressionRecordList = ImpressionBO.Instance.GetTargetUserImpressionRecords(SpaceOwnerID, page, 5);

                WaitForFillSimpleUsers <ImpressionRecord>(m_ImpressionRecordList, 0);
            }

            #region 访问者源判断

            string source = _Request.Get("source", Method.Get);

            switch (source)
            {
            case "show":                    //竞价排名
                PointShowBO.Instance.CheckPointShow(My, SpaceOwnerID, IPUtil.GetCurrentIP());
                break;
            }

            #endregion
        }
Exemplo n.º 22
0
    public void Init(SpaceData space)
    {
        spaceData = space;

        Rect bounds = space.bounds;

        bounds.xMin -= BORDER_WIDTH;
        bounds.yMin -= BORDER_WIDTH;
        bounds.xMax += BORDER_WIDTH;
        bounds.yMax += BORDER_WIDTH;
        this.bounds = bounds;

        foreach (PlanetData planet in spaceData.planets) {
            CreatePlanet(planet);
        }

        // Initialise the background texture:
        background.transform.localPosition = new Vector3(bounds.xMin, bounds.yMin, 10);
        Vector2 scaling = new Vector2(bounds.width / backgroundTexture.width, bounds.height / backgroundTexture.height);    //scaling of the background to be as big as the map

        //Update the textureRect according to the aspect ratio:
        float mapRatio = scaling.x / scaling.y;
        float backgroundRatio = backgroundTexture.width / backgroundTexture.height;

        Rect textureRect;
        //textureRect = new Rect(0, 0, backgroundTexture.width, backgroundTexture.height);
        if (mapRatio > backgroundRatio) {       // clip top/bottom of texture
            float height = backgroundTexture.height / mapRatio;
            scaling.y = scaling.x;
            textureRect = new Rect(0, (backgroundTexture.height - height) / 2, backgroundTexture.width, height);
        } else {                                // clip left/right
            float width = backgroundTexture.width * mapRatio;
            scaling.x = scaling.y;
            textureRect = new Rect((backgroundTexture.width - width) / 2, 0, width, backgroundTexture.height);
        }
        background.transform.localScale = new Vector3(scaling.x, scaling.y, 1);

        Sprite sprite = Sprite.Create(backgroundTexture, textureRect, new Vector2(0, 0), 1);    //origin (pivot) = corner
        backgroundRenderer.sprite = sprite;

        //translate the whole Space gameobject so that it's origin is the map's center:
        Vector2 center = bounds.center;
        transform.localPosition = new Vector3(-center.x, -center.y, 0);
        tactileBackground.Init(bounds);

        // set
        particleSystem.transform.localPosition = new Vector3(center.x, center.y, 0);
        particleSystem.transform.localScale = new Vector3(bounds.size.x, bounds.size.y, 1);

        //add planets into the dictionary
        foreach (Planet p in planets)
        {
            planetDict.Add(p.planetData, p);
        }
    }