public void ConnectToCell(LevelData.CellBall cell)
 {
     pCellBall          = cell;
     transform.position = pCellBall.position;
     setColor();
     gameObject.SetActive(true);
 }
示例#2
0
    // Update is called once per frame
    void Update()
    {
        if (SelectedMECell != null)
        {
            Vector2 v = Camera.main.ScreenToWorldPoint(Input.mousePosition);
            SelectedMECell.transform.position = v;

            if (Input.GetMouseButtonUp(1))
            {
                MapGenerator.mapGenerator.SelectedMECell = null;
            }
        }

        if (Input.GetKey(KeyCode.LeftShift))
        {
            if (Input.GetMouseButtonDown(0))
            {
                if (GetComponent <Collider2D>().OverlapPoint(Camera.main.ScreenToWorldPoint(Input.mousePosition)))
                {
                    Vector2 pos = Camera.main.ScreenToWorldPoint(Input.mousePosition);
                    verts.Add(pos);
                }
            }
            if (Input.GetMouseButtonDown(1))
            {
                if (GetComponent <Collider2D>().OverlapPoint(Camera.main.ScreenToWorldPoint(Input.mousePosition)))
                {
                    GameObject go = new GameObject();
                    MeshObject mo = go.AddComponent <MeshObject>();
                    mo.SetVerts(verts);
                    verts = new List <Vector3>();
                }
            }
        }


        if (Input.GetKey(KeyCode.LeftControl))
        {
            if (Input.GetMouseButtonDown(0))
            {
                if (GetComponent <Collider2D>().OverlapPoint(Camera.main.ScreenToWorldPoint(Input.mousePosition)))
                {
                    Vector2            pos  = Camera.main.ScreenToWorldPoint(Input.mousePosition);
                    GameObject         go   = Instantiate(MECell, pos, Quaternion.identity) as GameObject;
                    LevelData.CellBall ball = new LevelData.CellBall();

                    ball.position = go.transform.position;

                    go.GetComponent <MECell>().ConnectToCell(ball);
                    go.GetComponent <MECell>().ToBrush();

                    mCurrentLevelData.CellBallList.Add(ball);
                }
            }
        }
    }
示例#3
0
    public BallScriptPointer newBall(LevelData.CellBall _Cell)
    {
        BallScriptPointer pball = GetFreeBall();

        pball.setPosition(_Cell.position);

        pball.getBall().isbasic = _Cell.basic;
        pball.getBall().armor   = _Cell.armor;
        pball.getBall().GetComponent <Rigidbody2D> ().isKinematic = _Cell.frozen;
        pball.setColor(_Cell.type);

        pball.getGameObject().SetActive(true);

        return(pball);

        //pball.getBall ().isbasic = isbasic ? true : false;
    }
    private bool ReadBlock(BinaryReader _BinaryReader)
    {
        DATABLOCK block = (DATABLOCK)_BinaryReader.ReadByte();

        switch (block)
        {
        case DATABLOCK.VERSION:
                        #if DEBUGSAVE
            Debug.Log("ReadBlock: VERSION");
                        #endif
            version = _BinaryReader.ReadInt32();
                        #if DEBUGSAVE
            Debug.Log("Version " + version);
                        #endif
            if (version < 4)
            {
                Debug.LogError("OLDVERSION");
                return(false);
            }
            return(true);

        case DATABLOCK.CHAPTER:
                        #if DEBUGSAVE
            Debug.Log("ReadBlock: CHAPTER");
                        #endif

            ID          = _BinaryReader.ReadInt32();
            GameType    = (GAMETYPE)_BinaryReader.ReadByte();
            Name        = _BinaryReader.ReadString();
            Description = _BinaryReader.ReadString();

            return(true);

        case DATABLOCK.LEVEL:
                        #if DEBUGSAVE
            Debug.Log("ReadBlock: LEVEL");
                        #endif
            currentLevelData = new LevelData();
            LevelList.Add(currentLevelData);
            while (ReadBlock(_BinaryReader))
            {
                continue;
            }

            return(true);

        case DATABLOCK.CELL_BALL:
                        #if DEBUGSAVE
            Debug.Log("ReadBlock: CELL_BALL");
                        #endif
            if (currentLevelData == null)
            {
                Debug.LogError("ReadBlock: CELL_BALL NO LEVEL");
                return(false);
            }

            LevelData.CellBall ball = new LevelData.CellBall();

            ball.position.Set(
                _BinaryReader.ReadSingle(),
                _BinaryReader.ReadSingle(),
                0.0f);

            ball.type   = (BALLTYPE)_BinaryReader.ReadByte();
            ball.basic  = _BinaryReader.ReadBoolean();
            ball.frozen = _BinaryReader.ReadBoolean();
            ball.armor  = _BinaryReader.ReadInt32();

            currentLevelData.CellBallList.Add(ball);

            return(true);

        case DATABLOCK.BALLCOLORLINE:
                        #if DEBUGSAVE
            Debug.Log("ReadBlock: BALLCOLORLINE");
                        #endif

            BALLTYPE bt = (BALLTYPE)_BinaryReader.ReadByte();
            while (bt != BALLTYPE.LASTONE)
            {
                currentLevelData.BallsColorLine.Add(bt);
                bt = (BALLTYPE)_BinaryReader.ReadByte();
            }
            return(true);

        case DATABLOCK.LEVELEND:
                        #if DEBUGSAVE
            Debug.Log("ReadBlock: LEVELEND");
                        #endif
            return(false);

        case DATABLOCK.END:
                        #if DEBUGSAVE
            Debug.Log("ReadBlock: END");
                        #endif
            return(false);

        default:
                        #if DEBUGSAVE
            Debug.LogError("ReadBlock: NO DATA");
                        #endif
            return(false);
        }
    }
 public void Clear()
 {
     ClearChild();
     pCellBall = null;
     gameObject.SetActive(false);
 }