Beispiel #1
0
    public void SetToCell(FloorTypes value, int name, ObstacleTypes obstacleType, FloorAttributes floorAtt)
    {
        FloorCellManage cellManage = new FloorCellManage();

        cellManage.floorType    = value;
        cellManage.obstacleType = obstacleType;
        cellManage.floorAtt     = floorAtt;
        floorCell.Add(name, cellManage);
    }
Beispiel #2
0
    void OnTriggerEnter2D(Collider2D c)
    {
        if (c.gameObject.tag == "Collider")
        {
            Flowingfloor floor = c.transform.parent.gameObject.GetComponent <Flowingfloor>();
            string       name  = c.gameObject.transform.parent.gameObject.name + "_" + c.gameObject.name;

            if (name != getLastObjectInstance)
            {
                floorPosition    = floor.floorPosition;
                userFlowingSpeed = (int)floor.floorType;
                userFloorAtt     = FloorAttributes.BAMBOO;

                flowingFloorObject    = c.gameObject;
                getLastObjectInstance = name;
            }
        }
    }
Beispiel #3
0
    void SetNewDataToCell(int setCount, bool startState)
    {
        int collectionId = GetCollectionId();

        if (startState == true)
        {
            collectionId = defaultFloor.defaultFloorCollection;
        }

        int columnNo;
        int columnCount;

        for (int width = 0; width < setCount; width++)
        {
            columnCount = floorSetup.floorSetCollection[collectionId].floorSetConf.Count;
            columnNo    = GetColumnId(columnCount);

            if (columnNo == 1)
            {
                collectionId = GetCollectionId();
            }

            FloorColumnDef floorColumnDef      = floorSetup.floorSetCollection[collectionId].floorSetConf[columnNo];
            FloorColumnSet floorList           = floorSetup.floorColumnSetList[floorColumnDef.columnIndex];
            int            floorSetupListCount = floorList.floorSetList.Count;
            int            floorObjectIndex    = 0;
            int            obstacleObjectIndex = 0;
            int            index;

            for (int length = 0; length < modelLengthNumOnScreen; length++)
            {
                bool            listDataMatchState = false;
                int             name         = GetName(length, presentBlockNum);
                FloorSet        tempFloorSet = new FloorSet();
                ObstacleTypes   obstacleType = ObstacleTypes.NONE;
                FloorAttributes tempFloorAtt = FloorAttributes.FLOOR;

                if (floorObjectIndex < floorSetupListCount)
                {
                    tempFloorSet = floorList.floorSetList[floorObjectIndex];
                    if (tempFloorSet.index == length)
                    {
                        tempFloorAtt = tempFloorSet.floorAttribute;
                        if (tempFloorSet.obstacleType != ObstacleTypes.NONE && tempFloorSet.obstacleType != null)
                        {
                            obstacleType = tempFloorSet.obstacleType;
                        }

                        listDataMatchState = true;
                        Floor.instance.SetToCell(tempFloorSet.floorType, name, obstacleType, tempFloorAtt);
                        floorObjectIndex++;
                    }
                }

                if (listDataMatchState == false)
                {
                    tempFloorSet = defaultFloor.initFloor;
                    Floor.instance.SetToCell(tempFloorSet.floorType, name, obstacleType, tempFloorAtt);
                    listDataMatchState = true;
                }
            }

            int widthSize = GetWidthSize(presentBlockNum);
            // If ninjastar has existing
            if (floorColumnDef.ninjastarIndex != null && floorColumnDef.ninjastarIndex > 0)
            {
                if (tempStars.ContainsKey(widthSize) == false)
                {
                    index = floorColumnDef.ninjastarIndex;
                    NinjaStarManage tempNinjastar = new NinjaStarManage();
                    tempNinjastar.columnNumber = widthSize;
                    tempNinjastar.ninjaStarSet = ninjastarSetup.ninjaStarSetList[index];
                    tempNinjastar.movingState  = NinjastarState.NONE;
                    tempNinjastar.starsCount   = 0;
                    tempStars.Add(widthSize, tempNinjastar);

                    if (ninjastarSetup.ninjaStarSetList[index].position == FloorPosition.TOP)
                    {
                        int enemyLocation = GetName(3, presentBlockNum);
                        Floor.instance.SetObstacleType(ObstacleTypes.SOLDIER, enemyLocation);
                    }
                }
            }

            if (floorColumnDef.stickfloorIndex != null && floorColumnDef.stickfloorIndex > 0)
            {
                if (tempStickfloors.ContainsKey(widthSize) == false)
                {
                    index = floorColumnDef.stickfloorIndex;
                    StickfloorManage tempStickfloor = new StickfloorManage();
                    tempStickfloor.columnNumber   = widthSize;
                    tempStickfloor.idleTimeCount  = 0f;
                    tempStickfloor.stickfloorSet  = stickfloorSetup.stickfloorSetList[index];
                    tempStickfloor.movingState    = StickfloorState.NONE;
                    tempStickfloor.leftStickfloor = 0;
                    tempStickfloor.speedTimeCount = 0;
                    tempStickfloors.Add(widthSize, tempStickfloor);
                }
            }

            if (floorColumnDef.flowingfloorId != null && floorColumnDef.flowingfloorId > 0)
            {
                if (tempFlowingfloors.ContainsKey(widthSize) == false)
                {
                    index = floorColumnDef.flowingfloorId;
                    FlowingfloorManage tempFlowingfloor = new FlowingfloorManage();
                    tempFlowingfloor.columnNumber    = widthSize;
                    tempFlowingfloor.flowingfloorSet = flowingfloorSetup.flowingfloorSetList[index];
                    tempFlowingfloor.movingState     = FlowingfloorState.NONE;
                    tempFlowingfloor.count           = 0;
                    tempFlowingfloors.Add(widthSize, tempFlowingfloor);
                }
            }

            if (floorColumnDef.rollingRockId != null && floorColumnDef.rollingRockId > 0)
            {
                if (tempRollingRocks.ContainsKey(widthSize) == false)
                {
                    index = floorColumnDef.rollingRockId;
                    RollingRockManage tempRollingRock = new RollingRockManage();
                    tempRollingRock.columnNumber          = widthSize;
                    tempRollingRock.rollingRockSet        = rollingRockSetup.rollingRockSetList[index];
                    tempRollingRock.movingState           = RollingRockState.NONE;
                    tempRollingRock.rollingRockCount      = 0;
                    tempRollingRock.rollingRockStartState = true;
                    tempRollingRocks.Add(widthSize, tempRollingRock);
                }
            }

            // Floor local position increase
            if (presentBlockNum < modelWidthNumOnScreen)
            {
                presentBlockNum++;
            }
        }
    }
