Esempio n. 1
0
    private IEnumerator HandlePlayerTriggeredEvents()
    {
        List <PlayerTriggeredEvent> activatedEvents = new List <PlayerTriggeredEvent>();
        GameObject player = GameObject.FindGameObjectWithTag("Player");

        while (true)
        {
            foreach (PlayerTriggeredEvent e in events)
            {
                if (player.transform.position.x >= e.minimumPositionForTrigger.x && player.transform.position.z >= e.minimumPositionForTrigger.y && e.activated == false)
                {
                    activatedEvents.Add(e);
                    e.activated = true;
                }
            }

            for (int i = activatedEvents.Count - 1; i >= 0; i--)
            {
                PlayerTriggeredEvent a = activatedEvents[i];
                a.timeActive++;
                if (a.type == PlayerTriggeredEventType.DisappearingWorld)
                {
                    GameObject nextBlock = blocks[a.blockIndex + (a.timeActive)];
                    try
                    {
                        DisappearingBlock db = nextBlock.AddComponent <DisappearingBlock>();
                        StartCoroutine(db.ShrinkAndDisappear());
                    }
                    catch { }
                }
                else if (a.type == PlayerTriggeredEventType.BulletRain)
                {
                    Instantiate(bullet, player.transform.position + new Vector3(0f, 10f, 0f), Quaternion.identity);
                }

                if (a.timeActive >= a.timeSpan)
                {
                    activatedEvents.Remove(a);
                }
            }
            yield return(new WaitForSeconds(0.5f));
        }
    }
        public void RemoveBlock(AbstractBlock aBlock, int aAmountOfDisappearingBlocks, int aCurrentBlock)
        {
            Point position = aBlock.GetPosition();

            int animationTime = 30;

            int delayBetweenAnimations = 15;

            int currentBlockDelta = aCurrentBlock * delayBetweenAnimations;

            int totalAnimationtime = aAmountOfDisappearingBlocks * delayBetweenAnimations + animationTime;

            int blockIndex = myGridBundle.Container.myBlocks.LastIndexOf(aBlock);

            if (blockIndex == -1)
            {
                return;
            }
            aBlock = new DisappearingBlock(myGridBundle, ((AbstractColorBlock)aBlock).GetColor(),
                                           totalAnimationtime,
                                           currentBlockDelta);

            myGridBundle.Container.InitializeBlock(position, aBlock);
        }
Esempio n. 3
0
        public DisappearingBlock DisappearingBlockSkin(char type, char part = '0', char side = '0')
        {
            DisappearingBlock block = null;

            switch (type)
            {
            case 'B':
                block = new DisappearingBlock(BrickBlockSpriteSheet)
                {
                    SourceRectangle = new Rectangle(new Point(), new Point(32))
                };
                break;

            case 'F':
                switch (part)
                {
                case 'C':
                    block = new DisappearingBlock(CastleFloor);
                    break;

                case 'U':
                    switch (side)
                    {
                    case 'N':
                        block = new DisappearingBlock(UndergroundFloorNormal);
                        break;

                    case 'R':
                        block = new DisappearingBlock(UndergroundFloorRight);
                        break;

                    case 'L':
                        block = new DisappearingBlock(UndergroundFloorLeft);
                        break;

                    case 'T':
                        block = new DisappearingBlock(UndergroundFloorTop);
                        break;

                    default:
                        block = new DisappearingBlock(UndergroundFloorBlank);
                        break;
                    }
                    break;

                default:
                    block = new DisappearingBlock(FloorBlockSpriteSheet);
                    break;
                }
                break;

            case 'R':
                block = new DisappearingBlock(Rock);
                Rectangle sr = new Rectangle()
                {
                    Size = new Point(32)
                };

                switch (part)
                {
                case 'M':
                    sr.Location = new Point(32);
                    break;

                case 'T':
                    sr.Location = new Point(32, 0);
                    break;

                case 'B':
                    sr.Location = new Point(32, 64);
                    break;

                case 'L':
                    switch (side)
                    {
                    case 'T':
                        sr.Location = new Point(0, 0);
                        break;

                    case 'B':
                        sr.Location = new Point(0, 64);
                        break;

                    default:
                        sr.Location = new Point(0, 32);
                        break;
                    }
                    break;

                case 'R':
                    switch (side)
                    {
                    case 'T':
                        sr.Location = new Point(64, 0);
                        break;

                    case 'B':
                        sr.Location = new Point(64, 64);
                        break;

                    default:
                        sr.Location = new Point(64, 32);
                        break;
                    }
                    break;
                }
                block.SourceRectangle = sr;
                break;

            case 'Y':
                block = new DisappearingBlock(PyramidBlockSpriteSheet);
                break;
            }
            return(block);
        }