示例#1
0
    void CreateIceBlockAt(Vector3 v)
    {
        Transform          newBie   = Instantiate(IceBlockPreFab, SnapTo(v), Quaternion.identity);
        IceBlockController HiNewbie = newBie.gameObject.GetComponent <IceBlockController>();

        HiNewbie.ThisIsMe(this);
    }
    internal Vector3 getDestinationForIceblockMoving(IceBlockController iceBlockController, Vector3 pusherPosition)
    {
        Vector3 positionOfIceBlock = iceBlockController.transform.position;
        Vector3 direction          = positionOfIceBlock - SnapTo(pusherPosition);

        return(direction);
    }
示例#3
0
    private IEnumerator CheckSliding(IceBlockController iceBlockController)
    {
        yield return(new WaitForSeconds(0.1f));

        if (!iceBlockController.sliding)
        {
            isActive = true;
            EditorHandler.CheckSokobanBlocks();
        }
    }
示例#4
0
    internal Vector3 getDestinationForIceblock(IceBlockController iceBlockController, Vector3 pusherPosition)
    {
        Vector3 positionOfIceBlock = iceBlockController.transform.position;
        Vector3 direction          = positionOfIceBlock - SnapTo(pusherPosition);

        if (!((direction.magnitude < 0.1f) || (direction.magnitude > 1.1f)))
        {
            return(SnapTo(positionOfIceBlock + 5.0f * direction));
        }

        return(positionOfIceBlock);
    }
示例#5
0
 void Start()
 {
     if (gameObject.transform.parent.CompareTag("SokobanBlock"))
     {
         unpassableBlocksTags = unpassableSokobanBlocksTags;
     }
     block = transform.parent.gameObject;
     iceBlockController = block.GetComponent <IceBlockController>();
     antiBlock          = transform.parent.GetChild(2).GetComponent <BlockLeftController>();
     player             = GameObject.FindGameObjectWithTag("Player");
     playerController   = player.GetComponent <PlayerController>();
     playerMovement     = player.transform.GetChild(3).GetComponent <LeftController>();
     collider           = gameObject.GetComponent <BoxCollider2D>();
 }
    void CreateIceBlockAt(Vector3 v, Boolean MakeItRed)
    {
        Transform newBie = Instantiate(IceBlockPreFab, SnapTo(v, v.y), Quaternion.identity);

        newBie.parent = transform;
        if (MakeItRed)
        {
            newBie.GetComponent <Renderer>().material.color = Color.red;
        }


        IceBlockController HiNewbie = newBie.gameObject.GetComponent <IceBlockController>();


        HiNewbie.ThisIsMe(this);
    }
    private void push()
    {
        Ray        r    = new Ray(transform.position, transform.forward);
        RaycastHit info = new RaycastHit();

        Debug.DrawRay(transform.position, this.transform.forward, Color.blue);
        if (Physics.Raycast(r, out info, 4f))
        {
            IceBlockController iceBlock = info.collider.GetComponent <IceBlockController>();

            if (iceBlock)
            {
                iceBlock.push(this.transform.position);
            }
            Debug.Log("RayCast works");
        }
    }
    internal Boolean canMove(IceBlockController iceBlockController, Vector3 pusherPosition)
    {
        //Step 1: get direction
        //Vector3 positionOfIceBlock = iceBlockController.transform.position;
        //Vector3 direction = positionOfIceBlock - SnapTo(pusherPosition);

        //Step 2: make raycast to check if there is something in the way
        Ray        r    = new Ray(iceBlockController.transform.position, iceBlockController.transform.forward);
        RaycastHit info = new RaycastHit();

        Debug.DrawRay(iceBlockController.transform.position, iceBlockController.transform.forward, Color.blue);
        if (Physics.Raycast(r, out info, 0.5f))
        {
            //Step3: There is somethink in the way
            return(false);
        }
        else
        {
            //Step3: There is nothing in the way, start moving
            return(true);
        }
    }
    /// <summary>
    ///
    /// </summary>
    /// <param name="iceBlockController"></param>
    /// <param name="pusherPosition"></param>
    /// <returns></returns>
    internal Vector3 getDestinationForIceblock(IceBlockController iceBlockController, Vector3 pusherPosition)
    {
        /*
         * Vector3 positionOfIceBlock = iceBlockController.transform.position;
         *
         * Vector3 direction = positionOfIceBlock - SnapTo(pusherPosition);
         *
         * if (!((direction.magnitude < 0.9f) || (direction.magnitude > 1.1f)))
         *
         *  return SnapTo(positionOfIceBlock + 5.0f * direction);
         *
         *
         * return positionOfIceBlock;
         */

        //Step 1: Check if something is in the way

        //Step 2: If, return 0 for destroing

        //Step 3: If not, make a raycast to get the destination for the next object that can block the iceblock

        //Step 4: Return the maximum distance and wait for the collision
        throw new Exception("maybe don't use this");
    }