コード例 #1
0
ファイル: UIManager.cs プロジェクト: filthmancer/greatgrand
 public void SetGrandUI(GreatGrand g)
 {
     /*UIObj info = GrandUI["info"];
      * UIObj face = GrandUI["face"];
      *
      * info.Txt[0].text = g.Info.Name;
      * info.Txt[1].text = g.Info.Age+"";
      * info.Txt[2].text = "";
      *
      * if(ActiveFace != null)
      * {
      *
      *      Destroy(ActiveFace.gameObject);
      *      face.Child = new UIObj[0];
      * }
      *
      * if(g.Face != null)
      * {
      *      ActiveFace = g.CloneFace();
      *
      *      face.AddChild(ActiveFace);
      *
      *      ActiveFace.transform.localPosition = Vector3.zero;
      *      ActiveFace.transform.localScale = Vector3.one * 0.35F;
      *
      *      ActiveFace.transform.localRotation = Quaternion.Euler(0,0,0);
      * }*/
 }
コード例 #2
0
    public void GenerateGrumpsReal(GreatGrand g, int num)
    {
        _Grump [] final = new _Grump[num];
        for (int i = 0; i < num; i++)
        {
            bool has_targ = false;

            GrumpObj targ = null;

            while (!has_targ)
            {
                targ     = GetRandomGG(g);
                has_targ = true;

                for (int x = 0; x < i; x++)
                {
                    if (final[x].Target == targ)
                    {
                        has_targ = false;
                    }
                }
            }
            int  dist = _TableManager.SeatDistance(targ as GreatGrand, g);
            bool like = false;
            if (dist == 1)
            {
                like = true;
            }

            final[i] = new _Grump(like, g, targ);
        }
        g.Grumps = final;
    }
コード例 #3
0
    public void CreateDinner(int d = 0)
    {
        Running = false;

        FOBJ fparent = MOB["faceparent"];

        Difficulty = d;
        Grands     = new GreatGrand[GGNum];

        _TableManager.SetupTable(Difficulty);
        Faces = new Face[GGNum];

        List <GrandData> hungry = GameManager.Data.SortResidentsBy(AlertType.Hunger);

        Guests = new List <GreatGrand>();
        for (int i = 0; i < GGNum; i++)
        {
            if (i < hungry.Count && hungry[i].Hunger.Current < 95)
            {
                Grands[i] = hungry[i].GrandObj;
            }
            else
            {
                GreatGrand g = GameManager.Generator.GenerateGuest();
                Guests.Add(g);
                g.transform.SetParent(GameManager.Data.GuestParent.transform);
                Grands[i] = g;
            }

            Faces[i] = GameManager.Generator.GenerateNewFace(Grands[i].Data);
            fparent.AddChild(Faces[i]);

            Grands[i].Data.TargetFace = (Faces[i]);
            SetupFace(Faces[i], Grands[i]);
        }

        for (int i = 0; i < GGNum; i++)
        {
            SitImmediate(Grands[i], _TableManager.Seat[i]);
        }

        for (int i = 0; i < GGNum; i++)
        {
            int gnum = 1 + Random.Range(0, Difficulty);
            //if(Random.value > 0.8F) gnum ++;
            GenerateGrumpsReal(Grands[i], gnum);
        }

        GG_Indexes = new int[0];
        while (NumberHappy > GGNum / 2)
        {
            GG_Indexes = ShuffleGG();
        }

        for (int i = 0; i < GGNum; i++)
        {
            Faces[i].SetActive(false);
        }
    }
コード例 #4
0
 public int SeatDistance(GreatGrand a, GrumpObj b)
 {
     if (b is GreatGrand)
     {
         return(SeatDistance(a, b as GreatGrand));
     }
     return(0);
 }
