コード例 #1
0
    void SelectRamdomType()
    {
        int ramdomInt = Random.Range(1, obstacles.Length + 1);

        switch (ramdomInt)
        {
        case 1:
            currentObstacleSpawn = ObstacleTypes.CircleObstacle;
            break;

        case 2:
            currentObstacleSpawn = ObstacleTypes.VentilatorObstacle;
            break;

        case 3:
            currentObstacleSpawn = ObstacleTypes.TunelObstacle;
            break;

        case 4:
            currentObstacleSpawn = ObstacleTypes.SpikesObstacle;
            break;

        case 5:
            currentObstacleSpawn = ObstacleTypes.BoxObstacle;
            break;
        }
    }
コード例 #2
0
 public void SetObstacleType(ObstacleTypes type, int name)
 {
     if (floorCell.ContainsKey(name))
     {
         floorCell[name].obstacleType = type;
     }
 }
コード例 #3
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);
    }
コード例 #4
0
        public void CheckPuzzle()
        {
            if (IsChecked)
            {
                return;
            }

            IsChecked     = true;
            ObstacleTypes = ObstacleTypes.None;
            PositionModel.Clear();
            CheckPuzzleEvent?.Invoke(this);
        }
コード例 #5
0
 GameObject ObstaclesByType(ObstacleTypes type)
 {
     for (int i = 0; i < obstacleList.Count; ++i)
     {
         if (obstacleList[i].GetComponent <Obstacle>().obstacles == type)
         {
             if (!obstacleList[i].activeInHierarchy)
             {
                 obstacleList[i].gameObject.SetActive(true);
                 return(obstacleList[i].gameObject);
             }
         }
     }
     return(null);
 }
コード例 #6
0
ファイル: Grid.cs プロジェクト: snaptothegrid/Tilebase
    // ===============================================================
    // Entities
    // ===============================================================
    public Obstacle CreateObstacle(int x, int y, ObstacleTypes type, Color color)
    {
        Transform parent = this.container.Find("Entities/Obstacles");

        GameObject obj = GameObject.Instantiate(prefabs.obstacles[type]);
        obj.transform.SetParent(parent, false);
        obj.name = type.ToString(); //"Obstacle";
        Obstacle obstacle = obj.GetComponent<Obstacle>();
        obstacle.Init(this, x, y, color);

        obstacle.type = type;

        return obstacle;
    }
コード例 #7
0
ファイル: FloorManager.cs プロジェクト: crackerm/crossy
    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++;
            }
        }
    }