Пример #1
0
 public BlockInfo(GameObject _gameObject, BlockMover _blockMover, Vector3 _moveDirection)
 {
     gameObject    = _gameObject;
     mover         = _blockMover;
     moveDirection = _moveDirection;
     block         = _gameObject.GetComponent <Block>();
 }
Пример #2
0
    private void AddPushable(float x, float z)
    {
        BlockMover bc = AddBlock(PushablePrefab, PushableGroup, new Vector3(x, othersStartHeight, z), new Vector3(x, pushableOffsetY, z), startMoveDamping, Materials[4]);

        SetCoordState(x, z, CoordState.kPushable);

        visibles.Add(bc.transform);
    }
Пример #3
0
    private void AddGoal(float x, float z)
    {
        BlockMover bc = AddBlock(GoalPrefab, GoalGroup, new Vector3(x, othersStartHeight, z), new Vector3(x, goalOffsetY, z), startMoveDamping, Materials[2]);

        ++numGoals;

        visibles.Add(bc.transform);
    }
Пример #4
0
    private void AddPlayer(float x, float z)
    {
        BlockMover bc = AddBlock(PlayerPrefab, PlayerGroup, new Vector3(x, othersStartHeight, z), new Vector3(x, playerOffsetY, z), startMoveDamping, Materials[3]);

        SetCoordState(x, z, CoordState.kPlayer);

        visibles.Add(bc.transform);
    }
Пример #5
0
    private BlockMover AddBlock(GameObject prefab, GroupController group, Vector3 start, Vector3 dest, float moveDamp, Material material)
    {
        BlockMover bc = Instantiate(prefab, group.transform)
                        .GetComponent <BlockMover>();

        bc.MoveTo(start, dest, moveDamp);
        bc.material = material;
        return(bc);
    }
Пример #6
0
    private void Start()
    {
        activeCharacters = Characters.Both;

        world1BlockMover = world1Character.GetComponent <BlockMover>();
        world2BlockMover = world2Character.GetComponent <BlockMover>();

        cameraController.SetCameraTargets(world1Door.transform, world2Door.transform);
    }
Пример #7
0
    public void Draw()
    {
        if (output == null)
        {
            Debug.Log("output was null");
            Generate();
            Draw();
        }
        if (group == null)
        {
            Debug.Log("group was null");
            return;
        }

        undrawn = false;
        try{
            for (int y = 0; y < depth; y++)
            {
                for (int x = 0; x < width; x++)
                {
                    if (rendering[x, y] == null)
                    {
                        int v = (int)model.Sample(x, y);
                        if (v != 99 && v < training.tiles.Length)
                        {
                            Vector3    pos = new Vector3(x * gridsize, y * gridsize, 0f);
                            int        rot = (int)training.RS[v];
                            GameObject fab = training.tiles[v] as GameObject;
                            if (fab != null)
                            {
                                GameObject tile   = (GameObject)Instantiate(fab, new Vector3(), Quaternion.identity);
                                Vector3    fscale = tile.transform.localScale;
                                tile.transform.parent        = group;
                                tile.transform.localPosition = pos;
                                BlockMover bm = tile.GetComponent <BlockMover>();
                                if (bm != null)
                                {
                                    tile.transform.localPosition += bm.dist;
                                }
                                tile.transform.localEulerAngles = new Vector3(0, 0, 360 - (rot * 90));
                                tile.transform.localScale       = fscale;
                                rendering[x, y] = tile;
                            }
                        }
                        else
                        {
                            undrawn = true;
                        }
                    }
                }
            }
        } catch (IndexOutOfRangeException e) {
            model = null;
            return;
        }
    }
Пример #8
0
    public GameRunner(BlockMover mover, ScoreboardFactory scoreboardFactory, AudioPlayer audio)
    {
        this.scoreboardFactory = scoreboardFactory;
        this.mover             = mover;
        this.audio             = audio;

        leftShifter  = new InputRepeater(0.25, 0.02, mover.MoveLeft);
        rightShifter = new InputRepeater(0.25, 0.02, mover.MoveRight);
        spinShifter  = new InputRepeater(0.5, 0.1, mover.RotateAntiClockwise);
    }
