Inheritance: MonoBehaviour
        public List<Center> GetAllCenter(int districtId, int thanaId)
        {
            string query = "SELECT * FROM tbl_center WHERE DistrictId='" + districtId + "' AND thanaId='" + thanaId + "' ORDER BY CenterName ASC";
            sqlConnection.Open();
            sqlCommand.CommandText = query;
            SqlDataReader aReader = sqlCommand.ExecuteReader();
            List<Center> centerList = new List<Center>();

            while (aReader.Read())
            {
                Center aCenter = new Center();

                aCenter.Id = (int)aReader["id"];
                aCenter.Name = aReader["CenterName"].ToString();
                aCenter.DistrictId = (int)aReader["DistrictId"];
                aCenter.ThanaId = (int)aReader["ThanaId"];
                aCenter.CenterCode = aReader["CenterCode"].ToString();

                centerList.Add(aCenter);

            }
            aReader.Close();
            sqlConnection.Close();
            return centerList;
        }
        protected void creatCenterButton_Click(object sender, EventArgs e)
        {
            Center aCenter = new Center();

            aCenter.Name = centerNameTextBox.Text;
            aCenter.DistrictId = Convert.ToInt32(districtDropDownList.SelectedValue);
            aCenter.ThanaId = Convert.ToInt32(thanaDropDownList.SelectedValue);
            aCenter.CenterCode = aCenter.Name+centerManager.RandomCode();
            aCenter.Password = centerManager.Encryptdata(centerManager.RandomPassword());

            int num = centerManager.CreateCenter(aCenter);
            if (num==0)
            {

                Session["CENTER"] = aCenter;
                Response.Redirect("~/UI/Admin/MessageUI.aspx");
            }
            else if (num==1)
            {
                messageLabel.Text = "Sorry this Tenter Name already exists in" + thanaDropDownList.SelectedValue;
            }
            else if (num==2)
            {
                messageLabel.Text = "Sorry this center code already exists. Please try again";
                Server.TransferRequest(Request.Url.AbsolutePath, false);
                messageLabel.ForeColor = Color.Red;
            }
            else
            {
                messageLabel.Text = "Sorry save failed";
                messageLabel.ForeColor = Color.Red;
            }
        }
Ejemplo n.º 3
0
Archivo: Cell.cs Proyecto: Lyloox/Abimn
        public void Draw(Pos pos, Center center = Center.None)
        {
            byte[] clone = _id.ToArray();

            G.tiles[(int)Tiles.Main][clone[0] - 1].Draw(pos, center);
            for (byte i = 1; i < clone.Length; i++)
                G.tiles[(int)Tiles.MainDeco][clone[i] - 1].Draw(pos, center);
        }
Ejemplo n.º 4
0
Archivo: Tile.cs Proyecto: Lyloox/Abimn
 /// <summary>
 /// Dessine le sprite en utilisant ses attributs et le spritebatch donné
 /// </summary>
 /// <param name="spriteBatch">Le spritebatch avec lequel dessiner</param>
 /// <param name="gameTime">Le GameTime de la frame</param>
 public virtual void Draw(Pos pos, Center center = Center.None)
 {
     if (center == Center.Horizontal || center == Center.All)
         pos.X = pos.X = pos.X - _texture.Width / 2;
     if (center == Center.Vertical || center == Center.All)
         pos.Y = pos.Y = pos.Y - _texture.Height / 2;
     G.spriteBatch.Draw(_texture, pos.ToVector2(), Color.White);
 }
Ejemplo n.º 5
0
        public DummyStandalone()
        {
            var frature = new DummyFrature();

            _Storage = new ExpansionFeature(frature, frature, frature);
            _Updater = new Updater();
            _Center = new Center(_Storage);
        }
 public int SaveCenter(Center aCenter)
 {
     SqlConnection connection = new SqlConnection(connectionString);
     string query = "INSERT INTO center_table VALUES ('" + aCenter.Name+ "', '" + aCenter.Code+ "', '" + aCenter.Password + "', '"+aCenter.ThanaId + "') ";
     SqlCommand aCommand = new SqlCommand(query, connection);
     connection.Open();
     int rowAffedted = aCommand.ExecuteNonQuery();
     connection.Close();
     return rowAffedted;
 }
Ejemplo n.º 7
0
 public void FindAllPossiblePlacements(Center center)
 {
     for (int i = 0; i < BuildingManager.Directions.Count; i++)
     {
         //check to make sure it's not going to place on another branch of the structure that
         //  isn't necessarily a parent or child
         if (!BuildingManager.DetectOtherObjects(BuildingManager.ToDirFromSpot(i), this.transform))
             center.SetPlacement(BuildingManager.ToDirFromSpot(i), this.transform);
     }
 }
Ejemplo n.º 8
0
Archivo: Cell.cs Proyecto: Lyloox/Abimn
 public void Draw(Pos pos, Center center = Center.None, bool fighting = false)
 {
     if (fighting)
         Tile.Draw("fight/" + IdFloor, pos);
     else
     {
         Tile.Draw("main/" + IdFloor, pos);
         if (IdDeco != 0)
             Tile.Draw("main deco/" + IdDeco, pos);
     }
 }
 public string SaveCenter(Center aCenter)
 {
     if (aCenterGateway.SaveCenter(aCenter) > 0)
     {
         return "Saved Successfully";
     }
     else
     {
         return "Failed";
     }
 }
 protected void saveButton_Click(object sender, EventArgs e)
 {
     Center aCenter = new Center();
     aCenter.Name = centerTextBox.Text;
     string thanaName = thanaDropDownList.SelectedItem.ToString();
     aCenter.ThanaId = int.Parse(thanaDropDownList.SelectedValue);
     aCenter.Password = CreatePassword();
     aCenter.Code = CreateCode(thanaName);
     Session["Name"] = aCenter.Name;
     Session["Code"] = aCenter.Code;
     Session["Password"] = aCenter.Password;
     msgLabel.Text = aCenterManager.SaveCenter(aCenter);
     Response.Redirect("CenterView.aspx");
 }
        protected void Page_Load(object sender, EventArgs e)
        {
            aCenter = (Center) Session["CENTER"];
            string name = aCenter.Name;
            int districtId = aCenter.DistrictId;
            int thanaId = aCenter.ThanaId;
            string centerCode = aCenter.CenterCode;
            string password = aCenter.Password;

            districtNameLabel.Text = dropDownManager.GetDistrict(districtId);
            thanaNameLabel.Text = dropDownManager.GetThana(thanaId);
            centerNameLabel.Text = name;
            centerCodeLabel.Text = centerCode;
            passwordLabel.Text = Decryptdata(password);
        }
 public bool CreateCenter(Center aCenter)
 {
     string saveMedicine = "INSERT INTO tbl_center (CenterName,CenterCode,CenterPassward,DistrictId,ThanaId) VALUES(@name,@CenterCode,@CenterPassward,@DistrictId,@ThanaId)";
     sqlConnection.Open();
     sqlCommand.CommandText = saveMedicine;
     sqlCommand.Parameters.AddWithValue("@name", aCenter.Name);
     sqlCommand.Parameters.AddWithValue("@CenterCode", aCenter.CenterCode);
     sqlCommand.Parameters.AddWithValue("@CenterPassward", aCenter.Password);
     sqlCommand.Parameters.AddWithValue("@DistrictId", aCenter.DistrictId);
     sqlCommand.Parameters.AddWithValue("@ThanaId", aCenter.ThanaId);
     int rowAffected = sqlCommand.ExecuteNonQuery();
     sqlConnection.Close();
     if (rowAffected > 0)
     {
         return true;
     }
     return false;
 }
        public List<Center> GetAllCenter(int id)
        {
            string searchMedicine = "SELECT * FROM tbl_center where ThanaId='" + id + "' Order By CenterName ASC";
            sqlConnection.Open();
            sqlCommand.CommandText = searchMedicine;
            SqlDataReader reader = sqlCommand.ExecuteReader();
            List<Center> centerList = new List<Center>();
            while (reader.Read())
            {
                Center aCenter = new Center();
                aCenter.Id = Convert.ToInt32(reader["id"].ToString());
                aCenter.Name = reader["CenterName"].ToString();
                centerList.Add(aCenter);

            }
            reader.Close();
            sqlConnection.Close();
            return centerList;
        }
        public List<Center> ShowthanaList()
        {
            List<Center> thanaList = new List<Center>();

            SqlConnection connection = new SqlConnection(connectionString);
            string query = "SELECT * FROM thana_table";
            SqlCommand command = new SqlCommand(query, connection);
            connection.Open();
            SqlDataReader aReader = command.ExecuteReader();
            while (aReader.Read())
            {
                Center aStudent = new Center();
                aStudent.Id = (int)aReader["thana_id"];
                aStudent.Name = (string)aReader["thana_name"];
                thanaList.Add(aStudent);
            }
            aReader.Close();
            connection.Close();
            return thanaList;
        }
 public int CreateCenter(Center aCenter)
 {
     if (centerGateway.IsThisCenterNameExists(aCenter.Name,aCenter.ThanaId))
     {
         return 1;
     }
     else if (centerGateway.IsThisCenterCodeExists(aCenter.CenterCode))
     {
         return 2;
     }
     else
     {
         if (centerGateway.CreateCenter(aCenter))
         {
             return 0;
         }
         else
         {
             return -1;
         }
     }
 }
