コード例 #1
0
    void GenerateBlocks()
    {
        GameObject o;
        Slot       s;
        Block      b;

        for (int x = 0; x < field.width; x++)
        {
            for (int y = 0; y < field.height; y++)
            {
                field.blocks[x, y] = LevelProfile.main.GetBlock(x, height - y - 1);
                if (field.slots[x, y] && field.blocks[x, y] > 0)
                {
                    s = GetSlot(x, y);
                    o = ContentAssistant.main.GetItem("Block");
                    o.transform.position = s.transform.position;
                    o.name             = "Block_" + x + "x" + y;
                    o.transform.parent = s.transform;
                    b = o.GetComponent <Block>();
                    s.SetBlock(b);
                    b.slot  = s;
                    b.level = field.blocks[x, y];
                    b.Initialize();
                }
            }
        }

        SlotGravity.Reshading();
    }
コード例 #2
0
ファイル: Block.cs プロジェクト: mengtest/BerryMatchThree
 // Crush block funtion
 override public void  BlockCrush(bool force)
 {
     if (destroying)
     {
         return;
     }
     if (eventCountBorn == SessionAssistant.main.eventCount && !force)
     {
         return;
     }
     eventCountBorn = SessionAssistant.main.eventCount;
     level--;
     if (level == 0)
     {
         slot.SetScore(1);
         slot.block = null;
         SlotGravity.Reshading();
         StartCoroutine(DestroyingRoutine());
         return;
     }
     if (level > 0)
     {
         anim.Play("BlockCrush");
         AudioAssistant.Shot("BlockHit");
         sr.sprite = sprites[level - 1];
     }
 }
コード例 #3
0
ファイル: Branch.cs プロジェクト: dqtoy/jewels2
 public void Initialize()
 {
     gravity         = slot.GetComponent <SlotGravity> ();
     slot.gravity    = false;
     gravity.enabled = false;
     eventCountBorn  = SessionAssistant.main.eventCount;
 }
コード例 #4
0
ファイル: Branch.cs プロジェクト: amisiak7/jewels2
 public void Initialize()
 {
     gravity = slot.GetComponent<SlotGravity> ();
     slot.gravity = false;
     gravity.enabled = false;
     eventCountBorn = SessionAssistant.main.eventCount;
 }
コード例 #5
0
    // Crush block funtion
    override public void  BlockCrush()
    {
        if (eventCountBorn == SessionAssistant.main.eventCount)
        {
            return;
        }
        eventCountBorn = SessionAssistant.main.eventCount;
        GameObject o = ContentAssistant.main.GetItem("BlockCrush");

        o.transform.position = transform.position;
        level--;
        FieldAssistant.main.field.blocks [slot.x, slot.y] = level;
        if (level == 0)
        {
            slot.gravity = true;
            SlotGravity.Reshading();
            Destroy(gameObject);
            return;
        }
        if (level > 0)
        {
            GetComponent <Animation>().Play("BlockCrush");
            sr.sprite = sprites[level - 1];
        }
    }
コード例 #6
0
ファイル: Branch.cs プロジェクト: dqtoy/jewels2
    public override void BlockCrush()
    {
        if (eventCountBorn == SessionAssistant.main.eventCount)
        {
            return;
        }
        if (destroying)
        {
            return;
        }
        eventCountBorn = SessionAssistant.main.eventCount;
        GameObject o = ContentAssistant.main.GetItem("BranchCrush");

        o.transform.position = transform.position;
        slot.gravity         = true;
        SlotGravity.Reshading();
        Destroy(gameObject);
        return;
    }
コード例 #7
0
    IEnumerator DestroyingRoutine()
    {
        destroying = true;

        GameObject o = ContentAssistant.main.GetItem(crush_effect);

        o.transform.position = transform.position;

        AudioAssistant.Shot("WeedCrush");
        anim.Play("JellyDestroy");
        while (anim.isPlaying)
        {
            yield return(0);
        }

        slot.block = null;
        SlotGravity.Reshading();
        Destroy(gameObject);
    }
コード例 #8
0
    // Crush block funtion
    override public void  BlockCrush()
    {
        if (eventCountBorn == SessionAssistant.main.eventCount)
        {
            return;
        }
        if (destroying)
        {
            return;
        }

        lastSwapWithCrush = SessionAssistant.main.swapEvent;

        destroying     = true;
        eventCountBorn = SessionAssistant.main.eventCount;
        GameObject o = ContentAssistant.main.GetItem("WeedCrush");

        o.transform.position = transform.position;

        slot.gravity = true;
        SlotGravity.Reshading();
        Destroy(gameObject);
        return;
    }
