Beispiel #1
0
    //タップ結果コールバック
    public void TapCbs(List <Vector2Int> rt)
    {
        AddUnit("AAA", new Vector2Int(rt[0].x, rt[0].y), players[0], Unit.Surveillance);

        testUnit.addMoveList(rt.Select(pos => new Vector2(map.GetComponent <Grid>().CellToLocal(new Vector3Int(MapCtl.offset_stg2tile_x(pos.x), MapCtl.offset_stg2tile_y(pos.y), 0)).x,
                                                          map.GetComponent <Grid>().CellToLocal(new Vector3Int(MapCtl.offset_stg2tile_x(pos.x), MapCtl.offset_stg2tile_y(pos.y), 0)).y)).ToList());

        // 線の幅
        renderer.SetWidth(0.1f, 0.1f);
        // 頂点の数
        renderer.SetVertexCount(rt.Count);
        // 頂点を設定
        for (int i = 0; i < rt.Count; i++)
        {
            renderer.SetPosition(i, map.GetComponent <Grid>().CellToLocal(new Vector3Int(MapCtl.offset_stg2tile_x(rt[i].x), MapCtl.offset_stg2tile_y(rt[i].y), 0)) + new Vector3(0f, 0f, -1f));
        }
    }
Beispiel #2
0
    // Update is called once per frame
    void Update()
    {
        if (Input.GetMouseButtonUp(0))
        {
            Tap(Input.mousePosition);
        }

        if (Input.GetMouseButtonDown(1))
        {
            ChangeTile(Input.mousePosition);
        }

        /* 座標表示 */
        TextObj.transform.position = Input.mousePosition;
        Vector3    screenToWorldPointPosition = Camera.main.ScreenToWorldPoint(Input.mousePosition);
        Vector3Int cellPosition = GridMap.GetComponent <Grid>().LocalToCell(screenToWorldPointPosition);

        TextObj.GetComponent <Text>().text = "[" + MapCtl.offset_tile2stg_x(cellPosition.x) + "," + MapCtl.offset_tile2stg_y(cellPosition.y) + "]";
    }
Beispiel #3
0
    //Vector2座標→ステージ座標変換
    public static Vector2Int offset_vec2stg(Vector2 pos)
    {
        Vector3Int cellPosition = instance.GetComponent <Grid>().LocalToCell(pos);

        return(offset_tile2stg(new Vector2Int(cellPosition.x, cellPosition.y)));
    }
Beispiel #4
0
    //ユニット作成(リスト追加は外部で実施すること)
    public static UnitObj Create(String _name, Unit _type, Vector2Int _pos, PlayerCtl _player)
    {
        UnitObj newObj = Instantiate(_player.utltList.FirstOrDefault(u => u.units == _type));
        //対象のシェーダー情報を取得
        Shader sh = _player.utltList.FirstOrDefault(u => u.units == _type).transform.GetComponent <SpriteRenderer>().material.shader;    //Find("Texture").
        //取得したシェーダーを元に新しいマテリアルを作成
        Material mat = new Material(sh);

        newObj.transform.GetComponent <SpriteRenderer>().material = mat; //Find("Texture").

        newObj.name    = _name;
        newObj.pos     = _pos;
        newObj.old_pos = _pos;
        newObj.hp      = newObj.hpMax;
        newObj.fuel    = newObj.fuelMax;
        newObj.gameObject.SetActive(true); //表示
        newObj.lock_max = UnityEngine.Random.Range(10, 100);
        newObj.player   = _player;
        newObj.gameObject.SetActive(true);
        newObj.GetComponent <SpriteRenderer>().color = _player.pColor;
        newObj.chgWorkType(WorkType.Newing);
        newObj.gameObject.name = "Obj_" + _player.pnum + "_" + _type.ToString();
        _player.vMap.moveAdd(_pos, 3);
        if (newObj.type != uType.Building)
        {
            StageCtl.UnitList[newObj.player.pnum].Insert(0, newObj);      //先頭
        }
        else
        {
            StageCtl.UnitList[newObj.player.pnum].Add(newObj);      //末尾
        }
        newObj.transform.position = map.GetComponent <Grid>().GetCellCenterWorld(new Vector3Int(MapCtl.offset_stg2tile_x(_pos.x), MapCtl.offset_stg2tile_y(_pos.y), 0)) - new Vector3(0f, 0f, 1f);
        return(newObj);
    }