コード例 #1
0
    /// <summary>
    /// 设置子弹的属性
    /// <para>bullet</para>
    /// <para>BulletParaType paraType</para>
    /// <para>float value</para>
    /// </summary>
    /// <param name="luaState"></param>
    /// <returns></returns>
    public static int SetBulletPara(ILuaState luaState)
    {
        EnemyBulletBase bullet   = luaState.ToUserData(-3) as EnemyBulletBase;
        BulletParaType  paraType = (BulletParaType)luaState.ToInteger(-2);
        float           value    = (float)luaState.ToNumber(-1);

        luaState.Pop(3);
        bullet.SetBulletPara(paraType, value);
        return(0);
    }
コード例 #2
0
    private void UpdateChangeData(int idx)
    {
        BulletParasChangeData changeData = _changeList[idx];

        if (!changeData.isFinish)
        {
            if (changeData.delay > 0)
            {
                changeData.delay--;
            }
            else
            {
                if (changeData.repeatIntervalTime == 0)
                {
                    if (!changeData.isCached)
                    {
                        CacheChangeData(changeData);
                    }
                    changeData.changeTime++;
                    float changeValue = changeData.GetInterpolationValueFunc(changeData.begin, changeData.end, changeData.changeTime, changeData.changeDuration);
                    _bullet.SetBulletPara(changeData.paraType, changeValue);
                    if (changeData.changeTime >= changeData.changeDuration)
                    {
                        changeData.repeatCount--;
                        if (changeData.repeatCount <= 0)
                        {
                            changeData.isFinish = true;
                        }
                        else
                        {
                            changeData.repeatIntervalTime = changeData.repeatInterval;
                            // 再次执行时需要重新计算一下各个数值
                            changeData.isCached = false;
                        }
                    }
                }
                if (changeData.repeatIntervalTime > 0)
                {
                    changeData.repeatIntervalTime--;
                }
            }
        }
    }