예제 #1
0
    public void SwapTwoItemNow(Chip a, Chip b)
    {
        if (!a || !b)
        {
            return;
        }
        if (a == b)
        {
            return;
        }

        Vector3 posA = a.parentSlot.transform.position;
        Vector3 posB = b.parentSlot.transform.position;

        a.transform.position = posB;
        b.transform.position = posA;

        a.movementID = SessionAssistant.main.GetMovementID();
        b.movementID = SessionAssistant.main.GetMovementID();

        SlotForChip slotA = a.parentSlot;
        SlotForChip slotB = b.parentSlot;

        slotB.SetChip(a);
        slotA.SetChip(b);
    }
예제 #2
0
    public Chip AddPowerup(int x, int y, Powerup p)
    {
//		Debug.Log (p.ToString());
        SlotForChip slot = GetSlot(x, y).GetComponent <SlotForChip> ();
        Chip        chip = slot.chip;
        int         id;

        if (chip)
        {
            id = chip.id;
        }
        else
        {
            id = Random.Range(0, LevelProfile.main.chipCount);
        }
        if (chip)
        {
            Destroy(chip.gameObject);
        }
        switch (p)
        {
        case Powerup.SimpleBomb: chip = FieldAssistant.main.GetNewBomb(slot.slot.x, slot.slot.y, slot.transform.position, id); break;

        case Powerup.CrossBomb: chip = FieldAssistant.main.GetNewCrossBomb(slot.slot.x, slot.slot.y, slot.transform.position, id); break;

        case Powerup.ColorBomb: chip = FieldAssistant.main.GetNewColorBomb(slot.slot.x, slot.slot.y, slot.transform.position, id); break;
        }
        return(chip);
    }
예제 #3
0
 // Function of creation effect of mixing chips based on the pair
 public static void Mix(BombPair pair, SlotForChip slot)
 {
     if (!ContainsPair(pair)) return;
     BombMixEffect effect = ContentAssistant.main.GetItem<BombMixEffect> (data [pair]);
     effect.GetChip().can_move = false;
     effect.GetChip().gravity = false;
     slot.SetChip (effect.GetChip ());
 }
예제 #4
0
 public void  ParentRemove()
 {
     if (!parentSlot)
     {
         return;
     }
     parentSlot.chip = null;
     parentSlot      = null;
 }
예제 #5
0
    // Function of creation effect of mixing chips based on the pair
    public static void Mix(BombPair pair, SlotForChip slot)
    {
        if (!ContainsPair(pair))
        {
            return;
        }
        BombMixEffect effect = ContentAssistant.main.GetItem <BombMixEffect> (data [pair]);

        slot.SetChip(effect.GetChip());
    }
예제 #6
0
    public void AddPowerup(Powerup p)
    {
        SimpleChip[] chips = GameObject.FindObjectsOfType <SimpleChip>();
        if (chips.Length == 0)
        {
            return;
        }
        SimpleChip chip = null;

        while (chip == null || chip.matching)
        {
            chip = chips[Random.Range(0, chips.Length - 1)];
        }
        SlotForChip slot = chip.chip.parentSlot;

        AddPowerup(slot.slot.x, slot.slot.y, p);
    }
