Exemple #1
0
    /// <summary>
    /// Загрузить данные о механизме
    /// </summary>
    public virtual void SetData(InterObjData _intObjData)
    {
        MovPlatformData mData = _intObjData is MovPlatformData? (MovPlatformData)_intObjData: null;

        if (mData != null && platformPositions.Count > 1)
        {
            transform.position = mData.position;
            moving             = mData.activated;
            orientation        = mData.direction;
            currentPosition    = mData.currentPosition;
            int     nextIndex = currentPosition + orientation;
            Vector2 nextPoint = Vector2.zero;
            if (currentPosition == 0)
            {
                nextPoint = platformPositions[1];
            }
            else if (currentPosition == platformPositions.Count - 1)
            {
                nextPoint = platformPositions[platformPositions.Count - 2];
            }
            else
            {
                nextPoint = platformPositions[currentPosition + orientation];
            }
            direction = (nextPoint - platformPositions[currentPosition]).normalized;
        }
    }
Exemple #2
0
    /// <summary>
    /// Сохранить данные о механизме
    /// </summary>
    public virtual InterObjData GetData()
    {
        MovPlatformData mData = new MovPlatformData(id, moving, transform.position, orientation, currentPosition);

        return(mData);
    }