コード例 #1
0
    /// <summary>
    /// 机器人战斗函数
    /// </summary>
    private void AutoFight()
    {
        //武器模块
        BaseWeaponInfo[] baseWeapons = RobotInfo.Instance.WeaponModule;
        if (null != baseWeapons)
        {
            foreach (BaseWeaponInfo weapon in baseWeapons)
            {
                int speed = weapon.shootSpeed + weapon.shootSpeedUpPerLevel * weapon.weaponLevel;
                int power = weapon.shootPower + weapon.shootPowerUpPerLevel * weapon.weaponLevel;

                int frame = WeaponInfo.GetWeaponShootFrame(speed);

                if (Time.frameCount % frame == 0)
                {
                    Vector3[] pos = weapon.pos;

                    int count = weapon.pos.Length;
                    for (int i = 0; i < count; i++)
                    {
                        PoolManager.Instance.CreateBullet(weapon.weaponBulletType, RobotTransform, pos[i], power);
                    }
                }
            }
        }
    }