コード例 #1
0
    private void BuildBlocks()
    {
        // calculate how mnay blocks fit on the screen
        blocksFitHorizontally = Mathf.Floor(screenXRounded * 2 / boxSizeXRoundedUp);
        float yPos = ScreenUtils.ScreenTop - ((Mathf.Abs(ScreenUtils.ScreenTop) + Mathf.Abs(ScreenUtils.ScreenBottom)) / 5);

        // auto build 3 rows of blocks horizontally with a row of gap
        for (int blockY = 0; blockY < blockRows * 2; blockY += 2)
        {
            for (int blockX = 0; blockX <= blocksFitHorizontally; blockX++)
            {
                PickRandomBlock();
                GameObject block = Instantiate(randomBlockPrefab,
                                               new Vector2(-screenXRounded + (boxSizeXRoundedUp * blockX), yPos - (boxSizeXRoundedUp * blockY)),
                                               Quaternion.identity);

                // check if the block is a pickup block
                PickupBlock pickupBlock = block.GetComponent <PickupBlock>();
                if (pickupBlock != null)
                {
                    pickupBlock.BlockEffect = pickupEffect;
                }
            }
        }
    }
コード例 #2
0
    /// <summary>
    /// Places a randomly-selected block at the given position
    /// </summary>
    /// <param name="position">position of the block</param>
    void PlaceBlock(Vector2 position)
    {
        float randomBlockType = Random.value;

        if (randomBlockType < ConfigurationUtils.StandardBlockProbability)
        {
            Instantiate(prefabStandardBlock, position, Quaternion.identity);
        }
        else if (randomBlockType <
                 (ConfigurationUtils.StandardBlockProbability + ConfigurationUtils.BonusBlockProbability))
        {
            Instantiate(prefabBonusBlock, position, Quaternion.identity);
        }
        else
        {
            // pickup block selected
            GameObject  pickupBlock       = Instantiate(prefabPickupBlock, position, Quaternion.identity);
            PickupBlock pickupBlockScript = pickupBlock.GetComponent <PickupBlock>();

            // set pickup effect
            float freezerThreshold = ConfigurationUtils.StandardBlockProbability +
                                     ConfigurationUtils.BonusBlockProbability +
                                     ConfigurationUtils.FreezerBlockProbability;
            if (randomBlockType < freezerThreshold)
            {
                pickupBlockScript.Effect = PickupEffect.Freezer;
            }
            else
            {
                pickupBlockScript.Effect = PickupEffect.Speedup;
            }
        }
    }
コード例 #3
0
    private void InstantiateRandomBlock(float posX, float posY)
    {
        float probability = Random.Range(0f, 1f);
        float cumulative  = ConfigurationUtils.PickupBlockProbability;

        if (probability < cumulative)
        {
            PickupBlock pickupBlock            = Instantiate(pickupBlockPrefab, new Vector3(posX, posY, 0), Quaternion.identity).GetComponent <PickupBlock>();
            int         pickupBlockProbability = Random.Range(0, 100);
            if (pickupBlockProbability < 50)
            {
                pickupBlock.PickupEffect = PickupEffect.Speedup;
            }
            else
            {
                pickupBlock.PickupEffect = PickupEffect.Freezer;
            }
            return;
        }
        cumulative += ConfigurationUtils.BonusBlockProbability;
        if (probability < cumulative)
        {
            Instantiate(bonusBlockPrefab, new Vector3(posX, posY, 0), Quaternion.identity).GetComponent <PickupBlock>();
            return;
        }

        Instantiate(standardBlockPrefab, new Vector3(posX, posY, 0), Quaternion.identity).GetComponent <PickupBlock>();
    }
コード例 #4
0
 //Speddy
 public static void AddSpeddyInvoker(PickupBlock invoker)
 {
     speddyInvokers.Add(invoker);
     foreach (UnityAction <float, float> speddyListener in speddyListeners)
     {
         invoker.AddSpeddyListener(speddyListener);
     }
 }
コード例 #5
0
 //Freezy
 public static void AddFreezerInvoker(PickupBlock invoker)
 {
     freezerInvokers.Add(invoker);
     foreach (UnityAction <float> freezerListener in freezerListeners)
     {
         invoker.AddFreezListener(freezerListener);
     }
 }
コード例 #6
0
    //For SPEED EFFECT

    public static void SAddInvoker(PickupBlock script)
    {
        Sinvoker = script;
        if (Slistener != null)
        {
            Sinvoker.AddFSpeedEffectListener(Slistener);
        }
    }
コード例 #7
0
    // METHODS
    //For FREEZE EFFECT

    public static void AddInvoker(PickupBlock script)
    {
        Finvoker = script;
        if (Flistener != null)
        {
            Finvoker.AddFreezerEffectListener(Flistener);
        }
    }
コード例 #8
0
 public static void AddSpeedInvoker(PickupBlock script)
 {
     speedInvoker = script;
     if (speedListener != null)
     {
         speedInvoker.AddSpeedEffectListener(speedListener);
     }
 }
