예제 #1
0
        /**
         * @brief Instantiates a new prefab in a deterministic way.
         *
         * @param prefab GameObject's prefab to instantiate.
         * @param position Position to place the new GameObject.
         * @param rotation Rotation to set in the new GameObject.
         **/
        public static GameObject SyncedInstantiate(GameObject prefab, FPVector position, FPQuaternion rotation)
        {
            if (instance != null && instance.lockstep != null)
            {
                GameObject go = GameObject.Instantiate(prefab, position.ToVector(), rotation.ToQuaternion()) as GameObject;

                if (ReplayRecord.replayMode != ReplayMode.LOAD_REPLAY)
                {
                    AddGameObjectOnSafeMap(go);
                }

                MonoBehaviour[] monoBehaviours = go.GetComponentsInChildren <MonoBehaviour>();
                for (int index = 0, length = monoBehaviours.Length; index < length; index++)
                {
                    MonoBehaviour bh = monoBehaviours[index];

                    if (bh is IFrameSyncBehaviour)
                    {
                        instance.queuedBehaviours.Add(instance.NewManagedBehavior((IFrameSyncBehaviour)bh));
                    }
                }

                InitializeGameObject(go, position, rotation);

                return(go);
            }

            return(null);
        }
예제 #2
0
파일: AstarPath.cs 프로젝트: kyondi/ZMOBA
        public void SetWalkable()
        {
            for (int i = 0; i < this.gridX; i++)
            {
                for (int j = 0; j < this.gridY; j++)
                {
                    FPVector   point     = this.m_data.gridGraph.GetCenterPoint(i, j);
                    Vector2Int nodeIndex = new Vector2Int(i, j);

                    if (IsWalkable(point.ToVector()))
                    {
                        this.m_data.gridGraph.UnblockCell(nodeIndex);
                        //Debug.Log("point:" + point + ",nodeIndex:" + nodeIndex);
                    }
                    else
                    {
                        this.m_data.gridGraph.BlockCell(nodeIndex);
                    }
                }
            }
        }
        //private void UpdatePlayMode()
        //{
        //    if (rb != null)
        //    {
        //        if (rb.interpolation == FPRigidBody.InterpolateMode.Interpolate)
        //        {
        //            transform.position = Vector3.Lerp(transform.position, position.ToVector(), Time.deltaTime * DELTA_TIME_FACTOR);
        //            transform.rotation = Quaternion.Lerp(transform.rotation, rotation.ToQuaternion(), Time.deltaTime * DELTA_TIME_FACTOR);
        //            transform.localScale = Vector3.Lerp(transform.localScale, scale.ToVector(), Time.deltaTime * DELTA_TIME_FACTOR);
        //            return;
        //        }
        //        else if (rb.interpolation == FPRigidBody.InterpolateMode.Extrapolate)
        //        {
        //            transform.position = (position + rb.tsCollider.Body.TSLinearVelocity * Time.deltaTime * DELTA_TIME_FACTOR).ToVector();
        //            transform.rotation = Quaternion.Lerp(transform.rotation, rotation.ToQuaternion(), Time.deltaTime * DELTA_TIME_FACTOR);
        //            transform.localScale = Vector3.Lerp(transform.localScale, scale.ToVector(), Time.deltaTime * DELTA_TIME_FACTOR);
        //            return;
        //        }
        //    }

        //    transform.position = position.ToVector();
        //    transform.rotation = rotation.ToQuaternion();
        //    transform.localScale = scale.ToVector();
        //}

        public void SetPosition(FPVector fpPosition)
        {
            this.position      = fpPosition;
            transform.position = fpPosition.ToVector();
        }