Ejemplo n.º 16
0
	// Build graph data structure in 'edges', 'centers', 'corners',
    // based on information in the Voronoi results: point.neighbors
    // will be a list of neighboring points of the same type (corner
    // or center); point.edges will be a list of edges that include
    // that point. Each edge connects to four points: the Voronoi edge
    // edge.{v0,v1} and its dual Delaunay triangle edge edge.{d0,d1}.
    // For boundary polygons, the Delaunay edge will have one null
    // point, and the Voronoi edge may be null.
	public void buildGraph(List<Vector2> points, csDelaunay.Voronoi voronoi){

		Center p;
		var centerLookup = new Dictionary<Vector2, Center> ();
		var libedges = voronoi.Edges;


		// Build Center objects for each of the points, and a lookup map
		// to find those Center objects again as we build the graph
		foreach (var point in points) {
			p = new Center();
			p.index = centers.Count;
			p.point = point;
			p.neighbors = new List<Center>();
			p.borders =   new List<Edge>();
			p.corners =   new List<Corner>();
			centers.Add(p);
			centerLookup[point] = p;
		}

		// Workaround for Voronoi lib bug: we need to call region() before Edges or neighboringSites are available
		foreach (var c in centers) {
			voronoi.Region(c.point);		
		}


		// The Voronoi library generates multiple Point objects for
		// corners, and we need to canonicalize to one Corner object.
		// To make lookup fast, we keep an array of Points, bucketed by
		// x value, and then we only have to look at other Points in
		// nearby buckets. When we fail to find one, we'll create a new
		// Corner object.
		var  _cornerMap = new Dictionary<int, List<Corner>> ();
		Func<Vector2, Corner> makeCorner = delegate(Vector2 point) {
			int bucket;
			
			if (point == Vector2.zero) { return null; }
			
			for (bucket = (int)(point.x)-1; bucket <= (int)(point.x)+1; bucket++) {
				if(_cornerMap.ContainsKey(bucket)){
					foreach(var c in _cornerMap[bucket]){
						var dx = point.x - c.point.x;
						var dy = point.y - c.point.y;
						if(dx*dx+dy*dy<1e-6F){
							return c;
						}
					}
				}
			}
			
			bucket = (int)point.x;
			if (!_cornerMap.ContainsKey (bucket)) {
				_cornerMap.Add(bucket, null);
			}
			if(_cornerMap[bucket] == null) {_cornerMap[bucket] = new List<Corner>();}
			
			
			var q = new Corner ();
			q.index = corners.Count;
			corners.Add (q);
			q.point = point;
			q.border = (point.x == 0F || point.x == SIZE || point.y == 0F || point.y == SIZE);
			q.touches = new List<Center> ();
			q.protrudes = new List<Edge> ();
			q.adjacent = new List<Corner> ();
			_cornerMap[bucket].Add(q);
			
			return q;
		};

		// Helper functions for the following for loop;
		Action<List<Corner>, Corner> addToCornerList = delegate(List<Corner> v, Corner x) 
        {
			if (x != null && v.IndexOf (x) < 0) { v.Add (x); }
		};
		Action<List<Center>, Center> addToCenterList = delegate(List<Center> v, Center x) 
        {
			if (x != null && v.IndexOf (x) < 0) { v.Add (x); }
		};

		foreach (var libedge in libedges) {
			var dedge = libedge.delaunayLine();
			var vedge = libedge.voronoiEdge();

			var edge = new Edge();
			edge.index = edges.Count;
			edge.river = 0;
			edges.Add(edge);
			if (vedge.p0 != Vector2.zero && vedge.p1 != Vector2.zero)
            {
					edge.midpoint = Vector2.Lerp(vedge.p0, vedge.p1, 0.5F);
			}

			
			edge.v0 = makeCorner(vedge.p0);
			edge.v1 = makeCorner(vedge.p1);
			edge.d0 = centerLookup[dedge.p0];
			edge.d1 = centerLookup[dedge.p1];
			
			if (edge.d0 != null) { edge.d0.borders.Add(edge); }
			if (edge.d1 != null) { edge.d1.borders.Add(edge); }
			if (edge.v0 != null) { edge.v0.protrudes.Add(edge); }
			if (edge.v1 != null) { edge.v1.protrudes.Add(edge); }
			
			if (edge.d0 != null && edge.d1 != null) {
				addToCenterList(edge.d0.neighbors, edge.d1);
				addToCenterList(edge.d1.neighbors, edge.d0);
			}
			if (edge.v0 != null && edge.v1 != null) {
				addToCornerList(edge.v0.adjacent, edge.v1);
				addToCornerList(edge.v1.adjacent, edge.v0);
			}
			if (edge.d0 != null) {
				addToCornerList(edge.d0.corners, edge.v0);
				addToCornerList(edge.d0.corners, edge.v1);
			}
			if (edge.d1 != null) {
				addToCornerList(edge.d1.corners, edge.v0);
				addToCornerList(edge.d1.corners, edge.v1);
			}
			if (edge.v0 != null) {
				addToCenterList(edge.v0.touches, edge.d0);
				addToCenterList(edge.v0.touches, edge.d1);
			}
			if (edge.v1 != null) {
				addToCenterList(edge.v1.touches, edge.d0);
				addToCenterList(edge.v1.touches, edge.d1);
			}
		}
	}
Ejemplo n.º 17
0
	// Look up a Voronoi Edge object given two adjacent Voronoi
    // polygons, or two adjacent Voronoi corners
	public Edge lookupEdgeFromCenter(Center p, Center r) {
		foreach (var edge in p.borders) {
			if (edge.d0 == r || edge.d1 == r) return edge;
		}
		return null;
	}
Ejemplo n.º 18
0
 /// <summary>
 /// Compare this circle with <paramref name="circle2"/>
 /// </summary>
 /// <param name="circle2">The other box to be compared</param>
 /// <returns>true if the two boxes equals</returns>
 public bool Equals(CircleF circle2)
 {
     return(Center.Equals(circle2.Center) && Radius.Equals(circle2.Radius));
 }
Ejemplo n.º 19
0
 // Update is called once per frame
 void Update()
 {
     Center.Get <ITickComponent>().Tick(Time.deltaTime);
 }
Ejemplo n.º 20
0
 public void Dispose()
 {
     Center.Dispose();
 }
Ejemplo n.º 21
0
        private void fill(Corner p1, Corner p2, Center c1, Center c2, Edge e)
        {
            e.d0 = c1;
            c1.borders.Add(e.ID, e);
            e.d1 = c2;
            c2.borders.Add(e.ID, e);
            e.v0 = p1;
            p1.protrudes.Add(e.ID, e);
            e.v1 = p2;
            p2.protrudes.Add(e.ID, e);

            if (!c1.neighbors.ContainsKey(c2.position))
            {
                c1.neighbors.Add(c2.position, c2);
                c2.neighbors.Add(c1.position, c1);
            }

            p1.adjacent.Add(p2.position, p2);
            p2.adjacent.Add(p1.position, p1);

            if (!c1.corners.ContainsKey(p1.position))
            {
                c1.corners.Add(p1.position, p1);
                p1.touches.Add(c1.position, c1);
            }
            if (!c1.corners.ContainsKey(p2.position))
            {
                c1.corners.Add(p2.position, p2);
                p2.touches.Add(c1.position, c1);
            }
            if (!c2.corners.ContainsKey(p1.position))
            {
                c2.corners.Add(p1.position, p1);
                p1.touches.Add(c2.position, c2);
            }
            if (!c2.corners.ContainsKey(p2.position))
            {
                c2.corners.Add(p2.position, p2);
                p2.touches.Add(c2.position, c2);
            }
        }