コード例 #5
0
    public IEnumerator Exit(GreatGrand g, float time)
    {
        Transform t = g.TargetFace.transform;

        g.isSeated = false;
        Vector3 d     = ExitDoor.position;
        Vector3 start = GetMovementPointAtSeat(g.Seat.Index);
        Vector3 end   = GetMovementPoint(0.5F);

        float start_norm = GetMovementNormalAtSeat(g.Seat.Index);
        float end_norm   = 0.5F;
        float movenorm   = end_norm - start_norm;

        /*float getup_init = 0.3F;
         * float getup_time = 0.0F;
         * while((getup_time += Time.deltaTime) < getup_init)
         * {
         *      t.position = Vector3.Lerp(d, start, getup_time/getup_init);
         *      t.LookAt(TableObj.transform.position);
         *      t.rotation *= Quaternion.Euler(x_rot, 0,180);
         *      yield return null;
         * }*/

        float timer     = 0.0F;
        float norm      = start_norm;
        float norm_rate = movenorm / time;

        while ((timer += Time.deltaTime) < time)
        {
            t.position = GetMovementPoint(norm);
            t.LookAt(ExitDoor.transform.position, Vector3.forward);
            t.rotation *= Quaternion.Euler(x_rot, 0, 180);
            norm       += norm_rate * Time.deltaTime;
            if (norm < 0.0F)
            {
                norm = 1.0F;
            }
            if (norm > 1.0F)
            {
                norm = 0.0F;
            }
            yield return(null);
        }

        float sitdown_init = 0.3F;
        float sitdown_time = 0.0F;

        while ((sitdown_time += Time.deltaTime) < sitdown_init)
        {
            t.position = Vector3.Lerp(end, d, sitdown_time / sitdown_init);
            //t.rotation = Quaternion.Slerp(t.rotation,
            //							Seat[seat].Rotation * Quaternion.Euler(5, 180,180),
            //							sitdown_time/sitdown_init);
            yield return(null);
        }
        //g.isSeated = true;
        yield return(null);
    }
コード例 #6
0
 public void GenerateGrumpsPrimitive(GreatGrand g, int num)
 {
     g.Grumps = new _Grump[num];
     for (int i = 0; i < num; i++)
     {
         GrumpObj targ = GetRandomGG(g);
         _Grump   newg = new _Grump(false, g, targ);
         g.Grumps[i] = newg;
     }
 }
コード例 #7
0
    public void ReleaseTarget()
    {
        drag_targ = _TableManager.NearestSeat(GameManager.InputPos);
        DragSit(Target, drag_targ);

        //if(drag_targ.CanSeat(Target) && drag_targ != Target.Seat) Target.DragSit(drag_targ);
        //else
        isDragging = false;
        Target     = null;
    }
コード例 #8
0
    public GreatGrand GetRandomGG(GreatGrand g)
    {
        GreatGrand final = Grands[Random.Range(0, Grands.Length)];

        while (final == g)
        {
            final = Grands[Random.Range(0, Grands.Length)];
        }
        return(final);
    }
コード例 #9
0
ファイル: Generator.cs プロジェクト: filthmancer/greatgrand
    public GreatGrand Randomise()
    {
        GreatGrand final = (GreatGrand)Instantiate(GGObj);

        final.Generate(0);

        FaceObj _base = RandomiseFace(final);

        final.SetFace(_base);
        TitleObj.text = final.Data.Info.Name + "\nAge " + final.Data.Age.Value;
        return(final);
    }
コード例 #10
0
ファイル: Generator.cs プロジェクト: filthmancer/greatgrand
    public GreatGrand GenerateGuest()
    {
        GrandData guest = GenerateGrand();

        guest.RoleType = Role.Visitor;
        guest.Hunger.Set(Random.Range(25, 50));
        guest.Social.Set(Random.Range(25, 50));
        guest.Fitness.Set(Random.Range(25, 50));
        GreatGrand fin = Generate(guest);

        return(fin);
    }
コード例 #11
0
    public void SetupFace(Face f, GreatGrand g)
    {
        f.AddAction(TouchAction.Down, () =>
        {
            SetTarget(g);
        });

        /*	f.AddAction(TouchAction.Up, () =>
         *      {
         *
         *      });*/
    }
コード例 #12
0
ファイル: Generator.cs プロジェクト: filthmancer/greatgrand
    public GreatGrand Generate(int num)
    {
        GreatGrand final = (GreatGrand)Instantiate(GGObj);

        final.Generate(num);
        final.Data.Hex      = System.Guid.NewGuid();
        final.Data.RoleType = Role.Visitor;
        final.Data.GrandObj = final;
        RandomiseGrandData(final.Data);
        RandomiseFaceData(final.Data);
        final.gameObject.name = final.Data.Info.Name + "-" + final.Data.RoleType;
        return(final);
    }
