Exemple #1
0
        public void Release(GameObject go)
        {
            UN.SetActive(go, false);
            bool foundIt = _active.Remove(go);

            Dbg.Assert(foundIt);
            _inactive.Enqueue(go);
        }
Exemple #2
0
        // -----------------------------------------------------------------------------------------------------------
        /// <summary>
        ///  this moves our arc pieces to link the given positions together
        /// </summary>
        /// <param name="positions"></param>
        void BuildTrajectoryLine(List <Vector3> positions)
        // -----------------------------------------------------------------------------------------------------------
        {
            Vector3 startPos;
            Vector3 endPos;
            Vector3 delta;

            Vector3 arcPieceScale = _arcPieceOriginalLocalScale;

            GameObject currentArcPiece = null;


            // make sure we have enough arc pieces
            for (int i = _arcPieceList.Count; i < positions.Count; i++)
            {
                _arcPieceList.Add(MakeArcPiece());
            }


            Debug.Assert(_arcPieceList.Count >= positions.Count);

            // start at 1, as we're always going to go from previous size to this one
            // also note that we use this after the below loop to set inactive pieces
            int currentPieceNdx = 1;

            for (; currentPieceNdx < positions.Count; ++currentPieceNdx)
            {
                currentArcPiece = _arcPieceList[currentPieceNdx - 1];
                UN.SetActive(currentArcPiece, true);

                // set positions
                startPos = positions[currentPieceNdx - 1];
                endPos   = positions[currentPieceNdx];
                currentArcPiece.transform.position = startPos;

                // set scale

                delta           = endPos - startPos;                   // gap between points
                arcPieceScale.z = delta.magnitude / _arcDefaultLength; // stretch or shrink along z
                currentArcPiece.transform.localScale = arcPieceScale;  // set scale


                // set rotations
                currentArcPiece.transform.rotation = Quaternion.LookRotation(delta.normalized);
            }

            // make sure pieces we don't use are disabled
            for (; currentPieceNdx < _arcPieceList.Count; currentPieceNdx++)
            {
                UN.SetActive(_arcPieceList[currentPieceNdx], false);
            }
        }
 void AddToInactiveList(GameObject go)
 {
     UN.SetActive(go, false);
     _inactiveElements.Add(go);
 }
Exemple #4
0
 // ---------------------------------------------------------------------------------------------------
 void Awake()
 // ---------------------------------------------------------------------------------------------------
 {
     _arcPieceOriginalLocalScale = _arcPiece.transform.localScale;
     UN.SetActive(_arcPiece, false);
 }
Exemple #5
0
 private void Start()
 {
     UN.SetActive(_template, false);
 }
Exemple #6
0
 public override bool Update()
 {
     base.Update();
     UN.SetActive(_object, _on);
     return(false);
 }
Exemple #7
0
        // -----------------------------------------------------------------------------------------------------------
        /// <summary>
        ///  this moves our arc pieces to link the given positions together
        /// </summary>
        /// <param name="positions"></param>
        public void SetLine(List <Vector3> positions)
        // -----------------------------------------------------------------------------------------------------------
        {
            // first quick and dirty - if we don't have any positions, hide everything
            if (positions.Count < 2)
            {
                for (int i = 0; i < _arcPieceList.Count; i++)
                {
                    UN.SetActive(_arcPieceList[i], false);
                }
                return;
            }

            int numSegRequired = positions.Count - 1;

            // make sure we have enough arc pieces
            for (int i = _arcPieceList.Count; i < numSegRequired; i++)
            {
                _arcPieceList.Add(MakeArcPiece());
            }


            Debug.Assert(_arcPieceList.Count >= positions.Count - 1);



            // start at 1, as we're always going to go from previous size to this one
            // also note that we use this after the below loop to set inactive pieces
            int        curSegment = 0;
            Vector3    startPos;
            Vector3    endPos;
            Vector3    delta;
            GameObject currentArcPiece = null;
            Vector3    arcPieceScale   = _arcPieceOriginalLocalScale; // we are going to scale z to stretch the line

            for (; curSegment < positions.Count - 1; ++curSegment)
            {
                currentArcPiece = _arcPieceList[curSegment];
                UN.SetActive(currentArcPiece, true);

                // set positions
                startPos = positions[curSegment];
                endPos   = positions[curSegment + 1];
                currentArcPiece.transform.position = startPos;

                // set scale

                delta           = endPos - startPos;                     // gap between points
                arcPieceScale.z = delta.magnitude / _pieceDefaultLength; // stretch or shrink along z
                currentArcPiece.transform.localScale = arcPieceScale;    // set scale


                // set rotations
                currentArcPiece.transform.rotation = Quaternion.LookRotation(delta.normalized);
            }

            // make sure pieces we don't use are disabled
            for (; curSegment < _arcPieceList.Count; curSegment++)
            {
                UN.SetActive(_arcPieceList[curSegment], false);
            }

            if (_end != null)
            {
                if (positions.Count > 0)
                {
                    _end.transform.position = positions[positions.Count - 1];
                }
                else
                {
                    UN.SetActive(_end, false);
                }
            }
        }