Exemplo n.º 1
0
 public void accept(int id, BlockAdapter par)
 {
     blockID = id;
     GetComponent <Image> ().sprite = BlocksContainer.instanse.blocks [id].GetComponent <BlockObject> ().sprite;
     GetComponent <Button> ().onClick.AddListener(delegate {
         BuildManager.instance.currentId = id;
         //par.container.SetActive(false);
     });
 }
Exemplo n.º 2
0
 private RecyclerView initRecycler()
 {
     //Initialize the RecyclerView
     recycler                = view.FindViewById <RecyclerView>(Resource.Id.BlockRecycler);
     layoutMgr               = new GridLayoutManager(activity, 2);
     reportCategories        = new CategoriesOfReports();
     blockAdapter            = new BlockAdapter(activity, reportCategories);
     blockAdapter.ItemClick += OnItemClick;
     recycler.SetLayoutManager(layoutMgr);
     recycler.SetAdapter(blockAdapter);
     return(recycler);
 }
Exemplo n.º 3
0
        void PopulateBlock(string estateCode, string afdelingCode)
        {
            List <Block> blocks = SqliteDatabase.GetBlocks(estateCode, afdelingCode);

            if (blocks != null)
            {
                _blockItems = new BlockAdapter(this, blocks.ToArray());
                FindViewById <Spinner>(Resource.Id.spin_block).Adapter = _blockItems;
            }
            else
            {
                FindViewById <Spinner>(Resource.Id.spin_block).Adapter = null;
            }
        }
Exemplo n.º 4
0
    private void DrawLaser()
    {
        ResetLineRenderer();
        AddPositionToLineRenderer(firePosition);
        bool       isLineEnd     = false;
        GameObject lastHitObject = null;

        Vector2 currentPosition  = new Vector2(firePosition.x, firePosition.y);
        Vector2 currentDirection = new Vector2(fireDirection.x, fireDirection.y);

        RaycastHit2D objectHitData = Physics2D.Raycast(currentPosition, currentDirection, lineLength, 1 << StaticVar.LAYER_BLOCK);

        while (objectHitData && lineRenderer.positionCount <= maxReflectCount && !isLineEnd)
        {
            DetectEnemy(currentPosition, currentDirection, objectHitData.distance, 1);
            lastHitObject = objectHitData.collider.gameObject;

            BlockAdapter blockAdapter = lastHitObject.GetComponent <BlockAdapter>();
            if (blockAdapter)
            {
                //print("attack");
                blockAdapter.HitByAttack();
            }

            AddPositionToLineRenderer(new Vector3(objectHitData.point.x, objectHitData.point.y));

            if (objectHitData.collider.gameObject.tag == StaticVar.BLOCK_TAG_REFLECTIVE)
            {
                Vector2 reflectDirection = Vector2.Reflect(currentDirection, objectHitData.normal);
                //print(objectHit.collider.gameObject.ToString() + " " + reflectDirection.ToString());

                currentPosition  = new Vector2(objectHitData.point.x, objectHitData.point.y);
                currentDirection = reflectDirection;
            }
            else
            {
                isLineEnd = true;
                break;
            }

            objectHitData = Physics2D.Raycast(currentPosition + objectHitData.normal * 0.01f, currentDirection, lineLength, 1 << StaticVar.LAYER_BLOCK);
        }

        if (!isLineEnd)
        {
            DetectEnemy(currentPosition, currentDirection, lineLength, 1);
            AddPositionToLineRenderer(new Vector3(currentPosition.x + (currentDirection.x * lineLength),
                                                  currentPosition.y + (currentDirection.y * lineLength)));
        }
    }
Exemplo n.º 5
0
    public void DrawLaser(Vector2 firePosition, Vector2 fireDirection)
    {
        ResetLineRenderer();
        AddPositionToLineRenderer(firePosition);
        bool       isLineEnd     = false;
        GameObject lastHitObject = null;

        Vector2 currentPosition  = new Vector2(firePosition.x, firePosition.y);
        Vector2 currentDirection = new Vector2(fireDirection.x, fireDirection.y);

        RaycastHit2D objectHitData = Physics2D.Raycast(currentPosition, currentDirection, lineLength, 1 << StaticVar.LAYER_BLOCK);

        foreach (BlockAdapter gameObject in GameObject.FindObjectsOfType <BlockAdapter>())
        {
            gameObject.NotHitbyLaser();
        }

        while (objectHitData && lineRenderer.positionCount <= maxReflectCount && !isLineEnd)
        {
            lastHitObject = objectHitData.collider.gameObject;

            BlockAdapter blockAdapter = lastHitObject.GetComponent <BlockAdapter>();
            if (blockAdapter)
            {
                foreach (BlockAdapter ba in GameObject.FindObjectsOfType <BlockAdapter>())
                {
                    ba.NotHitbyLaser();
                }
                if (isMainLaser)
                {
                    blockAdapter.HitByLaser();
                }
            }

            AddPositionToLineRenderer(new Vector3(objectHitData.point.x, objectHitData.point.y));

            if (objectHitData.collider.gameObject.tag == StaticVar.BLOCK_TAG_REFLECTIVE && isMainLaser)
            {
                Vector2 reflectDirection = Vector2.Reflect(currentDirection, objectHitData.normal);
                //print(objectHit.collider.gameObject.ToString() + " " + reflectDirection.ToString());

                currentPosition  = new Vector2(objectHitData.point.x, objectHitData.point.y);
                currentDirection = reflectDirection;
            }
            else
            {
                isLineEnd = true;
                break;
            }

            //lastHitObject.GetComponent<Collider2D>().enabled = false;
            objectHitData = Physics2D.Raycast(currentPosition + objectHitData.normal * 0.01f, currentDirection, lineLength, 1 << StaticVar.LAYER_BLOCK);
            //lastHitObject.GetComponent<Collider2D>().enabled = true;
        }

        if (!isLineEnd)
        {
            AddPositionToLineRenderer(new Vector3(currentPosition.x + (currentDirection.x * lineLength),
                                                  currentPosition.y + (currentDirection.y * lineLength)));
        }
    }