Ejemplo n.º 22
0
        public virtual void MakeDecision(RealtimeSimulation simulation)
        {
            var others               = simulation.Cells.Where(x => x != this);
            var otherSmarts          = others.OfType <SmartCell>();
            var otherDummys          = others.Except(otherSmarts);
            var isAnyBiggerThanMe    = others.Count(x => x.Mass > Mass) > 0;
            var otherBiggest         = others.OrderByDescending(x => x.Mass).FirstOrDefault();
            var otherSmallest        = others.OrderBy(x => x.Mass).FirstOrDefault();;
            var otherSmalls          = others.Where(x => x.Mass <Mass && x.Mass> Mass / minMassDivisor).OrderByDescending(x => x.Mass);
            var biggestOfOtherSmalls = otherSmalls.FirstOrDefault();
            var otherBigs            = others.Where(x => x.Mass > Mass).OrderByDescending(x => x.Mass);
            var nearestBig           = others.Where(x => x.Mass > Mass).OrderBy(x => Center.Subtract(x.Center).Length).FirstOrDefault();
            var nearestSmall         = others.Where(x => x.Mass <Mass && x.Mass> Mass / minMassDivisor)
                                       .OrderBy(x => Center.Subtract(x.Center).Length)
                                       .ThenByDescending(x => x.Mass).FirstOrDefault();
            var slowestOfOtherSmalls = otherSmalls.OrderBy(x => x.Velocity.Length).FirstOrDefault();
            var fastestOfOtherSmalls = otherSmalls.OrderByDescending(x => x.Velocity.Length).FirstOrDefault();
            var biggestMomentum      = otherSmalls.OrderByDescending(x => x.Momentum.Length).FirstOrDefault();

            switch (Character)
            {
            case CharacterType.CatchSmall:
            {
                if (!isAnyBiggerThanMe)
                {
                    return;
                }
                if (biggestOfOtherSmalls == null)
                {
                    return;
                }
                var vector   = biggestOfOtherSmalls.Center - this.Center;
                var uVector1 = vector * -1;
                var uVector2 = biggestOfOtherSmalls.Velocity * -1;
                var uVector  = (uVector1 + uVector2).UnitVector;
                if (uVector.Length == 0)
                {
                    return;
                }
                var dropCell = new Cell()
                {
                    Mass = this.Mass * massDivisor, Velocity = uVector * velocityMultiplier
                };
                dropCell.GenerateRadiusFromMass();
                if (dropCell.Radius < 1 || Radius < 1)
                {
                    return;
                }
                caculateDropCellPosition(dropCell);
                DropObject(dropCell);
                simulation.AddCell(dropCell);
            }
            break;

            case CharacterType.EvadeBig:
            {
                if (!isAnyBiggerThanMe)
                {
                    return;
                }
                if (nearestBig == null)
                {
                    return;
                }
                var vector   = nearestBig.Position - this.Position;
                var uVector1 = vector * 1;
                var uVector2 = nearestBig.Velocity * 1;
                var uVector  = (uVector1 + uVector2).UnitVector;
                if (uVector.Length == 0)
                {
                    return;
                }
                var dropCell = new Cell()
                {
                    Mass = this.Mass * massDivisor, Velocity = uVector * velocityMultiplier
                };
                dropCell.GenerateRadiusFromMass();
                if (dropCell.Radius < 1 || Radius < 1)
                {
                    return;
                }
                caculateDropCellPosition(dropCell);
                DropObject(dropCell);
                simulation.AddCell(dropCell);
            }
            break;

            case CharacterType.CatchNearest:
            {
                if (nearestSmall == null)
                {
                    return;
                }
                if (!isAnyBiggerThanMe)
                {
                    return;
                }
                var vector   = nearestSmall.Position - this.Position;
                var uVector1 = vector * -1;
                var uVector2 = nearestSmall.Velocity * -1;
                var uVector  = (uVector1 + uVector2).UnitVector;
                if (uVector.Length == 0)
                {
                    return;
                }
                var dropCell = new Cell()
                {
                    Mass = this.Mass * massDivisor, Velocity = uVector * velocityMultiplier
                };
                dropCell.GenerateRadiusFromMass();
                if (dropCell.Radius < 1 || Radius < 1)
                {
                    return;
                }
                caculateDropCellPosition(dropCell);
                DropObject(dropCell);
                simulation.AddCell(dropCell);
            }
            break;

            case CharacterType.NoSpeed:
            {
                if (!isAnyBiggerThanMe)
                {
                    return;
                }
                if (Velocity.Length < minVelocityThresold)
                {
                    return;
                }
                var noSpeedMassDivider = 1 / massDivisor;
                var v1       = this.Velocity;
                var v2       = v1 * noSpeedMassDivider;
                var m2       = Mass / noSpeedMassDivider;
                var dropCell = new Cell()
                {
                    Mass = m2, Velocity = v2
                };
                dropCell.GenerateRadiusFromMass();
                if (dropCell.Radius < 1 || Radius < 1)
                {
                    return;
                }
                caculateDropCellPosition(dropCell);
                DropObject(dropCell);
                simulation.AddCell(dropCell);
            }
            break;

            case CharacterType.CatchSmallAndEvadeBig:
            {
                if (subCharacter == CharacterType.CatchSmall)
                {
                    subCharacter = CharacterType.EvadeBig;
                    if (!isAnyBiggerThanMe)
                    {
                        return;
                    }
                    if (biggestOfOtherSmalls == null)
                    {
                        return;
                    }
                    var vector   = biggestOfOtherSmalls.Center - this.Center;
                    var uVector1 = vector * -1;
                    var uVector2 = biggestOfOtherSmalls.Velocity * -1;
                    var uVector  = (uVector1 + uVector2).UnitVector;
                    if (uVector.Length == 0)
                    {
                        return;
                    }
                    var dropCell = new Cell()
                    {
                        Mass = this.Mass * massDivisor, Velocity = uVector * velocityMultiplier
                    };
                    dropCell.GenerateRadiusFromMass();
                    if (dropCell.Radius < 1 || Radius < 1)
                    {
                        return;
                    }
                    caculateDropCellPosition(dropCell);
                    DropObject(dropCell);
                    simulation.AddCell(dropCell);
                }
                else
                {
                    subCharacter = CharacterType.CatchSmall;
                    if (!isAnyBiggerThanMe)
                    {
                        return;
                    }
                    if (nearestBig == null)
                    {
                        return;
                    }
                    var vector   = nearestBig.Position - this.Position;
                    var uVector1 = vector * 1;
                    var uVector2 = nearestBig.Velocity * 1;
                    var uVector  = (uVector1 + uVector2).UnitVector;
                    if (uVector.Length == 0)
                    {
                        return;
                    }
                    var dropCell = new Cell()
                    {
                        Mass = this.Mass * massDivisor, Velocity = uVector * velocityMultiplier
                    };
                    dropCell.GenerateRadiusFromMass();
                    if (dropCell.Radius < 1 || Radius < 1)
                    {
                        return;
                    }
                    caculateDropCellPosition(dropCell);
                    DropObject(dropCell);
                    simulation.AddCell(dropCell);
                }
            }
            break;

            case CharacterType.CatchNearestAndEvadeBig:
            {
                if (subCharacter == CharacterType.CatchNearest)
                {
                    subCharacter = CharacterType.EvadeBig;
                    if (nearestSmall == null)
                    {
                        return;
                    }
                    if (!isAnyBiggerThanMe)
                    {
                        return;
                    }
                    var vector   = nearestSmall.Position - this.Position;
                    var uVector1 = vector * -1;
                    var uVector2 = nearestSmall.Velocity * -1;
                    var uVector  = (uVector1 + uVector2).UnitVector;
                    if (uVector.Length == 0)
                    {
                        return;
                    }
                    var dropCell = new Cell()
                    {
                        Mass = this.Mass * massDivisor, Velocity = uVector * velocityMultiplier
                    };
                    dropCell.GenerateRadiusFromMass();
                    if (dropCell.Radius < 1 || Radius < 1)
                    {
                        return;
                    }
                    caculateDropCellPosition(dropCell);
                    DropObject(dropCell);
                    simulation.AddCell(dropCell);
                }
                else
                {
                    subCharacter = CharacterType.CatchNearest;
                    if (!isAnyBiggerThanMe)
                    {
                        return;
                    }
                    if (nearestBig == null)
                    {
                        return;
                    }
                    var vector   = nearestBig.Position - this.Position;
                    var uVector1 = vector * 1;
                    var uVector2 = nearestBig.Velocity * 1;
                    var uVector  = (uVector1 + uVector2).UnitVector;
                    if (uVector.Length == 0)
                    {
                        return;
                    }
                    var dropCell = new Cell()
                    {
                        Mass = this.Mass * massDivisor, Velocity = uVector * velocityMultiplier
                    };
                    dropCell.GenerateRadiusFromMass();
                    if (dropCell.Radius < 1 || Radius < 1)
                    {
                        return;
                    }
                    caculateDropCellPosition(dropCell);
                    DropObject(dropCell);
                    simulation.AddCell(dropCell);
                }
            }
            break;

            case CharacterType.CatchSlow:
            {
                if (!isAnyBiggerThanMe)
                {
                    return;
                }
                if (slowestOfOtherSmalls == null)
                {
                    return;
                }
                var vector   = slowestOfOtherSmalls.Position - this.Position;
                var uVector1 = vector * -1;
                var uVector2 = slowestOfOtherSmalls.Velocity * -1;
                var uVector  = (uVector1 + uVector2).UnitVector;
                if (uVector.Length == 0)
                {
                    return;
                }
                var dropCell = new Cell()
                {
                    Mass = this.Mass * massDivisor, Velocity = uVector * velocityMultiplier
                };
                dropCell.GenerateRadiusFromMass();
                if (dropCell.Radius < 1 || Radius < 1)
                {
                    return;
                }
                caculateDropCellPosition(dropCell);
                DropObject(dropCell);
                simulation.AddCell(dropCell);
            }
            break;

            case CharacterType.CatchFast:
            {
                if (!isAnyBiggerThanMe)
                {
                    return;
                }
                if (fastestOfOtherSmalls == null)
                {
                    return;
                }
                var vector   = fastestOfOtherSmalls.Position - this.Position;
                var uVector1 = vector * -1;
                var uVector2 = fastestOfOtherSmalls.Velocity * -1;
                var uVector  = (uVector1 + uVector2).UnitVector;
                if (uVector.Length == 0)
                {
                    return;
                }
                var dropCell = new Cell()
                {
                    Mass = this.Mass * massDivisor, Velocity = uVector * velocityMultiplier
                };
                dropCell.GenerateRadiusFromMass();
                if (dropCell.Radius < 1 || Radius < 1)
                {
                    return;
                }
                caculateDropCellPosition(dropCell);
                DropObject(dropCell);
                simulation.AddCell(dropCell);
            }
            break;

            case CharacterType.FollowBig:
            {
                if (!isAnyBiggerThanMe)
                {
                    return;
                }
                if (otherBiggest != null)
                {
                    var vector   = otherBiggest.Position - this.Position;
                    var uVector  = vector.UnitVector * ((vector.Length > otherBiggest.Radius * 2) ? -1 : 1);
                    var dropCell = new Cell()
                    {
                        Mass = this.Mass * massDivisor, Velocity = uVector * velocityMultiplier
                    };
                    dropCell.GenerateRadiusFromMass();
                    if (dropCell.Radius < 1 || Radius < 1)
                    {
                        return;
                    }
                    caculateDropCellPosition(dropCell);
                    DropObject(dropCell);
                    simulation.AddCell(dropCell);
                }
            }
            break;

            case CharacterType.Matador:
            {
                if (!isAnyBiggerThanMe)
                {
                    return;
                }
                if (nearestBig != null)
                {
                    Point?ip1 = null;
                    if (nearestBig.Velocity.Length > 0)
                    {
                        ip1 = Geometry.IntersectionPoint(nearestBig.Center.Point, Diagonale, nearestBig.Velocity.X, nearestBig.Velocity.Y);
                        if (ip1 == null)
                        {
                            ip1 = Geometry.IntersectionPoint(nearestBig.Center.Point, InverseDiagonale, nearestBig.Velocity.X, nearestBig.Velocity.Y);
                        }
                    }

                    Point?ip2 = null;
                    if (Velocity.Length > 0)
                    {
                        ip2 = Geometry.IntersectionPoint(Center.Point, nearestBig.Diagonale, Velocity.X, Velocity.Y);
                        if (ip2 == null)
                        {
                            ip2 = Geometry.IntersectionPoint(Center.Point, nearestBig.InverseDiagonale, Velocity.X, Velocity.Y);
                        }
                    }

                    if (ip2 == null && ip1 == null)
                    {
                        return;
                    }

                    var uVector = new Vector2D(nearestBig.Velocity.Y, nearestBig.Velocity.X).UnitVector;
                    if (ip1 == null)
                    {
                        uVector = new Vector2D(Velocity.Y, Velocity.X).UnitVector;
                    }

                    var dropCell = new Cell()
                    {
                        Mass = this.Mass * massDivisor, Velocity = uVector * velocityMultiplier
                    };
                    dropCell.GenerateRadiusFromMass();
                    if (dropCell.Radius < 1 || Radius < 1)
                    {
                        return;
                    }
                    caculateDropCellPosition(dropCell);
                    DropObject(dropCell);
                    simulation.AddCell(dropCell);
                }
            }
            break;

            case CharacterType.CatchMomentum:
            {
                if (!isAnyBiggerThanMe)
                {
                    return;
                }
                if (biggestMomentum == null)
                {
                    return;
                }
                var vector   = biggestMomentum.Position - this.Position;
                var uVector1 = vector * -1;
                var uVector2 = biggestMomentum.Velocity * -1;
                var uVector  = (uVector1 + uVector2).UnitVector;
                if (uVector.Length == 0)
                {
                    return;
                }
                var dropCell = new Cell()
                {
                    Mass = this.Mass * massDivisor, Velocity = uVector * velocityMultiplier
                };
                dropCell.GenerateRadiusFromMass();
                if (dropCell.Radius < 1 || Radius < 1)
                {
                    return;
                }
                caculateDropCellPosition(dropCell);
                DropObject(dropCell);
                simulation.AddCell(dropCell);
            }
            break;

            default:
                break;
            }
        }
