Exemplo n.º 1
0
    private void OnMessage(Messages.Param param)
    {
        blocks.RemoveAll(x => x == null);

        switch (param.type)
        {
        case Messages.Type.TurnEnded:
        {
            IsBlockReachedWarn = CheckBlocksReached(2);
            IsBlockReachedDown = CheckBlocksReached(1);
            if (IsBlockReachedDown == false)
            {
                GoNextTurn();
            }
            SendMessageUpwards("CheckMission");
        }
        break;

        case Messages.Type.BlockDead:
        {
            blocks.Remove(param.As <BlockBase>());
            if (blocks.Exists(x => x.IsDangerous) == false)
            {
                transform.parent.Broadcast(Messages.Type.EndTurn);
            }
        }
        break;

        case Messages.Type.UseAbility:
        {
            var ability = param.As <AbilityType>();
            tmpList.Clear();
            tmpList.AddRange(blocks);
            for (int i = 0; i < tmpList.Count; i++)
            {
                tmpList[i].UsedAbility(ability);
            }
            IsBlockReachedWarn = CheckBlocksReached(2);
            IsBlockReachedDown = CheckBlocksReached(1);
            switch (ability)
            {
            case AbilityType.Bomb:
                usedAbilityCount += 15;
                DelayCall(1, GoNextTurn);
                break;

            case AbilityType.Missle: usedAbilityCount += 7; break;

            case AbilityType.Hammer: usedAbilityCount += 3; break;
            }
        }
        break;
        }
    }
Exemplo n.º 2
0
    private void OnMessage(Messages.Param param)
    {
        switch (param.type)
        {
        case Messages.Type.EndTurn:
            var speed = Rigidbody.velocity.magnitude;
            if (speed > 0.1f)
            {
                //var dir = BallManager.SpawnPoint - transform.localPosition + new Vector3(Random.Range(-1f, 1f), -1, 0);
                var dir = new Vector3(Random.Range(-1f, 1f), -3, 0);
                Rigidbody.velocity = dir.normalized * speed;
            }
            break;

        case Messages.Type.TurnEnded:
        {
            Rigidbody.velocity = Vector2.zero;
            Collider.enabled   = false;
            StopAllCoroutines();
            if (Vector3.Distance(transform.localPosition, BallManager.SpawnPoint) > 0.05f)
            {
                StartCoroutine(MoveToMain(param.As <BallManager>()));
            }
        }
        break;
        }
    }
Exemplo n.º 3
0
    private void OnMessage(Messages.Param param)
    {
        switch (param.type)
        {
        case Messages.Type.TurnStarted:
            started = true;
            count   = 0;
            break;

        case Messages.Type.TurnEnded:
            started = false;
            count   = 0;
            break;

        case Messages.Type.BlockDead:
            if (started && param.As <BlockBase>().Type != BlockType.Obstacle)
            {
                var ticks = System.DateTime.Now.Ticks / System.TimeSpan.TicksPerMillisecond;
                var delta = ticks - countTime;
                if (delta > 400)
                {
                    count++;
                    countTime = ticks;
                    CheckCount(param);
                }
            }
            break;
        }
    }
Exemplo n.º 4
0
    private void Display(int index, Messages.Param param)
    {
        var child = transform.GetChild(index);

        if (child == null)
        {
            return;
        }
        var pos   = param.As <BlockBase>().transform.position + Vector3.back;
        var delta = pos - lastPos;

        if (delta.magnitude < 2)
        {
            return;
        }
        lastPos = pos;

        pos.x         *= 0.7f;
        child.position = pos;
        child.gameObject.SetActive(true);
        var particle = child.GetComponent <ParticleSystem>();

        particle.Simulate(0, true, true);
        particle.Play(true);
    }