예제 #7
0
    IEnumerator SwapTwoItemRoutine(Chip a, Chip b)
    {
        if (swaping)
        {
            yield break;
        }
        if (!a || !b)
        {
            yield break;
        }
        if (!SessionAssistant.main.CanIAnimate())
        {
            yield break;
        }
        switch (LevelProfile.main.target)
        {
        case FieldTarget.Jelly:
        case FieldTarget.Score:
            if (SessionAssistant.main.movesCount <= 0)
            {
                yield break;
            }
            break;

        case FieldTarget.Timer:
            if (SessionAssistant.main.timeLeft <= 0)
            {
                yield break;
            }
            break;
        }

        bool mix = false;

        if (BombMixEffect.ContainsPair(a.chipType, b.chipType))
        {
            mix = true;
        }

        int move = 0;

        SessionAssistant.main.animate++;
        swaping = true;

        Vector3 posA = a.parentSlot.transform.position;
        Vector3 posB = b.parentSlot.transform.position;

        float progress = 0;

        while (progress < swapDuration)
        {
            a.transform.position = Vector3.Lerp(posA, posB, progress / swapDuration);
            if (!mix)
            {
                b.transform.position = Vector3.Lerp(posB, posA, progress / swapDuration);
            }

            progress += Time.deltaTime;

            yield return(0);
        }

        a.transform.position = posB;
        if (!mix)
        {
            b.transform.position = posA;
        }

        a.movementID = SessionAssistant.main.GetMovementID();
        b.movementID = SessionAssistant.main.GetMovementID();

        if (mix)
        {
            swaping = false;
            BombPair    pair = new BombPair(a.chipType, b.chipType);
            SlotForChip slot = b.parentSlot;
            a.HideChip();
            b.HideChip();
            BombMixEffect.Mix(pair, slot);
            SessionAssistant.main.movesCount--;
            SessionAssistant.main.animate--;
            yield break;
        }

        SlotForChip slotA = a.parentSlot;
        SlotForChip slotB = b.parentSlot;

        slotB.SetChip(a);
        slotA.SetChip(b);


        move++;

        int count = 0;

        SessionAssistant.Solution solution;

        solution = slotA.MatchAnaliz();
        if (solution != null)
        {
            count += solution.count;
        }

        solution = slotB.MatchAnaliz();
        if (solution != null)
        {
            count += solution.count;
        }


        if (count == 0 && !forceSwap)
        {
            AudioAssistant.Shot("SwapFailed");
            while (progress > 0)
            {
                a.transform.position = Vector3.Lerp(posA, posB, progress / swapDuration);
                b.transform.position = Vector3.Lerp(posB, posA, progress / swapDuration);

                progress -= Time.deltaTime;

                yield return(0);
            }

            a.transform.position = posA;
            b.transform.position = posB;

            a.movementID = SessionAssistant.main.GetMovementID();
            b.movementID = SessionAssistant.main.GetMovementID();

            slotB.SetChip(b);
            slotA.SetChip(a);

            move--;
        }
        else
        {
            AudioAssistant.Shot("SwapSuccess");
        }

        SessionAssistant.main.movesCount -= move;
        SessionAssistant.main.MatchingCounter();

        SessionAssistant.main.animate--;
        swaping = false;
    }
예제 #8
0
 // Function of creation effect of mixing chips based on the pair
 public static void Mix(string pa, string pb, SlotForChip slot)
 {
     Mix (new BombPair (pa, pb), slot);
 }
예제 #9
0
 void Awake()
 {
     slot = GetComponent<Slot>();
     slotForChip = GetComponent<SlotForChip>();
 }
예제 #10
0
 void  Awake()
 {
     slotForChip = GetComponent <SlotForChip>();
     slotGravity = GetComponent <SlotGravity>();
 }
예제 #11
0
 void Awake()
 {
     slotForChip = GetComponent<SlotForChip>();
     slotGravity = GetComponent<SlotGravity>();
     slotTeleport = GetComponent<SlotTeleport>();
 }
예제 #12
0
파일: Chip.cs 프로젝트: amisiak7/jewels2
 // separation of the chips from the parent slot
 public void ParentRemove()
 {
     if (!parentSlot) return;
     parentSlot.chip = null;
     parentSlot = null;
 }
 void  Awake()
 {
     slot        = GetComponent <Slot>();
     slotForChip = GetComponent <SlotForChip>();
 }
예제 #14
0
    float delay    = 0.15f;  // delay between the generations

    void  Awake()
    {
        slot           = GetComponent <Slot>();
        slot.generator = true;
        slotForChip    = GetComponent <SlotForChip>();
    }