コード例 #9
0
    public IEnumerator  CreateField()
    {
        RemoveField();

        field = new Field(LevelProfile.main.GetClone());

        Slot.folder      = new GameObject().transform;
        Slot.folder.name = "Slots";


        Slot.all.Clear();

        Vector3 fieldDimensions = new Vector3(field.width - 1, field.height - 1, 0) * ProjectParameters.main.slot_offset;

        foreach (SlotSettings settings in field.slots.Values)
        {
            yield return(0);

            Slot slot;

            #region Creating a new empty slot
            Vector3    position = new Vector3(settings.position.x, settings.position.y, 0) * ProjectParameters.main.slot_offset - fieldDimensions / 2;
            GameObject obj      = ContentAssistant.main.GetItem("SlotEmpty", position);
            obj.name = "Slot_" + settings.position.x + "x" + settings.position.y;
            obj.transform.SetParent(Slot.folder);
            slot       = obj.GetComponent <Slot>();
            slot.coord = settings.position;
            Slot.all.Add(slot.coord, slot);
            #endregion

            #region Creating a generator
            if (settings.generator)
            {
                slot.gameObject.AddComponent <SlotGenerator>();
            }
            #endregion

            #region Creating a block
            if (settings.block_type != "")
            {
                GameObject b_obj = ContentAssistant.main.GetItem(settings.block_type);
                b_obj.transform.SetParent(slot.transform);
                b_obj.transform.localPosition = Vector3.zero;
                b_obj.name = settings.block_type + "_" + settings.position.x + "x" + settings.position.y;
                IBlock block = b_obj.GetComponent <IBlock>();
                slot.block  = block;
                block.slot  = slot;
                block.level = settings.block_level;
                block.Initialize();
            }
            #endregion

            #region Create a chip
            if (!string.IsNullOrEmpty(settings.chip) && (slot.block == null || slot.block.CanItContainChip()))
            {
                MatchThree.ChipInfo chipInfo = MatchThree.main.chipInfos.Find(x => x.name == settings.chip);
                if (chipInfo != null)
                {
                    string     key   = chipInfo.contentName + (chipInfo.color ? Chip.chipTypes[Mathf.Clamp(settings.color_id, 0, Chip.colors.Length - 1)] : "");
                    GameObject c_obj = ContentAssistant.main.GetItem(key);
                    c_obj.transform.SetParent(slot.transform);
                    c_obj.transform.localPosition = Vector3.zero;
                    c_obj.name = key;
                    slot.chip  = c_obj.GetComponent <Chip>();
                }
            }
            #endregion
        }

        Slot.Initialize();

        List <Pair <int2> > outlines = new List <Pair <int2> >();
        foreach (Slot slot in Slot.all.Values)
        {
            foreach (Side side in Utils.straightSides)
            {
                if (slot[side] != null)
                {
                    continue;
                }

                Pair <int2> pair = new Pair <int2>(slot.coord, slot.coord + Utils.SideOffset(side));
                if (outlines.Contains(pair))
                {
                    continue;
                }

                yield return(0);

                #region Create a outline object
                Vector3 position = new Vector3(Utils.SideOffsetX(side), Utils.SideOffsetY(side), 0) * 0.353f;

                GameObject ol_obj = ContentAssistant.main.GetItem("Outline");
                ol_obj.transform.SetParent(slot.transform);
                ol_obj.transform.localPosition = position;
                ol_obj.name = "Outline_" + side;
                if (Utils.SideOffsetY(side) != 0)
                {
                    ol_obj.transform.Rotate(0, 0, 90);
                }

                outlines.Add(pair);
                #endregion
            }
        }

        SlotGravity.Reshading();

        yield return(0);
    }
コード例 #10
0
 void  Awake()
 {
     slotForChip = GetComponent <SlotForChip>();
     slotGravity = GetComponent <SlotGravity>();
 }
コード例 #11
0
ファイル: Slot.cs プロジェクト: waqasnu/SweetCyCrsh
 void  Awake()
 {
     slotGravity = GetComponent <SlotGravity>();
 }