Пример #9
0
 public void Drag(Vector3 mouse, TileLayerEditor.TileOperation op)
 {
     Resize();
     if (tileobs == null)
     {
         Restore();
     }
     if (this.ValidCoords((int)cursor.x, (int)cursor.y))
     {
         if (op == TileLayerEditor.TileOperation.Sampling)
         {
             UnityEngine.Object s = PrefabUtility.GetPrefabParent(tileobs[(int)cursor.x, (int)cursor.y]);
             if (s != null)
             {
                 color          = s;
                 color_rotation = tileobs[(int)cursor.x, (int)cursor.y].transform.localRotation;
             }
         }
         else
         {
             DestroyImmediate(tileobs[(int)cursor.x, (int)cursor.y]);
             if (op == TileLayerEditor.TileOperation.Drawing)
             {
                 if (color == null)
                 {
                     return;
                 }
                 GameObject o = CreatePrefab(color, new Vector3(), color_rotation);
                 o.transform.parent = tiles.transform;
                 BlockMover bm = o.GetComponent <BlockMover>();
                 if (bm == null)
                 {
                     o.transform.localPosition = (cursor * gridsize);
                 }
                 else
                 {
                     o.transform.localPosition = (cursor * gridsize) + bm.dist;
                 }
                 o.transform.localRotation             = color_rotation;
                 tileobs[(int)cursor.x, (int)cursor.y] = o;
             }
         }
     }
     else
     {
         if (op == TileLayerEditor.TileOperation.Sampling)
         {
             if (cursor.y == -1 && cursor.x >= 0 && cursor.x < palette.Count)
             {
                 color          = palette[(int)cursor.x];
                 color_rotation = Quaternion.identity;
             }
         }
     }
 }
Пример #10
0
 private void MoveDown(GroupController group, float depthY, float moveDaming, bool isSmooth)
 {
     Transform[] transforms = group.GetElements();
     foreach (var tf in transforms)
     {
         Vector3    pos        = tf.position;
         BlockMover blockMover = tf.GetComponent <BlockMover>();
         blockMover.MoveTo(new Vector3(pos.x, pos.y - depthY, pos.z), moveDaming);
         blockMover.isSmooth = isSmooth;
     }
 }
Пример #11
0
    public void SpawnNewLevelBlock()
    {
        Vector3 randomSide = GetRandomMoveDirection();

        //set center
        currentLevelCenter = lastBlockTransform.position;
        //increas level height
        currentLevelCenter += Vector3.up * levelHeight;
        //create block
        BlockMover mover = CreateMovingBlock(randomSide);

        mover.StartMove();
    }
Пример #12
0
    private void SpawnBlock(bool isHeld)
    {
        if (isHeld && !m_SpawnBlockPressed)
        {
            m_SpawnBlockPressed = true;

            m_CurrentlyControlledBlock = BlockSpawner.SpawnBlock().gameObject.GetComponent <BlockMover>();
        }
        else if (!isHeld)
        {
            m_SpawnBlockPressed = false;
        }
    }
Пример #13
0
        private IEnumerator WaitForMover()
        {
            mover = default;
            while (mover == null)
            {
                mover = Object.FindObjectOfType <BlockMover>();
                yield return(null);
            }

            tickManager           = Object.FindObjectOfType <TickManager>();
            tickManager.IsFreezed = true;

            gridManager = Object.FindObjectOfType <GridManager>();
        }
Пример #14
0
    private bool IsArrived(GroupController group)
    {
        Transform[] transforms = group.GetElements();
        foreach (var tf in transforms)
        {
            BlockMover blockMover = tf.GetComponent <BlockMover>();
            if (!blockMover.isArrived)
            {
                return(false);
            }
        }

        return(true);
    }