예제 #15
0
 // Function of creation effect of mixing chips based on the pair
 public static void Mix(string pa, string pb, SlotForChip slot)
 {
     Mix(new BombPair(pa, pb), slot);
 }
    // Coroutine swapping 2 chips
    IEnumerator SwapTwoItemRoutine(Chip a, Chip b)
    {
        // cancellation terms
        if (swaping)
        {
            yield break;                  // If the process is already running
        }
        if (!a || !b)
        {
            yield break;                   // If one of the chips is missing
        }
        if (a.parentSlot.slot.GetBlock() || b.parentSlot.slot.GetBlock())
        {
            yield break;                                                                       // If one of the chips is blocked
        }
        if (!SessionAssistant.main.CanIAnimate())
        {
            yield break;                                               // If the core prohibits animation
        }
        switch (LevelProfile.main.limitation)
        {
        case Limitation.Moves:
            if (SessionAssistant.main.movesCount <= 0)
            {
                yield break;
            }
            break;                                                                             // If not enough moves

        case Limitation.Time:
            if (SessionAssistant.main.timeLeft <= 0)
            {
                yield break;
            }
            break;                                                                           // If not enough time
        }

        bool mix = false;                                       // The effect of mixing or not

        if (BombMixEffect.ContainsPair(a.chipType, b.chipType)) // Checking the possibility of mixing
        {
            mix = true;
        }

        int move = 0;         // Number of points movement which will be expend

        SessionAssistant.main.animate++;
        swaping = true;

        Vector3 posA = a.parentSlot.transform.position;
        Vector3 posB = b.parentSlot.transform.position;

        float progress = 0;

        Vector3 normal = a.parentSlot.slot.x == b.parentSlot.slot.x ? Vector3.right : Vector3.up;

        // Animation swapping 2 chips
        while (progress < swapDuration)
        {
            a.transform.position = Vector3.Lerp(posA, posB, progress / swapDuration) + normal * Mathf.Sin(3.14f * progress / swapDuration) * 0.2f;
            if (!mix)
            {
                b.transform.position = Vector3.Lerp(posB, posA, progress / swapDuration) - normal * Mathf.Sin(3.14f * progress / swapDuration) * 0.2f;
            }

            progress += Time.deltaTime;

            yield return(0);
        }

        a.transform.position = posB;
        if (!mix)
        {
            b.transform.position = posA;
        }

        a.movementID = SessionAssistant.main.GetMovementID();
        b.movementID = SessionAssistant.main.GetMovementID();

        if (mix)           // Scenario mix effect
        {
            swaping = false;
            BombPair    pair = new BombPair(a.chipType, b.chipType);
            SlotForChip slot = b.parentSlot;
            a.HideChip();
            b.HideChip();
            BombMixEffect.Mix(pair, slot);
            SessionAssistant.main.movesCount--;
            SessionAssistant.main.animate--;
            yield break;
        }

        // Scenario the effect of swapping two chips
        SlotForChip slotA = a.parentSlot;
        SlotForChip slotB = b.parentSlot;

        slotB.SetChip(a);
        slotA.SetChip(b);


        move++;

        // searching for solutions of matching
        int count = 0;

        SessionAssistant.Solution solution;

        solution = slotA.MatchAnaliz();
        if (solution != null)
        {
            count += solution.count;
        }

        solution = slotB.MatchAnaliz();
        if (solution != null)
        {
            count += solution.count;
        }

        // Scenario canceling of changing places of chips
        if (count == 0 && !forceSwap)
        {
            AudioAssistant.Shot("SwapFailed");
            while (progress > 0)
            {
                a.transform.position = Vector3.Lerp(posA, posB, progress / swapDuration) - normal * Mathf.Sin(3.14f * progress / swapDuration) * 0.2f;
                b.transform.position = Vector3.Lerp(posB, posA, progress / swapDuration) + normal * Mathf.Sin(3.14f * progress / swapDuration) * 0.2f;

                progress -= Time.deltaTime;

                yield return(0);
            }

            a.transform.position = posA;
            b.transform.position = posB;

            a.movementID = SessionAssistant.main.GetMovementID();
            b.movementID = SessionAssistant.main.GetMovementID();

            slotB.SetChip(b);
            slotA.SetChip(a);

            move--;
        }
        else
        {
            AudioAssistant.Shot("SwapSuccess");
            SessionAssistant.main.swapEvent++;
        }

        SessionAssistant.main.firstChipGeneration = false;

        SessionAssistant.main.movesCount -= move;
        SessionAssistant.main.EventCounter();

        SessionAssistant.main.animate--;
        swaping = false;
    }
예제 #17
0
 void Awake()
 {
     slot = GetComponent<Slot>();
     slot.generator = true;
     slotForChip = GetComponent<SlotForChip>();
 }