コード例 #12
0
ファイル: Slot.cs プロジェクト: Bakiet/ZombieMatchSurvival
 void Awake()
 {
     slotForChip = GetComponent<SlotForChip>();
     slotGravity = GetComponent<SlotGravity>();
     slotTeleport = GetComponent<SlotTeleport>();
 }
コード例 #13
0
    // Field generator
    public IEnumerator  CreateField()
    {
        RemoveField();          // Removing old field

        field = new Field(LevelProfile.main.GetClone());

        Slot.folder      = new GameObject().transform;
        Slot.folder.name = "Slots";

        Slot.all.Clear();

        Vector3 fieldDimensions = new Vector3(field.width - 1, field.height - 1, 0) * ProjectParameters.main.slot_offset;

        foreach (SlotSettings settings in field.slots.Values)
        {
            yield return(0);

            Slot slot;

            #region Creating a new empty slot
            Vector3    position = new Vector3(settings.position.x, settings.position.y, 0) * ProjectParameters.main.slot_offset - fieldDimensions / 2;
            GameObject obj      = ContentAssistant.main.GetItem("SlotEmpty", position);
            obj.name = "Slot_" + settings.position.x + "x" + settings.position.y;
            obj.transform.SetParent(Slot.folder);
            slot       = obj.GetComponent <Slot>();
            slot.coord = settings.position;
            Slot.all.Add(slot.coord, slot);
            #endregion

            #region Creating a generator
            if (settings.generator)
            {
                slot.gameObject.AddComponent <SlotGenerator>();
            }
            #endregion

            #region Creating a teleport
            if (settings.teleport != int2.Null)
            {
                slot.slotTeleport.target_postion = settings.teleport;
            }
            else
            {
                Destroy(slot.slotTeleport);
            }
            #endregion

            #region Setting gravity direction
            slot.slotGravity.gravityDirection = settings.gravity;
            #endregion

            #region Setting sugar target (by slot tag)
            if (LevelProfile.main.target == FieldTarget.SugarDrop && settings.tags.Contains("SugarDrop"))
            {
                slot.sugarDropSlot = true;
                GameObject sd = ContentAssistant.main.GetItem("SugarDrop", position);
                sd.name                    = "SugarDrop";
                sd.transform.parent        = slot.transform;
                sd.transform.localPosition = Vector3.zero;
                sd.transform.Rotate(0, 0, Utils.SideToAngle(settings.gravity) + 90);
            }
            #endregion

            #region Creating a block
            if (settings.block_type != "")
            {
                GameObject b_obj = ContentAssistant.main.GetItem(settings.block_type);
                b_obj.transform.SetParent(slot.transform);
                b_obj.transform.localPosition = Vector3.zero;
                b_obj.name = settings.block_type + "_" + settings.position.x + "x" + settings.position.y;
                IBlock block = b_obj.GetComponent <IBlock>();
                slot.block  = block;
                block.slot  = slot;
                block.level = settings.block_level;
                block.Initialize();
            }
            #endregion

            #region Create a jelly
            if (LevelProfile.main.target == FieldTarget.Jelly && settings.jelly_level > 0)
            {
                GameObject j_obj;
                switch (settings.jelly_level)
                {
                case 1: j_obj = ContentAssistant.main.GetItem("SingleLayerJelly");
                    break;

                case 2:
                default: j_obj = ContentAssistant.main.GetItem("Jelly");
                    break;
                }
                j_obj.transform.SetParent(slot.transform);
                j_obj.transform.localPosition = Vector3.zero;
                j_obj.name = "Jelly_" + settings.position.x + "x" + settings.position.y;
                Jelly jelly = j_obj.GetComponent <Jelly>();
                slot.jelly = jelly;
            }
            #endregion

            #region Create a jam
            if (LevelProfile.main.target == FieldTarget.Jam)
            {
                Jam.JamIt(slot, settings.jam);
            }
            #endregion

            #region Create a chip
            if (!string.IsNullOrEmpty(settings.chip) && (slot.block == null || slot.block.CanItContainChip()))
            {
                SessionAssistant.ChipInfo chipInfo = SessionAssistant.main.chipInfos.Find(x => x.name == settings.chip);
                if (chipInfo != null)
                {
                    string     key   = chipInfo.contentName + (chipInfo.color ? Chip.chipTypes[Mathf.Clamp(settings.color_id, 0, Chip.colors.Length - 1)] : "");
                    GameObject c_obj = ContentAssistant.main.GetItem(key);
                    c_obj.transform.SetParent(slot.transform);
                    c_obj.transform.localPosition = Vector3.zero;
                    c_obj.name = key;
                    slot.chip  = c_obj.GetComponent <Chip>();
                }
            }
            #endregion
        }

        Slot.Initialize();

        foreach (int2 coord in field.wall_vertical)
        {
            yield return(0);

            #region Create a vertical wall
            Slot slot = Slot.GetSlot(coord);
            if (slot)
            {
                slot.SetWall(Side.Left);
                slot = slot[Side.Left];
                if (slot)
                {
                    slot.SetWall(Side.Right);
                }
            }
            #endregion
        }

        foreach (int2 coord in field.wall_horizontal)
        {
            yield return(0);

            #region Create a horizontal wall
            Slot slot = Slot.GetSlot(coord);
            if (slot)
            {
                slot.SetWall(Side.Bottom);
                slot = slot[Side.Bottom];
                if (slot)
                {
                    slot.SetWall(Side.Top);
                }
            }
            #endregion
        }

        List <Pair <int2> > walls = new List <Pair <int2> >();
        foreach (Slot slot in Slot.all.Values)
        {
            foreach (Side side in Utils.straightSides)
            {
                if (slot[side] != null)
                {
                    continue;
                }

                Pair <int2> pair = new Pair <int2>(slot.coord, slot.coord + Utils.SideOffset(side));
                if (walls.Contains(pair))
                {
                    continue;
                }

                yield return(0);

                #region Create a wall object
                Vector3 position = new Vector3(Utils.SideOffsetX(side), Utils.SideOffsetY(side), 0) * 0.353f;

                GameObject w_obj = ContentAssistant.main.GetItem("Wall");
                w_obj.transform.SetParent(slot.transform);
                w_obj.transform.localPosition = position;
                w_obj.name = "Wall_" + side;
                if (Utils.SideOffsetY(side) != 0)
                {
                    w_obj.transform.Rotate(0, 0, 90);
                }

                walls.Add(pair);
                #endregion
            }
        }

        SlotGravity.Reshading();

        yield return(0);

        SUBoosterButton.Generate(Slot.folder);

        // 広告用に位置をずらしてます
        Slot.folder.transform.localPosition = new Vector3(0.0f, 0.45f, 0.0f);
    }