コード例 #9
0
 public static void AddFreezeInvoker(PickupBlock script)
 {
     freezeInvoker = script;
     if (freezeListener != null)
     {
         freezeInvoker.AddFreezeEffectListener(freezeListener);
     }
 }
コード例 #10
0
 public static void AddInvokerTwo(PickupBlock pickupTwo)
 {
     invokersTwo.Add(pickupTwo);
     foreach (UnityAction <float, float> unityAction in listenersTwo)
     {
         pickupTwo.AddSpeedUpEffectListener(unityAction);
     }
 }
コード例 #11
0
 public static void AddInvoker(PickupBlock pickup)
 {
     invoker = pickup;
     if (listener != null)
     {
         invoker.AddFreezerEffectListener(listener);
     }
 }
コード例 #12
0
 public static void AddSpeedUpInvoker(PickupBlock invoker)
 {
     speedUpEventInvoker = invoker;
     if (speedUpEventListener != null)
     {
         speedUpEventInvoker.AddSpeedUpEventListener(speedUpEventListener);
     }
 }
コード例 #13
0
 //Freezer Event support
 public static void AddFreezerInvoker(PickupBlock script)
 {
     freezerInvokers.Add(script);
     foreach (UnityAction listener in freezerListeners)
     {
         script.AddFreezerEffectListener(listener);
     }
 }
コード例 #14
0
 public static void AddFreezerEffectActivatedInvoker(PickupBlock invoker)
 {
     FreezerEffectActivatedInvokers.Add(invoker);
     foreach (var freezerEffectActivatedListener in FreezerEffectActivatedListeners)
     {
         invoker.AddFreezerEffectListener(freezerEffectActivatedListener);
     }
 }
コード例 #15
0
 public static void addFreezeInvoker(PickupBlock invoker)
 {
     freezeEffectInvoker.Add(invoker);
     foreach (UnityAction <float> lsnr in freezeListener)
     {
         invoker.AddFreezeEffectListener(lsnr);
     }
 }
コード例 #16
0
ファイル: EventManager.cs プロジェクト: Medill-East/Coursera
 public static void AddFreezerEffectInvoker(PickupBlock invoker)
 {
     invokers.Add(invoker);
     foreach (UnityAction <float> lisener in freezerListeners)
     {
         invoker.AddFreezerEffectListener(lisener);
     }
 }
コード例 #17
0
ファイル: EventManager.cs プロジェクト: Medill-East/Coursera
 public static void AddSpeedupEffectInvoker(PickupBlock invoker)
 {
     invokers.Add(invoker);
     foreach (UnityAction <float, float> lisener in speedupListeners)
     {
         invoker.AddSpeedupEffectListener(lisener);
     }
 }
コード例 #18
0
 /// <summary>
 /// Adds the invoker for the freeze event
 /// </summary>
 /// <param name="invoker"></param>
 public static void AddFreezeInvoker(PickupBlock invoker)
 {
     freezeInvoker = invoker;
     if (freezeListener != null)
     {
         freezeInvoker.AddFreezerEffectListener(freezeListener);
     }
 }
コード例 #19
0
 public static void AddInvokerSpeedup(PickupBlock invoker)
 {
     invokersSpeedup.Add(invoker);
     foreach (UnityAction <float, float> listener in listenersSpeedup)
     {
         invoker.AddSpeedupEffectListener(listener);
     }
 }
コード例 #20
0
 // Speedup Event support
 public static void AddSpeedupInvoker(PickupBlock script)
 {
     speedupInvokers.Add(script);
     foreach (UnityAction listener in speedupListeners)
     {
         script.AddSpeedupEffectListener(listener);
     }
 }
コード例 #21
0
 public static void AddSpeedupEffectActivatedInvoker(PickupBlock invoker)
 {
     SpeedupEffectActivatedInvokers.Add(invoker);
     foreach (var speedupEffectActivatedListener in SpeedupEffectActivatedListeners)
     {
         invoker.AddSpeedupEffectListener(speedupEffectActivatedListener);
     }
 }
コード例 #22
0
 public static void addSpeedInvoker(PickupBlock invoker)
 {
     speedEffectInvoker.Add(invoker);
     foreach (UnityAction <float, float> lsnr in speedListener)
     {
         invoker.AddSpeedEffectListener(lsnr);
     }
 }
コード例 #23
0
 /// <summary>
 /// Adds the given script as a freezer effect invoker
 /// </summary>
 /// <param name="invoker">invoker</param>
 public static void AddFreezerEffectInvoker(PickupBlock invoker)
 {
     // add invoker to list and add all listeners to invoker
     freezerEffectInvokers.Add(invoker);
     foreach (UnityAction <float> listener in freezerEffectListeners)
     {
         invoker.AddFreezerEffectListener(listener);
     }
 }
コード例 #24
0
ファイル: EventManager.cs プロジェクト: oclipa/Breakout
    public static void AddSpeedupEffectInvoker(PickupBlock speedupEffectInvoker)
    {
        // add the new invoker to the list of invokers
        speedupEffectInvokers.Add(speedupEffectInvoker);

        // ensure that all existing listeners are added to this new invoker
        foreach (UnityAction <float> listener in speedupEffectListeners)
        {
            speedupEffectInvoker.AddSpeedupEffectListener(listener);
        }
    }
