Exemple #1
0
    public void Update()
    {
        if (mAnimationList == null)
        {
            return;
        }

        float currentHeight = -1.0f;

        //遍历列表,进行更新或关闭操作
        for (int i = 0; i < mAnimationList.Count;)
        {
            AnimationEffect anim = mAnimationList[i];

            bool bRemove = false;
            if (anim.needClose == true) //动作需要关闭并移除
            {
                anim.Close();
                bRemove = true;
            }
            else
            {
                if (anim.rigidHeight)
                {
                    if (currentHeight < 0.0f)
                    {
                        Vector3    pos = transform.position;
                        RaycastHit hitInfo;
                        Ray        PointToGroundRay = new Ray(pos, new Vector3(0, -1, 0));
                        if (Physics.Raycast(PointToGroundRay, out hitInfo, 100, collisionLayers))
                        {
                            currentHeight = pos.y - hitInfo.point.y;
                        }
                        else
                        {
                            currentHeight = 0.0f;
                        }
                    }

                    anim.currentHeight = currentHeight;
                }
                if (anim.Update() == false) //否则,对动作进行更新,更新失败的关闭并移除
                {
                    anim.Close();
                    bRemove = true;
                }
            }

            if (bRemove)
            {
                mAnimationList.Remove(anim);
            }
            else
            {
                i++;
            }
        }
    }