Example #1
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;
            }
        }
    }
Example #2
0
    // Flowfloor control function
    void Flowfloors()
    {
        if (tempFlowingfloors.Count > 0)
        {
            int sfPos;

            List <int> arrayList = new List <int>(tempFlowingfloors.Keys);
            for (int index = 0; index < arrayList.Count; index++)
            {
                FlowingfloorManage flowingfloors = tempFlowingfloors[arrayList[index]];
                switch (flowingfloors.movingState)
                {
                case FlowingfloorState.NONE:
                    flowingfloors.movingState = FlowingfloorState.MOVING;
                    break;

                case FlowingfloorState.MOVING:
                    int ffPos;
                    int widthSize = flowingfloors.columnNumber;

                    if (flowingfloors.flowingfloorSet.position == FloorPosition.TOP)
                    {
                        ffPos = 0;
                    }
                    else
                    {
                        ffPos = modelLengthNumOnScreen;
                    }

                    int     originalName = Floor.instance.GetOriginalName(ffPos, flowingfloors.columnNumber);
                    Vector3 position     = Floor.instance.GetPosition(ffPos, widthSize, 0);
                    position.x -= 2.2f;

                    Quaternion objRotation = Quaternion.Euler(0, 0, 0);
                    string     name        = "Flowingfloor_" + flowingFloorCount;
                    flowingFloorCount++;
                    flowingfloors.count++;

                    GameObject   floor            = this.GetGameObject(flowingfloorObject[(int)flowingfloors.flowingfloorSet.flowingfloorSizeType], position, objRotation, flowingfloors.count, name);
                    Flowingfloor tempFlowingfloor = floor.GetComponent <Flowingfloor>();
                    tempFlowingfloor.ResetParameter();
                    tempFlowingfloor.floorPosition        = flowingfloors.flowingfloorSet.position;
                    tempFlowingfloor.floorType            = flowingfloors.flowingfloorSet.type;
                    tempFlowingfloor.width                = flowingfloors.columnNumber;
                    tempFlowingfloor.index                = originalName;
                    tempFlowingfloor.ChangeSpeed          = (int)flowingfloors.flowingfloorSet.type;
                    tempFlowingfloor.flowingfloorSizeType = flowingfloors.flowingfloorSet.flowingfloorSizeType;
                    flowingfloors.idleTimeCount           = 0;
                    flowingfloors.movingState             = FlowingfloorState.IDLING;

                    break;

                case FlowingfloorState.IDLING:
                    if (flowingfloors.idleTimeCount >= flowingfloors.flowingfloorSet.idleTime)
                    {
                        flowingfloors.movingState = FlowingfloorState.NONE;
                    }
                    else
                    {
                        flowingfloors.idleTimeCount += Time.deltaTime;
                    }
                    break;
                }
            }
        }
    }
Example #3
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();
        }
    }