コード例 #13
0
ファイル: Generator.cs プロジェクト: filthmancer/greatgrand
    public FaceObj GenerateFace(GreatGrand targ)
    {
        GameObject _base = (GameObject)Instantiate(targ.Data.Info.Base.Obj);

        FaceObj final = _base.GetComponent <FaceObj>();

        final.SetSkinColor(targ.Data.Info.C_Skin);
        final.SetHairColor(targ.Data.Info.C_Hair);
        final.SetOffsetColor(targ.Data.Info.C_Offset);
        final.SetNoseColor(targ.Data.Info.C_Nose);

        targ.SetFace(final);
        final._Name = targ.Data.Info.Name;
        _base.name  = targ.Data.Info.Name;
        return(final);
    }
コード例 #14
0
ファイル: GameManager.cs プロジェクト: filthmancer/greatgrand
    public void SetTargetGrand(GreatGrand g)
    {
        if (g != null)
        {
            if (TargetGrand != null)
            {
                TargetGrand.Release(InputPos);
            }
            else
            {
                g.Tap(InputPos);
            }
        }

        UI.SetGrandUI(g);
        TargetGrand = g;
    }
コード例 #15
0
ファイル: Generator.cs プロジェクト: filthmancer/greatgrand
    public GreatGrand Generate(GrandData g)
    {
        GreatGrand final = (GreatGrand)Instantiate(GGObj);

        final.Data          = g;
        final.Data.GrandObj = final;

        Transform p = GameManager.Data.ResidentParent.transform;

        if (g.RoleType == Role.Visitor)
        {
            p = GameManager.Data.GuestParent.transform;
        }
        final.transform.SetParent(p);
        final.gameObject.name = final.Data.Info.Name + "-" + final.Data.RoleType;
        return(final);
    }
コード例 #16
0
    public int SeatDistance(GreatGrand a, GreatGrand b)
    {
        if (a.Seat == null || b.Seat == null)
        {
            return(0);
        }
        int ai = a.Seat.Index;
        int bi = b.Seat.Index;

        if (ai > bi + Seat.Length / 2)
        {
            bi += Seat.Length;
        }
        if (bi > ai + Seat.Length / 2)
        {
            ai += Seat.Length;
        }
        return(Mathf.Abs(ai - bi));
    }
コード例 #17
0
ファイル: Generator.cs プロジェクト: filthmancer/greatgrand
    public FaceObj RandomiseFace(GreatGrand f)
    {
        /*Eye.Randomise(Vector3.zero);
         * Brow.Randomise(Vector3.zero);
         * Ear.Randomise(Vector3.zero);
         * Jaw.Randomise(Vector3.zero, 0.0F);
         * Hair.Randomise(Vector3.zero, 0.0F, 0.0F);
         * Nose.Randomise(Vector3.zero);
         * Base.Randomise(Vector3.zero, 0.0F, 0.15F);*/

        SkinCurrent   = SkinGrad.Evaluate(Random.value);
        HairCurrent   = HairGrad.Evaluate(Random.value);
        OffsetCurrent = Random.ColorHSV();

        FaceObj fin = GenerateFace(f);

        //CheckDifferences(fin);
        return(fin);
    }
コード例 #18
0
ファイル: Module.cs プロジェクト: filthmancer/greatgrand
    public List <_Grump> GetRelatedGrumps(GreatGrand g)
    {
        List <_Grump> fin = new List <_Grump>();

        for (int i = 0; i < Grands.Length; i++)
        {
            if (Grands[i] == g)
            {
                continue;
            }
            for (int x = 0; x < Grands[i].Grumps.Length; x++)
            {
                if (Grands[i].Grumps[x].Target == g)
                {
                    fin.Add(Grands[i].Grumps[x]);
                }
            }
        }
        return(fin);
    }
コード例 #19
0
    public void DragSit(GreatGrand t, _Seat s)
    {
        if (s == null)
        {
            return;
        }

        if (s.Target && s.Target != t)
        {
            t.Seat.Target = null;

            StartCoroutine(SitAt(s.Target, t.Seat));
        }

        t.Seat = s;
        t.Seat.SetTarget(t);

        t.TargetFace.transform.position = t.Seat.Position;
        t.TargetFace.transform.rotation = t.Seat.Rotation;
        t.isSeated = true;
    }