Beispiel #4
0
    void Move(SwipeDirection direction)
    {
        if (isJumping == true)
        {
            return;
        }

        //   Game starting
        if (GameManager.I.StartState == false)
        {
            GameManager.I.StartState = true;
        }

        animator.SetBool("SitIdle", false);

        Vector3 fromPosition = transform.position;         //charaObject.transform.position;
        int     result, nextPosition;
        int     userPosition = userHashPosition;

        if (userFloorAtt == FloorAttributes.BAMBOO)
        {
            int width = Floor.instance.GetWidth(userHashPosition);
            userPosition = Floor.instance.GetNearestFloorCell(width, transform.position, 1);
        }

        nextPosition = userPosition;
        result       = (int)FloorAttributes.FLOOR;

        switch (direction)
        {
        case SwipeDirection.Down:
            nextPosition = userPosition + 1;
            result       = GetNextWallAtt(SwipeDirection.Down, userPosition, nextPosition);
            break;

        case SwipeDirection.Up:
            nextPosition = userPosition - 1;
            result       = GetNextWallAtt(SwipeDirection.Up, userPosition, nextPosition);
            break;

        case SwipeDirection.Left:
            nextPosition       = userPosition - Floor.instance.modelLengthNumOnScreen;
            result             = GetNextWallAtt(SwipeDirection.Left, userPosition, nextPosition);
            flowingFloorObject = null;
            break;

        case SwipeDirection.Right:
        case SwipeDirection.Tap:
            nextPosition       = userPosition + Floor.instance.modelLengthNumOnScreen;
            result             = GetNextWallAtt(SwipeDirection.Right, userPosition, nextPosition);
            flowingFloorObject = null;
            break;

        default:
            nextPosition = userPosition;
            result       = (int)FloorAttributes.FLOOR;
            break;
        }

        if (result != (int)FloorAttributes.WALL)
        {
            int  nextWidth          = Floor.instance.GetWidth(nextPosition);
            int  nextLength         = Floor.instance.GetLength(nextPosition);
            bool upDownBamboo       = false;
            bool useDefaultMovement = true;

            // Score up
            if (userMaxLength < nextWidth)
            {
                GameManager.I.UserScore += 1;
                userMaxLength            = nextWidth;
            }

            if (direction == SwipeDirection.Up || direction == SwipeDirection.Down)
            {
                upDownBamboo = true;
            }

            if (flowingFloorObject != null && userFloorAtt == FloorAttributes.BAMBOO && upDownBamboo == true)
            {
                Flowingfloor         flowingFloor = flowingFloorObject.transform.parent.GetComponent <Flowingfloor>();
                FlowingfloorSizeType sizeType     = flowingFloor.flowingfloorSizeType;
                int        currentFloor           = int.Parse(flowingFloorObject.gameObject.name);
                GameObject nextGameObject;

                switch (sizeType)
                {
                case FlowingfloorSizeType.LONG:
                    if (direction == SwipeDirection.Up)
                    {
                        if (currentFloor < 3 && currentFloor > 0)
                        {
                            nextGameObject = flowingFloorObject.transform.parent.transform.Find((currentFloor + 1).ToString()).gameObject;
                            if (nextGameObject != null)
                            {
                                toPos = nextGameObject.transform.position;
                                flowingFloorObject = nextGameObject;
                                useDefaultMovement = false;
                            }
                        }
                    }
                    else
                    {
                        if (currentFloor > 1 && currentFloor < 4)
                        {
                            nextGameObject = flowingFloorObject.transform.parent.transform.Find((currentFloor - 1).ToString()).gameObject;
                            if (nextGameObject != null)
                            {
                                toPos = nextGameObject.transform.position;
                                flowingFloorObject = nextGameObject;
                                useDefaultMovement = false;
                            }
                        }
                    }
                    break;

                case FlowingfloorSizeType.MEDIUM:
                    if (direction == SwipeDirection.Up)
                    {
                        if (currentFloor < 2 && currentFloor > 0)
                        {
                            nextGameObject = flowingFloorObject.transform.parent.transform.Find((currentFloor + 1).ToString()).gameObject;
                            if (nextGameObject != null)
                            {
                                toPos = nextGameObject.transform.position;
                                flowingFloorObject = nextGameObject;
                                useDefaultMovement = false;
                            }
                        }
                    }
                    else
                    {
                        if (currentFloor > 1 && currentFloor < 3)
                        {
                            nextGameObject = flowingFloorObject.transform.parent.transform.Find((currentFloor - 1).ToString()).gameObject;
                            if (nextGameObject != null)
                            {
                                toPos = nextGameObject.transform.position;
                                flowingFloorObject = nextGameObject;
                                useDefaultMovement = false;
                            }
                        }
                    }
                    break;

                case FlowingfloorSizeType.SHORT:
                    break;
                }
            }

            if (useDefaultMovement == true)
            {
                flowingFloorObject = null;
                toPos = Floor.instance.GetPosition(nextLength, nextWidth, nextLength);
                spriteRenderer.GetComponent <Renderer>().sortingOrder = nextLength + 1;
                toPos.y += floorDiffY;
                toPos.x += floorDiffX;
            }

//			Floor.refreshFloorBack = nextWidth - 1;
//			Floor.refreshFloorFront = nextWidth + 1;

            userHashPosition = nextPosition;
            userFloorAtt     = (FloorAttributes)GetUserFloorAttribute(userHashPosition);

            if (userDirection == SwipeDirection.Left)
            {
                transform.eulerAngles = new Vector2(0, 180);
            }
            else
            {
                transform.eulerAngles = new Vector2(0, 0);
            }

            animator.SetTrigger("Jump");

            fromPos   = fromPosition;
            isJumping = true;
            TestSoundManager.I.PlayJumpSound();
        }
    }