Ejemplo n.º 23
0
 private bool Equals(MapSpan other)
 {
     return(Center.Equals(other.Center) && LongitudeDegrees.Equals(other.LongitudeDegrees) && LatitudeDegrees.Equals(other.LatitudeDegrees));
 }
Ejemplo n.º 24
0
        /// <inheritdoc />
        public bool Equals([AllowNull] Geo other)
        {
            if (other == null)
            {
                return(false);
            }
            if (ReferenceEquals(this, other))
            {
                return(true);
            }

            return
                ((
                     Domain == other.Domain ||
                     Domain != null &&
                     Domain.Equals(other.Domain)
                     ) &&
                 (
                     FitBounds == other.FitBounds ||
                     FitBounds != null &&
                     FitBounds.Equals(other.FitBounds)
                 ) &&
                 (
                     Resolution == other.Resolution ||
                     Resolution != null &&
                     Resolution.Equals(other.Resolution)
                 ) &&
                 (
                     Scope == other.Scope ||
                     Scope != null &&
                     Scope.Equals(other.Scope)
                 ) &&
                 (
                     Projection == other.Projection ||
                     Projection != null &&
                     Projection.Equals(other.Projection)
                 ) &&
                 (
                     Center == other.Center ||
                     Center != null &&
                     Center.Equals(other.Center)
                 ) &&
                 (
                     Visible == other.Visible ||
                     Visible != null &&
                     Visible.Equals(other.Visible)
                 ) &&
                 (
                     ShowCoastlines == other.ShowCoastlines ||
                     ShowCoastlines != null &&
                     ShowCoastlines.Equals(other.ShowCoastlines)
                 ) &&
                 (
                     CoastlineColor == other.CoastlineColor ||
                     CoastlineColor != null &&
                     CoastlineColor.Equals(other.CoastlineColor)
                 ) &&
                 (
                     CoastlineWidth == other.CoastlineWidth ||
                     CoastlineWidth != null &&
                     CoastlineWidth.Equals(other.CoastlineWidth)
                 ) &&
                 (
                     ShowLand == other.ShowLand ||
                     ShowLand != null &&
                     ShowLand.Equals(other.ShowLand)
                 ) &&
                 (
                     LandColor == other.LandColor ||
                     LandColor != null &&
                     LandColor.Equals(other.LandColor)
                 ) &&
                 (
                     ShowOcean == other.ShowOcean ||
                     ShowOcean != null &&
                     ShowOcean.Equals(other.ShowOcean)
                 ) &&
                 (
                     OceanColor == other.OceanColor ||
                     OceanColor != null &&
                     OceanColor.Equals(other.OceanColor)
                 ) &&
                 (
                     ShowLakes == other.ShowLakes ||
                     ShowLakes != null &&
                     ShowLakes.Equals(other.ShowLakes)
                 ) &&
                 (
                     LakeColor == other.LakeColor ||
                     LakeColor != null &&
                     LakeColor.Equals(other.LakeColor)
                 ) &&
                 (
                     ShowRivers == other.ShowRivers ||
                     ShowRivers != null &&
                     ShowRivers.Equals(other.ShowRivers)
                 ) &&
                 (
                     RiverColor == other.RiverColor ||
                     RiverColor != null &&
                     RiverColor.Equals(other.RiverColor)
                 ) &&
                 (
                     RiverWidth == other.RiverWidth ||
                     RiverWidth != null &&
                     RiverWidth.Equals(other.RiverWidth)
                 ) &&
                 (
                     ShowCountries == other.ShowCountries ||
                     ShowCountries != null &&
                     ShowCountries.Equals(other.ShowCountries)
                 ) &&
                 (
                     CountryColor == other.CountryColor ||
                     CountryColor != null &&
                     CountryColor.Equals(other.CountryColor)
                 ) &&
                 (
                     CountryWidth == other.CountryWidth ||
                     CountryWidth != null &&
                     CountryWidth.Equals(other.CountryWidth)
                 ) &&
                 (
                     ShowSubUnits == other.ShowSubUnits ||
                     ShowSubUnits != null &&
                     ShowSubUnits.Equals(other.ShowSubUnits)
                 ) &&
                 (
                     SubUnitColor == other.SubUnitColor ||
                     SubUnitColor != null &&
                     SubUnitColor.Equals(other.SubUnitColor)
                 ) &&
                 (
                     SubUnitWidth == other.SubUnitWidth ||
                     SubUnitWidth != null &&
                     SubUnitWidth.Equals(other.SubUnitWidth)
                 ) &&
                 (
                     ShowFrame == other.ShowFrame ||
                     ShowFrame != null &&
                     ShowFrame.Equals(other.ShowFrame)
                 ) &&
                 (
                     FrameColor == other.FrameColor ||
                     FrameColor != null &&
                     FrameColor.Equals(other.FrameColor)
                 ) &&
                 (
                     FrameWidth == other.FrameWidth ||
                     FrameWidth != null &&
                     FrameWidth.Equals(other.FrameWidth)
                 ) &&
                 (
                     BgColor == other.BgColor ||
                     BgColor != null &&
                     BgColor.Equals(other.BgColor)
                 ) &&
                 (
                     LonAxis == other.LonAxis ||
                     LonAxis != null &&
                     LonAxis.Equals(other.LonAxis)
                 ) &&
                 (
                     LaTaxis == other.LaTaxis ||
                     LaTaxis != null &&
                     LaTaxis.Equals(other.LaTaxis)
                 ) &&
                 (
                     UiRevision == other.UiRevision ||
                     UiRevision != null &&
                     UiRevision.Equals(other.UiRevision)
                 ));
        }
