public void SpawnMovingCoin(object sender, EventArgs data)
    {
        Slot clickedSlot = (Slot)sender;
        Slot targetSlot  = GetLowestEmptySlotInCollum(clickedSlot.slotCoordinate.x);

        MovingCoin movingCoin = Instantiate(MovingCoinPrefab, GameObject.Find("GameBackground").gameObject.transform).GetComponent <MovingCoin>();

        movingCoin.transform.SetSiblingIndex(0);
        movingCoin.gameObject.name = "MovingCoin";

        movingCoin.destinationReached += OnMovingCoinDestinationReached;

        movingCoin.Initialize(this, clickedSlot.transform.position, targetSlot);
    }
Exemple #2
0
    public void populateTrackObjects(Transform trackObjectsRoot)
    {
        if (trackObjectsRoot == null)
        {
            Debug.Log("trackObjectsRoot yok");
        }

        foreach (Transform trackItem in trackObjectsRoot.transform)
        {
            TrackObject currentTrackObject = trackItem.GetComponent <TrackObject>();
            if (currentTrackObject != null)
            {
                if (currentTrackObject.placeHolder == true)
                {
                    if (currentTrackObject.objectGroup == TrackObject.ObjectGroup.None)
                    {
                        GameObject selectedObject = getRandomTrackObjectByType(currentTrackObject.objectType);

                        if (selectedObject != null)
                        {
                            // Positioning New Object
                            selectedObject.transform.parent   = trackItem.transform.parent;
                            selectedObject.transform.position = trackItem.transform.position;


                            // Handle Selected
                            switch (currentTrackObject.objectType)
                            {
                            case TrackObject.ObjectType.PointsLine:

                                CoinLine CurrencyLine_placeHolder = currentTrackObject.GetComponent <CoinLine>();
                                CoinLine CurrencyLine_selected    = selectedObject.GetComponent <CoinLine>();

                                if (CurrencyLine_placeHolder != null && CurrencyLine_selected != null)
                                {
                                    CurrencyLine_selected.coinSpacing        = CurrencyLine_placeHolder.coinSpacing;
                                    CurrencyLine_selected.length             = CurrencyLine_placeHolder.length;
                                    CurrencyLine_selected.coinLineRefraction = CurrencyLine_placeHolder.coinLineRefraction;

                                    CurrencyLine_selected.doActive();
                                }

                                break;

                            case TrackObject.ObjectType.PointsCurve:
                                CoinCurve CurrencyCurve_placeHolder = currentTrackObject.GetComponent <CoinCurve>();
                                CoinCurve CurrencyCurve_selected    = selectedObject.GetComponent <CoinCurve>();

                                if (CurrencyCurve_placeHolder != null && CurrencyCurve_selected != null)
                                {
                                    CurrencyCurve_selected.offsetObject = null;
                                    CurrencyCurve_selected.offsetObject = CurrencyCurve_placeHolder.offsetObject;

                                    CurrencyCurve_selected.doActive();
                                }


                                break;

                            case TrackObject.ObjectType.PointsMovingLine:

                                MovingCoin MovingCoin_placeHolder = currentTrackObject.GetComponent <MovingCoin>();
                                MovingCoin MovingCoin_selected    = selectedObject.GetComponent <MovingCoin>();

                                if (MovingCoin_placeHolder != null && MovingCoin_selected != null)
                                {
                                    MovingCoin_selected.speed = MovingCoin_placeHolder.speed;
                                }

                                CoinLine SubCoinLine_placeHolder = currentTrackObject.GetComponent <CoinLine>();
                                CoinLine SubCoinLine_selected    = selectedObject.transform.Find("movingMesh").gameObject.AddComponent <CoinLine>();

                                if (SubCoinLine_placeHolder != null && SubCoinLine_selected != null)
                                {
                                    SubCoinLine_selected.coinSpacing        = SubCoinLine_placeHolder.coinSpacing;
                                    SubCoinLine_selected.length             = SubCoinLine_placeHolder.length;
                                    SubCoinLine_selected.coinLineRefraction = SubCoinLine_placeHolder.coinLineRefraction;

                                    SubCoinLine_selected.doActive();
                                }

                                // Moving Coin
                                if (MovingCoin_selected != null)
                                {
                                    MovingCoin_selected.doActive();
                                }

                                break;
                            }
                        }
                        else
                        {
                            Debug.Log("Regular Item not found" + currentTrackObject.name);
                        }
                    }
                    else
                    {
                        GameObject selectedObject = null;

                        if (currentTrackObject.disableShuffle == false)
                        {
                            selectedObject = getRandomTrackObjectByGroup(currentTrackObject.objectGroup);
                        }
                        else
                        {
                            selectedObject = getRandomTrackObjectByType(currentTrackObject.objectType);
                        }

                        // Power-up handle codes places here
                        if (currentTrackObject.objectGroup == TrackObject.ObjectGroup.PowerUps)
                        {
                            if (checkPowerUpSpawning(selectedObject) == false)
                            {
                                continue;
                            }
                        }

                        // Pickables handle codes places here
                        if (currentTrackObject.objectGroup == TrackObject.ObjectGroup.Pickables)
                        {
                            if (checkPowerUpSpawning(selectedObject) == false)
                            {
                                continue;
                            }
                        }


                        if (selectedObject != null)
                        {
                            // Handle Selected
                            switch (currentTrackObject.objectGroup)
                            {
                            case TrackObject.ObjectGroup.None:
                                break;

                            case TrackObject.ObjectGroup.CharacterObstacles:

                                // Character Obstacles
                                CharacterObstacle CharacterObstacle_placeHolder = currentTrackObject.GetComponent <CharacterObstacle>();
                                CharacterObstacle CharacterObstacle_selected    = selectedObject.GetComponent <CharacterObstacle>();

                                if (CharacterObstacle_placeHolder != null && CharacterObstacle_selected != null)
                                {
                                    CharacterObstacle_selected.lastWarrior   = CharacterObstacle_placeHolder.lastWarrior;
                                    CharacterObstacle_selected.singleWarrior = CharacterObstacle_placeHolder.singleWarrior;
                                    CharacterObstacle_selected.doActive();
                                }

                                break;

                            case TrackObject.ObjectGroup.Bales1:
                                break;

                            case TrackObject.ObjectGroup.Bales3:
                                break;

                            case TrackObject.ObjectGroup.Bales5:
                                break;

                            case TrackObject.ObjectGroup.Barriers:
                                break;

                            case TrackObject.ObjectGroup.MovingObstaclesSingle:

                                // Moving Obstacles Single
                                MovingObstacle MovingObstaclesSingle_placeHolder = currentTrackObject.GetComponent <MovingObstacle>();
                                MovingObstacle MovingObstaclesSingle_selected    = selectedObject.GetComponent <MovingObstacle>();

                                if (MovingObstaclesSingle_placeHolder != null && MovingObstaclesSingle_selected != null)
                                {
                                    MovingObstaclesSingle_selected.trainCount = MovingObstaclesSingle_placeHolder.trainCount;
                                    MovingObstaclesSingle_selected.speed      = MovingObstaclesSingle_placeHolder.speed;
                                    MovingObstaclesSingle_selected.doActive();
                                }


                                break;

                            case TrackObject.ObjectGroup.MovingObstaclesTrail3:

                                // Moving Obstacles Trail
                                MovingObstacle MovingObstaclesTrail_placeHolder3 = currentTrackObject.GetComponent <MovingObstacle>();
                                MovingObstacle MovingObstaclesTrail_selected3    = selectedObject.GetComponent <MovingObstacle>();

                                if (MovingObstaclesTrail_placeHolder3 != null && MovingObstaclesTrail_selected3 != null)
                                {
                                    MovingObstaclesTrail_selected3.trainCount = MovingObstaclesTrail_placeHolder3.trainCount;
                                    MovingObstaclesTrail_selected3.speed      = MovingObstaclesTrail_placeHolder3.speed;
                                    MovingObstaclesTrail_selected3.doActive();
                                }

                                break;

                            case TrackObject.ObjectGroup.MovingObstaclesTrail5:

                                // Moving Obstacles Trail
                                MovingObstacle MovingObstaclesTrail_placeHolder5 = currentTrackObject.GetComponent <MovingObstacle>();
                                MovingObstacle MovingObstaclesTrail_selected5    = selectedObject.GetComponent <MovingObstacle>();

                                if (MovingObstaclesTrail_placeHolder5 != null && MovingObstaclesTrail_selected5 != null)
                                {
                                    MovingObstaclesTrail_selected5.trainCount = MovingObstaclesTrail_placeHolder5.trainCount;
                                    MovingObstaclesTrail_selected5.speed      = MovingObstaclesTrail_placeHolder5.speed;
                                    MovingObstaclesTrail_selected5.doActive();
                                }

                                break;
                            }

                            // Positioning New Object
                            selectedObject.transform.parent   = trackItem.transform.parent;
                            selectedObject.transform.position = trackItem.transform.position;
                        }
                        else
                        {
                            Debug.Log("Shuffled Item not found" + currentTrackObject.name);
                        }
                    }
                }
            }
        }
    }
Exemple #3
0
 public void disableMovingObstacles()
 {
     MovingObstacle.ActivateResumeMotion();
     MovingCoin.ActivateResumeMotion();
 }