Floors

The haptic horror

4 weeks Engine Icon Platform Icon 4 Devs 4 weeks Engine Icon Platform Icon 4 Devs

My Work

oops something whent wrong, reload the page

Under construction

using System;
using UnityEngine;

public class KeyTaskManager : MonoBehaviour
{
    /// summary
    /// this script is responsible for scattering all keys
    /// 
    /// array with transforms must have 4 minimum
    /// summary

    [Header("SpawnPoints")]
    [SerializeField] private Transform[] transforms;

    #region --- FUNCTIONS ---
    public void ScatterKeys(GameObject[] keys)
    {
        //scatter keys at random positions
        foreach (GameObject key in keys)
        {
            int number = RandomPosition();
            key.transform.position = transforms[number].position;
            RemoveAt(ref transforms, number);
        }
    }
    #endregion

    #region --- ARRAY FUNCTIONS ---
    private int RandomPosition()
    {
        return UnityEngine.Random.Range(0, transforms.Length);
        //return random position for key
    }

    private void RemoveAt(ref T[] _array, int index)
    {
        for (int _a = index; _a < _array.Length - 1; _a++)
        {
            // moves ellements downards
            _array[_a] = _array[_a + 1];
        }
        // resize array 
        Array.Resize(ref _array, _array.Length - 1);
    }
    #endregion
}                                    

oops something whent wrong, reload the page

About the game

Technique