Пример #15
0
    private BlockMover CreateMovingBlock(Vector3 moveDirection)
    {
        //create block
        Vector3 newSize = lastBlockTransform.scale != Vector3.zero ? lastBlockTransform.scale
            : new Vector3(1.0f, levelHeight, 1.0f);
        Color      newColor = colorManager.GetColorFromGradient();
        GameObject newBlock = blockCrafter.CreateBlock(newSize, newColor);

        newBlock.name = "Block_" + blockCount;
        //place on start
        newBlock.transform.position = currentLevelCenter + moveDirection * blockStartOffset;
        //add moving component to block
        BlockMover mover = newBlock.AddComponent <BlockMover>();

        mover.Construct(moveDirection, blockLoopDelta, blocksSpeed, currentLevelCenter);//
        // save info
        currentBlock = new BlockInfo(newBlock, mover, moveDirection);
        blockCount++;
        return(mover);
    }
Пример #16
0
    private void BreakTerrain()
    {
        //isBreakingTerrain = true;
        CameraController.isFloating = false;

        const float hideFactor = 30f;
        const float moveDaming = 6f;

        MoveDown(PlayerGroup, hideFactor, moveDaming, true);
        MoveDown(PushableGroup, hideFactor, moveDaming, true);
        MoveDown(GoalGroup, hideFactor, moveDaming, true);

        Transform[] transforms = TerrainGroup.GetElements();
        foreach (var tf in transforms)
        {
            Vector3    pos        = tf.position;
            BlockMover blockMover = tf.GetComponent <BlockMover>();
            blockMover.MoveTo(new Vector3(pos.x, pos.y - Random.Range(1f, 4f), pos.z), moveDaming);
        }
    }
Пример #17
0
    public void Draw()
    {
        if (output == null)
        {
            return;
        }
        if (group == null)
        {
            return;
        }
        undrawn = false;
        for (int y = 0; y < depth; y++)
        {
            for (int x = 0; x < width; x++)
            {
                if (rendering[x, y] == null)
                {
                    string     v   = model.Sample(x, y);
                    int        rot = 0;
                    GameObject fab = null;
                    if (v != "?")
                    {
                        rot = int.Parse(v.Substring(0, 1));                        // siin juba rotation metsas

                        v = v.Substring(1);
                        if (!obmap.ContainsKey(v))
                        {
                            fab      = (GameObject)Resources.Load(v, typeof(GameObject));
                            obmap[v] = fab;
                        }
                        else
                        {
                            fab = obmap[v];
                        }
                        if (fab == null)
                        {
                            continue;
                        }
                        Vector3    pos    = new Vector3(x * gridsize, y * gridsize, 0f);
                        GameObject tile   = (GameObject)Instantiate(fab, new Vector3(), Quaternion.identity);
                        Vector3    fscale = tile.transform.localScale;
                        tile.transform.parent = group;
                        BlockMover bm = tile.GetComponent <BlockMover>();
                        if (bm != null)
                        {
                            tile.transform.localPosition = pos + bm.dist;
                        }
                        else
                        {
                            tile.transform.localPosition = pos;
                        }

                        tile.transform.localEulerAngles = new Vector3(0, 0, 360 - (rot * 90));
                        tile.transform.localScale       = fscale;
                        rendering[x, y] = tile;
                    }
                    else
                    {
                        undrawn = true;
                    }
                }
            }
        }
    }
