Пример #1
0
    void Awake()
    {
        gc           = FindObjectOfType <GlobalController>();
        parentObject = FindObjectOfType <TotalObjects>();
        pointer      = FindObjectOfType <Pointer>();
        if (!gc.GetIsLoading())
        {
            SetID(pointer.GetHeldID());
        }
        build = FindObjectOfType <BuildSettings>();

        //remove limiters, keep trackers though
        if (objectType <= 5)
        {
            if (build.GetCurrentObjects(objectType) + objectValue <= build.GetMaxObjects(objectType))             //used to limit and track number of objects placed. Mainly used to limit player to 1
            {
                build.IncrementObject(objectType, objectValue);
            }
            if (build.GetCurrentObjects(objectType) + objectValue > build.GetMaxObjects(objectType))
            {
                Debug.Log(build.GetCurrentObjects(objectType));
                Erase();
            }
        }
        if (objectType >= 6)
        {
            if (build.GetCurrentObjects(objectType) <= build.GetMaxObjects(objectType))             //used to limit and track number of objects placed. Mainly used to limit player to 1
            {
                build.IncrementObject(objectType, objectValue);
            }
            if (build.GetCurrentObjects(objectType) > build.GetMaxObjects(objectType))
            {
                Debug.Log(build.GetCurrentObjects(objectType));
                Erase();
            }
        }
        defaultPosition = transform.position;
        //ensuring object is placed within bounds, can remove this
        if (defaultPosition.x < build.GetLevelSmallest().x || defaultPosition.y < build.GetLevelSmallest().y)
        {
            Erase();
        }
        if (defaultPosition.x > build.GetLevelLimit().x || defaultPosition.y > build.GetLevelLimit().y)
        {
            Erase();
        }
    }