Example #1
0
    //移すのに成功した状態
    //
    void UpdateSuccess()
    {
        ShareWeightBox lSourceShare = mSource.GetComponent <ShareWeightBox>();
        ShareWeightBox lDestShare   = mDest.GetComponent <ShareWeightBox>();

        mSource.GetComponent <WeightManager>().PushWeight(mDest.GetComponent <WeightManager>(), GetShiftWeight());


        //共有ボックスなら、他の共有ボックスに重さを伝える
        //

        //もし移し元が共有ボックスなら
        if (lSourceShare != null)
        {
            foreach (var s in lSourceShare.GetShareAllListExceptOwn())
            {
                s.GetComponent <WeightManager>().WeightLv = mSource.GetComponent <WeightManager>().WeightLv;
            }
        }

        //もし移し先が共有ボックスなら
        if (lDestShare != null)
        {
            foreach (var s in lDestShare.GetShareAllListExceptOwn())
            {
                s.GetComponent <WeightManager>().WeightLv = mDest.GetComponent <WeightManager>().WeightLv;
            }
        }

        DestroyLightBall(mLightBall);           //光の弾を消去する
        ChangeState(CSelectState.cNormal);      //通常状態へ

        SoundManager.SPlay(mShiftDestSE);
    }
Example #2
0
    //その移し元から移し先へ、重さを移せるか
    //
    bool CanShiftSourceToDest(GameObject aSource, GameObject aDest)
    {
        if (aSource == null)
        {
            return(false);
        }
        if (aDest == null)
        {
            return(false);
        }

        ShareWeightBox lSourceShare = aSource.GetComponent <ShareWeightBox>();
        ShareWeightBox lDestShare   = aDest.GetComponent <ShareWeightBox>();

        //両方とも共有ボックスで
        if (lSourceShare != null && lDestShare != null)
        {
            //同じ共有グループなら
            if (lSourceShare.IsShare(lDestShare))
            {
                return(false);                  //移せない
            }
        }

        //移し先のボックスの重さが2なら
        if (aDest.GetComponent <WeightManager>().WeightLv == WeightManager.Weight.heavy)
        {
            return(false);              //移せない
        }

        return(true);
    }
Example #3
0
    // Update is called once per frame
    void Update()
    {
        ShareWeightBox s = GetComponent <ShareWeightBox>();

        if (Input.GetKeyDown(KeyCode.A))
        {
            foreach (var ts in s.GetShareAllListExceptOwn())
            {
                Debug.Log(ts, this);
            }
        }
    }
Example #4
0
 //そのボックスが、このボックスと重さを共有しているか
 public bool IsShare(ShareWeightBox aShareWeightBox)
 {
     return(mShareWeightBoxList.Contains(aShareWeightBox));
 }
Example #5
0
    //重さを移すのに失敗して、移し元から共有ブロックへ光の弾が戻っていく状態
    //
    void UpdateReturnToShare()
    {
        if (mInitState == true)
        {
            mInitState = false;


            //共有ボックスの処理
            //

            ShareWeightBox lDestShare = mDest.GetComponent <ShareWeightBox>();
            mLightBallShare.Clear();

            //共有ボックスの数だけ光の弾を生成
            foreach (var s in lDestShare.GetShareAllListExceptOwn())
            {
                GameObject l = Instantiate(mLightBallPrefab, transform);
                l.GetComponent <LightBall>().InitPoint(GetMassPosition(mDest), GetMassPosition(s.gameObject));
                l.GetComponent <LightBall>().PlayEffect();
                mLightBallShare.Add(l);
            }


            //全ての光る球の到達する時間は一定だ
            //移す先の共有ボックスと、他の共有ボックスの一番近い距離を求め、その時間で到達するように速度を変更する
            //
            float lMinDistance = float.MaxValue;
            foreach (var l in mLightBallShare)
            {
                LightBall lc = l.GetComponent <LightBall>();
                lMinDistance = Mathf.Min((lc.From - lc.To).magnitude, lMinDistance);
            }

            foreach (var l in mLightBallShare)
            {
                LightBall lc = l.GetComponent <LightBall>();
                lc.mMoveSpeed = (lc.From - lc.To).magnitude / lMinDistance * mLightBallTemplate.GetComponent <LightBall>().mMoveSpeed;
            }

            SoundManager.SPlay(mShiftDestSE);
        }


        //全ての光の弾が他の共有ボックスへ到達するまで、光の弾の更新を続ける
        //

        var lShareList = mSource.GetComponent <ShareWeightBox>().GetShareAllListExceptOwn();

        bool lAllReach = true;

        for (int i = 0; i < mLightBallShare.Count; i++)
        {
            LightBall      l = mLightBallShare[i].GetComponent <LightBall>();
            ShareWeightBox s = lShareList[i].GetComponent <ShareWeightBox>();
            l.SetPoint(GetMassPosition(mDest), GetMassPosition(s.gameObject));
            l.UpdatePoint();
            if (l.IsReached == false)
            {
                lAllReach = false;
            }
        }

        //全て到達したら
        if (lAllReach == true)
        {
            //光の弾の削除
            foreach (var s in mLightBallShare)
            {
                DestroyLightBall(s);
            }

            //見かけの重さを戻す
            foreach (var s in mDest.GetComponent <ShareWeightBox>().GetShareAllListExceptOwn())
            {
                s.GetComponent <WeightManager>().WeightLvSeem += GetShiftWeight();
            }
            ChangeState(CSelectState.cFail);                //失敗状態へ
            SoundManager.SPlay(mShiftDestSE);
        }
    }
