Esempio n. 1
0
 public Pipe(Game game, Rectangle rect, SosEngine.Level level, PipeTypes pipeType, string destination) :
     base(game, "", 0, 0)
 {
     this.rect = rect;
     if (rect.Width > rect.Height)
     {
         this.Orientation = PipeOrientation.Horizontal;
         if (pipeType == PipeTypes.Entrance)
         {
             this.rect.Inflate(-4, -4);
             this.rect.Offset(0, -8);
         }
     }
     else
     {
         this.Orientation = PipeOrientation.Vertical;
         if (pipeType == PipeTypes.Entrance)
         {
             this.rect.Inflate(-4, -4);
             this.rect.Offset(-4, 0);
         }
     }
     this.level       = level;
     this.PipeType    = pipeType;
     this.destination = destination;
 }
Esempio n. 2
0
 public Pipe(PipeOrientation orientation, float y)
 {
     image            = PlayState.pipe;
     x                = GameMain.VIRTUAL_WIDTH;
     this.y           = y;
     width            = image.Width;
     height           = image.Height;
     this.orientation = orientation;
 }
 public EndothelialCell(Vector3 cellPosition, EndothelialCell.PipeOrientation orientation, float size, EndothelialCell parent)
     : base(cellPosition)
 {
     children = new List<EndothelialCell>();
     this.orientation = orientation;
     this.size = size;
     Environment.Instance.GetSectorAt(cellPosition).PipeValue += size;
     CirculatorySystem.Instance.PipeCells.Add(this);
     Environment.Instance.GetContentsAt(cellPosition).pipes.Add(this);
     travelingCells = new List<TissueCell>();
     this.parent = parent;
 }
Esempio n. 4
0
        private void UpdateMeshAndDirection()
        {
            // Count number of connections along cardinal (which is all that we use atm)
            var cardinalInfo = adjacents.GetCardinalInfo();

            // Determine rotation and mesh specially for every single case.
            float rotation = 0.0f;
            Mesh  mesh;

            if (cardinalInfo.IsO())
            {
                mesh        = o;
                orientation = PipeOrientation.o;
            }
            else if (cardinalInfo.IsU())
            {
                if (cardinalInfo.north > 0 || cardinalInfo.east > 0)
                {
                    mesh        = uNorth;
                    orientation = PipeOrientation.uNorth;
                }
                else
                {
                    mesh        = uSouth;
                    orientation = PipeOrientation.uSouth;
                }
                rotation = DirectionHelper.AngleBetween(Direction.North, cardinalInfo.GetOnlyPositive());
            }
            else if (cardinalInfo.IsI())
            {
                mesh        = i;
                orientation = PipeOrientation.i;
                rotation    = OrientationHelper.AngleBetween(Orientation.Vertical, cardinalInfo.GetFirstOrientation());
            }
            else if (cardinalInfo.IsL())
            {
                Direction sides = cardinalInfo.GetCornerDirection();
                mesh = sides == Direction.NorthEast ? lNE
                    : sides == Direction.SouthEast ? lSE
                    : sides == Direction.SouthWest ? lSW
                    : lNW;

                orientation = sides == Direction.NorthEast ? PipeOrientation.lNE
                    : sides == Direction.SouthEast ? PipeOrientation.lSE
                    : sides == Direction.SouthWest ? PipeOrientation.lSW
                    : PipeOrientation.lNW;

                rotation = 90;
            }
            else if (cardinalInfo.IsT())
            {
                Direction notside = cardinalInfo.GetOnlyNegative();
                mesh = notside == Direction.North ? tSWE
                    : notside == Direction.East ? tNSW
                    : notside == Direction.South ? tNEW
                    : tNSE;

                orientation = notside == Direction.North ? PipeOrientation.tSWE
                    : notside == Direction.East ? PipeOrientation.tNSW
                    : notside == Direction.South ? PipeOrientation.tNEW
                    : PipeOrientation.tNSE;

                rotation = 90;
            }
            else // Must be X
            {
                mesh        = x;
                orientation = PipeOrientation.x;

                rotation = 90;
            }

            if (filter == null)
            {
                filter = GetComponent <MeshFilter>();
            }

            filter.mesh             = mesh;
            transform.localRotation = Quaternion.Euler(transform.localRotation.eulerAngles.x, rotation, transform.localRotation.eulerAngles.z);
        }
        public static EndothelialCell.PipeInfo getGrowthDirection(Vector3 start, Vector3 end)
        {
            EndothelialCell.PipeOrientation orientation;
            Vector3 unitVector;
            Vector3 direction = end - start;

            float absX = Math.Abs(direction.X);
            float absY = Math.Abs(direction.Y);
            float absZ = Math.Abs(direction.Z);

            if (absX > absY)
            {
                if (absX > absZ) // if X is biggest
                {
                    if (direction.X == absX)
                    {
                        unitVector = Vector3.Right;
                        orientation = PipeOrientation.posX;
                    }
                    else
                    {
                        unitVector = Vector3.Left;
                        orientation = PipeOrientation.negX;
                    }
                }

                else // if Z is biggest
                {
                    if (direction.Z == absZ)
                    {
                        unitVector = Vector3.Backward;
                        orientation = PipeOrientation.posZ;
                    }
                    else
                    {
                        unitVector = Vector3.Forward;
                        orientation = PipeOrientation.negZ;
                    }
                }
            }

            else
            {
                if (absY > absZ) // if Y is biggest
                {
                    if (direction.Y == absY)
                    {
                        unitVector = Vector3.Up;
                        orientation = PipeOrientation.posY;
                    }
                    else
                    {
                        unitVector = Vector3.Down;
                        orientation = PipeOrientation.negY;
                    }
                }
                else // if Z is biggest
                {
                    if (direction.Z == absZ)
                    {
                        unitVector = Vector3.Backward;
                        orientation = PipeOrientation.posZ;
                    }
                    else
                    {
                        unitVector = Vector3.Forward;
                        orientation = PipeOrientation.negZ;
                    }
                }
            }

            PipeInfo newPipeInfo = new PipeInfo(unitVector, orientation);
            return newPipeInfo;
        }
 public PipeInfo(Vector3 direction, PipeOrientation orientation)
 {
     this.direction = direction;
     this.orientation = orientation;
 }