Example #1
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);
        }
    }
Example #2
0
    public void GridUpdate()
    {
        GameObject CellAtPos = GridManagement.getObjectFromPosition(transform.position, true);

        if (CellAtPos && CellAtPos.GetComponent <Cell>().alive)
        {
            filled           = true;
            spriteComp.color = Color.blue;
            //print("filled");
        }
        else
        {
            filled           = false;
            spriteComp.color = Color.red;
        }
    }
Example #3
0
    void CheckForLife(Vector3 place)
    {
        GameObject thing = GridManagement.getObjectFromPosition(place);

        if (thing && thing.tag == "Pushable")
        {
            liveNeighbours++;
        }
        else if (!thing)
        {
            if (alive) //only generate new friends if you're alive
            {
                //check if there's a dead cell there, if not make one, so the grid can expand
                if (!GridManagement.getObjectFromPosition(place, false))
                {
                    Instantiate(GridManagement.instance.voidPrefab, place, Quaternion.identity);
                }
            }
        }
    }
Example #4
0
    // Update is called once per frame
    void Update()
    {
        if (player1)
        {
            if (Input.GetButtonDown("Reset") && canActuallyReset)//some levels used to use reset to progress
            {
                AudioManager.instance.RunItBack();
                GridManagement.ResetScene();
            }
            else if (Input.GetKeyDown(KeyCode.N))
            {
                skipped = true;
                StartCoroutine(StartEndSequence());
            }
            foreach (Camera camComp in camComps)
            {
                if (Input.GetAxis("Scroll") < 0)
                {
                    camComp.orthographicSize = Mathf.Clamp(camComp.orthographicSize + zoomSpeed, minZoom, maxZoom);
                }
                else if (Input.GetAxis("Scroll") > 0)
                {
                    camComp.orthographicSize = Mathf.Clamp(camComp.orthographicSize - zoomSpeed, minZoom, maxZoom);
                }
            }
        }
        if (player1 && !moving && Input.GetButtonDown("Fire"))
        {
            iterations++;
            iterationText.text = "steps: " + iterations;
            Iterate();
        }
        else if (!GridManagement.playerDead) //if the player is dead you can still scroll and iterate but you can't win or move
        {
            if (Input.GetAxis(hInput) < -inputThresh)
            {
                dir = -transform.right;
            }
            else if (Input.GetAxis(hInput) > inputThresh)
            {
                dir = transform.right;
            }
            else if (Input.GetAxis(vInput) > inputThresh)
            {
                dir = transform.up;
            }
            else if (Input.GetAxis(vInput) < -inputThresh)
            {
                dir = -transform.up;
            }
            else
            {
                return;
            }
            if (!moving)
            {
                GameObject thingInTheWay = GridManagement.getObjectFromPosition(transform.position + dir);
                if (thingInTheWay)
                {
                    if (canPush)
                    {
                        if (thingInTheWay.tag == "Pushable")
                        {
                            Move(thingInTheWay);
                            //update the grid to account for the push
                            Invoke("UpdateCellCounts", GridMovementGeneral.instance.timeForLerps + .1f);
                        }
                    }
                }

                moving = true;
                Move(gameObject);
                Invoke("ResetMovin", GridMovementGeneral.instance.timeForLerps + .1f);
            }
        }
    }