コード例 #1
0
 public void RecalculateWorldPoints(TectonicPlate plate)
 {
     //foreach (TectonicPlate plate in Plates)
     {
         List <TectonicPoint> badPoints = new List <TectonicPoint>();
         foreach (TectonicPoint point in plate.Points.Values)
         {
             WorldPoint wp = plate.TectonicPointToWorldPoint(point);
             if (wp != null)
             {
                 bool continueAfter = true;
                 if (wp.TecPoint != null)
                 {
                     //one plate subducts
                     TectonicPoint otherPlatePoint = wp.TecPoint;
                     if (otherPlatePoint.age > point.age)
                     {
                         //the other plate is older and more dense, and that one subducts
                         otherPlatePoint.plate.Points.Remove(otherPlatePoint.Pos);
                         List <TectonicPoint> neighbors = otherPlatePoint.plate.GetNeighbors(otherPlatePoint);
                         foreach (TectonicPoint n in neighbors)
                         {
                             otherPlatePoint.plate.SubductionForce += n.Pos - otherPlatePoint.Pos;
                         }
                     }
                     else
                     {
                         //this plate is older and more dense, this one subducts
                         badPoints.Add(point);
                         continueAfter = false;
                         List <TectonicPoint> neighbors = plate.GetNeighbors(point);
                         foreach (TectonicPoint n in neighbors)
                         {
                             plate.SubductionForce += n.Pos - point.Pos;
                         }
                     }
                 }
                 if (continueAfter)
                 {
                     wp.TecPoint = point;
                 }
             }
         }
         foreach (TectonicPoint badPoint in badPoints)
         {
             plate.Points.Remove(badPoint.Pos);
         }
     }
     foreach (TectonicPoint point in plate.Points.Values)
     {
         WorldPoint wp = plate.TectonicPointToWorldPoint(point);
         if (wp != null)
         {
             wp.go.GetComponent <MeshRenderer>().material.color = point.plate.c;
         }
     }
     plate.WorldPointCenter.go.GetComponent <MeshRenderer>().material.color = Color.black;
 }
コード例 #2
0
 public void AddToVoids()
 {
     foreach (WorldPoint wp in WorldPoints.Values.Where(p => p.TecPoint == null))
     {
         if (wp.OldTectonicPoint == null)
         {
             continue;
         }
         TectonicPlate tp = wp.OldTectonicPoint.plate;
         TectonicPoint createdTecPoint = new TectonicPoint(wp.Pos - tp.WorldPointCenter.Pos, -age, tp);
         wp.TecPoint = createdTecPoint;
         tp.Points.Add(createdTecPoint.Pos, createdTecPoint);
         wp.go.GetComponent <MeshRenderer>().material.color = tp.c;
     }
 }
コード例 #3
0
        public List <TectonicPoint> GetNeighbors(TectonicPoint point)
        {
            List <TectonicPoint> Neighbors = new List <TectonicPoint>();

            for (int x = -1; x <= 1; x++)
            {
                for (int y = -1; y <= 1; y++)
                {
                    if (x == 0 && y == 0)
                    {
                        continue;
                    }
                    if (Points.ContainsKey(new Vector2(x + point.Pos.x, y + point.Pos.y)))
                    {
                        Neighbors.Add(Points[new Vector2(x + point.Pos.x, y + point.Pos.y)]);
                    }
                }
            }
            return(Neighbors);
        }
コード例 #4
0
        public WorldPoint TectonicPointToWorldPoint(TectonicPoint point)
        {
            Vector2 mod = Vector2.zero;

            if (point.Pos.x + WorldPointCenter.Pos.x > 99)
            {
                mod = new Vector2(-100, 0);
            }
            if (point.Pos.x + WorldPointCenter.Pos.x < 0)
            {
                mod = new Vector2(100, 0);
            }
            if (point.Pos.y + WorldPointCenter.Pos.y >= 100)
            {
                return(null);
            }
            if (point.Pos.y + WorldPointCenter.Pos.y < 0)
            {
                return(null);
            }
            return(Sim.WorldPoints[point.Pos + WorldPointCenter.Pos + mod]);
        }