예제 #1
0
    void  Update()
    {
        if (!SessionAssistant.main.CanIGravity())
        {
            return;
        }

        chip = slotForChip.GetChip();

        if (chip)
        {
            return;
        }

        if (slot.GetBlock())
        {
            return;
        }

        if (lastTime + delay > Time.time)
        {
            return;
        }

        lastTime = Time.time;

        if (!auto && slot.y != FieldAssistant.height - 1)
        {
            Destroy(this);
            return;
        }

        FieldAssistant.main.GetNewSimpleChip(slot.x, slot.y, transform.position + new Vector3(0, 0.2f, 0));
    }
예제 #2
0
 public Chip GetChip()
 {
     if (slotForChip)
     {
         return(slotForChip.GetChip());
     }
     return(null);
 }
    // Gravity iteration
    void  GravityReaction()
    {
        if (!SessionAssistant.main.CanIGravity())
        {
            return;                                               // Work is possible only in "Gravity" mode
        }
        chip = slotForChip.GetChip();
        if (!chip)
        {
            return;                // Work is possible only with the chips, otherwise nothing will move
        }
        if (transform.position != chip.transform.position)
        {
            return;                                                        // Work is possible only if the chip is physically clearly in the slot
        }
        if (!slot [Side.Bottom] || !slot [Side.Bottom].gravity)
        {
            return;                                                             // Work is possible only if there is another bottom slot
        }
        // provided that bottom neighbor doesn't contains chip, give him our chip
        if (!slot[Side.Bottom].GetChip())
        {
            slot[Side.Bottom].SetChip(chip);
            GravityReaction();
            return;
        }

        // Otherwise, we try to give it to their neighbors from the bottom-left and bottom-right side
        if (Random.value > 0.5f)           // Direction priority is random
        {
            SlideLeft();
            SlideRight();
        }
        else
        {
            SlideRight();
            SlideLeft();
        }
    }
예제 #4
0
    void  GravityReaction()
    {
        if (!SessionAssistant.main.CanIGravity())
        {
            return;
        }

        chip = slotForChip.GetChip();
        if (!chip)
        {
            return;
        }

        if (transform.position != chip.transform.position)
        {
            return;
        }

        if (slot[Side.Bottom] && slot[Side.Bottom].gravity)
        {
            if (!slot[Side.Bottom].GetChip())
            {
                slot[Side.Bottom].SetChip(chip);
                GravityReaction();
            }
            else if (Random.value > 0.5f)
            {
                SlideLeft();
                SlideRight();
            }
            else
            {
                SlideRight();
                SlideLeft();
            }
        }
    }
예제 #5
0
    void  Update()
    {
        if (!SessionAssistant.main.CanIGravity())
        {
            return;                                                // Generation is possible only in case of mode "gravity"
        }
        if (slotForChip.GetChip())
        {
            return;                                // Generation is impossible, if slot already contains chip
        }
        if (slot.GetBlock())
        {
            return;                          // Generation is impossible, if the slot is blocked
        }
        if (lastTime + delay > Time.time)
        {
            return;                                       // limit of frequency generation
        }
        lastTime = Time.time;

        if (SessionAssistant.main.creatingSugarTask > 0 && !SessionAssistant.main.firstChipGeneration)
        {
            FieldAssistant.main.GetSugarChip(slot.x, slot.y, transform.position + new Vector3(0, 0.2f, 0)); // creating new sugar chip
            SessionAssistant.main.creatingSugarTask--;
            return;
        }

        if (Random.value > LevelProfile.main.stonePortion)
        {
            FieldAssistant.main.GetNewSimpleChip(slot.x, slot.y, transform.position + new Vector3(0, 0.2f, 0));             // creating new chip
        }
        else
        {
            FieldAssistant.main.GetNewStone(slot.x, slot.y, transform.position + new Vector3(0, 0.2f, 0));             // creating new stone
        }
    }