コード例 #14
0
ファイル: Slot.cs プロジェクト: mengtest/BerryMatchThree
 void  Awake()
 {
     slotGravity  = GetComponent <SlotGravity>();
     slotTeleport = GetComponent <SlotTeleport>();
 }
コード例 #15
0
    // Generation of destructible blocks
    void GenerateBlocks()
    {
        GameObject o;
        Slot       s;
        Block      b;
        Weed       w;
        Branch     brch;

        for (int x = 0; x < field.width; x++)
        {
            for (int y = 0; y < field.height; y++)
            {
                field.blocks[x, y] = LevelProfile.main.GetBlock(x, height - y - 1);
                if (field.slots[x, y])
                {
                    if (field.blocks[x, y] > 0)
                    {
                        if (field.blocks[x, y] <= 3)
                        {
                            s = GetSlot(x, y);
                            o = ContentAssistant.main.GetItem("Block");
                            o.transform.position = s.transform.position;
                            o.name             = "Block_" + x + "x" + y;
                            o.transform.parent = s.transform;
                            b = o.GetComponent <Block>();
                            s.SetBlock(b);
                            b.slot  = s;
                            b.level = field.blocks[x, y];
                            b.Initialize();
                        }
                        if (field.blocks[x, y] == 4)
                        {
                            s = GetSlot(x, y);
                            o = ContentAssistant.main.GetItem("Weed");
                            o.transform.position = s.transform.position;
                            o.name             = "Weed_" + x + "x" + y;
                            o.transform.parent = s.transform;
                            w = o.GetComponent <Weed>();
                            s.SetBlock(w);
                            w.slot = s;
                            w.Initialize();
                        }
                        if (field.blocks[x, y] == 5)
                        {
                            s = GetSlot(x, y);
                            o = ContentAssistant.main.GetItem("Branch");
                            o.transform.position = s.transform.position;
                            o.name             = "Branch_" + x + "x" + y;
                            o.transform.parent = s.transform;
                            brch = o.GetComponent <Branch>();
                            s.SetBlock(brch);
                            brch.slot = s;
                            brch.Initialize();
                        }
                    }
                }
            }
        }

        SlotGravity.Reshading();
    }