コード例 #1
0
    private void LowerThePack(ArchBlockPack pack, out float waitTime)
    {
        waitTime = 0.0f;
        double betweenRatio = 1.0d;

        for (int i = 0; i < pack.Length; i++)
        {
            var block = pack[i];

            foreach (var other in _StackingArchBlocks)
            {
                if (Mathf.Abs(other.RotationZ - block.RotationZ) < 1.0f)
                {
                    betweenRatio = Math.Min(other.Ratio - block.Ratio, betweenRatio);
                }
            }
        }
        betweenRatio = Math.Ceiling(betweenRatio * 10) * 0.1d;
        for (int i = 0; i < pack.Length; i++)
        {
            var block = pack[i];
            var ratio = Mathf.Min((float)(block.Ratio + betweenRatio - ArchBlock.BlockThicknessD), 1.0f);

            float time = (ratio - block.Ratio + block.RatioOffset + ArchBlock.BlockThicknessF) * BlockLowerTime;
            ArchBlockShooter.Instance.MoveLower(block, (ratio + block.RatioOffset <= block.Ratio ? ratio : ratio + block.RatioOffset), time);

            waitTime = Mathf.Max(waitTime, time);
        }
    }
コード例 #2
0
    private IEnumerator ApperNextPackEnd(ArchBlockPack pack, float time)
    {
        for (float i = 0; i < time; i += Time.deltaTime)
        {
            yield return(null);
        }

        NextArchPack = pack;
    }
コード例 #3
0
    public void ShootOrder()
    {
        if (TargetPack == null && NextArchPack != null)
        {
            TargetPack   = NextArchPack;
            NextArchPack = null;

            Shoot();
        }
    }
コード例 #4
0
    private void Start()
    {
        _StackingArchBlocks = ArchBlockManager.Instance._StackingBlocks;

        _UpdateRoutine = new Coroutine(this);
        _UpdateRoutine.Start(UpdateRoutine());

        _OriginalRotSpeed   = _RotSpeed;
        _SpeedRewindRoutine = new Coroutine(this);

        ArchBlockShooter.Instance.ShootEndEvent += pack =>
        {
            _LastArchPack = pack;

            if (_StackingArchBlocks.Count > 0)
            {
                _UpdateRoutine.Stop();

                float rotZ = ArchBlockManager.Instance.ContactBlock.RotationZ - 90f;
                rotZ = rotZ < 0f ? 360f + rotZ : rotZ;

                float axisAngle = FindCloestAxisAngle(rotZ);
                float closet    = rotZ - axisAngle + pack.FitAxisOffset;

                float time = Mathf.Abs(closet * BlockFittingTimeScale);

                foreach (var archBlock in _StackingArchBlocks)
                {
                    StartCoroutine(FittingRoutine(archBlock, archBlock.RotationZ - closet, time));
                }

                StartCoroutine(PostProcessing(time, () =>
                {
                    for (int i = 0; i < _LastArchPack.Length; i++)
                    {
                        var block = _LastArchPack[i];

                        if (!_StackingArchBlocks.Contains(block))
                        {
                            _StackingArchBlocks.Add(block);
                        }
                    }
                    if (_SpeedRewindRoutine.IsOver)
                    {
                        _SpeedRewindRoutine.Start(SpeedRewindRoutine(SpeedRewindTime));
                    }

                    StartCoroutine(CheckBlockClear());
                }));
            }
            else
            {
                StartCoroutine(PostProcessing(BlockFittingTimeScale * 1.5f, () =>
                {
                    for (int i = 0; i < _LastArchPack.Length; i++)
                    {
                        _StackingArchBlocks.Add(_LastArchPack[i]);
                    }

                    if (_SpeedRewindRoutine.IsOver)
                    {
                        _SpeedRewindRoutine.Start(SpeedRewindRoutine(SpeedRewindTime));
                    }

                    ArchBlockShooter.Instance.TargetPack = null;

                    ArchBlockShooter.Instance.PrepareNextBlock();
                }));
            }
        };
    }