コード例 #20
0
    public void SitImmediate(GreatGrand t, _Seat s)
    {
        if (s == null)
        {
            return;
        }

        if (s.Target)
        {
            _Seat temp = t.Seat;
            t.Seat = null;
            SitImmediate(s.Target, temp);
        }

        t.Seat = s;
        t.Seat.SetTarget(t);

        t.TargetFace.transform.position = s.Position;
        t.TargetFace.transform.rotation = s.Rotation;
        t.isSeated = true;
    }
コード例 #21
0
    public IEnumerator SitAt(GreatGrand t, _Seat s)
    {
        if (s == null)
        {
            yield break;
        }
        int ind = t.Seat.Index;

        if (s.Target && s.Target != t)
        {
            t.Seat.Target = null;
            StartCoroutine(s.Target.SitAt(t.Seat));
        }

        yield return(StartCoroutine(_TableManager.MoveSeat(t, ind, s.Index, 0.22F)));

        t.Seat = s;
        t.Seat.SetTarget(t);

        t.TargetFace.transform.position = t.Seat.Position;
        t.TargetFace.transform.rotation = t.Seat.Rotation;
        t.isSeated = true;
    }
コード例 #22
0
    public IEnumerator MoveSeat(GreatGrand g, int from, int to, float time)
    {
        Transform t = g.TargetFace.transform;

        g.isSeated = false;
        Vector3 start = GetMovementPointAtSeat(from);
        Vector3 end   = GetMovementPointAtSeat(to);

        if (start == end)
        {
            yield break;
        }

        float start_norm = GetMovementNormalAtSeat(from);
        float end_norm   = GetMovementNormalAtSeat(to);

        //Checking to see if clockwise or anticlockwise movement will be faster
        float movenorm = 0.0F, clockwise, anticlock;

        if (end_norm > start_norm)
        {
            clockwise = end_norm - start_norm;
            anticlock = (1.0F + start_norm) - end_norm;
        }
        else
        {
            clockwise = start_norm - (end_norm + 1.0F);
            anticlock = end_norm - start_norm;
        }

        if (Mathf.Abs(clockwise) < Mathf.Abs(anticlock))
        {
            movenorm = clockwise;
        }
        else
        {
            movenorm = anticlock;
        }

        float timer       = 0.0F;
        float timer_total = Mathf.Clamp(1.1F * Mathf.Abs(movenorm), 0.2F, 0.9F);

        float norm      = start_norm;
        float norm_rate = movenorm / timer_total;

        float getup_init = 0.05F;
        float getup_time = 0.0F;

        while ((getup_time += Time.deltaTime) < getup_init)
        {
            t.position = Vector3.Lerp(Seat[from].transform.position, start, getup_time / getup_init);
            t.LookAt(TableObj.transform.position, Vector3.up);
            t.rotation *= Quaternion.Euler(x_rot, 180, 0);
            yield return(null);
        }

        while ((timer += Time.deltaTime) < timer_total)
        {
            t.position = GetMovementPoint(norm);
            t.LookAt(TableObj.transform.position, Vector3.up);
            t.rotation *= Quaternion.Euler(x_rot, 180, 0);

            norm += norm_rate * Time.deltaTime;
            if (norm < 0.0F)
            {
                norm = 1.0F;
            }
            if (norm > 1.0F)
            {
                norm = 0.0F;
            }
            yield return(null);
        }

        float sitdown_init = 0.05F;
        float sitdown_time = 0.0F;

        while ((sitdown_time += Time.deltaTime) < sitdown_init)
        {
            t.position           = Vector3.Lerp(end, Seat[to].Position, sitdown_time / sitdown_init);
            t.transform.rotation = Quaternion.Slerp(t.transform.rotation,
                                                    Seat[to].Rotation,
                                                    sitdown_time / sitdown_init);
            yield return(null);
        }
        g.isSeated = true;
        yield return(null);
    }
コード例 #23
0
 public bool CanSeat(GreatGrand g)
 {
     return(CanBeSwapped);
 }
コード例 #24
0
 public void SetTarget(GreatGrand g)
 {
     Target = g;
 }
コード例 #25
0
ファイル: GameData.cs プロジェクト: filthmancer/greatgrand
 public _Grump(bool like, GreatGrand p, GrumpObj t = null)
 {
     Parent  = p;
     Target  = t;
     LikesIt = like;
 }
