コード例 #1
0
 /// <summary> 设置 WaveData 的 一个WaveDataMask 的 WaveModification </summary>
 /// <param name="index"> 要设置的 WaveDataMask </param>
 /// <param name="newWaveModification"> 新的 WaveModification </param>
 internal void SetWaveModification(
     int index,
     WaveModification newWaveModification
     )
 {
     waveDataMasks[index].Modification.CopyFrom(newWaveModification);
 }
コード例 #2
0
    private void CheckUserAnswer()
    {
        WaveModification ans =
            DataController.Instance.GetCurrentLevelData().modification;
        WaveModification usr = new WaveModification(); // TODO

        if ((usr - ans) / ans < /* theNumber */ 1)
        {
            /* SendMessage("Win this level.") */;
        }
    }
コード例 #3
0
ファイル: WaveData.cs プロジェクト: escape0707/Oscilloscope
    /// <summary>
    /// 获取波在横坐标为 x 时的函数值
    /// </summary>
    /// <param name="x"> 求值用到的横坐标 x </param>
    /// <returns> 返回横坐标为 x 时波的函数值 </returns>
    internal float ReturnValueAt(float x)
    {
        float y = 0;

        // 累加获得 y,每次累加的值为此次循环得到的 WaveAttribute 被蒙版修改后的值
        foreach (WaveDataMask mask in waveDataMasks)
        {
            WaveModification mod = mask.Modification;
            foreach (WaveAttribute wa in mask)
            {
                y += (wa.A * mod.A) *
                     Mathf.Sin((wa.Omega * mod.Omega) *
                               (x + wa.Phi + mod.Phi));
            }
        }
        return(y);
    }
コード例 #4
0
    // 根据屏幕坐标寻找要修改的纸片的 WaveModification 和 WaveController
    private bool FindWaveRefByScreenPos(
        Vector2 screenPointOne,
        Vector2?screenPointTwo = null
        )
    {
        // 将 屏幕坐标 转换到 世界坐标
        Vector2 worldPoint = mainCamera.ScreenToWorldPoint(new Vector3(
                                                               screenPointOne.x,
                                                               screenPointOne.y
                                                               ));

        // 如果坐标落在某个 可修改纸片的内部
        for (int i = 0; i < 2; ++i)
        {
            if (inBound(worldPoint, i))
            {
                // 如果传入了第二个点
                if (screenPointTwo != null)
                {
                    // 将 屏幕坐标 转换到 世界坐标
                    worldPoint = mainCamera.ScreenToWorldPoint(new Vector3(
                                                                   screenPointOne.x,
                                                                   screenPointOne.y
                                                                   ));
                    // 如果第二个点不在第i张纸片上,返回 false,并且不更新引用们
                    if (!inBound(worldPoint, i))
                    {
                        return(false);
                    }
                }

                // 记录用户要更改的 WaveModification
                waveModification = waveModifications[i];
                waveModificationOrigin.CopyFrom(waveModification);
                // 记录要应用更改的 WaveData 和 WaveController
                waveData       = waveDatas[i];
                waveController = waveControllers[i];

                // 返回 true:已找到
                return(true);
            }
        }

        // 否则返回 false:未找到
        return(false);
    }
コード例 #5
0
ファイル: WaveData.cs プロジェクト: escape0707/Oscilloscope
 /// <summary>
 /// 修改 WaveData 的 第index个 WaveDataMask
 /// </summary>
 /// <param name="index"> 被改 WaveDataMask 的索引 </param>
 /// <param name="modification"> 修改量 </param>
 internal void ModifyByMask(int index, WaveModification modification)
 {
     waveDataMasks[index].Modification.StageWith(modification);
 }
コード例 #6
0
ファイル: WaveData.cs プロジェクト: escape0707/Oscilloscope
 /// <summary>
 /// 拷贝 WaveModification 的构造
 /// </summary>
 /// <param name="wdm"> 被拷贝的 WaveDataMask </param>
 internal WaveDataMask(WaveDataMask wdm)
 {
     First        = wdm.First;
     Last         = wdm.Last;
     Modification = new WaveModification(wdm.Modification);
 }
コード例 #7
0
ファイル: WaveData.cs プロジェクト: escape0707/Oscilloscope
 /// <summary> 默认构造函数 </summary>
 internal WaveDataMask()
 {
     Modification = new WaveModification();
 }
コード例 #8
0
 /// <summary>
 /// 拷贝另一个 WaveModification 的内容
 /// </summary>
 /// <param name="other"> 要拷贝的 WaveModification </param>
 internal void CopyFrom(WaveModification other)
 {
     A     = other.A;
     Omega = other.Omega;
     Phi   = other.Phi;
 }
コード例 #9
0
 /// <summary>
 /// 叠加另一个 WaveModification 效果
 /// </summary>
 /// <param name="other"> 要叠加的 WaveModification </param>
 internal void StageWith(WaveModification other)
 {
     A     *= other.A;
     Omega *= other.Omega;
     Phi   += other.Phi;
 }
コード例 #10
0
 /// <summary> 拷贝构造 </summary>
 internal WaveModification(WaveModification other) :
     this(other.A, other.Omega, other.Phi)
 {
 }