Ejemplo n.º 1
0
    // ----------------------------- public functions ----------------------------



    /// <summary>
    /// Set line renderer and position-variables. Set z-position to fieldsBeforeSurface-value.
    /// </summary>
    public void SetVertices(Vector3 start, Vector3 mid, Vector3 end, Vector3[] positions)
    {
        // 1. Set z-position
        float zPos = Player.inst.transform.position.z - VisualController.inst.fieldsBeforeSurface;

        start.z = zPos;
        mid.z   = zPos;
        end.z   = zPos;
        for (int i = 0; i < positions.Length; i++)
        {
            positions[i].z = zPos;
        }

        // 2. Assign
        this.start     = start;
        this.mid       = mid;
        this.end       = end;
        this.positions = positions;

        // 3. Set line renderer
        var linePositions = MeshUpdate.PreventLineRendFromBending(positions);

        lineRend.positionCount = linePositions.Length;
        lineRend.SetPositions(linePositions);
    }
Ejemplo n.º 2
0
    // ENVIRONMENT

    /// <summary>
    /// Create a complete field set, with parented gameObjects, line renderers and outer surfaces. Initialize with data (ID, positions, isCorner, isEdgeMid, lineRend) and return the field set.
    /// </summary>
    public static MusicField[] CreateFieldSet()
    {
        int fieldsCount = TunnelData.FieldsCount;

        MusicField[] fields = new MusicField[fieldsCount];

        // 1. Create gameObjects, lineRenderers and initialize with data (no positions)
        for (int i = 0; i < fieldsCount; i++)
        {
            // Get data
            int          ID        = i;
            bool         isCorner  = MusicField.IsCorner(ID);
            bool         isEdgeMid = MusicField.IsEdgeMid(ID);
            GameObject   newObj    = CreateContainer("Field" + ID, MeshRef.inst.musicFields_parent);
            LineRenderer lineRend  = newObj.AddLineRenderer(0, MeshRef.inst.musicFields_mat, VisualController.inst.fieldThickness, false);     // TO DO: init mit zwei empty lineRend positions?

            // Assign
            fields[ID] = new MusicField(ID, lineRend, isCorner, isEdgeMid);
        }

        // 2. Assign positions
        fields = MeshUpdate.UpdateFieldsVertices(fields);

        // 3. Surfaces
        CreateFieldsSurfaces(fields);

        return(fields);
    }
Ejemplo n.º 3
0
    public static void CreatePlayer()
    {
        CreatePlayerForm();

        MeshUpdate.UpdatePlayer();

        CreatePlayerFields();
    }
Ejemplo n.º 4
0
    // ----------------------------- Public methods ----------------------------



    public static void CreateAll()
    {
        MeshUpdate.GetTunnelVertices();

        CreateFields();
        CreatePlayer();

        InitMouseCollider();
        MeshUpdate.UpdateBeatTriangle();
    }
Ejemplo n.º 5
0
        public frmProfileManager(string torExecutableFilePath)
        {
            InitializeComponent();

            //init profiles
            RefreshProfileList();

            //init mesh update
            _meshUpdate = new MeshUpdate(_isPortableApp ? Program.UPDATE_URI_WINDOWS_PORTABLE_APP : Program.UPDATE_URI_WINDOWS_SETUP_APP, Program.UPDATE_CHECK_INTERVAL);
            _meshUpdate.UpdateAvailable   += meshUpdate_UpdateAvailable;
            _meshUpdate.NoUpdateAvailable += meshUpdate_NoUpdateAvailable;
            _meshUpdate.UpdateCheckFailed += meshUpdate_UpdateCheckFailed;

            //init tor controller
            _torController = new TorController(torExecutableFilePath);
            _torController.Socks5EndPoint = new IPEndPoint(IPAddress.Loopback, 9950);
            _torController.ControlPort    = 9951;
        }