コード例 #26
0
    IEnumerator EndGame()
    {
        while (!AllSeated)
        {
            yield return(null);
        }

        UIObj endgame = MUI["endgame"];

        Running = false;
        GameManager.IgnoreInput = true;
        timerobj.Txt[0].text    = "";
        timerobj.Txt[1].text    = "";

        if (!GameManager.WorldRes.Funds.Charge(DinnerCost))
        {
            endgame[0].TweenActive(true);
            endgame[1].SetActive(false);
            endgame[2].SetActive(false);

            endgame[0].Txt[0].text = "No Funds!";

            FinalScore = 0;

            yield return(new WaitForSeconds(0.8F));

            endgame[0].TweenActive(false);

            yield return(StartCoroutine(FinishDinner()));

            yield break;
        }

        endgame[0].TweenActive(true);
        endgame[1].SetActive(false);
        endgame[2].SetActive(false);

        endgame[0].Txt[0].text = "Let's Eat!";

        FinalScore = 0;

        yield return(new WaitForSeconds(0.85F));

        endgame[0].TweenActive(false);

        List <FOBJ> correct = new List <FOBJ>();
        List <FOBJ> wrong   = new List <FOBJ>();

        for (int i = 0; i < _TableManager.Seat.Length; i++)
        {
            GreatGrand grand = _TableManager.Seat[i].Target;

            if (grand == null)
            {
                continue;
            }

            int targ_grumps = grand.GetGrumps(false);
            yield return(new WaitForSeconds(Time.deltaTime * 5));

            Sprite s = targ_grumps >= 0 ? Alert_Right :  Alert_Wrong;

            FOBJ a = Instantiate(GameManager.UI.Prefabs.GetObject("FOBJ_Default") as GameObject).GetComponent <FOBJ>();
            (a as FIRL).IMG[0].sprite = s;
            a.SetActive(false);
            a.transform.position   = grand.TargetFace.pos - Vector3.forward * 1;
            a.transform.localScale = Vector3.one * 1.8F;
            a.TweenActive(true);

            if (targ_grumps >= 0)
            {
                correct.Add(a);
            }
            else
            {
                wrong.Add(a);
            }

            yield return(new WaitForSeconds(0.12F));
        }

        UIObj info = MUI["kitchen"];

        info.Txt[1].text = "HAPPY\nGRANDS";
        info.Txt[0].text = FinalScore + "";

        Tweens.Bounce(info.transform);
        info.TweenActive(true);
        yield return(new WaitForSeconds(0.5F));

        bool isCounting = true;

        for (int i = 0; i < correct.Count; i++)
        {
            SendCorrectAlert(correct[i], info.transform);
        }

        for (int i = 0; i < wrong.Count; i++)
        {
            wrong[i].transform.DOScale(Vector3.zero, 0.3F).OnComplete(() => {});
        }

        while (isCounting)
        {
            info.Txt[0].text = FinalScore + "";
            bool complete = true;
            for (int i = 0; i < correct.Count; i++)
            {
                if (correct[i] != null)
                {
                    complete = false;
                    break;
                }
            }
            if (complete)
            {
                isCounting = false;
            }
            yield return(null);
        }

        int rep = (int)((FinalScore * 5) * (1.0F + (Difficulty * Bonus_DifficultyMultiplier)));

        info.Txt[0].text = rep + "";

        if (GameTime < Timer)
        {
            yield return(new WaitForSeconds(0.4F));

            float mult = 1.0F - (GameTime / Timer * Bonus_TimerDecay);
            mult              = Mathf.Clamp(1.0F + mult, 1.0F, Bonus_TimerMax);
            rep               = (int)((float)rep * mult);
            info.Txt[0].text  = rep + "";
            info.Txt[1].text  = "TIME\nBONUS";
            info.Txt[1].color = Color.green;

            Tweens.Bounce(info.transform);
            yield return(null);
        }

        if (FinalScore == GGNum)
        {
            yield return(new WaitForSeconds(0.4F));

            rep = (int)((float)rep * Bonus_Perfect);
            info.Txt[0].text  = rep + "";
            info.Txt[1].text  = "PERFECT!";
            info.Txt[1].color = Color.blue;

            Tweens.Bounce(info.transform);
            yield return(null);
        }

        yield return(new WaitForSeconds(0.4F));

        StartCoroutine(GameManager.UI.ResourceAlert(GameManager.WorldRes.Rep, rep));

        List <FIRL> alerts = new List <FIRL>();

        for (int i = 0; i < _TableManager.Seat.Length; i++)
        {
            GrandData g = _TableManager.Seat[i].Target.Data;
            FIRL      a = GameManager.UI.MeterAlert(g, AlertType.Hunger);
            alerts.Add(a);
            Tweens.Bounce(a.transform);
            yield return(null);
        }

        //FUTURE ANIMATION OF GRANDS EATING
        yield return(new WaitForSeconds(0.3F));

//$$$$$$$
        int   hungerticks = 10 + FinalScore * 10;
        int   ticks       = 0;
        float tickrate    = 1;

        while (true)
        {
            for (int i = 0; i < _TableManager.Seat.Length; i++)
            {
                GrandData g = _TableManager.Seat[i].Target.Data;
                g.Hunger.Add((int)tickrate);
                alerts[i][0].transform.localScale = new Vector3(g.Hunger.Ratio, 1.0F, 1.0f);
            }
            ticks    += (int)tickrate;
            tickrate *= 1.1F;
            if (ticks >= hungerticks)
            {
                break;
            }
            yield return(null);
        }
        yield return(new WaitForSeconds(0.3F));

        for (int i = 0; i < alerts.Count; i++)
        {
            alerts[i].PoolDestroy();
        }

        yield return(new WaitForSeconds(0.5F));

        yield return(StartCoroutine(FinishDinner()));
    }
