Example #1
0
        public Transform GetHangPoint(string name, TSVector curPosition, TSVector curForward, out TSVector position, out TSVector forward)
        {
            position = curPosition;
            forward  = curForward;
            Transform transform    = null;
            bool      hasHangPoint = false;

            if (m_cHangPointItem != null)
            {
                var hangPointData = m_cHangPointItem.GetHangPointData(name);
                if (hangPointData != null)
                {
                    hasHangPoint = true;
                    FP nAngle = TSVector.Angle(TSVector.forward, curForward);
                    if (curForward.x < 0)
                    {
                        nAngle = 360 - nAngle;
                    }
                    TSQuaternion sQuat = TSQuaternion.AngleAxis(nAngle, TSVector.up);
                    position = curPosition + sQuat * hangPointData.position;
                    forward  = sQuat * hangPointData.forward;
                    forward.Normalize();
                }
            }
            if (m_cHangPointView != null)
            {
                transform    = m_cHangPointView.GetHangPoint(name);
                hasHangPoint = true;
            }
            if (!hasHangPoint)
            {
                CLog.LogError("对象" + this.name + "找不到挂点名为:" + name + "的挂点信息");
            }
            return(transform);
        }
    /// <summary>
    /// Generates a random position using min and max distribution radius
    /// </summary>
    /// <returns>new random position (TSVector)</returns>
    /// FIXME:  This method will occasionally generate positions which existing powerups may be already occupying
    private TSVector getRandomPosition()
    {
        // Place the powerup in a random location
        int direction = TSRandom.Range(0, 359);

        // Generate general position TSVector
        TSVector position = TSQuaternion.AngleAxis(direction, TSVector.up).Rotate(TSVector.forward);

        // Apply distance between min and max distribution radius
        return(position.normalized * TSRandom.Range(minDistributionRadius, maxDistributionRadius));
    }
Example #3
0
        public tableEdge(TSVector2 _start, TSVector2 _end, int _ID = -1)
        {
            ID      = _ID;
            start   = _start;
            end     = _end;
            edgeDir = end - start;
            midPos  = start + edgeDir.normalized * edgeDir.magnitude / 2;
            var normal3D = (TSQuaternion.AngleAxis(90, TSVector.up) * new TSVector(edgeDir.x, 0, edgeDir.y).normalized);

            normal = new TSVector2(normal3D.x, normal3D.z);
            var dir = end - start;

            farstart = start - dir * 100;
            farend   = end + dir * 100;
        }
Example #4
0
        private void UpdateCollider2(Check2DCollider collider, TSVector curPosition, TSVector curForward, BaseGameColliderData colliderData)
        {
            FP nAngle = TSVector.Angle(TSVector.forward, curForward);

            if (curForward.x < 0)
            {
                nAngle = 360 - nAngle;
            }
            TSQuaternion sQuat   = TSQuaternion.AngleAxis(nAngle, TSVector.up);
            TSVector     center  = curPosition + sQuat * colliderData.center;
            TSVector     forward = sQuat * colliderData.forward;

            collider.center  = new TSVector2(center.x, center.z);
            collider.forward = new TSVector2(forward.x, forward.z);
        }
Example #5
0
    /// <summary>
    /// RepositionLines - repositions the player lines evenly with a calculated angle determined by the number of players
    /// </summary>
    private void RepositionLines()
    {
        FP lineAngle = FP.Zero;

        if (_playerList.Count < 3)
        {
            lineAngle = new FP(170);
        }
        else
        {
            lineAngle = new FP(360 / _playerList.Count);
        }

        for (int index = 0; index < Line.LineList.Count; index++)
        {
            TSRigidBody rb = Line.LineList[index];
            rb.MovePosition(new TSVector(0, 1, 0));
            //rb.angularVelocity = TSVector.up;
            rb.tsTransform.rotation = TSQuaternion.AngleAxis(index * lineAngle, TSVector.up);
            rb.gameObject.name      = "Line " + index;
        }
    }
Example #6
0
 public override void OnSyncedStart()
 {
     for (int i = 0; i < xSize; i++)
     {
         for (int j = 0; j < ySize; j++)
         {
             for (int k = 0; k < zSize; k++)
             {
                 GameObject tObj = TrueSyncManager.SyncedInstantiate((i + j + k) % 2 == 0? sphere : capsule, new TSVector(
                                                                         (i - 1) * (boxWidth + xGap),
                                                                         (j - 1) * (boxWidth + yGap),
                                                                         (k - 1) * (boxWidth + zGap)), TSQuaternion.AngleAxis(0, TSVector.forward));
                 TSMaterial tMaterial = tObj.AddComponent <TSMaterial>();
                 tMaterial.restitution = 0;
                 tMaterial.friction    = 1;
                 objStack.Add(tObj);
                 tObj.SetActive(false);
             }
         }
     }
 }