Ejemplo n.º 6
0
    /// <summary>
    /// Scale the player over time, starting quick and becoming slow. Also update the player width(!). Used for when the player releases the play-button.
    /// </summary>
    public IEnumerator DampedScale(float targetScale, float timeToStart = 0)
    {
        yield return(new WaitForSeconds(timeToStart));

        float   maxTime  = 2.2f;
        float   timer    = 0;
        Vector3 maxScale = new Vector3(targetScale, targetScale, 1);

        while (timer < maxTime)
        {
            Vector3 scaleSpeed = (maxScale - this.transform.localScale) * bt_scaleDamp * DeltaTime;
            this.transform.localScale += scaleSpeed;

            MeshUpdate.UpdatePlayer();

            timer += Time.deltaTime;
            yield return(null);
        }
    }
Ejemplo n.º 7
0
    /// <summary>
    /// Perform rotation once. Damped by bt_rotationDamp. Update player mesh (!!).
    /// </summary>
    private void RotateToTarget(Vector3 targetPos)
    {
        // 1. Rotate
        Vector3 targetVec = targetPos - this.transform.position;
        Vector3 curVec    = OuterVertices[0] - this.transform.position;

        float nextRot = Vector2.SignedAngle(curVec, targetVec) * bt_rotationDamp * DeltaTime;

        this.transform.eulerAngles += new Vector3(this.transform.eulerAngles.x, this.transform.eulerAngles.y, nextRot);

        // Hack (gegen 180° & 60° Winkel)
        if ((Mathf.Abs(this.transform.eulerAngles.z) > 180f - 0.1f && Mathf.Abs(this.transform.eulerAngles.z) < 180f + 0.1f) ||
            Mathf.Abs(this.transform.eulerAngles.z) > 60f - 0.1f && Mathf.Abs(this.transform.eulerAngles.z) < 60f + 0.1f)
        {
            this.transform.eulerAngles += new Vector3(0, 0, 0.1f);
        }

        // 2. Update player meshes
        MeshUpdate.UpdatePlayer();
    }
Ejemplo n.º 8
0
    private static void QueueUpdate(ref MeshesCPUInfo mesh, Vector4 position)
    {
        MeshUpdate update = new MeshUpdate {
            IDInput  = new Vector2(mesh.vertID, mesh.vertcount),
            PosInput = position
        };

        if (mesh.isSingle)
        {
            if (!SinglePoolRegister.TryGetValue(mesh.meshtype, out GPUSinglePoolModel pool))
            {
                Debug.LogWarning($"Could not find model with id {mesh.vertID} in SinglePoolRegister");
            }

            pool.QueueUpdate(update);
        }
        else
        {
            MeshInit.QueueUpdate(update);
        }
    }
Ejemplo n.º 9
0
        public frmMain(MeshNode node, string profileFilePath, bool isPortableApp, MeshUpdate meshUpdate, frmProfileManager profileManager)
        {
            InitializeComponent();

            _node            = node;
            _profileFilePath = profileFilePath;
            _isPortableApp   = isPortableApp;
            _meshUpdate      = meshUpdate;
            _profileManager  = profileManager;

            _node.InvitationReceived += MeshNode_InvitationReceived;

            if (_node.Type == MeshNodeType.Anonymous)
            {
                this.Text += " [Anonymous]";
            }

            _meshUpdate.UpdateAvailable   += meshUpdate_UpdateAvailable;
            _meshUpdate.NoUpdateAvailable += meshUpdate_NoUpdateAvailable;
            _meshUpdate.UpdateCheckFailed += meshUpdate_UpdateCheckFailed;
        }
Ejemplo n.º 10
0
 private void meshUpdate_UpdateCheckFailed(MeshUpdate sender, Exception ex)
 {
     mnuCheckUpdate.Enabled = true;
     MessageBox.Show("Error ocurred while checking for update:\r\n\r\n" + ex.ToString(), "Mesh Update", MessageBoxButtons.OK, MessageBoxIcon.Error);
 }