コード例 #27
0
 public void SetTarget(GreatGrand g)
 {
     Target = g;
     StartCoroutine(GrumpAlert(Target.Grumps[0]));
     //Target.ShowGrumpLines();
 }
コード例 #28
0
    public IEnumerator DoorToSeat(GreatGrand g, int seat, float time)
    {
        Transform t = g.TargetFace.transform;

        g.isSeated = false;
        Vector3 d     = EntryDoor.position;
        Vector3 start = GetMovementPoint(0.0F);
        Vector3 end   = GetMovementPointAtSeat(seat);

        float start_norm = 0.0F;
        float end_norm   = GetMovementNormalAtSeat(seat);
        float movenorm   = end_norm - start_norm;

        float getup_init = 0.3F;
        float getup_time = 0.0F;

        while ((getup_time += Time.deltaTime) < getup_init)
        {
            t.position = Vector3.Lerp(d, start, getup_time / getup_init);
            //t.LookAt(TableObj.transform.position, Vector3.up);
            //t.rotation *= Quaternion.Euler(x_rot, 180,0);
            yield return(null);
        }

        float timer     = 0.0F;
        float norm      = start_norm;
        float norm_rate = movenorm / time;

        while ((timer += Time.deltaTime) < time)
        {
            t.position = GetMovementPoint(norm);
            //t.LookAt(TableObj.transform.position, Vector3.up);
            //t.rotation *= Quaternion.Euler(0,180,0);
            //t.rotation *= Quaternion.Euler(x_rot, 180,0);

            norm += norm_rate * Time.deltaTime;
            if (norm < 0.0F)
            {
                norm = 1.0F;
            }
            if (norm > 1.0F)
            {
                norm = 0.0F;
            }
            yield return(null);
        }

        float sitdown_init = 0.3F;
        float sitdown_time = 0.0F;

        while ((sitdown_time += Time.deltaTime) < sitdown_init)
        {
            t.position = Vector3.Lerp(end, Seat[seat].Position, sitdown_time / sitdown_init);
            t.rotation = Quaternion.Slerp(t.rotation,
                                          Seat[seat].Rotation,
                                          sitdown_time / sitdown_init);

            yield return(null);
        }
        g.isSeated = true;
        yield return(null);
    }
コード例 #29
0
 public GreatGrand GetNonNeighbourGG(GreatGrand g)
 {
     return(_TableManager.GetNonNeighbourSeat(g.Seat).Target);
 }