コード例 #25
0
ファイル: EventManager.cs プロジェクト: oclipa/Breakout
    public static void AddFreezerEffectInvoker(PickupBlock freezerEffectInvoker)
    {
        // add the new invoker to the list of invokers
        freezerEffectInvokers.Add(freezerEffectInvoker);

        // ensure that all existing listeners are added to this new invoker
        foreach (UnityAction <float> listener in freezerEffectListeners)
        {
            freezerEffectInvoker.AddFreezerEffectListener(listener);
        }
    }
コード例 #26
0
ファイル: EventManager.cs プロジェクト: robmux/Wacky-Breakout
 /// <summary>
 /// Adds the given event handler as a listener
 /// </summary>
 /// <param name="listener"></param>
 public static void AddSpeedUpEffectListener(UnityAction <float, float> listener)
 {
     twoArgsListeners.Add(listener);
     foreach (Block block in invokers)
     {
         PickupBlock pickupBlock = (block as PickupBlock);
         if (pickupBlock != null && pickupBlock.EffectKind.Equals(PickupEffect.Speedup))
         {
             pickupBlock.AddSpeedUpEffectListener(listener);
         }
     }
 }
コード例 #27
0
ファイル: EventManager.cs プロジェクト: robmux/Wacky-Breakout
 /// <summary>
 /// Add the given script as an invoker.
 /// </summary>
 /// <param name="invoker"></param>
 public static void AddSpeedUpInvoker(Block invoker)
 {
     invokers.Add(invoker);
     foreach (UnityAction <float, float> listener in twoArgsListeners)
     {
         PickupBlock pickupBlock = (invoker as PickupBlock);
         if (pickupBlock != null)
         {
             pickupBlock.AddSpeedUpEffectListener(listener);
         }
     }
 }
コード例 #28
0
ファイル: EventManager.cs プロジェクト: robmux/Wacky-Breakout
 /// <summary>
 /// Adds the given event handler as a listener
 /// </summary>
 /// <param name="listener">The event handler</param>
 public static void AddFreezerEffectListener(UnityAction <float> listener)
 {
     listeners.Add(listener);
     foreach (Block block in invokers)
     {
         PickupBlock pickupBlock = (block as PickupBlock);
         if (pickupBlock != null && pickupBlock.EffectKind.Equals(PickupEffect.Freezer))
         {
             pickupBlock.AddFreezerEffectListener(listener);
         }
     }
 }
コード例 #29
0
    // Calculates half width of sprite
    // Calculate probably for each block
    void CreateBlockSquadron()
    {
        Vector2 size      = block.GetComponent <BoxCollider2D>().size;
        float   width     = size.x;
        float   height    = size.y;
        float   halfWidth = size.x / 2;

        for (int i = 0; i < Rows; i++)
        {
            Vector3 spawnPosition = new Vector3(ScreenUtils.ScreenLeft + halfWidth, firstRowHeight, 0);  // ScreenUtils.ScreenTop - top

            while (spawnPosition.x <= ScreenUtils.ScreenRight)
            {
                // 100%
                float randomBlock = Random.Range(0, 101);

                if (randomBlock <= ConfigurationUtils.StandartBlockProbably)
                {
                    Instantiate <GameObject>(block, spawnPosition, Quaternion.identity);
                }
                else if (randomBlock <= bonusProbably)
                {
                    Instantiate <GameObject>(bonusBlock, spawnPosition, Quaternion.identity);
                }
                else if (randomBlock <= freezerProbably)
                {
                    GameObject  pickupGameobject  = Instantiate <GameObject>(pickupBlock, spawnPosition, Quaternion.identity);
                    PickupBlock pickupBlockScript = pickupGameobject.GetComponent <PickupBlock>();
                    pickupBlockScript.Effect = PickupEffect.Freezer;
                }
                else if (randomBlock <= speedupProbably)
                {
                    GameObject  pickupGameobject  = Instantiate <GameObject>(pickupBlock, spawnPosition, Quaternion.identity);
                    PickupBlock pickupBlockScript = pickupGameobject.GetComponent <PickupBlock>();
                    pickupBlockScript.Effect = PickupEffect.Speedup;
                }

                spawnPosition.x += width;
            }
            firstRowHeight -= height + 1;
        }
    }
コード例 #30
0
 public void UpdateUI()
 {
     if (!_selected.go)
     {
         _currentNumberInInventory.text = "";
     }
     else
     {
         PickupBlock tempBlock = _selected.go.GetComponent <PickupBlock>();
         if (tempBlock && tempBlock.value.ToString() != _currentNumberInInventory.text)
         {
             _currentNumberInInventory.text = tempBlock.value.ToString();
         }
     }
     if (_currentNumber.value == 0 || _currentBase.value == 0)
     {
         _startingNumber.text = "";
     }
     else
     {
         _startingNumber.text = "Current Conversion: " + DecimalEncoder.encode(_currentNumber.value, _currentBase.value) + " (" + _currentBase.value.ToString() + ")";
     }
 }