Пример #18
0
    private void Update()
    {
        bool isMovable = true;

        if (lastPushable != null)
        {
            if (!lastPushable.isArrived)
            {
                isMovable = false;
            }
        }

        if (blockMover.isArrived && isMovable)
        {
            float horizontal = Input.GetAxisRaw("Horizontal");
            float vertical   = Input.GetAxisRaw("Vertical");

            if (IsPressed(horizontal + vertical))
            {
                Vector3 movement = GetMovement(horizontal, vertical);
                Vector3 target   = _transform.position + movement;

                bool        isMove      = false;
                GameManager gameManager = GameManager.instance;
                CoordState  coordState  = gameManager.GetCoordState(target);
                if (coordState == CoordState.kPushable ||
                    coordState == CoordState.kGoal)
                {
                    Vector3 targetForPushable = target + movement;
                    if (gameManager.GetCoordState(targetForPushable) == CoordState.kMovable)
                    {
                        lastPushable = gameManager.GetPushable(target);
                        lastPushable.MoveTo(targetForPushable, moveDamping);

                        BlockMover goal = gameManager.GetGoal(targetForPushable);
                        if (goal)
                        {
                            lastPushable.material = Orange;
                            gameManager.SetCoordState(targetForPushable, CoordState.kGoal);
                        }
                        else
                        {
                            gameManager.SetCoordState(targetForPushable, CoordState.kPushable);
                        }

                        isMove = true;
                    }
                }
                else if (coordState == CoordState.kMovable)
                {
                    isMove = true;
                }

                if (isMove)
                {
                    blockMover.MoveTo(target, moveDamping * 0.4f);
                    blockMover.isSmooth = false;
                    gameManager.SetCoordState(target, CoordState.kPlayer);
                    gameManager.SetCoordState(_transform.position, CoordState.kMovable);

                    const float degreesXFactor = 0.5f;
                    const float degreesZFactor = 0.5f;
                    Quaternion  destination    = Quaternion.Euler(new Vector3(-movement.z * degreesXFactor, 0f, movement.x * degreesZFactor));
                    cameraController.rotationDestination = cameraController.rotation * destination;
                    cameraController.rotationDamping     = 3.0f;
                    cameraController.isLookAt            = false;
                }
            }
        }
    }
Пример #19
0
 private void Start()
 {
     _transform       = transform;
     blockMover       = GetComponent <BlockMover>();
     cameraController = Camera.main.GetComponent <CameraController>();
 }
Пример #20
0
 void Awake()
 {
     blockMover = GetComponent <BlockMover>();
     blockState = GetComponent <BlockState>();
 }
Пример #21
0
    private void SetStage3()
    {
        isStaging = true;
        visibles.Clear();

        _coordStates = new CoordState[6, 4];
        for (int i = 0; i < _coordStates.GetLength(0); ++i)
        {
            for (int j = 0; j < _coordStates.GetLength(1); ++j)
            {
                _coordStates[i, j] = CoordState.kNonReachable;
            }
        }
        coordOffset = 0;

        AddTerrain(1f, 0f, Materials[1]);
        AddTerrain(2f, 0f, Materials[0]);
        AddTerrain(0f, 1f, Materials[0]);
        AddTerrain(1f, 1f, Materials[1]);
        AddTerrain(2f, 1f, Materials[0]);
        AddTerrain(1f, 2f, Materials[1]);
        AddTerrain(2f, 2f, Materials[0]);
        AddTerrain(1f, 3f, Materials[1]);
        AddTerrain(2f, 3f, Materials[0]);
        AddTerrain(3f, 3f, Materials[1]);
        AddTerrain(0f, 4f, Materials[0]);
        AddTerrain(1f, 4f, Materials[1]);
        AddTerrain(2f, 4f, Materials[0]);
        AddTerrain(3f, 4f, Materials[1]);
        AddTerrain(0f, 5f, Materials[0]);
        AddTerrain(1f, 5f, Materials[1]);
        AddTerrain(2f, 5f, Materials[0]);
        AddTerrain(3f, 5f, Materials[1]);

        MoveStartPosition(TerrainGroup, 2.0f);

        AddGoal(0f, 4f);
        AddGoal(0f, 5f);
        AddGoal(1f, 5f);
        AddGoal(2f, 5f);
        AddGoal(3f, 5f);

        AddPushable(1f, 1f);
        AddPushable(1f, 2f);
        AddPushable(1f, 4f);
        AddPushable(2f, 3f);
        AddPushable(2f, 5f);

        AddPlayer(0f, 1f);

        CameraController.rotation            = Quaternion.Euler(55f, 255f, 0f);
        CameraController.rotationDestination = Quaternion.Euler(55f, 345f, 0f);
        CameraController.rotationDamping     = 3.0f;
        CameraController.isLookAt            = false;
        CameraController.visibles            = visibles;

        BlockMover blockMover = GetPushable(new Vector3(2f, 0f, 5f));

        blockMover.material = Materials[2];
        SetCoordState(2f, 5f, CoordState.kGoal);

        StageText.text = "Third Stage";
    }