// constructor method
        public Obstacle(PrimitiveType privitive, MoveMentType movement)
        {
            obstacle     = GameObject.CreatePrimitive(privitive);
            movementType = movement;

            myZposition = Random.Range(-10f, 10f);
            obstacle.transform.position = new Vector3(
                Random.Range(-10f, 10f),
                Random.Range(-10f, 10f),
                Random.Range(-10f, 10f));
        }
Esempio n. 2
0
        /// <summary>
        /// 利用Dotween进行简单的自定义动画(旋转、平移)
        /// </summary>
        /// <param name="movementType"></param>
        /// <param name="isCustomStateValue">初始状态值</param>
        /// <param name="customStateValue"></param>
        public virtual void HotspotMovement(MoveMentType movementType, bool isCustomStateValue = false, int customStateValue = 0)
        {
            if (isCustomStateValue)
            {
                if (customStateValue >= m_stateValueList.Count || customStateValue < 0)
                {
                    Debug.LogError("自定义状态值错误");
                    OperationManager.Instance.enabled = true;
                    return;
                }
                m_stateValue = customStateValue;
            }
            else
            {
                if (m_stateValue >= m_stateValueList.Count)
                {
                    m_stateValue = 0;
                }
            }

            OperationManager.Instance.enabled = false;
            switch (movementType)
            {
            case MoveMentType.Translate:
                m_model.transform.DOLocalMove(m_stateValueList[m_stateValue], m_tweenerTime).OnComplete(() => OnTweenerPlayEndCallBack(true));
                if (m_isUpdateCollider)
                {
                    this.transform.DOLocalMove(m_stateValueList[m_stateValue], m_tweenerTime);
                }
                break;

            case MoveMentType.Rotation:
                m_model.transform.DOLocalRotate(m_stateValueList[m_stateValue], m_tweenerTime).OnComplete(() => OnTweenerPlayEndCallBack(true));
                if (m_isUpdateCollider)
                {
                    this.transform.DOLocalRotate(m_stateValueList[m_stateValue], m_tweenerTime);
                }
                break;

            default:
                break;
            }
        }