예제 #1
0
파일: SnappingUnits.cs 프로젝트: LynnPi/OF
    private void DragObject()
    {
        if (!Grid_ || !GridCollider_)
        {
            return;
        }

#if !UNITY_EDITOR && !UNITY_STANDALONE && !UNITY_WEBPLAYER
        if (Input.touchCount > 1)
        {
            Debugger.Log("<color=red>more than one finger touched, do nothing! count: </color>" + Input.touchCount);
            return;
        }
#endif

        Vector3 cursorWorldPoint = ShootRay();

        CachedTransform_.position = cursorWorldPoint;
        Grid_.AlignTransform(CachedTransform_);
        CachedTransform_.position = DeployUnitPositionCorrector.CalculateOffsetY(Grid_, CachedTransform_);
        //DeployUnitPositionCorrector.CorrectOffsetXZ(Grid_, CachedTransform_, ShipWrapRadius);

        DeployUnitMenu.Instance.SetFollowTarget(transform);
        if (!FollowIconShow_) //仅在第一次显示跟随图标
        {
            FollowIcon.Follow();
        }
    }
예제 #2
0
 void Awake()
 {
     gridCollider = _grid.gameObject.GetComponent <Collider> ();
     //perform an initial align and snap the objects to the bottom
     _grid.AlignTransform(transform);
     transform.position = CalculateOffsetY();
     //store the first safe position
     oldPosition = transform.position;
     // setup the rigidbody for collision and contstruct a trigger
     SetupRigidbody();
     ConstructTrigger();
 }
예제 #3
0
    private void Awake()
    {
        grid = GridManager.Instance.Grid;

        grid.AlignTransform(transform);
        oldPosition = transform.position;
        Personality p = this.transform.GetComponent <Personality>();

        if (p != null)
        {
            p.Happy += () => {
                lastTile.MoodTile(happyTile);
            };
            p.Sad += () => {
                lastTile.MoodTile(sadTile);
            };
            p.Scared += () => {
                lastTile.MoodTile(scaredTile);
            };
            p.Angry += () => {
                lastTile.MoodTile(angryTile);
            };
        }
        SetupRigidbody();
    }
예제 #4
0
    //cache the transform for performance

    void Awake()
    {
        //make a check to prevent getting stuck in a null exception
        if (grid)
        {
            //snap to the grid  no matter where we are
            grid.AlignTransform(transform);
        }
    }
예제 #5
0
    private Transform cachedTransform; //cache the transform for performance

    void Awake()
    {
        cachedTransform = transform;

        //always make a sanity check
        if (grid)
        {
            gridCollider = grid.gameObject.GetComponent <Collider> ();
            if (gridCollider)
            {
                //perform an initial align and snap the objects to the bottom
                grid.AlignTransform(cachedTransform);
                cachedTransform.position = CalculateOffsetY();
            }
        }
        //store the first safe position
        oldPosition = cachedTransform.position;
        // setup the rigidbody for collision and contstruct a trigger
        SetupRigidbody();
        ConstructTrigger();
    }
예제 #6
0
    void Update()
    {
        if (!grid)
        {
            return;
        }

        if (autoSnapping && Selection.transforms.Length > 0)
        {
            foreach (Transform selectedTransform in Selection.transforms)
            {
                if (selectedTransform != gridTransform)
                {
                    if (selectedTransform)
                    {
                        if (!AlreadyAligned(selectedTransform))
                        {
                            grid.AlignTransform(selectedTransform, true, lockAxes, true);
                        }
                    }
                }
            }
        }
    }
예제 #7
0
 void AlignTransform(Transform t, bool rotate)
 {
     grid.AlignTransform(t, rotate, lockAxes);
     t.position += alignOffset;
 }
예제 #8
0
 public static void AlignTransformFixed(this GFGrid grid, Transform transform)
 {
     grid.AlignTransform(transform);
     transform.position = new Vector3(transform.position.x * 0.75f, transform.position.y * 1.15f, transform.position.z);
 }