Ejemplo n.º 25
0
 /// <inheritdoc />
 public override int GetHashCode()
 {
     unchecked // Overflow is fine, just wrap
     {
         var hashCode = 41;
         if (Domain != null)
         {
             hashCode = hashCode * 59 + Domain.GetHashCode();
         }
         if (FitBounds != null)
         {
             hashCode = hashCode * 59 + FitBounds.GetHashCode();
         }
         if (Resolution != null)
         {
             hashCode = hashCode * 59 + Resolution.GetHashCode();
         }
         if (Scope != null)
         {
             hashCode = hashCode * 59 + Scope.GetHashCode();
         }
         if (Projection != null)
         {
             hashCode = hashCode * 59 + Projection.GetHashCode();
         }
         if (Center != null)
         {
             hashCode = hashCode * 59 + Center.GetHashCode();
         }
         if (Visible != null)
         {
             hashCode = hashCode * 59 + Visible.GetHashCode();
         }
         if (ShowCoastlines != null)
         {
             hashCode = hashCode * 59 + ShowCoastlines.GetHashCode();
         }
         if (CoastlineColor != null)
         {
             hashCode = hashCode * 59 + CoastlineColor.GetHashCode();
         }
         if (CoastlineWidth != null)
         {
             hashCode = hashCode * 59 + CoastlineWidth.GetHashCode();
         }
         if (ShowLand != null)
         {
             hashCode = hashCode * 59 + ShowLand.GetHashCode();
         }
         if (LandColor != null)
         {
             hashCode = hashCode * 59 + LandColor.GetHashCode();
         }
         if (ShowOcean != null)
         {
             hashCode = hashCode * 59 + ShowOcean.GetHashCode();
         }
         if (OceanColor != null)
         {
             hashCode = hashCode * 59 + OceanColor.GetHashCode();
         }
         if (ShowLakes != null)
         {
             hashCode = hashCode * 59 + ShowLakes.GetHashCode();
         }
         if (LakeColor != null)
         {
             hashCode = hashCode * 59 + LakeColor.GetHashCode();
         }
         if (ShowRivers != null)
         {
             hashCode = hashCode * 59 + ShowRivers.GetHashCode();
         }
         if (RiverColor != null)
         {
             hashCode = hashCode * 59 + RiverColor.GetHashCode();
         }
         if (RiverWidth != null)
         {
             hashCode = hashCode * 59 + RiverWidth.GetHashCode();
         }
         if (ShowCountries != null)
         {
             hashCode = hashCode * 59 + ShowCountries.GetHashCode();
         }
         if (CountryColor != null)
         {
             hashCode = hashCode * 59 + CountryColor.GetHashCode();
         }
         if (CountryWidth != null)
         {
             hashCode = hashCode * 59 + CountryWidth.GetHashCode();
         }
         if (ShowSubUnits != null)
         {
             hashCode = hashCode * 59 + ShowSubUnits.GetHashCode();
         }
         if (SubUnitColor != null)
         {
             hashCode = hashCode * 59 + SubUnitColor.GetHashCode();
         }
         if (SubUnitWidth != null)
         {
             hashCode = hashCode * 59 + SubUnitWidth.GetHashCode();
         }
         if (ShowFrame != null)
         {
             hashCode = hashCode * 59 + ShowFrame.GetHashCode();
         }
         if (FrameColor != null)
         {
             hashCode = hashCode * 59 + FrameColor.GetHashCode();
         }
         if (FrameWidth != null)
         {
             hashCode = hashCode * 59 + FrameWidth.GetHashCode();
         }
         if (BgColor != null)
         {
             hashCode = hashCode * 59 + BgColor.GetHashCode();
         }
         if (LonAxis != null)
         {
             hashCode = hashCode * 59 + LonAxis.GetHashCode();
         }
         if (LaTaxis != null)
         {
             hashCode = hashCode * 59 + LaTaxis.GetHashCode();
         }
         if (UiRevision != null)
         {
             hashCode = hashCode * 59 + UiRevision.GetHashCode();
         }
         return(hashCode);
     }
 }
Ejemplo n.º 26
0
 public async Task Delete(Center center)
 {
     _repo.Delete(center);
     await _repo.Save();
 }
	public void createRoads(Map map) {
		var status = new Dictionary<int, string>();  // index -> status (undefined for unvisited, 'fringe', or 'closed')
		//var fringe = new List<Center>();  // locations that are still being analyzed
		//var p:Center, q:Corner, r:Center, edge:Edge, i:int;
		
		// Initialize
		foreach (var edge in map.edges) {
			road[edge.index] = 0;
		}
		
		// Start with the highest elevation Center -- everything else
		// will connect to this location
		var r = map.centers[0];
		foreach (var p in map.centers) {
			if (p.elevation > r.elevation) {
				r = p;
			}
		}

		status[r.index] = "fringe";
		var fringe = new List<Center>(){r};
		
		while (fringe.Count > 0) {
			// Pick a node randomly. Also interesting is to always pick the first or last node.
			int i = Mathf.FloorToInt(Random.value * (float)fringe.Count);
			// i = 0;
			// i = fringe.length - 1;
			if (i > 0 && Random.value < 0.5) i -= 1;
			var p = fringe[i];
			fringe[i] = fringe[0];
			fringe.RemoveAt(0);
			status[p.index] = "closed";
			
			foreach (var edge in p.borders) {
				r = (edge.d0 == p)? edge.d1 : edge.d0;
				if (r != null && !r.water) {
					if (!status.ContainsKey(r.index)) {
						// We've never been here, so let's add this to the fringe
						status[r.index] = "fringe";
						fringe.Add(r);
						road[edge.index] = 1;
					} 
					else if (status[r.index] == "fringe") {
						// We've been here -- what if the cost is lower?  TODO: ignore for now
					}
				}
			}
		}
		
		// Build the roadConnections list from roads
		foreach (var edge in map.edges) {
			if (road[edge.index]>0) {
				Center[] edgeArray = new Center[]{edge.d0, edge.d1};
				foreach (var p in edgeArray) {
					if (p != null) {
						if (!roadConnections.ContainsKey(p.index)) {
							roadConnections[p.index] = new List<Edge>();
						}
						roadConnections[p.index].Add(edge);
					}
				}
			}
		}
		// Rebuild roads from roadConnections
		foreach (var edge in map.edges) {
			if (road[edge.index]>0) {
				Center[] edgeArray = new Center[]{edge.d0, edge.d1};
				foreach (var p in edgeArray) {
					if (p != null) {
						road[edge.index] = Mathf.Max(road[edge.index], roadConnections[p.index].Count);
					}
				}
			}
			road[edge.index] = Mathf.Min(3, Mathf.Max(0, road[edge.index] - 2));
		}
	}
Ejemplo n.º 28
0
 public virtual void LoadContent(int idNormal, int idOver, int idPushed, Tiles tilesRef, Center center = Center.None)
 {
     _idTextureNormal = --idNormal;
     _idTextureOver = --idOver;
     _idTexturePushed = --idPushed;
     _tilesRef = (int) tilesRef;
     _rect.Width = G.tiles[_tilesRef][idNormal].Texture.Width;
     _rect.Height = G.tiles[_tilesRef][idNormal].Texture.Height;
     if (center == Center.Horizontal || center == Center.All)
         _pos.X = _rect.X = _rect.X - _rect.Width / 2;
     if (center == Center.Vertical || center == Center.All)
         _pos.Y = _rect.Y = _rect.Y - _rect.Height / 2;
 }
Ejemplo n.º 29
0
 public bool IsNextTo(ExplorationNode other)
 {
     return(Math.Abs(Center.Distance(other.Center) - _boxSize) < 1);
 }
