Esempio n. 1
0
        private async void Start()
        {
            Delay.Clamp();
            await YuoWait.WaitTimeAsync(Delay);

            gameObject.SetActive(false);
        }
Esempio n. 2
0
        private async void OnEnable()
        {
            Trigger = !Trigger;
            if (Trigger)
            {
                return;
            }
            gameObject.Hide();
            await YuoWait.WaitTimeAsync(Delay);

            gameObject.Show();
        }
Esempio n. 3
0
        public async void Connect()
        {
            foreach (var item in JumpPoints)
            {
                //foreach (var dir in item.jump.Dirs)
                foreach (var dir in Dirs)
                {
                    var Dir = dir;
                    Dir *= -1;
                    bool ThisDirIsOver = false;
                    int  dirNum        = 1;
                    //上下方向的就往左右找,左右方向的就往上下找
                    Vector2Int nextDir1;
                    Vector2Int nextDir2;
                    if (Dir.x == 0)
                    {
                        nextDir1 = Vector2Int.left;
                        nextDir2 = Vector2Int.right;
                    }
                    else
                    {
                        nextDir1 = Vector2Int.up;
                        nextDir2 = Vector2Int.down;
                    }
                    if (true)
                    {
                        List <Branch> branches   = new List <Branch>();
                        Branch        MainBranch = new Branch()
                        {
                            dir = Dir, pos = new Vector2Int(item.x, item.y)
                        };
                        bool over = false;
                        while (!over)
                        {
                            YuoGrid grid = null;
                            if (!MainBranch.Stop)
                            {
                                grid = GetGrid(MainBranch.Next());
                                if (grid == null)
                                {
                                    MainBranch.Stop = true;
                                }
                            }
                            if (!MainBranch.Stop)
                            {
                                if (!grid.CanMove)
                                {
                                    MainBranch.Stop = true;
                                }
                                else
                                {
                                    branches.Add(new Branch()
                                    {
                                        dir = nextDir1, pos = MainBranch.pos
                                    });
                                    branches.Add(new Branch()
                                    {
                                        dir = nextDir2, pos = MainBranch.pos
                                    });
                                }
                                if (grid.CanJump)
                                {
                                    await YuoWait.WaitTimeAsync(0.1f);

                                    DebugConnect(item, grid);
                                    over = true;
                                }
                            }
                            else
                            {
                                bool JumpOut = true;
                                foreach (var b in branches)
                                {
                                    if (!b.Stop)
                                    {
                                        JumpOut = false;
                                    }
                                }
                                if (JumpOut)
                                {
                                    break;
                                }
                            }
                            foreach (var b in branches)
                            {
                                if (b.Stop)
                                {
                                    continue;
                                }
                                var _grid = GetGrid(b.Next());
                                if (_grid == null)
                                {
                                    b.Stop = true;
                                    continue;
                                }
                                if (!_grid.CanMove)
                                {
                                    b.Stop = true;
                                }
                                if (_grid.CanJump)
                                {
                                    await YuoWait.WaitTimeAsync(0.1f);

                                    DebugConnect(item, _grid);
                                    over = true;
                                }
                            }
                        }
                    }
                    else
                    {
                        while (!ThisDirIsOver)
                        {
                            //await YuoWait.WaitTimeAsync(0.01f);
                            //往一个可通行方向一直找
                            Vector2Int startPos = Dir * dirNum + new Vector2Int(item.x, item.y);
                            //print(startPos);
                            var grid = GetGrid(startPos);
                            if (grid == null)
                            {
                                break;
                            }
                            if (!grid.CanMove)
                            {
                                break;
                            }
                            if (grid.CanJump)
                            {
                                ThisDirIsOver = true;
                                await YuoWait.WaitTimeAsync(0.1f);

                                DebugConnect(item, grid);
                                break;
                            }

                            //如果此方向这个位置没有,就开始往两边找

                            int posNum = 1;
                            while (true)
                            {
                                grid = GetGrid(startPos + posNum * nextDir1);
                                if (grid == null)
                                {
                                    break;
                                }
                                if (!grid.CanMove)
                                {
                                    break;
                                }
                                if (grid.CanJump)
                                {
                                    ThisDirIsOver = true;
                                    await YuoWait.WaitTimeAsync(0.1f);

                                    DebugConnect(item, grid);
                                    break;
                                }
                                posNum++;
                            }
                            posNum = 1;
                            while (true)
                            {
                                grid = GetGrid(startPos + posNum * nextDir2);
                                if (grid == null)
                                {
                                    break;
                                }
                                if (!grid.CanMove)
                                {
                                    break;
                                }
                                if (grid.CanJump)
                                {
                                    ThisDirIsOver = true;
                                    await YuoWait.WaitTimeAsync(0.1f);

                                    DebugConnect(item, grid);
                                    break;
                                }
                                posNum++;
                            }
                            dirNum++;
                        }
                    }
                }
            }
        }