| | |
| | | /// <param name="tower">The tower controller we're a ghost of</param> |
| | | public virtual void Initialize(Tower tower) |
| | | { |
| | | m_MeshRenderers = GetComponentsInChildren<MeshRenderer>(); |
| | | //m_MeshRenderers = GetComponentsInChildren<MeshRenderer>(); |
| | | controller = tower; |
| | | if (GameUI.instanceExists) |
| | | { |
| | |
| | | tmat.color = new Color(1.0f, 1.0f, 1.0f, 0.0f); |
| | | } |
| | | |
| | | // 查找子结点,技能塔拖动的时候半透明: |
| | | if (controller.towerFeature != EFeatureTower.NULL) |
| | | { |
| | | foreach (Transform t in transform.GetComponentsInChildren<Transform>()) |
| | | { |
| | | if (t.name == "Cube") |
| | | { |
| | | t.GetComponent<MeshRenderer>().material.color = new Color(1.0f, 1.0f, 1.0f, 1.0f); |
| | | t.GetComponent<MeshRenderer>().material.DOColor(new Color(1.0f, 1.0f, 1.0f, 0.4f), 0.4f); |
| | | } |
| | | } |
| | | } |
| | | //特效直接把塔做了进去 |
| | | // // 查找子结点,技能塔拖动的时候半透明: |
| | | // if (controller.towerFeature != EFeatureTower.NULL) |
| | | // { |
| | | // foreach (Transform t in transform.GetComponentsInChildren<Transform>()) |
| | | // { |
| | | // if (t.name == "Effect") |
| | | // { |
| | | // // t.GetComponent<MeshRenderer>().material.color = new Color(1.0f, 1.0f, 1.0f, 1.0f); |
| | | // // t.GetComponent<MeshRenderer>().material.DOColor(new Color(1.0f, 1.0f, 1.0f, 0.4f), 0.4f); |
| | | // // 改为拖动的时候播放特效 |
| | | // ParticleSystem ps = t.gameObject.GetComponent<ParticleSystem>(); |
| | | |
| | | // if (ps == null) |
| | | // ps = t.GetChild(0).GetComponent<ParticleSystem>(); |
| | | |
| | | // ps.Play(); |
| | | // break; |
| | | // } |
| | | // } |
| | | // } |
| | | } |
| | | |
| | | public void SetAttackArea(int lvl, int attid) |
| | |
| | | } |
| | | } |
| | | |
| | | Vector3 up = new Vector3(0, 10, 0); |
| | | /// <summary> |
| | | /// Moves this ghost to a given world position |
| | | /// </summary> |
| | |
| | | /// over invalid locations</param> |
| | | public virtual void Move(Vector3 worldPosition, Quaternion rotation, bool validLocation) |
| | | { |
| | | m_TargetPosition = worldPosition; |
| | | //Debug.Log("移动了"); |
| | | |
| | | if (!m_ValidPos) |
| | | { |
| | | // Immediately move to the given position |
| | | m_ValidPos = true; |
| | | transform.position = m_TargetPosition; |
| | | } |
| | | transform.position = worldPosition + up; |
| | | // if (!m_ValidPos) |
| | | // { |
| | | // // Immediately move to the given position |
| | | // m_ValidPos = true; |
| | | // transform.position = m_TargetPosition; |
| | | // } |
| | | } |
| | | |
| | | |
| | |
| | | /// </summary> |
| | | protected virtual void Update() |
| | | { |
| | | Vector3 currentPos = transform.position; |
| | | //Vector3 currentPos = transform.position; |
| | | //Debug.Log(transform.position); |
| | | // if (this.bInDisplay && (radiusObject != null)) |
| | | // { |
| | | // this.fadeInTime -= Time.deltaTime; |
| | | // if (this.fadeInTime <= 0.0f) |
| | | // { |
| | | // bInDisplay = false; |
| | | // fadeInTime = 0.0f; |
| | | // Material tmat = radiusObject.GetComponent<MeshRenderer>().material; |
| | | // tmat.DOColor(new Color(1.0f, 1.0f, 1.0f, 0.0f), 0.1f); |
| | | // } |
| | | // } |
| | | |
| | | if (this.bInDisplay && (radiusObject != null)) |
| | | { |
| | | this.fadeInTime -= Time.deltaTime; |
| | | if (this.fadeInTime <= 0.0f) |
| | | { |
| | | bInDisplay = false; |
| | | fadeInTime = 0.0f; |
| | | Material tmat = radiusObject.GetComponent<MeshRenderer>().material; |
| | | tmat.DOColor(new Color(1.0f, 1.0f, 1.0f, 0.0f), 0.1f); |
| | | } |
| | | } |
| | | // if (Vector3.SqrMagnitude(currentPos - m_TargetPosition) > 0.01f) |
| | | // { |
| | | // //currentPos = Vector3.SmoothDamp(currentPos, m_TargetPosition, ref m_MoveVel, dampSpeed); |
| | | |
| | | if (Vector3.SqrMagnitude(currentPos - m_TargetPosition) > 0.01f) |
| | | { |
| | | currentPos = Vector3.SmoothDamp(currentPos, m_TargetPosition, ref m_MoveVel, dampSpeed); |
| | | // //transform.position = currentPos; |
| | | // transform.position = m_TargetPosition; |
| | | |
| | | transform.position = currentPos; |
| | | } |
| | | else |
| | | { |
| | | m_MoveVel = Vector3.zero; |
| | | } |
| | | // } |
| | | // else |
| | | // { |
| | | // m_MoveVel = Vector3.zero; |
| | | // } |
| | | } |
| | | } |
| | | } |