コード例 #30
0
ファイル: Bowls.cs プロジェクト: filthmancer/greatgrand
    IEnumerator CreatePath()
    {
        Pathway.transform.position = Pathway_init;
        MoveSpeed_actual           = MoveSpeed;

        Safeway_Threshold_actual = Safeway_Threshold;

        int checks = 0;

        while (TargetGrand == null || TargetGrand.Data.Fitness.Ratio > 0.6F)
        {
            int r = Random.Range(0, GameManager.instance.Grands.Length);
            TargetGrand = GameManager.instance.Grands[r].GrandObj;
            checks++;
            if (checks > 10)
            {
                break;
            }
        }

        if (TargetGrand == null)
        {
            TargetGrand = GameManager.Generator.Generate(0);
        }

        TargetGrand_Face       = GameManager.Generator.GenerateNewFace(TargetGrand.Data);
        MOB[1].T.rotation      = Quaternion.Euler(face_rotation_x, 0, 0);
        MOB[1].T.localPosition = Vector3.zero;
        MOB[1].AddChild(TargetGrand_Face);

        TargetGrand_Face.transform.localPosition = Vector3.up * 4;
        BalancePoint = Vector3.zero;


        EndPoint.position = StartPoint.position - StartPoint.up * TotalDistance;
        MOB[0][0].transform.localScale = new Vector3(19.5F, TotalDistance / 3, 1.0F);

        MiddlePoints = new Transform[PathPoints];

        Velocity = EndPoint.position - StartPoint.position;
        Velocity.Normalize();
        CrossVelocity = Vector3.Cross(Velocity, -Vector3.forward).normalized;

        float pathrate = 0.9F / PathPoints;

        for (int i = 0; i < PathPoints; i++)
        {
            GameObject g = new GameObject("Path Point " + i);
            MiddlePoints[i]          = g.transform;
            MiddlePoints[i].position = Vector3.Lerp(StartPoint.position, EndPoint.position,
                                                    Mathf.Clamp(pathrate + (pathrate * i), 0.0F, 1.0F));
            MiddlePoints[i].position += CrossVelocity * ((Random.value - Random.value) * 10);
            MiddlePoints[i].SetParent(MOB[0].transform);
        }
        List <float>   splinewidths = new List <float>();
        List <Vector3> splinepoints = new List <Vector3>();

        splinepoints.Add(StartPoint.localPosition);
        splinewidths.Add(Safeway_Threshold);
        for (int i = 0; i < MiddlePoints.Length; i++)
        {
            splinepoints.Add(MiddlePoints[i].localPosition);
            splinewidths.Add(Safeway_Threshold / i + 1);
        }
        splinepoints.Add(EndPoint.localPosition);
        splinewidths.Add(0.0F);
        VectorLine.Destroy(ref Safeway);

        int mvmt_segments = 10 + MiddlePoints.Length * 10;

        Safeway = new VectorLine("Safeway Path", new List <Vector3>(mvmt_segments + 1), Safeway_Threshold_actual * 1.2F, LineType.Continuous);
        Safeway.MakeSpline(splinepoints.ToArray(), mvmt_segments, 0, false);

        Safeway.drawTransform = MOB[0].transform;
        Safeway.SetColor(PathColor);
        Safeway.joins = Joins.Fill;

        int objnum = 20 + MiddlePoints.Length * 5;

        PathInstances = new FOBJ[objnum];

        float point    = 0.0F;
        float objratio = 0.9F / objnum;

        for (int i = 0; i < objnum; i++)
        {
            PathInstances[i] = (FOBJ)Instantiate(PathPrefabs[Random.Range(0, PathPrefabs.Length)]);
            MOB[0].AddChild(PathInstances[i]);

            point += Random.Range(objratio / 1.5F, objratio * 1.5F);

            Vector3 pos     = Safeway.GetPoint3D01(point);
            Vector3 nextpos = Safeway.GetPoint3D01(point + 0.1F);
            Vector3 vel     = (nextpos - pos).normalized;

            Vector3 cross = Vector3.Cross(vel, -Vector3.forward).normalized;
            float   xd    = cross.x * Safeway_Threshold_actual / 10;
            pos.x += Random.value > 0.5F ? xd : -xd;

            PathInstances[i].T.position = pos;
            PathInstances[i].T.LookAt(pos + vel);
            PathInstances[i].T.rotation *= Quaternion.Euler(0, 90, 90);
        }
        Safeway.Draw3D();
        VectorLine.SetCamera3D(Camera.main);
        VectorManager.useDraw3D = true;

        yield return(null);
    }