Exemplo n.º 5
0
    private void OnMessage(Messages.Param param)
    {
        switch (param.type)
        {
        case Messages.Type.StartTurn:
        {
            turnStarted = true;
            float speed = GlobalConfig.Difficulty.startBallSpeed;
            if (BlockManager.blocks.Count < 16)
            {
                speed += speed * (16 - BlockManager.blocks.Count) * 0.05f;
            }
            StartCoroutine(DoStartTurn(param.As <Vector3>().normalized *speed));
            transform.root.Broadcast(Messages.Type.TurnStarted, this);
        }
        break;

        case Messages.Type.EndTurn:
        {
            StopAllCoroutines();
            ballsShooting = false;
            CheckAllBalls();
        }
        break;

        case Messages.Type.BlockDead:
        {
            if (param.Is <BlockBall>())
            {
                var ball = param.As <BlockBall>();
                if (ball.IsPregnant)
                {
                    var newball = SpawnBall(ball.transform.localPosition);
                    newball.Rigidbody.velocity = GlobalConfig.Difficulty.startBallSpeed * new Vector2(Random.Range(-1.0f, 1.0f), Random.Range(-1.0f, 1.0f)).normalized;
                }
            }
        }
        break;
        }
    }
Exemplo n.º 6
0
    public void OnMessage(Messages.Param param)
    {
        switch (param.type)
        {
        case Messages.Type.OnBlockHit:
        {
            if (param.Is <BlockBase>())
            {
                DispatchOnBlockHit(param.As <BlockBase>().Type);
            }
        }
        break;

        case Messages.Type.OnBlockDeath:
        {
            if (param.Is <BlockBase>())
            {
                DispatchOnBlockDeath(param.As <BlockBase>().Type);
            }
        }
        break;
        }
    }
Exemplo n.º 7
0
    private void OnMessage(Messages.Param param)
    {
        sounds.OnMessage(param);

        switch (param.type)
        {
        case Messages.Type.TurnStarted:
            ballsLabel.transform.position = BallManager.SpawnPoint;
            endTurnButton.gameObject.SetActive(true);
            abilityButton.gameObject.SetActive(false);
            UpdateBallText(BallManager.balls.Count);

            if (PlayModel.level.index == 1)
            {
                DelayCall(0.2f, () =>
                {
                    tutorial.transform.GetChild(0).gameObject.SetActive(false);
                    tutorial.transform.GetChild(1).gameObject.SetActive(true);
                    tutorial.transform.GetChild(2).gameObject.SetActive(false);
                    if (tutorial.Display(0, true, 111038, () => Time.timeScale = 1))
                    {
                        Time.timeScale = 0.005f;
                    }
                });
            }
            break;

        case Messages.Type.TurnEnded:
            ballsLabel.transform.position = BallManager.SpawnPoint;
            endTurnButton.gameObject.SetActive(false);
            abilityButton.gameObject.SetActive(true);
            UpdateBallText(BallManager.balls.Count);
            break;

        case Messages.Type.BallCount:
            UpdateBallText(param.As <int>());
            break;

        case Messages.Type.UseAbility:
            abilityButton.transform.SetActiveChild(BlockManager.IsBlockReachedWarn ? 1 : 0);
            break;
        }
    }
Exemplo n.º 8
0
    private void OnMessage(Messages.Param param)
    {
        if (PlayModel.level.targetItem0 < 1 && PlayModel.level.targetItem1 < 1)
        {
            return;
        }

        if (param.Is(Messages.Type.BlockDead) && param.Is <BlockValue>())
        {
            var subject = param.As <BlockValue>();
            if (PlayModel.level.targetItem0 > 0 && subject.ItemIndex == 0)
            {
                StartCoroutine(DoMoveToMissionUi(subject.transform, item0Image.transform.position));
            }
            else if (PlayModel.level.targetItem1 > 0 && subject.ItemIndex == 1)
            {
                StartCoroutine(DoMoveToMissionUi(subject.transform, item1Image.transform.position));
            }
        }
    }