Ejemplo n.º 11
0
    /// <summary>
    /// Generate all musical data and store it in TunnelData.fields.
    /// </summary>
    public static void Init()
    {
        // 0. Weights
        //weights = InitWeights();

        bool has1stRecord = Recorder.inst.Has1stRecord;

        // 1. key
        if (!has1stRecord)
        {
            curKey = MusicGenerationLogic.RandomKey();
        }

        // 2. tone range
        toneRangeMin = curKey.KeyNote + MusicManager.inst.toneRange_startNote;      // oct. 3
        if (has1stRecord)
        {
            var randAdd = Random.Range(-MusicManager.inst.toneRange_maxStartNoteShift, MusicManager.inst.toneRange_maxStartNoteShift);
            toneRangeMin += randAdd;
            toneRangeMin  = Mathf.Clamp(toneRangeMin, MusicManager.inst.toneRange_startNote, MusicManager.inst.toneRange_startNote + MusicManager.inst.toneRange);
        }
        toneRangeMax = toneRangeMin + MusicManager.inst.toneRange;                  // oct. 5

        // 3. velocity
        minVelocity = 0.08f;
        maxVelocity = 0.2f;

        // 3. chord structure
        // count
        chordTypeCount = MusicManager.inst.chordDegrees;
        // degrees
        int[] degrees = MusicGenerationLogic.RandomChordDegrees(curKey, chordTypeCount);
        // intervals
        int[] intervals;

        var chanceNoRec  = ExtensionMethods.Probability(MusicManager.inst.unusualIntervalsChance_NoRec);
        var chanceHasRec = ExtensionMethods.Probability(MusicManager.inst.unusualIntervalsChance_HasRec);
        var randIndex    = Random.Range(0, MusicManager.inst.unusualIntervals.Length);

        if (Time.time > 5f && ((has1stRecord && chanceHasRec) || (!has1stRecord && chanceNoRec)))
        {
            intervals = MusicManager.inst.unusualIntervals[randIndex].array;
            Debug.Log("unusual intervals: " + intervals[0] + ", " + intervals[1] + ", " + intervals[2]);
        }
        else
        {
            intervals = MusicManager.inst.standartIntervals;
        }

        // individual count
        int[] individualCounts = MusicGenerationLogic.RandomChordTypeCounts(chordTypeCount);
        // store!
        chordTypes = new ChordData[chordTypeCount];
        for (int i = 0; i < chordTypeCount; i++)
        {
            chordTypes[i] = new ChordData(degrees[i], intervals, individualCounts[i]);
        }

        int[] testArray = new int[] { curKey.KeyNote };
        Debug.Log("curKey: " + testArray.NoteNames() + "-" + curKey.Scale + ", baseNote: " + (curKey.KeyNote + 4 * MusicUtil.notesPerOctave));

        // 4. chords
        Chord[][] chords = MusicGenerationLogic.RandomChordsFromData(curKey, chordTypes, toneRangeMin, toneRangeMax);

        // 5. assign to fields
        var fieldTypes  = new MusicField.Type[FieldsCount];
        var selectables = new bool[FieldsCount];
        var spawnings   = new bool[FieldsCount];

        for (int i = 0; i < FieldsCount; i++)
        {
            fieldTypes[i]  = MusicField.Type.Chord;
            selectables[i] = true;
            spawnings[i]   = false;
        }
        TunnelData.fields = MusicFieldSet.SetDataToFields(TunnelData.fields, fieldTypes, chords, selectables, spawnings);

        // 6. field heights
        MeshUpdate.AdjustFieldHeights(TunnelData.fields);

        // 7. colors
        var colors = MeshUpdate.ColorsInRange();

        MusicFieldSet.SetColors(TunnelData.fields, colors);



        Player.inst.curFieldSet = TunnelData.fields;

        // 8. Beat data
        GetBeatData();
    }
Ejemplo n.º 12
0
 /// <summary>
 /// Collider for selection with the mouse. Fill with vertices from TunnelData-form.
 /// </summary>
 public static void InitMouseCollider()
 {
     MeshRef.inst.mouseColllider.points = ExtensionMethods.Vector3ToVector2(TunnelData.vertices);
     MeshUpdate.SetMouseColliderSize(VisualController.inst.mouseColliderSize_play);
 }
Ejemplo n.º 13
0
 private void meshUpdate_UpdateCheckFailed(MeshUpdate sender, Exception ex)
 {
     mnuCheckUpdate.Enabled = true;
 }