/// <summary>
 /// instantly updates the position and rotation of a gameobject
 /// </summary>
 /// <param name="thingToMove"></param>
 /// <param name="positionToMoveTo"></param>
 /// <param name="RotationToRotateTo"></param>
 static void InstantMovement(GameObject thingToMove, Vector3 positionToMoveTo, Quaternion RotationToRotateTo)
 {
     //this one is pretty easy
     thingToMove.transform.position = positionToMoveTo;
     thingToMove.transform.rotation = RotationToRotateTo;
     GridManagement.SetObjectToPosition(thingToMove, positionToMoveTo, false);
 }
Esempio n. 2
0
    // Use this for initialization
    void Start()
    {
        if (solid)
        {
            GameObject alreadyThere;
            //put the object in the grid at startup
            alreadyThere = GridManagement.getObjectFromPosition(transform.position);
            //if (alreadyThere!=null && alreadyThere.GetComponent<WormMovement>() != null)
            //{
            //    //if the other object has the capability to retreat, make it do that
            //    //alreadyThere.GetComponent<WormMovement>().Retract();
            //    GridManagement.SetObjectToPosition(gameObject, transform.position, true, false);
            //}
            //else
            //{

            GridManagement.SetObjectToPosition(gameObject, transform.position, true, overWriteOnStart);
            //}

            if (AlignOnStart)
            {
                transform.rotation = Quaternion.identity;
            }
        }
        else
        {
            //nonsolids dont care they just always overwrite, since they never do normal movements
            GridManagement.SetObjectToPosition(gameObject, transform.position, true, true, false);
        }
    }
Esempio n. 3
0
    void BecomeAlive()
    {
        if (name.Contains("Player"))
        {
            GridManagement.playerDead = false;
        }
        else
        {
            GridManagement.ClearPosition(transform.position, false, false); //get rid of what was there

            if (GridManagement.SetObjectToPosition(gameObject, transform.position, true, true, true))
            {
                //if this returns an object, its the player in a mode where the player should not be killed, so lose the block instead
                //stay dead i guess it would be
                return;
            }
            //track the fact that you are now solid and alive
            gridComp.solid = true;
            alive          = true;
            tag            = "Pushable";
            name           = "Live Cell";
            //visually become alive

            spriteComp.sortingOrder = 1;
            spriteComp.color        = Color.green;
        }
    }
 /// <summary>
 /// linearly updates position and rotation of a gameobject
 /// </summary>
 /// <param name="thingToMove"></param>
 /// <param name="positionToMoveTo"></param>
 /// <param name="RotationToRotateTo"></param>
 static void SmoothMovement(GameObject thingToMove, Vector3 positionToMoveTo, Quaternion RotationToRotateTo)
 {
     if (!GridManagement.SetObjectToPosition(thingToMove, positionToMoveTo, false)) //if theres something there dont move
     {
         instance.StartCoroutine(PositionLerp(thingToMove, positionToMoveTo));
         instance.StartCoroutine(RotationLerp(thingToMove, RotationToRotateTo));
     }
 }
Esempio n. 5
0
    void BecomeDead()
    {
        if (name.Contains("Player"))
        {
            GridManagement.playerDead = true;
        }
        else
        {
            GridManagement.ClearPosition(transform.position, true, false);                         //get rid of what was there

            GridManagement.SetObjectToPosition(gameObject, transform.position, true, true, false); //spawn a dead there
                                                                                                   //track that you are now dead
            gridComp.solid = false;
            alive          = false;
            tag            = "Untagged";

            name = "Dead Cell";
            //viz
            spriteComp.sortingOrder = 0;
            spriteComp.color        = Color.clear;
        }
    }
 static void InstantRotateSmoothMove(GameObject thingToMove, Vector3 positionToMoveTo, Quaternion rotationToRotateTo)
 {
     instance.StartCoroutine(PositionLerp(thingToMove, positionToMoveTo));
     thingToMove.transform.rotation = rotationToRotateTo;
     GridManagement.SetObjectToPosition(thingToMove, positionToMoveTo, false);
 }
 /// <summary>
 /// same as smooth movement but with overwriting turned on, used for worm retracting
 /// </summary>
 /// <param name="thingToMove"></param>
 /// <param name="positionToMoveTo"></param>
 /// <param name="RotationToRotateTo"></param>
 static void SmoothTunnel(GameObject thingToMove, Vector3 positionToMoveTo, Quaternion RotationToRotateTo)
 {
     instance.StartCoroutine(PositionLerp(thingToMove, positionToMoveTo));
     instance.StartCoroutine(RotationLerp(thingToMove, RotationToRotateTo));
     GridManagement.SetObjectToPosition(thingToMove, positionToMoveTo, false, true);
 }