Ejemplo n.º 30
0
 public override Shape clone()
 {
     return(new Circle((Point)Center.clone(), Area));
 }
Ejemplo n.º 31
0
 public void Draw(SpriteBatch spriteBatch)
 {
     if (projectileBase.Draw(spriteBatch))
     {
         spriteBatch.Draw(ProjectileHandler.ProjectileTexture[type], Center.WorldToScreenCoords(), null, Color.White, default, ProjectileHandler.ProjectileTexture[type].Size() / 2, spriteScale * GameMain.spriteScaling, default, default);
Ejemplo n.º 32
0
 bool Equals(RadialRegion other)
 {
     return(Center.Equals(other.Center) && LongitudeDegrees.Equals(other.LongitudeDegrees) && LatitudeDegrees.Equals(other.LatitudeDegrees));
 }
Ejemplo n.º 33
0
 public bool Concentric(Circle other, float tolerance = 0.0001f)
 {
     return(Center.Equals(other.Center, tolerance));
 }
Ejemplo n.º 34
0
 public override string ToString()
 {
     return("{" + Center.ToString() + "}, " + Radius.ToString());
 }
Ejemplo n.º 35
0
 void Start()
 {
     GameEventManager.NightStart += NightStart;
     center = player.GetComponent<Center>();
 }
Ejemplo n.º 36
0
 public override int GetHashCode()
 {
     return(Center.GetHashCode() ^ (Extents.GetHashCode() << 2));
 }
Ejemplo n.º 37
0
 /// <summary>
 /// Charge l'image voulue grâce au ContentManager donné
 /// </summary>
 /// <param name="content">Le ContentManager qui chargera l'image</param>
 /// <param name="assetName">L'asset name de l'image à charger pour ce Sprite</param>
 /// <param name="center"> Permet de centrer l'image par rapport à se position. Par défaut l'image n'est pas centrée</param>
 public virtual void LoadContent(int idNormal, Tiles tilesRef, Center center = Center.None)
 {
     this.LoadContent(idNormal, idNormal, idNormal, tilesRef, center);
 }
Ejemplo n.º 38
0
 public bool Equals(Bounds other)
 {
     return(Center.Equals(other.Center) && Extents.Equals(other.Extents));
 }
Ejemplo n.º 39
0
 public bool Equals(Obstacle other)
 {
     return(Center.Equals(other.Center) && Radius.Equals(other.Radius));
 }
Ejemplo n.º 40
0
    private void _ToMode(GameModeSelector<IUser> selector)
    {
        UserProvider<IUser> provider;
        if (Mode == MODE.REMOTING)
        {
            selector.AddFactoty("r", new RemotingUserFactory());
            provider = selector.CreateUserProvider("r");
        }
        else
        {
            this.Resource.Load();
            var feature = new Regulus.Project.ItIsNotAGame1.Game.DummyFrature();
            var center = new Center(feature, feature);

            _Updater.Add(center);
            selector.AddFactoty("s", new StandaloneUserFactory(center));
            provider = selector.CreateUserProvider("s");
        }

        var user = provider.Spawn("user");
        provider.Select("user");

        User = user;
        User.Remoting.OnlineProvider.Supply += _SupplyOnline;
        User.Remoting.OnlineProvider.Unsupply += _UnsupplyOnline;
        User.JumpMapProvider.Supply += _JumpMap;
    }
Ejemplo n.º 41
0
 void Do()
 {
     mainThread = Center.Get <IMainThread>();
     mainThread.RunOnMainThread(Log, null);
 }
Ejemplo n.º 42
0
 get => new Rectangle(Center - CenterOffset, 2 * CenterOffset);
Ejemplo n.º 43
0
	// Assign a biome type to each polygon. If it has
    // ocean/coast/water, then that's the biome; otherwise it depends
    // on low/high elevation and low/medium/high moisture. This is
    // roughly based on the Whittaker diagram but adapted to fit the
    // needs of the island map generator.
	static public string getBiome(Center p) {
		if (p.ocean) {
			return "OCEAN";
		} else if (p.water) {
			if (p.elevation < 0.1F) return "MARSH";
			if (p.elevation > 0.8F) return "ICE";
			return "LAKE";
		} else if (p.coast) {
			return "BEACH";
		} else if (p.elevation > 0.8F) {
			if (p.moisture > 0.50F) return "SNOW";
			else if (p.moisture > 0.33F) return "TUNDRA";
			else if (p.moisture > 0.16F) return "BARE";
			else return "SCORCHED";
		} else if (p.elevation > 0.6F) {
			if (p.moisture > 0.66F) return "TAIGA";
			else if (p.moisture > 0.33F) return "SHRUBLAND";
			else return "TEMPERATE_DESERT";
		} else if (p.elevation > 0.3F) {
			if (p.moisture > 0.83F) return "TEMPERATE_RAIN_FOREST";
			else if (p.moisture > 0.50F) return "TEMPERATE_DECIDUOUS_FOREST";
			else if (p.moisture > 0.16F) return "GRASSLAND";
			else return "TEMPERATE_DESERT";
		} else {
			if (p.moisture > 0.66F) return "TROPICAL_RAIN_FOREST";
			else if (p.moisture > 0.33F) return "TROPICAL_SEASONAL_FOREST";
			else if (p.moisture > 0.16F) return "GRASSLAND";
			else return "SUBTROPICAL_DESERT";
		}
	}
Ejemplo n.º 44
0
 /// <summary>
 /// Charge l'image voulue grâce au ContentManager donné en plaçant son centre sur sa position
 /// </summary>
 /// <param name="content">Le ContentManager qui chargera l'image</param>
 /// <param name="assetName">L'asset name de l'image à charger pour ce Sprite</param>
 /// <param name="center"> Permet de centrer l'image par rapport à se position</param>
 public virtual void LoadContent(int id, Tiles tilesRef, Center center = Center.None)
 {
     _id = --id;
     _tilesRef = (int)tilesRef;
     _rect.Width = G.tiles[_tilesRef][id].Texture.Width;
     _rect.Height = G.tiles[_tilesRef][id].Texture.Height;
     if (center == Center.Horizontal || center == Center.All)
         _pos.X = _rect.X = _rect.X - _rect.Width / 2;
     if (center == Center.Vertical || center == Center.All)
         _pos.Y = _rect.Y = _rect.Y - _rect.Height / 2;
 }
Ejemplo n.º 45
0
    void InitMeshData(GameObject gameObject, float maxHeight)
    {
        List <int> triangles = new List <int>();
        Dictionary <Site, Vector4>  vertexes   = new Dictionary <Site, Vector4>();
        Dictionary <Vector2, float> biomeValue = new Dictionary <Vector2, float>();
        Dictionary <Vector2, int>   biomeDis   = new Dictionary <Vector2, int>();
        Texture2D biomeTexture = new Texture2D(500, 400);

        Color[,] textureColor = new Color[600, 500];
        Queue <KeyValuePair <Vector2, float> > queue = new Queue <KeyValuePair <Vector2, float> >();

        for (int i = 0; i < voro.voronoiCenterList.Count; i++)
        {
            Site s = voro.voronoiCenterList[i].point;

            Vector3 v = new Vector3((float)s.x, voro.voronoiCenterList[i].elevation * maxHeight, (float)s.y);
            v += gameObject.transform.position;
            Vector4 v4 = v;
            v4.w = vertexes.Count;
            vertexes.Add(s, v4);
            float c = (float)(int)voro.voronoiCenterList[i].biome / (float)13;
            int   x = (int)s.x;
            int   y = (int)s.y;
        }

        foreach (KeyValuePair <Site, Corner> k in voro.voronoiCornerList)
        {
            Site s = k.Key;

            Vector3 v = new Vector3((float)s.x, k.Value.elevation * maxHeight, (float)s.y);
            v += gameObject.transform.position;
            Vector4 v4 = v;
            v4.w = vertexes.Count;
            vertexes.Add(s, v4);
            int sumBio = 0;
            foreach (KeyValuePair <int, Center> kc in k.Value.touches)
            {
                sumBio += (int)kc.Value.biome;
            }

            float c = (float)sumBio / (float)13;
            int   x = (int)s.x;
            int   y = (int)s.y;
        }
        Dictionary <int, int> biomeDic = new Dictionary <int, int>();

        for (int i = 0; i < voro.voronoiCenterList.Count; i++)
        {
            Center c = voro.voronoiCenterList[i];

            if (!c.water)
            {
                foreach (KeyValuePair <Edge, Edge> k in c.borders)
                {
                    Vector4 v4;
                    vertexes.TryGetValue(c.point, out v4);
                    triangles.Add((int)v4.w);
                    biomeDic.Add(triangles.Count - 1, (int)c.biome);
                    double x1, x2, y1, y2;
                    x1 = k.Value.a.x - c.point.x;
                    x2 = k.Value.b.x - c.point.x;
                    y1 = k.Value.a.y - c.point.y;
                    y2 = k.Value.b.y - c.point.y;
                    float j = (float)(x1 * y2 - x2 * y1);
                    if (j < 0)
                    {
                        vertexes.TryGetValue(k.Value.a, out v4);
                        triangles.Add((int)v4.w);
                        biomeDic.Add(triangles.Count - 1, (int)c.biome);

                        vertexes.TryGetValue(k.Value.b, out v4);
                        triangles.Add((int)v4.w);
                        biomeDic.Add(triangles.Count - 1, (int)c.biome);
                    }
                    else
                    {
                        vertexes.TryGetValue(k.Value.b, out v4);
                        triangles.Add((int)v4.w);
                        biomeDic.Add(triangles.Count - 1, (int)c.biome);

                        vertexes.TryGetValue(k.Value.a, out v4);
                        triangles.Add((int)v4.w);
                        biomeDic.Add(triangles.Count - 1, (int)c.biome);
                    }
                }
            }
        }

        Vector3[]    vertexesArray  = new Vector3[vertexes.Count];
        int[]        trianglesArray = new int[triangles.Count];
        Vector2[]    uvArray        = new Vector2[vertexes.Count];
        List <int>[] trianglesList  = new List <int> [13];
        for (int i = 0; i < 13; i++)
        {
            trianglesList[i] = new List <int>();
        }


        foreach (KeyValuePair <Site, Vector4> k in vertexes)
        {
            Vector3 v3 = k.Value;
            vertexesArray[(int)k.Value.w] = v3;
            uvArray[(int)k.Value.w]       = new Vector2(v3.x / 500, v3.z / 400);
        }
        for (int i = 0; i < triangles.Count; i++)
        {
            trianglesArray[i] = triangles[i];
            trianglesList[biomeDic[i]].Add(triangles[i]);
        }

        Mesh mesh = gameObject.AddComponent <MeshFilter>().mesh;


        gameObject.AddComponent <MeshRenderer>();


        gameObject.GetComponent <Renderer>().materials = biomeMat;
        for (int i = 0; i < 13; i++)
        {
            gameObject.GetComponent <Renderer>().materials[i].color = biomeColor[i];
        }

        /*设置mesh*/
        mesh.Clear();//更新
        mesh.vertices     = vertexesArray;
        mesh.uv           = uvArray;
        mesh.triangles    = trianglesArray;
        mesh.subMeshCount = 13;
        for (int i = 0; i < 13; i++)
        {
            mesh.SetTriangles(trianglesList[i], i);
        }

        mesh.RecalculateNormals();
        mesh.RecalculateBounds();
    }
Ejemplo n.º 46
0
        public override Widget build(BuildContext context)
        {
            List <Widget> _gestureChildren  = new List <Widget>();
            List <Color>  _backgroundColors = new List <Color>();
            int           index             = 0;
            int           selectedIndex     = 0;
            int           pressedIndex      = 0;

            foreach (T currentKey in widget.children.Keys)
            {
                selectedIndex = (widget.groupValue.Equals(currentKey)) ? index : selectedIndex;
                pressedIndex  = (_pressedKey.Equals(currentKey)) ? index : pressedIndex;
                TextStyle textStyle = DefaultTextStyle.of(context).style.copyWith(
                    color: getTextColor(index, currentKey)
                    );
                IconThemeData iconTheme = new IconThemeData(
                    color: getTextColor(index, currentKey)
                    );

                Widget child = new Center(
                    child: widget.children[currentKey]
                    );

                child = new GestureDetector(
                    onTapDown: (TapDownDetails _event) => {
                    _onTapDown(currentKey);
                },
                    onTapCancel: _onTapCancel,
                    onTap: () => {
                    _onTap(currentKey);
                },
                    child: new IconTheme(
                        data: iconTheme,
                        child: new DefaultTextStyle(
                            style: textStyle,
                            child: child
                            )
                        )
                    );

                _backgroundColors.Add(getBackgroundColor(index, currentKey));
                _gestureChildren.Add(child);
                index += 1;
            }

            Widget box = new _SegmentedControlRenderWidget <T>(
                children: _gestureChildren,
                selectedIndex: selectedIndex,
                pressedIndex: pressedIndex,
                backgroundColors: _backgroundColors,
                borderColor: _borderColor
                );

            return(new Padding(
                       padding: widget.padding ?? CupertinoSegmentedControlsUtils._kHorizontalItemPadding,
                       child: new UnconstrainedBox(
                           constrainedAxis: Axis.horizontal,
                           child: box
                           )
                       ));
        }
Ejemplo n.º 47
0
 public override int GetHashCode()
 {
     return(Center.GetHashCode());
 }
 // Update is called once per frame
 void Update()
 {
     Center.Tick(Time.deltaTime);
 }
Ejemplo n.º 49
0
        /// <summary>
        ///  Funkcja sprawdza wzajemne położenie dwóch kół.
        /// </summary>
        /// <param name="other">drugie koło</param>
        /// <param name="crossingPoints">
        /// Punkty przecięcia obwodów kół, jeśli zwracana jest wartość: Touches albo Crosses.
        /// Pusta tablica wpp.
        /// <returns>
        /// Disjoint - kiedy koła nie mają punktów wspólnych
        /// Contains - kiedy pierwsze koło całkowicie zawiera drugie
        /// IsContained - kiedy pierwsze koło jest całkowicie zawarte w drugim
        /// Identical - kiedy koła pokrywają się
        /// Touches - kiedy koła mają dokładnie jeden punkt wspólny
        /// Crosses - kiedy obwody kół mają dokładnie dwa punkty wspólne
        /// </returns>
        public IntersectionType GetIntersectionType(Disk other, out Point[] crossingPoints)
        {
            double dX    = other.Center.X - this.Center.X;
            double dY    = other.Center.Y - this.Center.Y;
            double dist2 = dX * dX + dY * dY;
            double dist  = Math.Sqrt(dist2);

            /*
             * tu zajmij się wszystkimi przypadkami wzajemnego położenia kół,
             * oprócz Crosses i Touches
             */
            crossingPoints = new Point[0];

            if (Math.Abs(Radius - other.Radius) < Program.epsilon && Center.Equals(other.Center))
            {
                return(IntersectionType.Identical);
            }

            double radiusSum = Radius + other.Radius;

            if (dist - radiusSum > Program.epsilon)
            {
                return(IntersectionType.Disjoint);
            }

            if (Radius - (dist + other.Radius) + Program.epsilon >= 0)
            {
                return(IntersectionType.Contains);
            }
            if (other.Radius - (dist + Radius) + Program.epsilon >= 0)
            {
                return(IntersectionType.IsContained);
            }


            // odległość od środka aktualnego koła (this) do punktu P,
            // który jest punktem przecięcia odcinka łączącego środki kół (this i other)
            // z odcinkiem łączącym punkty wspólne obwodów naszych kół
            double a = (this.Radius * this.Radius - other.Radius * other.Radius + dist2) / (2 * dist);

            // odległość punktów przecięcia obwodów do punktu P
            double h = Math.Sqrt(this.Radius * this.Radius - a * a);

            // punkt P
            double px = this.Center.X + (dX * a / dist);
            double py = this.Center.Y + (dY * a / dist);

            /*
             * teraz wiesz już wszystko co potrzebne do rozpoznania położenia Touches
             * zajmij się tym
             */
            if (h < Program.epsilon)
            {
                crossingPoints = new Point[1] {
                    new Point(px, py)
                };
                return(IntersectionType.Touches);
            }

            // przypadek Crosses - dwa punkty przecięcia - już jest zrobiony

            double rX = -dY * h / dist;
            double rY = dX * h / dist;

            crossingPoints    = new Point[2];
            crossingPoints[0] = new Point(px + rX, py + rY);
            crossingPoints[1] = new Point(px - rX, py - rY);
            return(IntersectionType.Crosses);
        }
 // Use this for initialization
 void Start()
 {
     Center.Init();
     Init();
 }
Ejemplo n.º 51
0
        private void MergeVoronoi(ref List <Center> resCenters, ref List <Edge> resEdges,
                                  ref List <Center> leftCenters, ref List <Edge> leftEdges,
                                  ref List <Center> rightCenters, ref List <Edge> rightEdges,
                                  ref Tuple <Point, Point> upSegm, ref Tuple <Point, Point> downSegm)
        {
            Tuple <Point, Point> curSegm = upSegm;
            Point st = new Point(Math.Round((curSegm.Item1.x + curSegm.Item2.x) / 2, StaticNums.round),
                                 Math.Round((curSegm.Item1.y + curSegm.Item2.y) / 2, StaticNums.round));
            Point temp;

            if (curSegm.Item2.x == curSegm.Item1.x)
            {
                temp = new Point(curSegm.Item1.x, StaticNums.limY);
            }
            else
            {
                double k = (curSegm.Item2.y - curSegm.Item1.y) / (curSegm.Item2.x - curSegm.Item1.x);
                temp = new Point(Math.Round(-k * StaticNums.limY + st.x + st.y * k, StaticNums.round), StaticNums.limY);
            }
            Center leftCenter  = leftCenters.Find(i => (i.point.AreEqual(curSegm.Item1)));
            Center rightCenter = rightCenters.Find(i => (i.point.AreEqual(curSegm.Item2)));

            while (!(curSegm.Item1.AreEqual(downSegm.Item1) && curSegm.Item2.AreEqual(downSegm.Item2)))
            {
                bool left       = false;
                Edge interEdge  = null;
                Edge interEdge2 = null;
                st = this.PerpPoint(curSegm, temp);
                st = new Point(Math.Round(st.x, StaticNums.round), Math.Round(st.y, StaticNums.round));
                Point interPoint = this.firstInterEdge(new Tuple <Point, Point>(st, temp),
                                                       leftCenter.borders, rightCenter.borders,
                                                       ref interEdge, ref left, temp.y, ref interEdge2);

                Tuple <Point, Point> newEdgeBorders = new Tuple <Point, Point>(temp, interPoint);
                if (left)
                {
                    this.ChangeEdges(ref leftEdges, leftCenter, newEdgeBorders);
                }
                if (!left || interEdge2 != null)
                {
                    this.ChangeEdges(ref rightEdges, rightCenter, newEdgeBorders);
                }
                Edge newEdge = new Edge(leftCenter, rightCenter, newEdgeBorders);
                leftCenter.borders.Add(newEdge);
                rightCenter.borders.Add(newEdge);
                leftCenter.neighbours.Add(rightCenter);
                rightCenter.neighbours.Add(leftCenter);
                leftEdges.Add(newEdge);
                rightEdges.Add(newEdge);

                if (left)
                {
                    if (interEdge.v0.point.AreEqual(leftCenter.point))
                    {
                        curSegm    = new Tuple <Point, Point>(interEdge.v1.point, curSegm.Item2);
                        leftCenter = interEdge.v1;
                    }
                    else
                    {
                        curSegm    = new Tuple <Point, Point>(interEdge.v0.point, curSegm.Item2);
                        leftCenter = interEdge.v0;
                    }
                }
                if (!left || interEdge2 != null)
                {
                    if (interEdge.v0.point.AreEqual(rightCenter.point))
                    {
                        curSegm     = new Tuple <Point, Point>(curSegm.Item1, interEdge.v1.point);
                        rightCenter = interEdge.v1;
                    }
                    else
                    {
                        curSegm     = new Tuple <Point, Point>(curSegm.Item1, interEdge.v0.point);
                        rightCenter = interEdge.v0;
                    }
                }
                temp = interPoint;
            }
            Point perp = this.PerpPoint(curSegm, temp);

            perp = new Point(Math.Round((perp.x - temp.x) / (perp.y - temp.y) * (-StaticNums.limY) +
                                        (temp.x * perp.y - perp.x * temp.y) / (perp.y - temp.y), StaticNums.round), -StaticNums.limY);
            Edge lastEdge = new Edge(leftCenter, rightCenter, new Tuple <Point, Point>(temp, perp));

            leftCenter.borders.Add(lastEdge);
            rightCenter.borders.Add(lastEdge);
            leftCenter.neighbours.Add(rightCenter);
            rightCenter.neighbours.Add(leftCenter);
            leftEdges.Add(lastEdge);
            rightEdges.Add(lastEdge);

            resCenters = new List <Center>();
            resEdges   = new List <Edge>();
            resCenters.AddRange(leftCenters);
            resCenters.AddRange(rightCenters);
            resEdges.AddRange(leftEdges);
            foreach (Edge b in rightEdges)
            {
                if (!resEdges.Contains(b))
                {
                    resEdges.Add(b);
                }
            }
        }
Ejemplo n.º 52
0
 public override Shape clone()
 {
     return(new Rectangle(Center.clone(), Area));
 }
Ejemplo n.º 53
0
 public bool Equals(Circle other, float tolerance = 0.0001f)
 {
     return(Center.Equals(other.Center, tolerance) && Math.Abs(Radius - other.Radius) < tolerance);
 }
Ejemplo n.º 54
0
	public float calculateLighting(Center p, Corner r, Corner s){
		var A = new Vector3(p.point.x, p.point.y, p.elevation);
		var B = new Vector3(r.point.x, r.point.y, r.elevation);
		var C = new Vector3(s.point.x, s.point.y, s.elevation);

		var normal = Vector3.Cross((B-A),(C-A));
		if (normal.z < 0) { normal.Scale(new Vector3(-1,-1,-1)); }
		normal.Normalize ();
		var light = 0.5F + 35F*Vector3.Dot(normal,lightVector);
		if (light < 0) light = 0F;
		if (light > 1) light = 1F;
		return light;
	}
Ejemplo n.º 55
0
 public RunFormulaStage( ExpansionFeature expansion_feature, Queue<ISoulBinder> binders)
 {
     _Binders = binders;
     _Updater = new Updater();
     _Center = new Center(expansion_feature);
 }
Ejemplo n.º 56
0
 public override void Print()
 {
     Console.WriteLine("This is a square centered in {0} with {1} side and with {2} area", Center.ToString(), Side, GetArea());
 }
Ejemplo n.º 57
0
    void Start()
    {
        selected = false;
        userSelected = false;
        center = player.GetComponent<Center>();

        nameText.renderer.sortingLayerName = "UI";
        nameText.renderer.sortingOrder = 2;
        costText.renderer.sortingLayerName = "UI";
        costText.renderer.sortingOrder = 2;

        GameEventManager.NightStart += NightStart;
    }
 public string SaveCenter(Center aCenter)
 {
     aCenterDbGateway.SaveCenter(aCenter);
     return("Successfully Saved");
 }
Ejemplo n.º 59
0
        public void GenVoronoi(IEnumerable<Vector> points)
        {
            VoronoiGraph graph = Fortune.ComputeVoronoiGraph(points);

            foreach (VoronoiEdge vedge in graph.Edges)
            {
                if (double.IsNaN(vedge.VVertexB[0]))
                {
                    Vector2 vectLeft = Tools.Functions.VectorToVector2(vedge.LeftData);
                    Vector2 vectRight = Tools.Functions.VectorToVector2(vedge.RightData);
                    Vector2 start = Tools.Functions.VectorToVector2(vedge.VVertexA);

                    Vector2 dir = new Vector2(-vectRight.Y + vectLeft.Y, vectRight.X - vectLeft.X);
                    dir.Normalize();
                    dir /= 2;
                    Vector2 end = dir + start;

                    if (end.X <= 1 && end.X >= 0 && end.Y >= 0 && end.Y <= 1)
                        end = start - dir;

                    vedge.VVertexB = Tools.Functions.Vector2ToVector(end);

                }
                if (!((vedge.VVertexA[0] < 0 || vedge.VVertexA[1] < 0 || vedge.VVertexA[0] > 1 || vedge.VVertexA[1] > 1)
                    && (vedge.VVertexB[0] < 0 || vedge.VVertexB[1] < 0 || vedge.VVertexB[0] > 1 || vedge.VVertexB[1] > 1))
                    && !double.IsNaN(vedge.VVertexB[0])
                    )
                {
                    Edge e = new Edge();

                    Center cent1, cent2;
                    Corner corn1, corn2;

                    if (!Centers.TryGetValue(Tools.Functions.VectorToVector2(vedge.LeftData), out cent1))
                    {
                        cent1 = new Center(Tools.Functions.VectorToVector2(vedge.LeftData));
                        Centers.Add(cent1.position, cent1);
                    }

                    if (!Centers.TryGetValue(Tools.Functions.VectorToVector2(vedge.RightData), out cent2))
                    {
                        cent2 = new Center(Tools.Functions.VectorToVector2(vedge.RightData));
                        Centers.Add(cent2.position, cent2);
                    }

                    if (!Corners.TryGetValue(Tools.Functions.VectorToVector2(vedge.VVertexA), out corn1))
                    {
                        corn1 = new Corner(Tools.Functions.VectorToVector2(vedge.VVertexA));
                        Corners.Add(corn1.position, corn1);
                    }

                    if (!Corners.TryGetValue(Tools.Functions.VectorToVector2(vedge.VVertexB), out corn2))
                    {
                        corn2 = new Corner(Tools.Functions.VectorToVector2(vedge.VVertexB));
                        Corners.Add(corn2.position, corn2);
                    }

                    if (corn1.position != corn2.position)
                    {
                        fill(corn1, corn2, cent1, cent2, e);
                        Edges.Add(e.ID, e);
                    }
                }
            }
        }
Ejemplo n.º 60
0
    // Use this for initialization
    void Start()
    {
        instance = this;
        GameEventManager.GameStart += GameStart;
        GameEventManager.GameOver += GameOver;
        enabled = false;
        playerBottom.renderer.enabled = false;
        centerTurret.renderer.enabled = false;

        HasPath = false;
        PathIsSet = false;
    }