Exemple #1
0
    //接触中
    void OnCollisionStay2D(Collision2D other)
    {
        if (works == WorkType.Moving)
        {
            lock_timer++;
            if (lock_timer == lock_max)
            {
                if (lock_retry < 3)
                {
                    if (destList?.Count > 1)
                    {
                        destList.RemoveAt(0);
                    }
                    var mList = map.tileRing(pos, 1).Where(c => map.chkMoveObj(c, type)).OrderBy(i => System.Guid.NewGuid()).ToList();                  //
                    if (mList?.Count > 1)
                    {
                        destList.Insert(0, MapCtl.offset_stg2vec(mList[0]));
                    }
                    //destList.Insert(0, new Vector2(transform.position.x + UnityEngine.Random.Range(-1, 2), transform.position.y + UnityEngine.Random.Range(-1, 2)));
                    lock_timer = 0;
                    lock_retry++;
                    //List<Vector2Int> Olist = new List<Vector2Int>();
                    //if (destList?.Count > 1) Olist.Add(MapCtl.offset_vec2stg(destList[1]));
                    //doMove(MapCtl.offset_vec2stg(LastDest), null, Olist);

                    /* 3回リトライしても解決しない場合は行動クリア */
                }
                else
                {
                    destList.Clear();
                    chgWorkType(WorkType.None);
                    destDir    = 999;
                    lock_timer = 0;
                    lock_retry = 0;
                }
            }
        }
    }