Example #6
0
    //共有ボックスが移し元になり、他の共有ブロックの重さが移ってくる状態
    void UpdateMoveFromShare()
    {
        if (mInitState == true)
        {
            mInitState = false;

            //カーソルを移せない表示に
            ChangeCursorState(CCursorState.cCanNotShift);

            //移す線を非表示に
            mMassShiftLine.SetActive(false);

            //選択先のハイライトを消し、移し先のハイライトを表示
            ShowModelHilight(mSelect, false, Color.white);
            ShowModelHilight(mDest, true, mDestColor * mDestColorPower);


            //共有ボックスの処理
            //

            ShareWeightBox lSourceShare = mSource.GetComponent <ShareWeightBox>();
            mLightBallShare.Clear();

            //共有ボックスの数だけ光の弾を生成
            foreach (var s in lSourceShare.GetShareAllListExceptOwn())
            {
                GameObject l = Instantiate(mLightBallPrefab, transform);
                l.GetComponent <LightBall>().InitPoint(GetMassPosition(s.gameObject), GetMassPosition(mSource));
                l.GetComponent <LightBall>().PlayEffect();
                mLightBallShare.Add(l);

                s.GetComponent <WeightManager>().WeightLvSeem -= GetShiftWeight();                      //見かけの重さを減らす
            }


            //全ての光る球の到達する時間は一定だ
            //移す元の共有ボックスと、他の共有ボックスの一番近い距離を求め、その時間で到達するように速度を変更する
            //
            float lMinDistance = float.MaxValue;
            foreach (var l in mLightBallShare)
            {
                LightBall lc = l.GetComponent <LightBall>();
                lMinDistance = Mathf.Min((lc.From - lc.To).magnitude, lMinDistance);
            }

            foreach (var l in mLightBallShare)
            {
                LightBall lc = l.GetComponent <LightBall>();
                lc.mMoveSpeed = (lc.From - lc.To).magnitude / lMinDistance * mLightBallTemplate.GetComponent <LightBall>().mMoveSpeed;
            }

            SoundManager.SPlay(mShiftSourceSE);
        }


        //全ての光の弾が移し元へ到達するまで、光の弾の更新を続ける
        //

        var lShareList = mSource.GetComponent <ShareWeightBox>().GetShareAllListExceptOwn();

        bool lAllReach = true;

        for (int i = 0; i < mLightBallShare.Count; i++)
        {
            LightBall      l = mLightBallShare[i].GetComponent <LightBall>();
            ShareWeightBox s = lShareList[i].GetComponent <ShareWeightBox>();
            l.SetPoint(GetMassPosition(s.gameObject), GetMassPosition(mSource));
            l.UpdatePoint();
            if (l.IsReached == false)
            {
                lAllReach = false;
            }
        }

        //全て届いたら
        if (lAllReach == true)
        {
            //光の弾を消去する
            foreach (var s in mLightBallShare)
            {
                DestroyLightBall(s);
            }
            ChangeState(CSelectState.cMoveSourceToDest);                //移し元から移し先へ移す状態へ
        }
    }